]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Remove several more hundred lines of dead code from shell.c.in.
authordrh <>
Sun, 9 Nov 2025 00:01:48 +0000 (00:01 +0000)
committerdrh <>
Sun, 9 Nov 2025 00:01:48 +0000 (00:01 +0000)
FossilOrigin-Name: 9de3e1d3fb0b2127e983aa455cda2f38646891da65eb9ac39bb5b00d8488f52f

manifest
manifest.uuid
src/shell.c.in

index eaec1683cad1c554facdd58c9fc9a01f622a329b..0ec2724637b4551c7163218a0b1da02c3ba817c4 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Remove\sabout\sa\sthousand\slines\sof\sdead\scode\sfrom\sshell.c.in.
-D 2025-11-08T23:35:57.752
+C Remove\sseveral\smore\shundred\slines\sof\sdead\scode\sfrom\sshell.c.in.
+D 2025-11-09T00:01:48.783
 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
@@ -735,7 +735,7 @@ F src/random.c 606b00941a1d7dd09c381d3279a058d771f406c5213c9932bbd93d5587be4b9c
 F src/resolve.c 5616fbcf3b833c7c705b24371828215ad0925d0c0073216c4f153348d5753f0a
 F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97
 F src/select.c ba9cd07ffa3277883c1986085f6ddc4320f4d35d5f212ab58df79a7ecc1a576a
-F src/shell.c.in b4c486e6ba11aa5639e8abe90b4e093b6b233d5b833d90c8c344ec959c7b0446
+F src/shell.c.in 5318466b78c1f33d4b65aa6dc5e41fca52d7d146254bf0b0d49a1237f3b72c15
 F src/sqlite.h.in 43f60117ce68847b9d4e7fa43c2ac42bb324185e66b924d3114b24d4037fc263
 F src/sqlite3.rc 015537e6ac1eec6c7050e17b616c2ffe6f70fca241835a84a4f0d5937383c479
 F src/sqlite3ext.h 7f236ca1b175ffe03316d974ef57df79b3938466c28d2f95caef5e08c57f3a52
@@ -2173,8 +2173,8 @@ F tool/version-info.c 33d0390ef484b3b1cb685d59362be891ea162123cea181cb8e6d2cf6dd
 F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7
 F tool/warnings.sh d924598cf2f55a4ecbc2aeb055c10bd5f48114793e7ba25f9585435da29e7e98
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 871567e377e976e0bb191d466019d1d4abe126f2da1880f1e25cd92b06a666d1
-R 7f92fe9bce1195a07bb82051f285216a
+P efbcc7decd5347e3460cc3ed62720c8c3932225dfdf92293a990c51895450906
+R 66a1f4906d686c9035f43c716801c83d
 U drh
-Z 0c39792436bfc66d82520f9e3f716ced
+Z cad66dc4b316d4d572021f7e287d84d0
 # Remove this line to create a well-formed Fossil manifest.
index 06f60e03b3441b6a832ef9fed1a36c85f8031321..f869199407524f1251cb1c9402ba9b6f9a9d7ef6 100644 (file)
@@ -1 +1 @@
-efbcc7decd5347e3460cc3ed62720c8c3932225dfdf92293a990c51895450906
+9de3e1d3fb0b2127e983aa455cda2f38646891da65eb9ac39bb5b00d8488f52f
index 30a80accce0e869d8868d832a773f00d98f358e7..34df6faaa40ad9dab9642fdca0660fdca460a675 100644 (file)
@@ -653,33 +653,6 @@ static void SQLITE_CDECL iotracePrintf(const char *zFormat, ...){
 }
 #endif
 
