diff options
author | drh <drh@noemail.net> | 2013-12-11 14:00:04 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2013-12-11 14:00:04 +0000 |
commit | a81ad1758c7cc9ab8dc8e78ceacc8878db77ef52 (patch) | |
tree | d0f1fdf3d388fe7a214d6bd616038ee93c1ee826 /src | |
parent | 39325bac1bc966b700270943ebb1842fc78d01be (diff) | |
download | sqlite-a81ad1758c7cc9ab8dc8e78ceacc8878db77ef52.tar.gz sqlite-a81ad1758c7cc9ab8dc8e78ceacc8878db77ef52.zip |
Fix a bug in the shell ".import" command: Do not end the field
when an escaped double-quote occurs at the end of a CRNL line.
FossilOrigin-Name: 5e239ecda0f7835ce037b38b04627a574b5854cd
Diffstat (limited to 'src')
-rw-r--r-- | src/shell.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/shell.c b/src/shell.c index 480ec5b45..7826fdf20 100644 --- a/src/shell.c +++ b/src/shell.c @@ -1836,7 +1836,7 @@ static void csv_append_char(CSVReader *p, int c){ ** + Report syntax errors on stderr */ static char *csv_read_one_field(CSVReader *p){ - int c, pc; + int c, pc, ppc; int cSep = p->cSeparator; p->n = 0; c = fgetc(p->in); @@ -1847,7 +1847,7 @@ static char *csv_read_one_field(CSVReader *p){ if( c=='"' ){ int startLine = p->nLine; int cQuote = c; - pc = 0; + pc = ppc = 0; while( 1 ){ c = fgetc(p->in); if( c=='\n' ) p->nLine++; @@ -1859,7 +1859,7 @@ static char *csv_read_one_field(CSVReader *p){ } if( (c==cSep && pc==cQuote) || (c=='\n' && pc==cQuote) - || (c=='\n' && pc=='\r' && p->n>=2 && p->z[p->n-2]==cQuote) + || (c=='\n' && pc=='\r' && ppc==cQuote) || (c==EOF && pc==cQuote) ){ do{ p->n--; }while( p->z[p->n]!=cQuote ); @@ -1877,6 +1877,7 @@ static char *csv_read_one_field(CSVReader *p){ break; } csv_append_char(p, c); + ppc = pc; pc = c; } }else{ |