]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Change shell.c so that it will compile under windows. Shorten the help
authordrh <drh@noemail.net>
Thu, 18 Apr 2002 12:39:03 +0000 (12:39 +0000)
committerdrh <drh@noemail.net>
Thu, 18 Apr 2002 12:39:03 +0000 (12:39 +0000)
command somewhat.  Add the state of ".header" to the output of ".show". (CVS 534)

FossilOrigin-Name: 0582168b8b853559b484f4a024d28c67192160c4

manifest
manifest.uuid
src/shell.c

index 40172c5dcf7b06416c937adfc81baeb7f98d01fc..7e6be7b582baf33813b0bd53119f4a0fdfa4e9a2 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Updated\sto\smatch\snew\sshell.c\sfunctionality.\s(CVS\s533)
-D 2002-04-18T02:53:54
+C Change\sshell.c\sso\sthat\sit\swill\scompile\sunder\swindows.\s\sShorten\sthe\shelp\ncommand\ssomewhat.\s\sAdd\sthe\sstate\sof\s".header"\sto\sthe\soutput\sof\s".show".\s(CVS\s534)
+D 2002-04-18T12:39:03
 F Makefile.in 50f1b3351df109b5774771350d8c1b8d3640130d
 F Makefile.template 89e373b2dad0321df00400fa968dc14b61a03296
 F README a4c0ba11354ef6ba0776b400d057c59da47a4cc0
@@ -39,7 +39,7 @@ F src/parse.y 9a8a2311dd95101bb02b3991042e619eea49729a
 F src/printf.c 300a90554345751f26e1fc0c0333b90a66110a1d
 F src/random.c 19e8e00fe0df32a742f115773f57651be327cabe
 F src/select.c 92aef3f69e90dc065d680d88b1f075409e9249bb
-F src/shell.c e473e19509c5c9b02bb2fb674be4b223cb052334
+F src/shell.c 4a225aa846f494488d9bab324b68749d25a890b7
 F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e
 F src/sqlite.h.in ffcacf73b5ed1a4939205d29a704a185758fa6a6
 F src/sqliteInt.h e47ca9267a4c4a98e9f8d90c2df994a18f23d699
@@ -131,7 +131,7 @@ F www/speed.tcl da8afcc1d3ccc5696cfb388a68982bc3d9f7f00f
 F www/sqlite.tcl 8b5884354cb615049aed83039f8dfe1552a44279
 F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
 F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
-P 4bdd040e4810565c91bcbb5f065580520c5e3c45
-R fccec3c1f56efdafc771baab879ce3fe
-U persicom
-Z f4c9300a9a77dcec47079904c2bfe5db
+P ff67ad40106a20fb85797cca4c495dc34ad5519b
+R 83edff024b8dcab1f99c47b3727e4d20
+U drh
+Z 1f0ab834158fafdf0840052f540be94f
index d8e698eaac2d379daa3a2010888a31925c7499e3..70c629226cd8a5a63072832845ca93d3dfead64c 100644 (file)
@@ -1 +1 @@
-ff67ad40106a20fb85797cca4c495dc34ad5519b
\ No newline at end of file
+0582168b8b853559b484f4a024d28c67192160c4
\ No newline at end of file
index 4a753f21d9a7dd1ee30295fb906d53b812cd3df6..c6b76f994309cb9f72dd61bfa3c55d0dc4b83b01 100644 (file)
 ** This file contains code to implement the "sqlite" command line
 ** utility for accessing SQLite databases.
 **
-** $Id: shell.c,v 1.52 2002/04/18 02:53:05 persicom Exp $
+** $Id: shell.c,v 1.53 2002/04/18 12:39:03 drh Exp $
 */
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 #include "sqlite.h"
 #include <ctype.h>
-#include <pwd.h>
-#include <sys/types.h>
 
 #if !defined(_WIN32) && !defined(WIN32)
 # include <signal.h>
+# include <pwd.h>
+# include <unistd.h>
+# include <sys/types.h>
 #endif
 
 #if defined(HAVE_READLINE) && HAVE_READLINE==1
@@ -473,8 +474,6 @@ static char zHelp[] =
   ".echo ON|OFF           Turn command echo on or off\n"
   ".exit                  Exit this program\n"
   ".explain ON|OFF        Turn output mode suitable for EXPLAIN on or off.\n"
