From ecb157cdc91eb311905926cb5e454e4121763d81 Mon Sep 17 00:00:00 2001 From: John Kerl Date: Tue, 1 Sep 2015 17:02:56 -0400 Subject: [PATCH] neaten --- c/experimental/getlines.c | 12 ------------ c/input/lrec_reader_stdio_csv.c | 8 ++++---- c/input/peek_file_reader.c | 2 +- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/c/experimental/getlines.c b/c/experimental/getlines.c index 7d72b23eb..26f0e28ea 100644 --- a/c/experimental/getlines.c +++ b/c/experimental/getlines.c @@ -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 diff --git a/c/input/lrec_reader_stdio_csv.c b/c/input/lrec_reader_stdio_csv.c index 32423db38..30fb7ddcb 100644 --- a/c/input/lrec_reader_stdio_csv.c +++ b/c/input/lrec_reader_stdio_csv.c @@ -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); diff --git a/c/input/peek_file_reader.c b/c/input/peek_file_reader.c index ed357629c..14fe37023 100644 --- a/c/input/peek_file_reader.c +++ b/c/input/peek_file_reader.c @@ -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; } // ----------------------------------------------------------------