1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-06 15:49:35 +03:00

In the CLI, quote strings that contain the separator character.

Ticket #2850. (CVS 4638)

FossilOrigin-Name: 493a17c46a66d2febc11205c052bf949a3f22bd8
This commit is contained in:
drh
2007-12-18 15:41:44 +00:00
parent 315e6697f8
commit c85375d598
3 changed files with 13 additions and 10 deletions

View File

@@ -12,7 +12,7 @@
** This file contains code to implement the "sqlite" command line
** utility for accessing SQLite databases.
**
** $Id: shell.c,v 1.170 2007/11/26 22:54:27 drh Exp $
** $Id: shell.c,v 1.171 2007/12/18 15:41:44 drh Exp $
*/
#include <stdlib.h>
#include <string.h>
@@ -469,8 +469,11 @@ static void output_csv(struct callback_data *p, const char *z, int bSep){
fprintf(out,"%s",p->nullvalue);
}else{
int i;
int nSep = strlen(p->separator);
for(i=0; z[i]; i++){
if( needCsvQuote[((unsigned char*)z)[i]] ){
if( needCsvQuote[((unsigned char*)z)[i]]
|| (z[i]==p->separator[0] &&
(nSep==1 || memcmp(z, p->separator, nSep)==0)) ){
i = 0;
break;
}