MCPcopy Create free account
hub / github.com/audacity/audacity / output_csv

Function output_csv

lib-src/sqlite/shell.c:11857–11883  ·  view source on GitHub ↗

** Output a single term of CSV. Actually, p->colSeparator is used for ** the separator, which may or may not be a comma. p->nullValue is ** the null value. Strings are quoted if necessary. The separator ** is only issued if bSep is true. */

Source from the content-addressed store, hash-verified

11855** is only issued if bSep is true.
11856*/
11857static void output_csv(ShellState *p, const char *z, int bSep){
11858 FILE *out = p->out;
11859 if( z==0 ){
11860 utf8_printf(out,"%s",p->nullValue);
11861 }else{
11862 int i;
11863 int nSep = strlen30(p->colSeparator);
11864 for(i=0; z[i]; i++){
11865 if( needCsvQuote[((unsigned char*)z)[i]]
11866 || (z[i]==p->colSeparator[0] &&
11867 (nSep==1 || memcmp(z, p->colSeparator, nSep)==0)) ){
11868 i = 0;
11869 break;
11870 }
11871 }
11872 if( i==0 ){
11873 char *zQuoted = sqlite3_mprintf("\"%w\"", z);
11874 utf8_printf(out, "%s", zQuoted);
11875 sqlite3_free(zQuoted);
11876 }else{
11877 utf8_printf(out, "%s", z);
11878 }
11879 }
11880 if( bSep ){
11881 utf8_printf(p->out, "%s", p->colSeparator);
11882 }
11883}
11884
11885/*
11886** This routine runs when the user presses Ctrl-C

Callers 1

shell_callbackFunction · 0.85

Calls 2

utf8_printfFunction · 0.85
strlen30Function · 0.85

Tested by

no test coverage detected