diff options
author | drh <drh@noemail.net> | 2012-12-04 00:59:05 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2012-12-04 00:59:05 +0000 |
commit | d483dfa4b4038ebe044838340c63dcc31f811f0c (patch) | |
tree | ee4b71a98238903e245ee7f71b60b288117f79fd /src | |
parent | 7b6be6f7bf82cd947ace21ef2f1a1a94fa8e998f (diff) | |
parent | 585dcb251bf297566d57aa4894f124045dea31d4 (diff) | |
download | sqlite-d483dfa4b4038ebe044838340c63dcc31f811f0c.tar.gz sqlite-d483dfa4b4038ebe044838340c63dcc31f811f0c.zip |
Improvements to the 'tcl' shell output mode. Escape doublequotes,
set separator to space when mode is set, and skip separator after final
column.
FossilOrigin-Name: 487ba753139c256b911f16aee9586144faea846f
Diffstat (limited to 'src')
-rw-r--r-- | src/shell.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/shell.c b/src/shell.c index 0283c9e13..7dd741b2d 100644 --- a/src/shell.c +++ b/src/shell.c @@ -541,6 +541,9 @@ static void output_c_string(FILE *out, const char *z){ if( c=='\\' ){ fputc(c, out); fputc(c, out); + }else if( c=='"' ){ + fputc('\\', out); + fputc('"', out); }else if( c=='\t' ){ fputc('\\', out); fputc('t', out); @@ -796,14 +799,14 @@ static int shell_callback(void *pArg, int nArg, char **azArg, char **azCol, int if( p->cnt++==0 && p->showHeader ){ for(i=0; i<nArg; i++){ output_c_string(p->out,azCol[i] ? azCol[i] : ""); - fprintf(p->out, "%s", p->separator); + if(i<nArg-1) fprintf(p->out, "%s", p->separator); } fprintf(p->out,"\n"); } if( azArg==0 ) break; for(i=0; i<nArg; i++){ output_c_string(p->out, azArg[i] ? azArg[i] : p->nullvalue); - fprintf(p->out, "%s", p->separator); + if(i<nArg-1) fprintf(p->out, "%s", p->separator); } fprintf(p->out,"\n"); break; @@ -2018,6 +2021,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ p->mode = MODE_Html; }else if( n2==3 && strncmp(azArg[1],"tcl",n2)==0 ){ p->mode = MODE_Tcl; + sqlite3_snprintf(sizeof(p->separator), p->separator, " "); }else if( n2==3 && strncmp(azArg[1],"csv",n2)==0 ){ p->mode = MODE_Csv; sqlite3_snprintf(sizeof(p->separator), p->separator, ","); |