99 * modify it under the terms of the GNU Lesser General Public
1010 * License as published by the Free Software Foundation; either
1111 * version 2.1 of the License, or (at your option) any later version.
12- *
12+ *
1313 * This library is distributed in the hope that it will be useful,
1414 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1515 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1616 * Lesser General Public License for more details.
17- *
17+ *
1818 * You should have received a copy of the GNU Lesser General Public
1919 * License along with this library; if not, write to the Free Software
2020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21- *
21+ *
2222 * $Id$
2323 *
2424 */
@@ -47,17 +47,17 @@ pylzma_comp_compress(CCompressionObject *self, PyObject *args)
4747 PyObject * result = NULL ;
4848 char * data ;
4949 PARSE_LENGTH_TYPE length ;
50- PY_LONG_LONG bufsize = BLOCK_SIZE ;
50+ Py_ssize_t bufsize = BLOCK_SIZE ;
5151 int res ;
5252 size_t before ;
53-
54- if (!PyArg_ParseTuple (args , "s#|L " , & data , & length , & bufsize ))
53+
54+ if (!PyArg_ParseTuple (args , "s#|n " , & data , & length , & bufsize ))
5555 return NULL ;
56-
56+
5757 if (!MemoryInOutStreamAppend (& self -> inStream , (Byte * ) data , length )) {
5858 return PyErr_NoMemory ();
5959 }
60-
60+
6161 Py_BEGIN_ALLOW_THREADS
6262 while (1 ) {
6363 before = self -> inStream .avail ;
@@ -71,17 +71,17 @@ pylzma_comp_compress(CCompressionObject *self, PyObject *args)
7171 PyErr_Format (PyExc_TypeError , "Error during compressing: %d" , res );
7272 return NULL ;
7373 }
74-
75- length = min (self -> outStream .size , bufsize );
74+
75+ length = min (self -> outStream .size , ( size_t ) bufsize );
7676 result = PyString_FromStringAndSize ((const char * )self -> outStream .data , length );
7777 if (result != NULL ) {
7878 MemoryOutStreamDiscard (& self -> outStream , length );
7979 }
80-
80+
8181 return result ;
8282}
8383
84- static char
84+ static char
8585doc_comp_flush [] = \
8686 "flush() -- Finishes the compression and returns any remaining compressed data." ;
8787
@@ -90,7 +90,7 @@ pylzma_comp_flush(CCompressionObject *self, PyObject *args)
9090{
9191 PyObject * result ;
9292 int res ;
93-
93+
9494 Py_BEGIN_ALLOW_THREADS
9595 while (1 ) {
9696 res = LzmaEnc_CodeOneBlock (self -> encoder , False , 0 , 0 );
@@ -103,13 +103,13 @@ pylzma_comp_flush(CCompressionObject *self, PyObject *args)
103103 PyErr_Format (PyExc_TypeError , "Error during compressing: %d" , res );
104104 return NULL ;
105105 }
106-
106+
107107 LzmaEnc_Finish (self -> encoder );
108108 result = PyString_FromStringAndSize ((const char * ) self -> outStream .data , self -> outStream .size );
109109 if (result != NULL ) {
110110 MemoryOutStreamDiscard (& self -> outStream , self -> outStream .size );
111111 }
112-
112+
113113 return result ;
114114}
115115
@@ -140,7 +140,7 @@ pylzma_comp_init(CCompressionObject *self, PyObject *args, PyObject *kwargs)
140140 Byte header [LZMA_PROPS_SIZE ];
141141 size_t headerSize = LZMA_PROPS_SIZE ;
142142 int result = -1 ;
143-
143+
144144 // possible keywords for this function
145145 static char * kwlist [] = {"dictionary" , "fastBytes" , "literalContextBits" ,
146146 "literalPosBits" , "posBits" , "algorithm" , "eos" , "multithreading" , "matchfinder" , NULL };
@@ -154,11 +154,11 @@ pylzma_comp_init(CCompressionObject *self, PyObject *args, PyObject *kwargs)
154154 char * matchfinder = NULL ; // matchfinder algorithm
155155 int algorithm = 2 ;
156156 int res ;
157-
157+
158158 if (!PyArg_ParseTupleAndKeywords (args , kwargs , "|iiiiiiiis" , kwlist , & dictionary , & fastBytes ,
159159 & literalContextBits , & literalPosBits , & posBits , & algorithm , & eos , & multithreading , & matchfinder ))
160160 return -1 ;
161-
161+
162162 CHECK_RANGE (dictionary , 0 , 28 , "dictionary must be between 0 and 28" );
163163 CHECK_RANGE (fastBytes , 5 , 255 , "fastBytes must be between 5 and 255" );
164164 CHECK_RANGE (literalContextBits , 0 , 8 , "literalContextBits must be between 0 and 8" );
@@ -172,15 +172,15 @@ pylzma_comp_init(CCompressionObject *self, PyObject *args, PyObject *kwargs)
172172 PyErr_Warn (PyExc_DeprecationWarning , "matchfinder selection is deprecated and will be ignored" );
173173#endif
174174 }
175-
175+
176176 self -> encoder = LzmaEnc_Create (& allocator );
177177 if (self -> encoder == NULL ) {
178178 PyErr_NoMemory ();
179179 return -1 ;
180180 }
181-
181+
182182 LzmaEncProps_Init (& props );
183-
183+
184184 props .dictSize = 1 << dictionary ;
185185 props .lc = literalContextBits ;
186186 props .lp = literalPosBits ;
@@ -207,10 +207,10 @@ pylzma_comp_init(CCompressionObject *self, PyObject *args, PyObject *kwargs)
207207 PyErr_SetString (PyExc_TypeError , "could not generate stream header" );
208208 goto exit ;
209209 }
210-
210+
211211 LzmaEnc_Prepare (self -> encoder , & self -> inStream .s , & self -> outStream .s , & allocator , & allocator );
212212 result = 0 ;
213-
213+
214214exit :
215215 return result ;
216216}
0 commit comments