@@ -196,14 +196,14 @@ int parser_init(parser_t *self) {
196
196
sz = STREAM_INIT_SIZE / 10 ;
197
197
sz = sz ? sz : 1 ;
198
198
self -> words = (char * * )malloc (sz * sizeof (char * ));
199
- self -> word_starts = (size_t * )malloc (sz * sizeof (size_t ));
199
+ self -> word_starts = (int64_t * )malloc (sz * sizeof (int64_t ));
200
200
self -> words_cap = sz ;
201
201
self -> words_len = 0 ;
202
202
203
203
// line pointers and metadata
204
- self -> line_start = (size_t * )malloc (sz * sizeof (size_t ));
204
+ self -> line_start = (int64_t * )malloc (sz * sizeof (int64_t ));
205
205
206
- self -> line_fields = (size_t * )malloc (sz * sizeof (size_t ));
206
+ self -> line_fields = (int64_t * )malloc (sz * sizeof (int64_t ));
207
207
208
208
self -> lines_cap = sz ;
209
209
self -> lines = 0 ;
@@ -247,7 +247,7 @@ void parser_del(parser_t *self) {
247
247
}
248
248
249
249
static int make_stream_space (parser_t * self , size_t nbytes ) {
250
- size_t i , cap ;
250
+ int64_t i , cap ;
251
251
int status ;
252
252
void * orig_ptr , * newptr ;
253
253
@@ -419,7 +419,7 @@ static void append_warning(parser_t *self, const char *msg) {
419
419
420
420
static int end_line (parser_t * self ) {
421
421
char * msg ;
422
- int fields ;
422
+ int64_t fields ;
423
423
int ex_fields = self -> expected_fields ;
424
424
size_t bufsize = 100 ; // for error or warning messages
425
425
@@ -468,8 +468,8 @@ static int end_line(parser_t *self) {
468
468
if (self -> error_bad_lines ) {
469
469
self -> error_msg = (char * )malloc (bufsize );
470
470
snprintf (self -> error_msg , bufsize ,
471
- "Expected %d fields in line %d , saw %d \n" ,
472
- ex_fields , self -> file_lines , fields );
471
+ "Expected %d fields in line %lld , saw %lld \n" ,
472
+ ex_fields , ( long long ) self -> file_lines , ( long long ) fields );
473
473
474
474
TRACE (("Error at line %d, %d fields\n" , self -> file_lines , fields ));
475
475
@@ -480,8 +480,9 @@ static int end_line(parser_t *self) {
480
480
// pass up error message
481
481
msg = (char * )malloc (bufsize );
482
482
snprintf (msg , bufsize ,
483
- "Skipping line %d: expected %d fields, saw %d\n" ,
484
- self -> file_lines , ex_fields , fields );
483
+ "Skipping line %lld: expected %d fields, saw %lld\n" ,
484
+ (long long )self -> file_lines , ex_fields ,
485
+ (long long )fields );
485
486
append_warning (self , msg );
486
487
free (msg );
487
488
}
@@ -632,7 +633,7 @@ static int parser_buffer_bytes(parser_t *self, size_t nbytes) {
632
633
stream = self->stream + self->stream_len; \
633
634
slen = self->stream_len; \
634
635
self->state = STATE; \
635
- if (line_limit > 0 && self->lines == start_lines + (size_t )line_limit) { \
636
+ if (line_limit > 0 && self->lines == start_lines + (int64_t )line_limit) { \
636
637
goto linelimit; \
637
638
}
638
639
@@ -647,7 +648,7 @@ static int parser_buffer_bytes(parser_t *self, size_t nbytes) {
647
648
stream = self->stream + self->stream_len; \
648
649
slen = self->stream_len; \
649
650
self->state = STATE; \
650
- if (line_limit > 0 && self->lines == start_lines + (size_t )line_limit) { \
651
+ if (line_limit > 0 && self->lines == start_lines + (int64_t )line_limit) { \
651
652
goto linelimit; \
652
653
}
653
654
@@ -1147,7 +1148,8 @@ static int parser_handle_eof(parser_t *self) {
1147
1148
case IN_QUOTED_FIELD :
1148
1149
self -> error_msg = (char * )malloc (bufsize );
1149
1150
snprintf (self -> error_msg , bufsize ,
1150
- "EOF inside string starting at line %d" , self -> file_lines );
1151
+ "EOF inside string starting at line %lld" ,
1152
+ (long long )self -> file_lines );
1151
1153
return -1 ;
1152
1154
1153
1155
case ESCAPED_CHAR :
@@ -1318,7 +1320,7 @@ void debug_print_parser(parser_t *self) {
1318
1320
char * token ;
1319
1321
1320
1322
for (line = 0 ; line < self -> lines ; ++ line ) {
1321
- printf ("(Parsed) Line %d : " , line );
1323
+ printf ("(Parsed) Line %lld : " , ( long long ) line );
1322
1324
1323
1325
for (j = 0 ; j < self -> line_fields [j ]; ++ j ) {
1324
1326
token = self -> words [j + self -> line_start [line ]];
0 commit comments