mirror of https://github.com/python/cpython.git
This couldn't compile on WIndows, due to hardcoded "long long". Repaired.
This commit is contained in:
parent
7cd83ca9ad
commit
e32280987c
|
@ -36,7 +36,7 @@ static char __author__[] =
|
||||||
(((long)bzs->total_out_hi32 << 32) + bzs->total_out_lo32)
|
(((long)bzs->total_out_hi32 << 32) + bzs->total_out_lo32)
|
||||||
#elif SIZEOF_LONG_LONG >= 8
|
#elif SIZEOF_LONG_LONG >= 8
|
||||||
#define BZS_TOTAL_OUT(bzs) \
|
#define BZS_TOTAL_OUT(bzs) \
|
||||||
(((long long)bzs->total_out_hi32 << 32) + bzs->total_out_lo32)
|
(((LONG_LONG)bzs->total_out_hi32 << 32) + bzs->total_out_lo32)
|
||||||
#else
|
#else
|
||||||
#define BZS_TOTAL_OUT(bzs) \
|
#define BZS_TOTAL_OUT(bzs) \
|
||||||
bzs->total_out_lo32;
|
bzs->total_out_lo32;
|
||||||
|
@ -109,14 +109,14 @@ Util_CatchBZ2Error(int bzerror)
|
||||||
"correctly");
|
"correctly");
|
||||||
ret = 1;
|
ret = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BZ_PARAM_ERROR:
|
case BZ_PARAM_ERROR:
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"the bz2 library has received wrong "
|
"the bz2 library has received wrong "
|
||||||
"parameters");
|
"parameters");
|
||||||
ret = 1;
|
ret = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BZ_MEM_ERROR:
|
case BZ_MEM_ERROR:
|
||||||
PyErr_NoMemory();
|
PyErr_NoMemory();
|
||||||
ret = 1;
|
ret = 1;
|
||||||
|
@ -214,8 +214,8 @@ Util_GetLine(BZ2FileObject *self, int n)
|
||||||
if (skipnextlf) {
|
if (skipnextlf) {
|
||||||
skipnextlf = 0;
|
skipnextlf = 0;
|
||||||
if (c == '\n') {
|
if (c == '\n') {
|
||||||
/* Seeing a \n here with
|
/* Seeing a \n here with
|
||||||
* skipnextlf true means we
|
* skipnextlf true means we
|
||||||
* saw a \r before.
|
* saw a \r before.
|
||||||
*/
|
*/
|
||||||
newlinetypes |= NEWLINE_CRLF;
|
newlinetypes |= NEWLINE_CRLF;
|
||||||
|
@ -377,7 +377,7 @@ Util_ReadAhead(BZ2FileObject *self, int bufsize)
|
||||||
PyFileObject *f = (PyFileObject*)self;
|
PyFileObject *f = (PyFileObject*)self;
|
||||||
|
|
||||||
if (f->f_buf != NULL) {
|
if (f->f_buf != NULL) {
|
||||||
if((f->f_bufend - f->f_bufptr) >= 1)
|
if((f->f_bufend - f->f_bufptr) >= 1)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
Util_DropReadAhead(self);
|
Util_DropReadAhead(self);
|
||||||
|
@ -418,11 +418,11 @@ Util_ReadAheadGetLineSkip(BZ2FileObject *bf, int skip, int bufsize)
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (f->f_buf == NULL)
|
if (f->f_buf == NULL)
|
||||||
if (Util_ReadAhead(bf, bufsize) < 0)
|
if (Util_ReadAhead(bf, bufsize) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
len = f->f_bufend - f->f_bufptr;
|
len = f->f_bufend - f->f_bufptr;
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
return (PyStringObject *)
|
return (PyStringObject *)
|
||||||
PyString_FromStringAndSize(NULL, skip);
|
PyString_FromStringAndSize(NULL, skip);
|
||||||
bufptr = memchr(f->f_bufptr, '\n', len);
|
bufptr = memchr(f->f_bufptr, '\n', len);
|
||||||
|
@ -431,7 +431,7 @@ Util_ReadAheadGetLineSkip(BZ2FileObject *bf, int skip, int bufsize)
|
||||||
len = bufptr - f->f_bufptr;
|
len = bufptr - f->f_bufptr;
|
||||||
s = (PyStringObject *)
|
s = (PyStringObject *)
|
||||||
PyString_FromStringAndSize(NULL, skip+len);
|
PyString_FromStringAndSize(NULL, skip+len);
|
||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
memcpy(PyString_AS_STRING(s)+skip, f->f_bufptr, len);
|
memcpy(PyString_AS_STRING(s)+skip, f->f_bufptr, len);
|
||||||
f->f_bufptr = bufptr;
|
f->f_bufptr = bufptr;
|
||||||
|
@ -471,10 +471,10 @@ BZ2File_read(BZ2FileObject *self, PyObject *args)
|
||||||
size_t bytesread, buffersize, chunksize;
|
size_t bytesread, buffersize, chunksize;
|
||||||
int bzerror;
|
int bzerror;
|
||||||
PyObject *ret = NULL;
|
PyObject *ret = NULL;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "|l:read", &bytesrequested))
|
if (!PyArg_ParseTuple(args, "|l:read", &bytesrequested))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ACQUIRE_LOCK(self);
|
ACQUIRE_LOCK(self);
|
||||||
switch (self->mode) {
|
switch (self->mode) {
|
||||||
case MODE_READ:
|
case MODE_READ:
|
||||||
|
@ -761,17 +761,17 @@ BZ2File_write(BZ2FileObject *self, PyObject *args)
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "s#", &buf, &len))
|
if (!PyArg_ParseTuple(args, "s#", &buf, &len))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ACQUIRE_LOCK(self);
|
ACQUIRE_LOCK(self);
|
||||||
switch (self->mode) {
|
switch (self->mode) {
|
||||||
case MODE_WRITE:
|
case MODE_WRITE:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_CLOSED:
|
case MODE_CLOSED:
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"I/O operation on closed file");
|
"I/O operation on closed file");
|
||||||
goto cleanup;;
|
goto cleanup;;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
PyErr_SetString(PyExc_IOError,
|
PyErr_SetString(PyExc_IOError,
|
||||||
"file is not ready for writing");
|
"file is not ready for writing");
|
||||||
|
@ -784,12 +784,12 @@ BZ2File_write(BZ2FileObject *self, PyObject *args)
|
||||||
BZ2_bzWrite (&bzerror, self->fp, buf, len);
|
BZ2_bzWrite (&bzerror, self->fp, buf, len);
|
||||||
self->pos += len;
|
self->pos += len;
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
|
|
||||||
if (bzerror != BZ_OK) {
|
if (bzerror != BZ_OK) {
|
||||||
Util_CatchBZ2Error(bzerror);
|
Util_CatchBZ2Error(bzerror);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
ret = Py_None;
|
ret = Py_None;
|
||||||
|
|
||||||
|
@ -945,7 +945,7 @@ BZ2File_seek(BZ2FileObject *self, PyObject *args)
|
||||||
int rewind = 0;
|
int rewind = 0;
|
||||||
PyObject *func;
|
PyObject *func;
|
||||||
PyObject *ret = NULL;
|
PyObject *ret = NULL;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "l|i:seek", &offset, &where))
|
if (!PyArg_ParseTuple(args, "l|i:seek", &offset, &where))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -955,12 +955,12 @@ BZ2File_seek(BZ2FileObject *self, PyObject *args)
|
||||||
case MODE_READ:
|
case MODE_READ:
|
||||||
case MODE_READ_EOF:
|
case MODE_READ_EOF:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MODE_CLOSED:
|
case MODE_CLOSED:
|
||||||
PyErr_SetString(PyExc_ValueError,
|
PyErr_SetString(PyExc_ValueError,
|
||||||
"I/O operation on closed file");
|
"I/O operation on closed file");
|
||||||
goto cleanup;;
|
goto cleanup;;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
PyErr_SetString(PyExc_IOError,
|
PyErr_SetString(PyExc_IOError,
|
||||||
"seek works only while reading");
|
"seek works only while reading");
|
||||||
|
@ -1192,7 +1192,7 @@ BZ2File_init(BZ2FileObject *self, PyObject *args, PyObject *kwargs)
|
||||||
int univ_newline = 0;
|
int univ_newline = 0;
|
||||||
|
|
||||||
self->size = -1;
|
self->size = -1;
|
||||||
|
|
||||||
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "et|sii:BZ2File",
|
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "et|sii:BZ2File",
|
||||||
kwlist, Py_FileSystemDefaultEncoding,
|
kwlist, Py_FileSystemDefaultEncoding,
|
||||||
&name, &mode, &buffering,
|
&name, &mode, &buffering,
|
||||||
|
@ -1240,7 +1240,7 @@ BZ2File_init(BZ2FileObject *self, PyObject *args, PyObject *kwargs)
|
||||||
mode = univ_newline ? "rbU" : "rb";
|
mode = univ_newline ? "rbU" : "rb";
|
||||||
else
|
else
|
||||||
mode = univ_newline ? "wbU" : "wb";
|
mode = univ_newline ? "wbU" : "wb";
|
||||||
|
|
||||||
file_args = Py_BuildValue("(ssi)", name, mode, buffering);
|
file_args = Py_BuildValue("(ssi)", name, mode, buffering);
|
||||||
if (!file_args)
|
if (!file_args)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -1952,7 +1952,7 @@ bz2_compress(PyObject *self, PyObject *args, PyObject *kwargs)
|
||||||
Py_DECREF(ret);
|
Py_DECREF(ret);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
bzerror = BZ2_bzCompress(bzs, BZ_FINISH);
|
bzerror = BZ2_bzCompress(bzs, BZ_FINISH);
|
||||||
|
@ -2025,7 +2025,7 @@ bz2_decompress(PyObject *self, PyObject *args)
|
||||||
Py_DECREF(ret);
|
Py_DECREF(ret);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
bzerror = BZ2_bzDecompress(bzs);
|
bzerror = BZ2_bzDecompress(bzs);
|
||||||
|
|
Loading…
Reference in New Issue