@@ -381,7 +381,7 @@ static int push_char(register parser_t *self, char c) {
381
381
return 0 ;
382
382
}
383
383
384
- int PANDAS_INLINE end_field (regiter parser_t * self ) {
384
+ int PANDAS_INLINE end_field (register parser_t * self ) {
385
385
// XXX cruft
386
386
if (self -> words_len >= self -> words_cap ) {
387
387
TRACE (
@@ -677,18 +677,16 @@ static int parser_buffer_bytes(register parser_t *self, size_t nbytes) {
677
677
#define IS_WHITESPACE (c ) ((c == ' ' || c == '\t'))
678
678
679
679
#define IS_TERMINATOR (c ) \
680
- ((self->lineterminator == '\0' && c == '\n') || \
681
- (self->lineterminator != '\0' && c == self->lineterminator))
680
+ (c == line_terminator)
682
681
683
682
#define IS_QUOTE (c ) ((c == self->quotechar && self->quoting != QUOTE_NONE))
684
683
685
684
// don't parse '\r' with a custom line terminator
686
- #define IS_CARRIAGE (c ) ((self->lineterminator == '\0' && c == '\r') )
685
+ #define IS_CARRIAGE (c ) (c == carriage_symbol )
687
686
688
- #define IS_COMMENT_CHAR (c ) \
689
- ((self->commentchar != '\0' && c == self->commentchar))
687
+ #define IS_COMMENT_CHAR (c ) (c == comment_symbol)
690
688
691
- #define IS_ESCAPE_CHAR (c ) ((self->escapechar != '\0' && c == self->escapechar) )
689
+ #define IS_ESCAPE_CHAR (c ) (c == escape_symbol )
692
690
693
691
#define IS_SKIPPABLE_SPACE (c ) \
694
692
((!self->delim_whitespace && c == ' ' && self->skipinitialspace))
@@ -739,13 +737,25 @@ int skip_this_line(register parser_t *self, int64_t rownum) {
739
737
}
740
738
}
741
739
742
- int tokenize_bytes (register parser_t * self , size_t line_limit , int64_t start_lines ) {
740
+ int tokenize_bytes (register parser_t * self ,
741
+ size_t line_limit , int64_t start_lines ) {
743
742
int64_t i , slen ;
744
743
int should_skip ;
745
744
char c ;
746
745
char * stream ;
747
746
char * buf = self -> data + self -> datapos ;
748
747
748
+ const char line_terminator = (self -> lineterminator == '\0' ) ?
749
+ '\n' : self -> lineterminator ;
750
+
751
+ // 1000 is something that couldn't fit in "char"
752
+ // thus comparing a char to it would always be "false"
753
+ const int carriage_symbol = (self -> lineterminator == '\0' ) ? '\r' : 1000 ;
754
+ const int comment_symbol = (self -> commentchar != '\0' ) ?
755
+ self -> commentchar : 1000 ;
756
+ const int escape_symbol = (self -> escapechar != '\0' ) ?
757
+ self -> escapechar : 1000 ;
758
+
749
759
if (make_stream_space (self , self -> datalen - self -> datapos ) < 0 ) {
750
760
int64_t bufsize = 100 ;
751
761
self -> error_msg = (char * )malloc (bufsize );
0 commit comments