-/*
-** Determines if a string is a number of not.
-*/
-static int isNumber(const char *z, int *realnum){
-  if( *z=='-' || *z=='+' ) z++;
-  if( !IsDigit(*z) ){
-    return 0;
-  }
-  z++;
-  if( realnum ) *realnum = 0;
-  while( IsDigit(*z) ){ z++; }
-  if( *z=='.' ){
-    z++;
-    if( !IsDigit(*z) ) return 0;
-    while( IsDigit(*z) ){ z++; }
-    if( realnum ) *realnum = 1;
-  }
-  if( *z=='e' || *z=='E' ){
-    z++;
-    if( *z=='+' || *z=='-' ) z++;
-    if( !IsDigit(*z) ) return 0;
-    while( IsDigit(*z) ){ z++; }
-    if( realnum ) *realnum = 1;
-  }
-  return *z==0;
-}
-
 /*
 ** Compute a string length that is limited to what can be stored in
 ** lower 30 bits of a 32-bit signed integer.
@@ -1673,126 +1646,6 @@ static void setCrlfMode(ShellState *p){
 #endif    
 }
 
-/*
-** Output the given string as a hex-encoded blob (eg. X'1234' )
-*/
-static void output_hex_blob(FILE *out, const void *pBlob, int nBlob){
-  int i;
-  unsigned char *aBlob = (unsigned char*)pBlob;
-
-  char *zStr = sqlite3_malloc64((i64)nBlob*2 + 1);
-  shell_check_oom(zStr);
-
-  for(i=0; i<nBlob; i++){
-    static const char aHex[] = {
-        '0', '1', '2', '3', '4', '5', '6', '7',
-        '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
-    };
-    zStr[i*2] = aHex[ (aBlob[i] >> 4) ];
-    zStr[i*2+1] = aHex[ (aBlob[i] & 0x0F) ];
-  }
-  zStr[i*2] = '\0';
-
-  sqlite3_fprintf(out, "X'%s'", zStr);
-  sqlite3_free(zStr);
-}
-
-/*
-** Output the given string as a quoted string using SQL quoting conventions:
-**
-**   (1)   Single quotes (') within the string are doubled
-**   (2)   The while string is enclosed in '...'
-**   (3)   Control characters other than \n, \t, and \r\n are escaped
-**         using \u00XX notation and if such substitutions occur,
-**         the whole string is enclosed in unistr('...') instead of '...'.
-**         
-** Step (3) is omitted if the control-character escape mode is OFF.
-**
-** See also: output_quoted_escaped_string() which does the same except
-** that it does not make exceptions for \n, \t, and \r\n in step (3).
-*/
-static void output_quoted_string(ShellState *p, const char *zInX){
-  int i;
-  int needUnistr = 0;
-  int needDblQuote = 0;
-  const unsigned char *z = (const unsigned char*)zInX;
-  unsigned char c;
-  FILE *out = p->out;
-  sqlite3_fsetmode(out, _O_BINARY);
-  if( z==0 ) return;
-  for(i=0; (c = z[i])!=0; i++){
-    if( c=='\'' ){ needDblQuote = 1; }
-    if( c>0x1f ) continue;
-    if( c=='\t' || c=='\n' ) continue;
-    if( c=='\r' && z[i+1]=='\n' ) continue;
-    needUnistr = 1;
-    break;
-  }
-  if( (needDblQuote==0 && needUnistr==0)
-   || (needDblQuote==0 && p->eEscMode==SHELL_ESC_OFF)
-  ){
-    sqlite3_fprintf(out, "'%s'",z);
-  }else if( p->eEscMode==SHELL_ESC_OFF ){
-    char *zEncoded = sqlite3_mprintf("%Q", z);
-    sqlite3_fputs(zEncoded, out);
-    sqlite3_free(zEncoded);
-  }else{
-    if( needUnistr ){
-      sqlite3_fputs("unistr('", out);
-    }else{
-      sqlite3_fputs("'", out);
-    }
-    while( *z ){
-      for(i=0; (c = z[i])!=0; i++){
-        if( c=='\'' ) break;
-        if( c>0x1f ) continue;
-        if( c=='\t' || c=='\n' ) continue;
-        if( c=='\r' && z[i+1]=='\n' ) continue;
-        break;
-      }
-      if( i ){
-        sqlite3_fprintf(out, "%.*s", i, z);
-        z += i;
-      }
-      if( c==0 ) break;
-      if( c=='\'' ){
-        sqlite3_fputs("''", out);
-      }else{
-        sqlite3_fprintf(out, "\\u%04x", c);
-      }
-      z++;
-    }
-    if( needUnistr ){
-      sqlite3_fputs("')", out);
-    }else{
-      sqlite3_fputs("'", out);
-    }
-  }
-  setCrlfMode(p);
-}
-
-/*
-** Output the given string as a quoted string using SQL quoting conventions.
-** Additionallly , escape the "\n" and "\r" characters so that they do not
-** get corrupted by end-of-line translation facilities in some operating
-** systems.
-**
-** This is like output_quoted_string() but with the addition of the \r\n
-** escape mechanism.
-*/
-static void output_quoted_escaped_string(ShellState *p, const char *z){
-  char *zEscaped;
-  sqlite3_fsetmode(p->out, _O_BINARY);
-  if( p->eEscMode==SHELL_ESC_OFF ){
-    zEscaped = sqlite3_mprintf("%Q", z);
-  }else{
-    zEscaped = sqlite3_mprintf("%#Q", z);
-  }
-  sqlite3_fputs(zEscaped, p->out);
-  sqlite3_free(zEscaped);
-  setCrlfMode(p);
-}
-
 /*
 ** Find earliest of chars within s specified in zAny.
 ** With ns == ~0, is like strpbrk(s,zAny) and s must be 0-terminated.
@@ -1890,142 +1743,6 @@ static void output_c_string(FILE *out, const char *z){
   sqlite3_fputs(zq, out);
 }
 
-/*
-** Output the given string as quoted according to JSON quoting rules.
-*/
-static void output_json_string(FILE *out, const char *z, i64 n){
-  unsigned char c;
-  static const char *zq = "\"";
-  static long ctrlMask = ~0L;
-  static const char *zDQBS = "\"\\";
-  const char *pcLimit;
-  char ace[3] = "\\?";
-  char cbsSay;
-
-  if( z==0 ) z = "";
-  pcLimit = z + ((n<0)? strlen(z) : (size_t)n);
-  sqlite3_fputs(zq, out);
-  while( z < pcLimit ){
-    const char *pcDQBS = anyOfInStr(z, zDQBS, pcLimit-z);
-    const char *pcPast = zSkipValidUtf8(z, (int)(pcLimit-z), ctrlMask);
-    const char *pcEnd = (pcDQBS && pcDQBS < pcPast)? pcDQBS : pcPast;
-    if( pcEnd > z ){
-      sqlite3_fprintf(out, "%.*s", (int)(pcEnd-z), z);
-      z = pcEnd;
-    }
-    if( z >= pcLimit ) break;
-    c = (unsigned char)*(z++);
-    switch( c ){
-    case '"': case '\\':
-      cbsSay = (char)c;
-      break;
-    case '\b': cbsSay = 'b'; break;
-    case '\f': cbsSay = 'f'; break;
-    case '\n': cbsSay = 'n'; break;
-    case '\r': cbsSay = 'r'; break;
-    case '\t': cbsSay = 't'; break;
-    default: cbsSay = 0; break;
-    }
-    if( cbsSay ){
-      ace[1] = cbsSay;
-      sqlite3_fputs(ace, out);
-    }else if( c<=0x1f || c>=0x7f ){
-      sqlite3_fprintf(out, "\\u%04x", c);
-    }else{
-      ace[1] = (char)c;
-      sqlite3_fputs(ace+1, out);
-    }
-  }
-  sqlite3_fputs(zq, out);
-}
-
-/*
-** Escape the input string if it is needed and in accordance with
-** eEscMode.
-**
-** Escaping is needed if the string contains any control characters
-** other than \t, \n, and \r\n
-**
-** If no escaping is needed (the common case) then set *ppFree to NULL
-** and return the original string.  If escaping is needed, write the
-** escaped string into memory obtained from sqlite3_malloc64() or the
-** equivalent, and return the new string and set *ppFree to the new string
-** as well.
-**
-** The caller is responsible for freeing *ppFree if it is non-NULL in order
-** to reclaim memory.
-*/
-static const char *escapeOutput(
-  ShellState *p,
-  const char *zInX,
-  char **ppFree
-){
-  i64 i, j;
-  i64 nCtrl = 0;
-  unsigned char *zIn;
-  unsigned char c;
-  unsigned char *zOut;
-
-
-  /* No escaping if disabled */
-  if( p->eEscMode==SHELL_ESC_OFF ){
-    *ppFree = 0;
-     return zInX;
-  }
-
-  /* Count the number of control characters in the string. */
-  zIn = (unsigned char*)zInX;
-  for(i=0; (c = zIn[i])!=0; i++){
-    if( c<=0x1f
-     && c!='\t'
-     && c!='\n'
-     && (c!='\r' || zIn[i+1]!='\n')
-    ){
-      nCtrl++;
-    }
-  }
-  if( nCtrl==0 ){
-    *ppFree = 0;
-    return zInX;
-  }
-  if( p->eEscMode==SHELL_ESC_SYMBOL ) nCtrl *= 2;
-  zOut = sqlite3_malloc64( i + nCtrl + 1 );
-  shell_check_oom(zOut);
-  for(i=j=0; (c = zIn[i])!=0; i++){
-    if( c>0x1f
-     || c=='\t'
-     || c=='\n'
-     || (c=='\r' && zIn[i+1]=='\n')
-    ){
-      continue;
-    }
-    if( i>0 ){
-      memcpy(&zOut[j], zIn, i);
-      j += i;
-    }
-    zIn += i+1;
-    i = -1;
-    switch( p->eEscMode ){
-      case SHELL_ESC_SYMBOL: 
-        zOut[j++] = 0xe2;
-        zOut[j++] = 0x90;
-        zOut[j++] = 0x80+c;
-        break;
-      case SHELL_ESC_ASCII:
-        zOut[j++] = '^';
-        zOut[j++] = 0x40+c;
-        break;
-    }
-  }
-  if( i>0 ){
-    memcpy(&zOut[j], zIn, i);
-    j += i;
-  }
-  zOut[j] = 0;
-  *ppFree = (char*)zOut;
-  return (char*)zOut;
-}
-
 /*
 ** Output the given string with characters that are special to
 ** HTML escaped.
@@ -2061,60 +1778,6 @@ static void output_html_string(FILE *out, const char *z){
   }
 }
 
-/*
-** If a field contains any character identified by a 1 in the following
-** array, then the string must be quoted for CSV.
-*/
-static const char needCsvQuote[] = {
-  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,
-  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,
-  1, 0, 1, 0, 0, 0, 0, 1,   0, 0, 0, 0, 0, 0, 0, 0,
-  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0,
-  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0,
-  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0,
-  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 0,
-  0, 0, 0, 0, 0, 0, 0, 0,   0, 0, 0, 0, 0, 0, 0, 1,
-  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,
-  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,
-  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,
-  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,
-  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,
-  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,
-  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,
-  1, 1, 1, 1, 1, 1, 1, 1,   1, 1, 1, 1, 1, 1, 1, 1,
-};
-
-/*
-** 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.
-*/
-static void output_csv(ShellState *p, const char *z, int bSep){
-  if( z==0 ){
-    sqlite3_fprintf(p->out, "%s",p->nullValue);
-  }else{
-    unsigned i;
-    for(i=0; z[i]; i++){
-      if( needCsvQuote[((unsigned char*)z)[i]] ){
-        i = 0;
-        break;
-      }
-    }
-    if( i==0 || strstr(z, p->colSeparator)!=0 ){
-      char *zQuoted = sqlite3_mprintf("\"%w\"", z);
-      shell_check_oom(zQuoted);
-      sqlite3_fputs(zQuoted, p->out);
-      sqlite3_free(zQuoted);
-    }else{
-      sqlite3_fputs(z, p->out);
-    }
-  }
-  if( bSep ){
-    sqlite3_fputs(p->colSeparator, p->out);
-  }
-}
-
 /*
 ** This routine runs when the user presses Ctrl-C
 */