[Python-checkins] CVS: python/dist/src/Modules zlibmodule.c,2.52,2.53
Tim Peters
tim_one@users.sourceforge.net
Tue, 16 Oct 2001 20:57:22 -0700
Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv16986/python/Modules
Modified Files:
zlibmodule.c
Log Message:
Trimmed trailing whitespace.
Index: zlibmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/zlibmodule.c,v
retrieving revision 2.52
retrieving revision 2.53
diff -C2 -d -r2.52 -r2.53
*** zlibmodule.c 2001/10/17 03:56:45 2.52
--- zlibmodule.c 2001/10/17 03:57:20 2.53
***************
*** 61,65 ****
static PyObject *ZlibError;
! typedef struct
{
PyObject_HEAD
--- 61,65 ----
static PyObject *ZlibError;
! typedef struct
{
PyObject_HEAD
***************
*** 79,88 ****
}
! static char compressobj__doc__[] =
"compressobj() -- Return a compressor object.\n"
"compressobj(level) -- Return a compressor object, using the given compression level.\n"
;
! static char decompressobj__doc__[] =
"decompressobj() -- Return a decompressor object.\n"
"decompressobj(wbits) -- Return a decompressor object, setting the window buffer size to wbits.\n"
--- 79,88 ----
}
! static char compressobj__doc__[] =
"compressobj() -- Return a compressor object.\n"
"compressobj(level) -- Return a compressor object, using the given compression level.\n"
;
! static char decompressobj__doc__[] =
"decompressobj() -- Return a decompressor object.\n"
"decompressobj(wbits) -- Return a decompressor object, setting the window buffer size to wbits.\n"
***************
*** 92,96 ****
newcompobject(PyTypeObject *type)
{
! compobject *self;
self = PyObject_New(compobject, type);
if (self == NULL)
--- 92,96 ----
newcompobject(PyTypeObject *type)
{
! compobject *self;
self = PyObject_New(compobject, type);
if (self == NULL)
***************
*** 110,114 ****
}
! static char compress__doc__[] =
"compress(string) -- Compress string using the default compression level, "
"returning a string containing compressed data.\n"
--- 110,114 ----
}
! static char compress__doc__[] =
"compress(string) -- Compress string using the default compression level, "
"returning a string containing compressed data.\n"
***************
*** 124,128 ****
int length, level=Z_DEFAULT_COMPRESSION, err;
z_stream zst;
!
/* require Python string object, optional 'level' arg */
if (!PyArg_ParseTuple(args, "s#|i:compress", &input, &length, &level))
--- 124,128 ----
int length, level=Z_DEFAULT_COMPRESSION, err;
z_stream zst;
!
/* require Python string object, optional 'level' arg */
if (!PyArg_ParseTuple(args, "s#|i:compress", &input, &length, &level))
***************
*** 174,183 ****
goto error;
}
!
err=deflateEnd(&zst);
if (err == Z_OK)
! ReturnVal = PyString_FromStringAndSize((char *)output,
zst.total_out);
! else
zlib_error(zst, err, "while finishing compression");
--- 174,183 ----
goto error;
}
!
err=deflateEnd(&zst);
if (err == Z_OK)
! ReturnVal = PyString_FromStringAndSize((char *)output,
zst.total_out);
! else
zlib_error(zst, err, "while finishing compression");
***************
*** 188,192 ****
}
! static char decompress__doc__[] =
"decompress(string) -- Decompress the data in string, returning a string containing the decompressed data.\n"
"decompress(string, wbits) -- Decompress the data in string with a window buffer size of wbits.\n"
--- 188,192 ----
}
! static char decompress__doc__[] =
"decompress(string) -- Decompress the data in string, returning a string containing the decompressed data.\n"
"decompress(string, wbits) -- Decompress the data in string with a window buffer size of wbits.\n"
***************
*** 203,207 ****
z_stream zst;
! if (!PyArg_ParseTuple(args, "s#|ii:decompress",
&input, &length, &wsize, &r_strlen))
return NULL;
--- 203,207 ----
z_stream zst;
! if (!PyArg_ParseTuple(args, "s#|ii:decompress",
&input, &length, &wsize, &r_strlen))
return NULL;
***************
*** 225,229 ****
case(Z_OK):
break;
! case(Z_MEM_ERROR):
PyErr_SetString(PyExc_MemoryError,
"Out of memory while decompressing data");
--- 225,229 ----
case(Z_OK):
break;
! case(Z_MEM_ERROR):
PyErr_SetString(PyExc_MemoryError,
"Out of memory while decompressing data");
***************
*** 301,305 ****
self = newcompobject(&Comptype);
! if (self==NULL)
return(NULL);
self->zst.zalloc = (alloc_func)NULL;
--- 301,305 ----
self = newcompobject(&Comptype);
! if (self==NULL)
return(NULL);
self->zst.zalloc = (alloc_func)NULL;
***************
*** 335,339 ****
self = newcompobject(&Decomptype);
! if (self == NULL)
return(NULL);
self->zst.zalloc = (alloc_func)NULL;
--- 335,339 ----
self = newcompobject(&Decomptype);
! if (self == NULL)
return(NULL);
self->zst.zalloc = (alloc_func)NULL;
***************
*** 395,399 ****
Byte *input;
unsigned long start_total_out;
!
if (!PyArg_ParseTuple(args, "s#:compress", &input, &inplen))
return NULL;
--- 395,399 ----
Byte *input;
unsigned long start_total_out;
!
if (!PyArg_ParseTuple(args, "s#:compress", &input, &inplen))
return NULL;
***************
*** 425,437 ****
self->zst.avail_out = length;
length = length << 1;
!
Py_BEGIN_ALLOW_THREADS
err = deflate(&(self->zst), Z_NO_FLUSH);
Py_END_ALLOW_THREADS
}
! /* We will only get Z_BUF_ERROR if the output buffer was full but
there wasn't more output when we tried again, so it is not an error
! condition.
! */
if (err != Z_OK && err != Z_BUF_ERROR) {
--- 425,437 ----
self->zst.avail_out = length;
length = length << 1;
!
Py_BEGIN_ALLOW_THREADS
err = deflate(&(self->zst), Z_NO_FLUSH);
Py_END_ALLOW_THREADS
}
! /* We will only get Z_BUF_ERROR if the output buffer was full but
there wasn't more output when we tried again, so it is not an error
! condition.
! */
if (err != Z_OK && err != Z_BUF_ERROR) {
***************
*** 441,445 ****
goto error;
}
! if (_PyString_Resize(&RetVal,
self->zst.total_out - start_total_out) < 0)
RetVal = NULL;
--- 441,445 ----
goto error;
}
! if (_PyString_Resize(&RetVal,
self->zst.total_out - start_total_out) < 0)
RetVal = NULL;
***************
*** 470,474 ****
unsigned long start_total_out;
! if (!PyArg_ParseTuple(args, "s#|i:decompress", &input,
&inplen, &max_length))
return NULL;
--- 470,474 ----
unsigned long start_total_out;
! if (!PyArg_ParseTuple(args, "s#|i:decompress", &input,
&inplen, &max_length))
return NULL;
***************
*** 480,484 ****
/* limit amount of data allocated to max_length */
! if (max_length && length > max_length)
length = max_length;
if (!(RetVal = PyString_FromStringAndSize(NULL, length)))
--- 480,484 ----
/* limit amount of data allocated to max_length */
! if (max_length && length > max_length)
length = max_length;
if (!(RetVal = PyString_FromStringAndSize(NULL, length)))
***************
*** 500,504 ****
So extend the output buffer and try again.
*/
! while (err == Z_OK && self->zst.avail_out == 0) {
/* If max_length set, don't continue decompressing if we've already
reached the limit.
--- 500,504 ----
So extend the output buffer and try again.
*/
! while (err == Z_OK && self->zst.avail_out == 0) {
/* If max_length set, don't continue decompressing if we've already
reached the limit.
***************
*** 510,514 ****
old_length = length;
length = length << 1;
! if (max_length && length > max_length)
length = max_length;
--- 510,514 ----
old_length = length;
length = length << 1;
! if (max_length && length > max_length)
length = max_length;
***************
*** 530,534 ****
if(max_length) {
Py_DECREF(self->unconsumed_tail);
! self->unconsumed_tail = PyString_FromStringAndSize(self->zst.next_in,
self->zst.avail_in);
if(!self->unconsumed_tail) {
--- 530,534 ----
if(max_length) {
Py_DECREF(self->unconsumed_tail);
! self->unconsumed_tail = PyString_FromStringAndSize(self->zst.next_in,
self->zst.avail_in);
if(!self->unconsumed_tail) {
***************
*** 539,545 ****
}
! /* The end of the compressed data has been reached, so set the
! unused_data attribute to a string containing the remainder of the
! data in the string. Note that this is also a logical place to call
inflateEnd, but the old behaviour of only calling it on flush() is
preserved.
--- 539,545 ----
}
! /* The end of the compressed data has been reached, so set the
! unused_data attribute to a string containing the remainder of the
! data in the string. Note that this is also a logical place to call
inflateEnd, but the old behaviour of only calling it on flush() is
preserved.
***************
*** 553,557 ****
goto error;
}
! /* We will only get Z_BUF_ERROR if the output buffer was full
but there wasn't more output when we tried again, so it is
not an error condition.
--- 553,557 ----
goto error;
}
! /* We will only get Z_BUF_ERROR if the output buffer was full
but there wasn't more output when we tried again, so it is
not an error condition.
***************
*** 602,606 ****
ENTER_ZLIB
!
start_total_out = self->zst.total_out;
self->zst.avail_in = 0;
--- 602,606 ----
ENTER_ZLIB
!
start_total_out = self->zst.total_out;
self->zst.avail_in = 0;
***************
*** 630,634 ****
/* If flushmode is Z_FINISH, we also have to call deflateEnd() to free
! various data structures. Note we should only get Z_STREAM_END when
flushmode is Z_FINISH, but checking both for safety*/
if (err == Z_STREAM_END && flushmode == Z_FINISH) {
--- 630,634 ----
/* If flushmode is Z_FINISH, we also have to call deflateEnd() to free
! various data structures. Note we should only get Z_STREAM_END when
flushmode is Z_FINISH, but checking both for safety*/
if (err == Z_STREAM_END && flushmode == Z_FINISH) {
***************
*** 642,648 ****
else
self->is_initialised = 0;
!
! /* We will only get Z_BUF_ERROR if the output buffer was full
! but there wasn't more output when we tried again, so it is
not an error condition.
*/
--- 642,648 ----
else
self->is_initialised = 0;
!
! /* We will only get Z_BUF_ERROR if the output buffer was full
! but there wasn't more output when we tried again, so it is
not an error condition.
*/
***************
*** 652,660 ****
RetVal = NULL;
}
!
if (_PyString_Resize(&RetVal, self->zst.total_out - start_total_out) < 0)
RetVal = NULL;
! error:
LEAVE_ZLIB
--- 652,660 ----
RetVal = NULL;
}
!
if (_PyString_Resize(&RetVal, self->zst.total_out - start_total_out) < 0)
RetVal = NULL;
! error:
LEAVE_ZLIB
***************
*** 669,680 ****
static PyObject *
PyZlib_unflush(compobject *self, PyObject *args)
! /*decompressor flush is a no-op because all pending data would have been
flushed by the decompress method. However, this routine previously called
! inflateEnd, causing any further decompress or flush calls to raise
exceptions. This behaviour has been preserved.*/
{
int err;
PyObject * retval = NULL;
!
if (!PyArg_ParseTuple(args, ""))
return NULL;
--- 669,680 ----
static PyObject *
PyZlib_unflush(compobject *self, PyObject *args)
! /*decompressor flush is a no-op because all pending data would have been
flushed by the decompress method. However, this routine previously called
! inflateEnd, causing any further decompress or flush calls to raise
exceptions. This behaviour has been preserved.*/
{
int err;
PyObject * retval = NULL;
!
if (!PyArg_ParseTuple(args, ""))
return NULL;
***************
*** 697,703 ****
static PyMethodDef comp_methods[] =
{
! {"compress", (binaryfunc)PyZlib_objcompress, METH_VARARGS,
comp_compress__doc__},
! {"flush", (binaryfunc)PyZlib_flush, METH_VARARGS,
comp_flush__doc__},
{NULL, NULL}
--- 697,703 ----
static PyMethodDef comp_methods[] =
{
! {"compress", (binaryfunc)PyZlib_objcompress, METH_VARARGS,
comp_compress__doc__},
! {"flush", (binaryfunc)PyZlib_flush, METH_VARARGS,
comp_flush__doc__},
{NULL, NULL}
***************
*** 706,712 ****
static PyMethodDef Decomp_methods[] =
{
! {"decompress", (binaryfunc)PyZlib_objdecompress, METH_VARARGS,
decomp_decompress__doc__},
! {"flush", (binaryfunc)PyZlib_unflush, METH_VARARGS,
decomp_flush__doc__},
{NULL, NULL}
--- 706,712 ----
static PyMethodDef Decomp_methods[] =
{
! {"decompress", (binaryfunc)PyZlib_objdecompress, METH_VARARGS,
decomp_decompress__doc__},
! {"flush", (binaryfunc)PyZlib_unflush, METH_VARARGS,
decomp_flush__doc__},
{NULL, NULL}
***************
*** 729,739 ****
ENTER_ZLIB
! if (strcmp(name, "unused_data") == 0) {
Py_INCREF(self->unused_data);
retval = self->unused_data;
! } else if (strcmp(name, "unconsumed_tail") == 0) {
Py_INCREF(self->unconsumed_tail);
retval = self->unconsumed_tail;
! } else
retval = Py_FindMethod(Decomp_methods, (PyObject *)self, name);
--- 729,739 ----
ENTER_ZLIB
! if (strcmp(name, "unused_data") == 0) {
Py_INCREF(self->unused_data);
retval = self->unused_data;
! } else if (strcmp(name, "unconsumed_tail") == 0) {
Py_INCREF(self->unconsumed_tail);
retval = self->unconsumed_tail;
! } else
retval = Py_FindMethod(Decomp_methods, (PyObject *)self, name);
***************
*** 743,747 ****
}
! static char adler32__doc__[] =
"adler32(string) -- Compute an Adler-32 checksum of string, using "
"a default starting value, and returning an integer value.\n"
--- 743,747 ----
}
! static char adler32__doc__[] =
"adler32(string) -- Compute an Adler-32 checksum of string, using "
"a default starting value, and returning an integer value.\n"
***************
*** 756,760 ****
Byte *buf;
int len;
!
if (!PyArg_ParseTuple(args, "s#|l:adler32", &buf, &len, &adler32val))
return NULL;
--- 756,760 ----
Byte *buf;
int len;
!
if (!PyArg_ParseTuple(args, "s#|l:adler32", &buf, &len, &adler32val))
return NULL;
***************
*** 762,767 ****
return PyInt_FromLong(adler32val);
}
!
! static char crc32__doc__[] =
"crc32(string) -- Compute a CRC-32 checksum of string, using "
"a default starting value, and returning an integer value.\n"
--- 762,767 ----
return PyInt_FromLong(adler32val);
}
!
! static char crc32__doc__[] =
"crc32(string) -- Compute a CRC-32 checksum of string, using "
"a default starting value, and returning an integer value.\n"
***************
*** 781,799 ****
return PyInt_FromLong(crc32val);
}
-
static PyMethodDef zlib_methods[] =
{
! {"adler32", (PyCFunction)PyZlib_adler32, METH_VARARGS,
adler32__doc__},
! {"compress", (PyCFunction)PyZlib_compress, METH_VARARGS,
compress__doc__},
! {"compressobj", (PyCFunction)PyZlib_compressobj, METH_VARARGS,
compressobj__doc__},
! {"crc32", (PyCFunction)PyZlib_crc32, METH_VARARGS,
! crc32__doc__},
! {"decompress", (PyCFunction)PyZlib_decompress, METH_VARARGS,
decompress__doc__},
! {"decompressobj", (PyCFunction)PyZlib_decompressobj, METH_VARARGS,
decompressobj__doc__},
{NULL, NULL}
--- 781,799 ----
return PyInt_FromLong(crc32val);
}
+
static PyMethodDef zlib_methods[] =
{
! {"adler32", (PyCFunction)PyZlib_adler32, METH_VARARGS,
adler32__doc__},
! {"compress", (PyCFunction)PyZlib_compress, METH_VARARGS,
compress__doc__},
! {"compressobj", (PyCFunction)PyZlib_compressobj, METH_VARARGS,
compressobj__doc__},
! {"crc32", (PyCFunction)PyZlib_crc32, METH_VARARGS,
! crc32__doc__},
! {"decompress", (PyCFunction)PyZlib_decompress, METH_VARARGS,
decompress__doc__},
! {"decompressobj", (PyCFunction)PyZlib_decompressobj, METH_VARARGS,
decompressobj__doc__},
{NULL, NULL}
***************
*** 834,839 ****
};
! /* The following insint() routine was blatantly ripped off from
! socketmodule.c */
/* Convenience routine to export an integer value.
--- 834,839 ----
};
! /* The following insint() routine was blatantly ripped off from
! socketmodule.c */
/* Convenience routine to export an integer value.
***************
*** 892,901 ****
PyModule_AddIntConstant(m, "Z_HUFFMAN_ONLY", Z_HUFFMAN_ONLY);
PyModule_AddIntConstant(m, "Z_DEFAULT_STRATEGY", Z_DEFAULT_STRATEGY);
!
PyModule_AddIntConstant(m, "Z_FINISH", Z_FINISH);
PyModule_AddIntConstant(m, "Z_NO_FLUSH", Z_NO_FLUSH);
PyModule_AddIntConstant(m, "Z_SYNC_FLUSH", Z_SYNC_FLUSH);
PyModule_AddIntConstant(m, "Z_FULL_FLUSH", Z_FULL_FLUSH);
!
ver = PyString_FromString(ZLIB_VERSION);
if (ver != NULL) {
--- 892,901 ----
PyModule_AddIntConstant(m, "Z_HUFFMAN_ONLY", Z_HUFFMAN_ONLY);
PyModule_AddIntConstant(m, "Z_DEFAULT_STRATEGY", Z_DEFAULT_STRATEGY);
!
PyModule_AddIntConstant(m, "Z_FINISH", Z_FINISH);
PyModule_AddIntConstant(m, "Z_NO_FLUSH", Z_NO_FLUSH);
PyModule_AddIntConstant(m, "Z_SYNC_FLUSH", Z_SYNC_FLUSH);
PyModule_AddIntConstant(m, "Z_FULL_FLUSH", Z_FULL_FLUSH);
!
ver = PyString_FromString(ZLIB_VERSION);
if (ver != NULL) {