]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Port some of the shell's CLI flag-handling code into sqlite3-rsync to make the arg...
authorstephan <stephan@noemail.net>
Thu, 12 Sep 2024 18:15:28 +0000 (18:15 +0000)
committerstephan <stephan@noemail.net>
Thu, 12 Sep 2024 18:15:28 +0000 (18:15 +0000)
FossilOrigin-Name: 53fb9b11807ff7accd8cd41f9cb6516d2503f161ea976940437a1d3aae868665

manifest
manifest.uuid
tool/sqlite3-rsync.c

index fabf4f8ef1e6cab5106c8a5e47377a930b82d3d8..9ee27c15a852abfb4f9eb8e05cdf8e53fb83a8f0 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Replica\smust\sbe\sin\swritable_schema\smode.
-D 2024-09-12T17:06:02.316
+C Port\ssome\sof\sthe\sshell's\sCLI\sflag-handling\scode\sinto\ssqlite3-rsync\sto\smake\sthe\sarg\shandling\smore\srobust.
+D 2024-09-12T18:15:28.846
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -2174,7 +2174,7 @@ F tool/speedtest8inst1.c 7ce07da76b5e745783e703a834417d725b7d45fd
 F tool/spellsift.tcl 52b4b04dc4333c7ab024f09d9d66ed6b6f7c6eb00b38497a09f338fa55d40618 x
 F tool/split-sqlite3c.tcl 5aa60643afca558bc732b1444ae81a522326f91e1dc5665b369c54f09e20de60
 F tool/sqldiff.c 847fc8fcfddf5ce4797b7394cad6372f2f5dc17d8186e2ef8fb44d50fae4f44a
-F tool/sqlite3-rsync.c a183370f4b837ac9e6dc2d347217b1df3b47c7300151a2e8207cea228df88f39
+F tool/sqlite3-rsync.c 20783cd979df8c32d33eab3c38c44a79343be63a73b6cbd1ee56a0a14d73b3fe
 F tool/sqlite3_analyzer.c.in 8da2b08f56eeac331a715036cf707cc20f879f231362be0c22efd682e2b89b4f
 F tool/sqltclsh.c.in 1bcc2e9da58fadf17b0bf6a50e68c1159e602ce057210b655d50bad5aaaef898
 F tool/sqltclsh.tcl 862f4cf1418df5e1315b5db3b5ebe88969e2a784525af5fbf9596592f14ed848
@@ -2213,8 +2213,8 @@ F vsixtest/vsixtest.tcl 6195aba1f12a5e10efc2b8c0009532167be5e301abe5b31385638080
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P b979d02ffd1370d8840328bce06c76c224f0fc1fb54b47d6c904547580a820a1
-R 726e2548d9f75b6be59271aa0b3ef896
-U drh
-Z f4621da70e1b6c4b3102731ca73be41a
+P e385525793c7d74ce8ee139c9d6cfc1248834754598f3fd45b22b9426ff106ee
+R 2634868962b675f42ebfd90b6ccf2615
+U stephan
+Z ca092fee4c8dab92860037cbb2c82076
 # Remove this line to create a well-formed Fossil manifest.
index ba2db44c525f49307f8b693dbb4450e46a772967..67577b0f49465dfe7a7f923c1c2a9e07067da46d 100644 (file)
@@ -1 +1 @@
-e385525793c7d74ce8ee139c9d6cfc1248834754598f3fd45b22b9426ff106ee
+53fb9b11807ff7accd8cd41f9cb6516d2503f161ea976940437a1d3aae868665
index e7d2e49551e29741d35b2ad751484a5cff096ad6..350ed84afd10d21cb81550c74ce67671b60ad0c9 100644 (file)
@@ -1190,6 +1190,20 @@ static int numVs(const char *z){
   return 0;
 }
 
+/*
+** Get the argument to an --option.  Throw an error and die if no argument
+** is available.
+*/
+static const char *cmdline_option_value(int argc, const char * const*argv,
+                                        int i){
+  if( i==argc ){
+    fprintf(stderr,"%s: Error: missing argument to %s\n",
+            argv[0], argv[argc-1]);
+    exit(1);
+  }
+  return argv[i];
+}
+
 
 /*
 ** Parse command-line arguments.  Dispatch subroutines to do the
@@ -1207,7 +1221,7 @@ static int numVs(const char *z){
 **
 ** The user types (1) or (2).  SSH launches (3) or (4).
 **
-** If (1) is seen then popen2 is used launch (4) on the remote and 
+** If (1) is seen then popen2 is used launch (4) on the remote and
 ** originSide() is called locally.
 **
 ** If (2) is seen, then popen2() is used to launch (3) on the remote
@@ -1217,7 +1231,7 @@ static int numVs(const char *z){
 **
 q** If (4) is seen, call replicaSide() on stdin and stdout.
 */
-int main(int argc, char **argv){
+int main(int argc, char const * const *argv){
   int isOrigin = 0;
   int isReplica = 0;
   int i;
@@ -1230,6 +1244,7 @@ int main(int argc, char **argv){
   const char *zExe = "sqlite3-rsync";
   char *zCmd = 0;
 
+#define cli_opt_val cmdline_option_value(argc, argv, ++i)
   memset(&ctx, 0, sizeof(ctx));
   for(i=1; i<argc; i++){
     const char *z = argv[i];
@@ -1246,11 +1261,11 @@ int main(int argc, char **argv){
       continue;
     }
     if( strcmp(z, "--ssh")==0 ){
-      zSsh = argv[++i];
+      zSsh = cli_opt_val;
       continue;
     }
     if( strcmp(z, "--exe")==0 ){
-      zExe = argv[++i];
+      zExe = cli_opt_val;
       continue;
     }
     if( strcmp(z, "-help")==0 || strcmp(z, "--help")==0
@@ -1324,7 +1339,7 @@ int main(int argc, char **argv){
   zDiv = strchr(ctx.zOrigin,':');
   if( zDiv ){
     if( strchr(ctx.zReplica,':')!=0 ){
-      fprintf(stderr, 
+      fprintf(stderr,
          "At least one of ORIGIN and REPLICA must be a local database\n"
          "You provided two remote databases.\n");
       return 1;