This commit is contained in:
John Kerl 2015-09-01 17:02:56 -04:00
parent 90b8397c67
commit ecb157cdc9
3 changed files with 5 additions and 17 deletions

View file

@ -445,15 +445,3 @@ int main(int argc, char** argv) {
// * string-builder is a little than fixed-length malloc, as expected
// -- it's adding value.
// ! peek_file_reader is where the optimization opportunities are
// type t_min t_mean t_max t_stddev
// getdelim 0.123838 0.177310 0.379211 0.112953
// mmap_psb 0.247112 0.268105 0.291486 0.017964
// getc_unlocked_psb 0.270824 0.297001 0.312675 0.015846
// getc_unlocked_fixed_len 0.500122 0.609473 0.829920 0.131760
// pfr_psb 0.689040 0.723372 0.790989 0.042090
// fgetc_psb 2.806522 2.880403 2.984247 0.081905
// fgetc_fixed_len 2.931093 3.016009 3.166140 0.092539

View file

@ -145,6 +145,10 @@ static field_wrapper_t get_csv_field(lrec_reader_stdio_csv_state_t* pstate) {
wrapper.termind = TERMIND_EOF;
return wrapper;
} else if (pfr_next_is(pstate->pfr, pstate->dquote, pstate->dquote_len)) {
if (!pfr_advance_past(pstate->pfr, pstate->dquote)) {
fprintf(stderr, "%s: Internal coding error: DQUOTE found and lost.\n", MLR_GLOBALS.argv0);
exit(1);
}
return get_csv_field_dquoted(pstate);
} else {
return get_csv_field_not_dquoted(pstate);
@ -187,10 +191,6 @@ static field_wrapper_t get_csv_field_not_dquoted(lrec_reader_stdio_csv_state_t*
}
static field_wrapper_t get_csv_field_dquoted(lrec_reader_stdio_csv_state_t* pstate) {
if (!pfr_advance_past(pstate->pfr, pstate->dquote)) {
fprintf(stderr, "%s: Internal coding error: DQUOTE found and lost.\n", MLR_GLOBALS.argv0);
exit(1);
}
while (TRUE) {
if (pfr_at_eof(pstate->pfr)) {
fprintf(stderr, "%s: imbalanced double-quote at line %lld.\n", MLR_GLOBALS.argv0, pstate->ilno);

View file

@ -28,7 +28,7 @@ peek_file_reader_t* pfr_alloc(FILE* fp, int maxnpeek) {
// ----------------------------------------------------------------
int pfr_at_eof(peek_file_reader_t* pfr) {
return pfr->npeeked == 1 && pfr->peekbuf[0] == EOF;
return pfr->npeeked >= 1 && pfr->peekbuf[0] == EOF;
}
// ----------------------------------------------------------------