@@ -73,13 +73,11 @@ static char __author__[] =
7373#define RELEASE_LOCK (obj )
7474#endif
7575
76- #ifdef WITH_UNIVERSAL_NEWLINES
7776/* Bits in f_newlinetypes */
7877#define NEWLINE_UNKNOWN 0 /* No newline seen, yet */
7978#define NEWLINE_CR 1 /* \r newline seen */
8079#define NEWLINE_LF 2 /* \n newline seen */
8180#define NEWLINE_CRLF 4 /* \r\n newline seen */
82- #endif
8381
8482/* ===================================================================== */
8583/* Structure definitions. */
@@ -94,11 +92,9 @@ typedef struct {
9492
9593 int f_softspace ; /* Flag used by 'print' command */
9694
97- #ifdef WITH_UNIVERSAL_NEWLINES
9895 int f_univ_newline ; /* Handle any newline convention */
9996 int f_newlinetypes ; /* Types of newlines seen */
10097 int f_skipnextlf ; /* Skip next \n */
101- #endif
10298
10399 BZFILE * fp ;
104100 int mode ;
@@ -227,11 +223,9 @@ Util_GetLine(BZ2FileObject *f, int n)
227223 size_t increment ; /* amount to increment the buffer */
228224 PyObject * v ;
229225 int bzerror ;
230- #ifdef WITH_UNIVERSAL_NEWLINES
231226 int newlinetypes = f -> f_newlinetypes ;
232227 int skipnextlf = f -> f_skipnextlf ;
233228 int univ_newline = f -> f_univ_newline ;
234- #endif
235229
236230 total_v_size = n > 0 ? n : 100 ;
237231 v = PyString_FromStringAndSize ((char * )NULL , total_v_size );
@@ -243,7 +237,6 @@ Util_GetLine(BZ2FileObject *f, int n)
243237
244238 for (;;) {
245239 Py_BEGIN_ALLOW_THREADS
246- #ifdef WITH_UNIVERSAL_NEWLINES
247240 if (univ_newline ) {
248241 while (1 ) {
249242 BZ2_bzRead (& bzerror , f -> fp , & c , 1 );
@@ -277,17 +270,14 @@ Util_GetLine(BZ2FileObject *f, int n)
277270 if (bzerror == BZ_STREAM_END && skipnextlf )
278271 newlinetypes |= NEWLINE_CR ;
279272 } else /* If not universal newlines use the normal loop */
280- #endif
281273 do {
282274 BZ2_bzRead (& bzerror , f -> fp , & c , 1 );
283275 f -> pos ++ ;
284276 * buf ++ = c ;
285277 } while (bzerror == BZ_OK && c != '\n' && buf != end );
286278 Py_END_ALLOW_THREADS
287- #ifdef WITH_UNIVERSAL_NEWLINES
288279 f -> f_newlinetypes = newlinetypes ;
289280 f -> f_skipnextlf = skipnextlf ;
290- #endif
291281 if (bzerror == BZ_STREAM_END ) {
292282 f -> size = f -> pos ;
293283 f -> mode = MODE_READ_EOF ;
@@ -323,9 +313,6 @@ Util_GetLine(BZ2FileObject *f, int n)
323313 return v ;
324314}
325315
326- #ifndef WITH_UNIVERSAL_NEWLINES
327- #define Util_UnivNewlineRead (a ,b ,c ,d ,e ) BZ2_bzRead(a,b,c,d)
328- #else
329316/* This is a hacked version of Python's
330317 * fileobject.c:Py_UniversalNewlineFread(). */
331318size_t
@@ -393,7 +380,6 @@ Util_UnivNewlineRead(int *bzerror, BZFILE *stream,
393380 f -> f_skipnextlf = skipnextlf ;
394381 return dst - buf ;
395382}
396- #endif
397383
398384/* This is a hacked version of Python's fileobject.c:drop_readahead(). */
399385static void
@@ -1190,7 +1176,6 @@ static PyMethodDef BZ2File_methods[] = {
11901176/* ===================================================================== */
11911177/* Getters and setters of BZ2File. */
11921178
1193- #ifdef WITH_UNIVERSAL_NEWLINES
11941179/* This is a hacked version of Python's fileobject.c:get_newlines(). */
11951180static PyObject *
11961181BZ2File_get_newlines (BZ2FileObject * self , void * closure )
@@ -1220,7 +1205,6 @@ BZ2File_get_newlines(BZ2FileObject *self, void *closure)
12201205 return NULL ;
12211206 }
12221207}
1223- #endif
12241208
12251209static PyObject *
12261210BZ2File_get_closed (BZ2FileObject * self , void * closure )
@@ -1243,10 +1227,8 @@ BZ2File_get_name(BZ2FileObject *self, void *closure)
12431227static PyGetSetDef BZ2File_getset [] = {
12441228 {"closed" , (getter )BZ2File_get_closed , NULL ,
12451229 "True if the file is closed" },
1246- #ifdef WITH_UNIVERSAL_NEWLINES
12471230 {"newlines" , (getter )BZ2File_get_newlines , NULL ,
12481231 "end-of-line convention used in this file" },
1249- #endif
12501232 {"mode" , (getter )BZ2File_get_mode , NULL ,
12511233 "file mode ('r', 'w', or 'U')" },
12521234 {"name" , (getter )BZ2File_get_name , NULL ,
@@ -1309,9 +1291,7 @@ BZ2File_init(BZ2FileObject *self, PyObject *args, PyObject *kwargs)
13091291 break ;
13101292
13111293 case 'U' :
1312- #ifdef WITH_UNIVERSAL_NEWLINES
13131294 self -> f_univ_newline = 1 ;
1314- #endif
13151295 break ;
13161296
13171297 default :
@@ -1441,7 +1421,6 @@ exist, and truncated otherwise. If the buffering argument is given, 0 means\n\
14411421unbuffered, and larger numbers specify the buffer size. If compresslevel\n\
14421422is given, must be a number between 1 and 9.\n\
14431423" )
1444- #ifdef WITH_UNIVERSAL_NEWLINES
14451424PyDoc_STR (
14461425"\n\
14471426Add a 'U' to mode to open the file for input with universal newline\n\
@@ -1451,7 +1430,6 @@ for this attribute is one of None (no newline read yet), '\\r', '\\n',\n\
14511430'\\r\\n' or a tuple containing all the newline types seen. Universal\n\
14521431newlines are available only when reading.\n\
14531432" )
1454- #endif
14551433;
14561434
14571435static PyTypeObject BZ2File_Type = {
0 commit comments