/ Check-in [d48eda16]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Rename a structure member to improve code clarity.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | asciiMode
Files: files | file ages | folders
SHA1: d48eda16ef8a84a93de9c6f38f794aceb4a6ba0d
User & Date: mistachkin 2014-12-11 03:29:14
Context
2014-12-11
04:49
Update a comment. check-in: e0e102a0 user: mistachkin tags: asciiMode
03:29
Rename a structure member to improve code clarity. check-in: d48eda16 user: mistachkin tags: asciiMode
03:25
Remove an unused structure member. check-in: d8404340 user: mistachkin tags: asciiMode
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.

   471    471     int showHeader;        /* True to show column names in List or Column mode */
   472    472     unsigned shellFlgs;    /* Various flags */
   473    473     char *zDestTable;      /* Name of destination table when MODE_Insert */
   474    474     char colSeparator[20]; /* Column separator character for several modes */
   475    475     char rowSeparator[20]; /* Row separator character for MODE_Ascii */
   476    476     int colWidth[100];     /* Requested width of each column when in column mode*/
   477    477     int actualWidth[100];  /* Actual width of each column */
   478         -  char nullvalue[20];    /* The text to print when a NULL comes back from
          478  +  char nullValue[20];    /* The text to print when a NULL comes back from
   479    479                            ** the database */
   480    480     SavedModeInfo normalMode;/* Holds the mode just before .explain ON */
   481    481     char outfile[FILENAME_MAX]; /* Filename for *out */
   482    482     const char *zDbFilename;    /* name of the database file */
   483    483     char *zFreeOnClose;         /* Filename to free when closing */
   484    484     const char *zVfs;           /* Name of VFS to use */
   485    485     sqlite3_stmt *pStmt;   /* Current statement if any. */