-  "                       \"off\" will revert to the output mode that was\n"
-  "                       previously in effect\n"
   ".header(s) ON|OFF      Turn display of headers on or off\n"
   ".help                  Show this message\n"
   ".indices TABLE         Show names of all indices on TABLE\n"
@@ -485,23 +484,13 @@ static char zHelp[] =
   ".output FILENAME       Send output to FILENAME\n"
   ".output stdout         Send output to the screen\n"
   ".prompt MAIN CONTINUE  Replace the standard prompts\n"
-  "                       \"sqlite > \" and \"   ...> \"\n"
-  "                       with the strings MAIN and CONTINUE\n"
-  "                       CONTINUE is optional.\n"
   ".quit                  Exit this program\n"
   ".read FILENAME         Execute SQL in FILENAME\n"
   ".reindex ?TABLE?       Rebuild indices\n"
 /*  ".rename OLD NEW        Change the name of a table or index\n" */
   ".schema ?TABLE?        Show the CREATE statements\n"
   ".separator STRING      Change separator string for \"list\" mode\n"
-  ".show                  Show the current values for the following:\n"
-  "                       .echo\n"
-  "                       .explain\n"
-  "                       .mode\n"
-  "                       .nullvalue\n"
-  "                       .output\n"
-  "                       .separator\n"
-  "                       .width\n"
+  ".show                  Show the current values for various settings\n"
   ".tables ?PATTERN?      List names of tables matching a pattern\n"
   ".timeout MS            Try opening locked tables for MS milliseconds\n"
   ".width NUM NUM ...     Set column widths for \"column\" mode\n"
@@ -592,10 +581,10 @@ static void do_meta_command(char *zLine, sqlite *db, struct callback_data *p){
     exit(0);
   }else
 
-  if( c=='e' && strncmp(azArg[0], "explain", n)==0 && nArg>1){
+  if( c=='e' && strncmp(azArg[0], "explain", n)==0 ){
     int j;
-    char *z = azArg[1];
-    int val = atoi(azArg[1]);
+    char *z = nArg>=2 ? azArg[1] : "1";
+    int val = atoi(z);
     for(j=0; z[j]; j++){
       if( isupper(z[j]) ) z[j] = tolower(z[j]);
     }
@@ -721,7 +710,7 @@ static void do_meta_command(char *zLine, sqlite *db, struct callback_data *p){
     }
   }else
 
-  if( c=='p' && strncmp(azArg[0], "prompt", n)==0 && nArg==2 || nArg==3){
+  if( c=='p' && strncmp(azArg[0], "prompt", n)==0 && (nArg==2 || nArg==3)){
     if( nArg >= 2) {
       strncpy(mainPrompt,azArg[1],(int)ArraySize(mainPrompt)-1);
     }
@@ -829,6 +818,7 @@ static void do_meta_command(char *zLine, sqlite *db, struct callback_data *p){
     int i;
     fprintf(p->out,"%9.9s: %s\n","echo", p->echoOn ? "on" : "off");
     fprintf(p->out,"%9.9s: %s\n","explain", p->explainPrev.valid ? "on" : "off");
+    fprintf(p->out,"%9.9s: %s\n","headers", p->showHeader ? "on" : "off");
     fprintf(p->out,"%9.9s: %s\n","mode", modeDescr[p->mode]);
     fprintf(p->out,"%9.9s: %s\n","nullvalue", p->nullvalue);
     fprintf(p->out,"%9.9s: %s\n","output", strlen(p->outfile) ? p->outfile : "stdout");
@@ -960,18 +950,20 @@ static void process_sqliterc(struct callback_data *p,
 
   char *home_dir = NULL;
   char *sqliterc = sqliterc_override;
-  struct passwd *pwent;
-  uid_t uid = getuid();
   FILE *in = NULL;
 
   if (sqliterc == NULL) {
     /* Figure out the user's home directory */
+#if !defined(_WIN32) && !defined(WIN32)
+    struct passwd *pwent;
+    uid_t uid = getuid();
     while( (pwent=getpwent()) != NULL) {
       if(pwent->pw_uid == uid) {
         home_dir = pwent->pw_dir;
         break;
       }
     }
+#endif
 
     if (!home_dir) {
       home_dir = getenv("HOME");
@@ -1003,7 +995,7 @@ static void process_sqliterc(struct callback_data *p,
   } else {
     printf("Loading resources from %s\n",sqliterc);
     process_input(p,in);
-    close (in);
+    fclose(in);
   }
   return;
 }