diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/shell.c.in | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/src/shell.c.in b/src/shell.c.in index 672c80a25..b4b4e2fcc 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -1762,19 +1762,14 @@ static void output_csv(ShellState *p, const char *z, int bSep){ if( z==0 ){ utf8_printf(out,"%s",p->nullValue); }else{ - int i; - int nSep = strlen30(p->colSeparator); - int n = strlen30(z); - for(i=0; i<n; i++){ - if( needCsvQuote[((unsigned char*)z)[i]] - || (z[i]==p->colSeparator[0] && - (nSep==1 || (i+nSep<n && memcmp(z+i, p->colSeparator, nSep)==0))) - ){ + unsigned i; + for(i=0; z[i]; i++){ + if( needCsvQuote[((unsigned char*)z)[i]] ){ i = 0; break; } } - if( i==0 ){ + if( i==0 || strstr(z, p->colSeparator)!=0 ){ char *zQuoted = sqlite3_mprintf("\"%w\"", z); utf8_printf(out, "%s", zQuoted); sqlite3_free(zQuoted); |