................................................................................
   689    689     1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   
   690    690     1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   
   691    691     1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,   
   692    692   };
   693    693   
   694    694   /*
   695    695   ** Output a single term of CSV.  Actually, p->separator is used for
   696         -** the separator, which may or may not be a comma.  p->nullvalue is
          696  +** the separator, which may or may not be a comma.  p->nullValue is
   697    697   ** the null value.  Strings are quoted if necessary.  The separator
   698    698   ** is only issued if bSep is true.
   699    699   */
   700    700   static void output_csv(ShellState *p, const char *z, int bSep){
   701    701     FILE *out = p->out;
   702    702     if( z==0 ){
   703         -    fprintf(out,"%s",p->nullvalue);
          703  +    fprintf(out,"%s",p->nullValue);
   704    704     }else{
   705    705       int i;
   706    706       int nSep = strlen30(p->colSeparator);
   707    707       for(i=0; z[i]; i++){
   708    708         if( needCsvQuote[((unsigned char*)z)[i]] 
   709    709            || (z[i]==p->colSeparator[0] && 
   710    710                (nSep==1 || memcmp(z, p->colSeparator, nSep)==0)) ){
................................................................................
   761    761         for(i=0; i<nArg; i++){
   762    762           int len = strlen30(azCol[i] ? azCol[i] : "");
   763    763           if( len>w ) w = len;
   764    764         }
   765    765         if( p->cnt++>0 ) fprintf(p->out, "%s", p->rowSeparator);
   766    766         for(i=0; i<nArg; i++){
   767    767           fprintf(p->out,"%*s = %s%s", w, azCol[i],
   768         -                azArg[i] ? azArg[i] : p->nullvalue, p->rowSeparator);
          768  +                azArg[i] ? azArg[i] : p->nullValue, p->rowSeparator);
   769    769         }
   770    770         break;
   771    771       }
   772    772       case MODE_Explain:
   773    773       case MODE_Column: {
   774    774         if( p->cnt++==0 ){
   775    775           for(i=0; i<nArg; i++){
................................................................................
   778    778               w = p->colWidth[i];
   779    779             }else{
   780    780               w = 0;
   781    781             }
   782    782             if( w==0 ){
   783    783               w = strlen30(azCol[i] ? azCol[i] : "");
   784    784               if( w<10 ) w = 10;
   785         -            n = strlen30(azArg && azArg[i] ? azArg[i] : p->nullvalue);
          785  +            n = strlen30(azArg && azArg[i] ? azArg[i] : p->nullValue);
   786    786               if( w<n ) w = n;
   787    787             }
   788    788             if( i<ArraySize(p->actualWidth) ){
   789    789               p->actualWidth[i] = w;
   790    790             }
   791    791             if( p->showHeader ){
   792    792               if( w<0 ){
................................................................................
   828    828             if( p->iIndent<p->nIndent ){
   829    829               fprintf(p->out, "%*.s", p->aiIndent[p->iIndent], "");
   830    830             }
   831    831             p->iIndent++;
   832    832           }
   833    833           if( w<0 ){
   834    834             fprintf(p->out,"%*.*s%s",-w,-w,
   835         -              azArg[i] ? azArg[i] : p->nullvalue,
          835  +              azArg[i] ? azArg[i] : p->nullValue,
   836    836                 i==nArg-1 ? p->rowSeparator : "  ");
   837    837           }else{
   838    838             fprintf(p->out,"%-*.*s%s",w,w,
   839         -              azArg[i] ? azArg[i] : p->nullvalue,
          839  +              azArg[i] ? azArg[i] : p->nullValue,
   840    840                 i==nArg-1 ? p->rowSeparator : "  ");
   841    841           }
   842    842         }
   843    843         break;
   844    844       }
   845    845       case MODE_Semi:
   846    846       case MODE_List: {
................................................................................
   849    849             fprintf(p->out,"%s%s",azCol[i],
   850    850                     i==nArg-1 ? p->rowSeparator : p->colSeparator);
   851    851           }
   852    852         }
   853    853         if( azArg==0 ) break;
   854    854         for(i=0; i<nArg; i++){
   855    855           char *z = azArg[i];
   856         -        if( z==0 ) z = p->nullvalue;
          856  +        if( z==0 ) z = p->nullValue;
   857    857           fprintf(p->out, "%s", z);
   858    858           if( i<nArg-1 ){
   859    859             fprintf(p->out, "%s", p->colSeparator);
   860    860           }else if( p->mode==MODE_Semi ){
   861    861             fprintf(p->out, ";%s", p->rowSeparator);
   862    862           }else{
   863    863             fprintf(p->out, "%s", p->rowSeparator);
................................................................................
   875    875           }
   876    876           fprintf(p->out,"</TR>\n");
   877    877         }
   878    878         if( azArg==0 ) break;
   879    879         fprintf(p->out,"<TR>");
   880    880         for(i=0; i<nArg; i++){
   881    881           fprintf(p->out,"<TD>");
   882         -        output_html_string(p->out, azArg[i] ? azArg[i] : p->nullvalue);
          882  +        output_html_string(p->out, azArg[i] ? azArg[i] : p->nullValue);
   883    883           fprintf(p->out,"</TD>\n");
   884    884         }
   885    885         fprintf(p->out,"</TR>\n");
   886    886         break;
   887    887       }
   888    888       case MODE_Tcl: {
   889    889         if( p->cnt++==0 && p->showHeader ){
................................................................................
   891    891             output_c_string(p->out,azCol[i] ? azCol[i] : "");
   892    892             if(i<nArg-1) fprintf(p->out, "%s", p->colSeparator);
   893    893           }
   894    894           fprintf(p->out, "%s", p->rowSeparator);
   895    895         }
   896    896         if( azArg==0 ) break;
   897    897         for(i=0; i<nArg; i++){
   898         -        output_c_string(p->out, azArg[i] ? azArg[i] : p->nullvalue);
          898  +        output_c_string(p->out, azArg[i] ? azArg[i] : p->nullValue);
   899    899           if(i<nArg-1) fprintf(p->out, "%s", p->colSeparator);
   900    900         }
   901    901         fprintf(p->out, "%s", p->rowSeparator);
   902    902         break;
   903    903       }
   904    904       case MODE_Csv: {
   905    905   #if defined(WIN32) || defined(_WIN32)
................................................................................
   960    960             fprintf(p->out,"%s",azCol[i] ? azCol[i] : "");
   961    961           }
   962    962           fprintf(p->out, "%s", p->rowSeparator);
   963    963         }
   964    964         if( azArg==0 ) break;
   965    965         for(i=0; i<nArg; i++){
   966    966           if( i>0 ) fprintf(p->out, "%s", p->colSeparator);
   967         -        fprintf(p->out,"%s",azArg[i] ? azArg[i] : p->nullvalue);
          967  +        fprintf(p->out,"%s",azArg[i] ? azArg[i] : p->nullValue);
   968    968         }
   969    969         fprintf(p->out, "%s", p->rowSeparator);
   970    970         break;
   971    971       }
   972    972     }
   973    973     return 0;
   974    974   }
................................................................................
  3047   3047            "ascii column csv html insert line list tabs tcl\n");
  3048   3048         rc = 1;
  3049   3049       }
  3050   3050     }else
  3051   3051   
  3052   3052     if( c=='n' && strncmp(azArg[0], "nullvalue", n)==0 ){
  3053   3053       if( nArg==2 ){
  3054         -      sqlite3_snprintf(sizeof(p->nullvalue), p->nullvalue,
  3055         -                       "%.*s", (int)ArraySize(p->nullvalue)-1, azArg[1]);
         3054  +      sqlite3_snprintf(sizeof(p->nullValue), p->nullValue,
         3055  +                       "%.*s", (int)ArraySize(p->nullValue)-1, azArg[1]);
  3056   3056       }else{
  3057   3057         fprintf(stderr, "Usage: .nullvalue STRING\n");
  3058   3058         rc = 1;
  3059   3059       }
  3060   3060     }else
  3061   3061   
  3062   3062     if( c=='o' && strncmp(azArg[0], "open", n)==0 && n>=2 ){
................................................................................
  3379   3379       }
  3380   3380       fprintf(p->out,"%12.12s: %s\n","echo", p->echoOn ? "on" : "off");
  3381   3381       fprintf(p->out,"%12.12s: %s\n","eqp", p->autoEQP ? "on" : "off");
  3382   3382       fprintf(p->out,"%9.9s: %s\n","explain", p->normalMode.valid ? "on" :"off");
  3383   3383       fprintf(p->out,"%12.12s: %s\n","headers", p->showHeader ? "on" : "off");
  3384   3384       fprintf(p->out,"%12.12s: %s\n","mode", modeDescr[p->mode]);
  3385   3385       fprintf(p->out,"%12.12s: ", "nullvalue");
  3386         -      output_c_string(p->out, p->nullvalue);
         3386  +      output_c_string(p->out, p->nullValue);
  3387   3387         fprintf(p->out, "\n");
  3388   3388       fprintf(p->out,"%12.12s: %s\n","output",
  3389   3389               strlen30(p->outfile) ? p->outfile : "stdout");
  3390   3390       fprintf(p->out,"%12.12s: ", "colseparator");
  3391   3391         output_c_string(p->out, p->colSeparator);
  3392   3392         fprintf(p->out, "\n");
  3393   3393       fprintf(p->out,"%12.12s: ", "rowseparator");
................................................................................
  4358   4358       }else if( strcmp(z,"-separator")==0 ){
  4359   4359         sqlite3_snprintf(sizeof(data.colSeparator), data.colSeparator,
  4360   4360                          "%s",cmdline_option_value(argc,argv,++i));
  4361   4361       }else if( strcmp(z,"-newline")==0 ){
  4362   4362         sqlite3_snprintf(sizeof(data.rowSeparator), data.rowSeparator,
  4363   4363                          "%s",cmdline_option_value(argc,argv,++i));
  4364   4364       }else if( strcmp(z,"-nullvalue")==0 ){
  4365         -      sqlite3_snprintf(sizeof(data.nullvalue), data.nullvalue,
         4365  +      sqlite3_snprintf(sizeof(data.nullValue), data.nullValue,
  4366   4366                          "%s",cmdline_option_value(argc,argv,++i));
  4367   4367       }else if( strcmp(z,"-header")==0 ){
  4368   4368         data.showHeader = 1;
  4369   4369       }else if( strcmp(z,"-noheader")==0 ){
  4370   4370         data.showHeader = 0;
  4371   4371       }else if( strcmp(z,"-echo")==0 ){
  4372   4372         data.echoOn = 1;