Fossil SCM
Avoid the use of stdarg.h in the "all" command, since it was causing problems for reasons I do not understand.
Commit
ec4c9352235ee6b468aa2d08a8b330b831aae7a1
Parent
bdbe6c74b82231e…
1 file changed
+21
-26
+21
-26
| --- src/allrepo.c | ||
| +++ src/allrepo.c | ||
| @@ -50,32 +50,19 @@ | ||
| 50 | 50 | /* |
| 51 | 51 | ** Build a string that contains all of the command-line options |
| 52 | 52 | ** specified as arguments. If the option name begins with "+" then |
| 53 | 53 | ** it takes an argument. Without the "+" it does not. |
| 54 | 54 | */ |
| 55 | -static const char *collect_arguments(const char *zArg, ...){ | |
| 56 | - va_list ap; | |
| 57 | - Blob res; | |
| 58 | - blob_zero(&res); | |
| 59 | - va_start(ap, zArg); | |
| 60 | - while( zArg!=0 ){ | |
| 61 | - if( zArg[0]=='+' ){ | |
| 62 | - const char *zValue = find_option(&zArg[1], 0, 1); | |
| 63 | - if( zValue ){ | |
| 64 | - blob_appendf(&res, " --%s %s", &zArg[1], zValue); | |
| 65 | - } | |
| 66 | - }else{ | |
| 67 | - if( find_option(zArg, 0, 0)!=0 ){ | |
| 68 | - blob_appendf(&res, " --%s", zArg); | |
| 69 | - } | |
| 70 | - } | |
| 71 | - zArg = va_arg(ap, const char*); | |
| 72 | - } | |
| 73 | - if( blob_size(&res)==0 ){ | |
| 74 | - return ""; | |
| 75 | - }else{ | |
| 76 | - return blob_str(&res); | |
| 55 | +static void collect_argument(Blob *pExtra, const char *zArg){ | |
| 56 | + if( find_option(zArg, 0, 0)!=0 ){ | |
| 57 | + blob_appendf(pExtra, " --%s", zArg); | |
| 58 | + } | |
| 59 | +} | |
| 60 | +static void collect_argument_value(Blob *pExtra, const char *zArg){ | |
| 61 | + const char *zValue = find_option(zArg, 0, 1); | |
| 62 | + if( zValue ){ | |
| 63 | + blob_appendf(pExtra, " --%s %s", zArg, zValue); | |
| 77 | 64 | } |
| 78 | 65 | } |
| 79 | 66 | |
| 80 | 67 | |
| 81 | 68 | /* |
| @@ -119,11 +106,11 @@ | ||
| 119 | 106 | Stmt q; |
| 120 | 107 | const char *zCmd; |
| 121 | 108 | char *zSyscmd; |
| 122 | 109 | char *zFossil; |
| 123 | 110 | char *zQFilename; |
| 124 | - const char *zExtra = ""; | |
| 111 | + Blob extra; | |
| 125 | 112 | int useCheckouts = 0; |
| 126 | 113 | int quiet = 0; |
| 127 | 114 | int testRun = 0; |
| 128 | 115 | int stopOnError = find_option("dontstop",0,0)==0; |
| 129 | 116 | int rc; |
| @@ -138,10 +125,11 @@ | ||
| 138 | 125 | if( g.argc<3 ){ |
| 139 | 126 | usage("changes|list|ls|pull|push|rebuild|sync"); |
| 140 | 127 | } |
| 141 | 128 | n = strlen(g.argv[2]); |
| 142 | 129 | db_open_config(1); |
| 130 | + blob_zero(&extra); | |
| 143 | 131 | zCmd = g.argv[2]; |
| 144 | 132 | if( strncmp(zCmd, "list", n)==0 || strncmp(zCmd,"ls",n)==0 ){ |
| 145 | 133 | zCmd = "list"; |
| 146 | 134 | useCheckouts = find_option("ckout","c",0)!=0; |
| 147 | 135 | }else if( strncmp(zCmd, "push", n)==0 ){ |
| @@ -148,12 +136,18 @@ | ||
| 148 | 136 | zCmd = "push -autourl -R"; |
| 149 | 137 | }else if( strncmp(zCmd, "pull", n)==0 ){ |
| 150 | 138 | zCmd = "pull -autourl -R"; |
| 151 | 139 | }else if( strncmp(zCmd, "rebuild", n)==0 ){ |
| 152 | 140 | zCmd = "rebuild"; |
| 153 | - zExtra = collect_arguments("cluster","compress","noverify","+pagesize", | |
| 154 | - "vacuum","deanalyze","wal","stats", 0); | |
| 141 | + collect_argument(&extra, "cluster"); | |
| 142 | + collect_argument(&extra, "compress"); | |
| 143 | + collect_argument(&extra, "noverify"); | |
| 144 | + collect_argument_value(&extra, "pagesize"); | |
| 145 | + collect_argument(&extra, "vacuum"); | |
| 146 | + collect_argument(&extra, "deanalyze"); | |
| 147 | + collect_argument(&extra, "wal"); | |
| 148 | + collect_argument(&extra, "stat"); | |
| 155 | 149 | }else if( strncmp(zCmd, "sync", n)==0 ){ |
| 156 | 150 | zCmd = "sync -autourl -R"; |
| 157 | 151 | }else if( strncmp(zCmd, "test-integrity", n)==0 ){ |
| 158 | 152 | zCmd = "test-integrity"; |
| 159 | 153 | }else if( strncmp(zCmd, "changes", n)==0 ){ |
| @@ -213,11 +207,12 @@ | ||
| 213 | 207 | if( zCmd[0]=='l' ){ |
| 214 | 208 | fossil_print("%s\n", zFilename); |
| 215 | 209 | continue; |
| 216 | 210 | } |
| 217 | 211 | zQFilename = quoteFilename(zFilename); |
| 218 | - zSyscmd = mprintf("%s %s %s%s", zFossil, zCmd, zQFilename, zExtra); | |
| 212 | + zSyscmd = mprintf("%s %s %s%s", | |
| 213 | + zFossil, zCmd, zQFilename, blob_str(&extra)); | |
| 219 | 214 | if( !quiet || testRun ){ |
| 220 | 215 | fossil_print("%s\n", zSyscmd); |
| 221 | 216 | fflush(stdout); |
| 222 | 217 | } |
| 223 | 218 | rc = testRun ? 0 : fossil_system(zSyscmd); |
| 224 | 219 |
| --- src/allrepo.c | |
| +++ src/allrepo.c | |
| @@ -50,32 +50,19 @@ | |
| 50 | /* |
| 51 | ** Build a string that contains all of the command-line options |
| 52 | ** specified as arguments. If the option name begins with "+" then |
| 53 | ** it takes an argument. Without the "+" it does not. |
| 54 | */ |
| 55 | static const char *collect_arguments(const char *zArg, ...){ |
| 56 | va_list ap; |
| 57 | Blob res; |
| 58 | blob_zero(&res); |
| 59 | va_start(ap, zArg); |
| 60 | while( zArg!=0 ){ |
| 61 | if( zArg[0]=='+' ){ |
| 62 | const char *zValue = find_option(&zArg[1], 0, 1); |
| 63 | if( zValue ){ |
| 64 | blob_appendf(&res, " --%s %s", &zArg[1], zValue); |
| 65 | } |
| 66 | }else{ |
| 67 | if( find_option(zArg, 0, 0)!=0 ){ |
| 68 | blob_appendf(&res, " --%s", zArg); |
| 69 | } |
| 70 | } |
| 71 | zArg = va_arg(ap, const char*); |
| 72 | } |
| 73 | if( blob_size(&res)==0 ){ |
| 74 | return ""; |
| 75 | }else{ |
| 76 | return blob_str(&res); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | |
| 81 | /* |
| @@ -119,11 +106,11 @@ | |
| 119 | Stmt q; |
| 120 | const char *zCmd; |
| 121 | char *zSyscmd; |
| 122 | char *zFossil; |
| 123 | char *zQFilename; |
| 124 | const char *zExtra = ""; |
| 125 | int useCheckouts = 0; |
| 126 | int quiet = 0; |
| 127 | int testRun = 0; |
| 128 | int stopOnError = find_option("dontstop",0,0)==0; |
| 129 | int rc; |
| @@ -138,10 +125,11 @@ | |
| 138 | if( g.argc<3 ){ |
| 139 | usage("changes|list|ls|pull|push|rebuild|sync"); |
| 140 | } |
| 141 | n = strlen(g.argv[2]); |
| 142 | db_open_config(1); |
| 143 | zCmd = g.argv[2]; |
| 144 | if( strncmp(zCmd, "list", n)==0 || strncmp(zCmd,"ls",n)==0 ){ |
| 145 | zCmd = "list"; |
| 146 | useCheckouts = find_option("ckout","c",0)!=0; |
| 147 | }else if( strncmp(zCmd, "push", n)==0 ){ |
| @@ -148,12 +136,18 @@ | |
| 148 | zCmd = "push -autourl -R"; |
| 149 | }else if( strncmp(zCmd, "pull", n)==0 ){ |
| 150 | zCmd = "pull -autourl -R"; |
| 151 | }else if( strncmp(zCmd, "rebuild", n)==0 ){ |
| 152 | zCmd = "rebuild"; |
| 153 | zExtra = collect_arguments("cluster","compress","noverify","+pagesize", |
| 154 | "vacuum","deanalyze","wal","stats", 0); |
| 155 | }else if( strncmp(zCmd, "sync", n)==0 ){ |
| 156 | zCmd = "sync -autourl -R"; |
| 157 | }else if( strncmp(zCmd, "test-integrity", n)==0 ){ |
| 158 | zCmd = "test-integrity"; |
| 159 | }else if( strncmp(zCmd, "changes", n)==0 ){ |
| @@ -213,11 +207,12 @@ | |
| 213 | if( zCmd[0]=='l' ){ |
| 214 | fossil_print("%s\n", zFilename); |
| 215 | continue; |
| 216 | } |
| 217 | zQFilename = quoteFilename(zFilename); |
| 218 | zSyscmd = mprintf("%s %s %s%s", zFossil, zCmd, zQFilename, zExtra); |
| 219 | if( !quiet || testRun ){ |
| 220 | fossil_print("%s\n", zSyscmd); |
| 221 | fflush(stdout); |
| 222 | } |
| 223 | rc = testRun ? 0 : fossil_system(zSyscmd); |
| 224 |
| --- src/allrepo.c | |
| +++ src/allrepo.c | |
| @@ -50,32 +50,19 @@ | |
| 50 | /* |
| 51 | ** Build a string that contains all of the command-line options |
| 52 | ** specified as arguments. If the option name begins with "+" then |
| 53 | ** it takes an argument. Without the "+" it does not. |
| 54 | */ |
| 55 | static void collect_argument(Blob *pExtra, const char *zArg){ |
| 56 | if( find_option(zArg, 0, 0)!=0 ){ |
| 57 | blob_appendf(pExtra, " --%s", zArg); |
| 58 | } |
| 59 | } |
| 60 | static void collect_argument_value(Blob *pExtra, const char *zArg){ |
| 61 | const char *zValue = find_option(zArg, 0, 1); |
| 62 | if( zValue ){ |
| 63 | blob_appendf(pExtra, " --%s %s", zArg, zValue); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | |
| 68 | /* |
| @@ -119,11 +106,11 @@ | |
| 106 | Stmt q; |
| 107 | const char *zCmd; |
| 108 | char *zSyscmd; |
| 109 | char *zFossil; |
| 110 | char *zQFilename; |
| 111 | Blob extra; |
| 112 | int useCheckouts = 0; |
| 113 | int quiet = 0; |
| 114 | int testRun = 0; |
| 115 | int stopOnError = find_option("dontstop",0,0)==0; |
| 116 | int rc; |
| @@ -138,10 +125,11 @@ | |
| 125 | if( g.argc<3 ){ |
| 126 | usage("changes|list|ls|pull|push|rebuild|sync"); |
| 127 | } |
| 128 | n = strlen(g.argv[2]); |
| 129 | db_open_config(1); |
| 130 | blob_zero(&extra); |
| 131 | zCmd = g.argv[2]; |
| 132 | if( strncmp(zCmd, "list", n)==0 || strncmp(zCmd,"ls",n)==0 ){ |
| 133 | zCmd = "list"; |
| 134 | useCheckouts = find_option("ckout","c",0)!=0; |
| 135 | }else if( strncmp(zCmd, "push", n)==0 ){ |
| @@ -148,12 +136,18 @@ | |
| 136 | zCmd = "push -autourl -R"; |
| 137 | }else if( strncmp(zCmd, "pull", n)==0 ){ |
| 138 | zCmd = "pull -autourl -R"; |
| 139 | }else if( strncmp(zCmd, "rebuild", n)==0 ){ |
| 140 | zCmd = "rebuild"; |
| 141 | collect_argument(&extra, "cluster"); |
| 142 | collect_argument(&extra, "compress"); |
| 143 | collect_argument(&extra, "noverify"); |
| 144 | collect_argument_value(&extra, "pagesize"); |
| 145 | collect_argument(&extra, "vacuum"); |
| 146 | collect_argument(&extra, "deanalyze"); |
| 147 | collect_argument(&extra, "wal"); |
| 148 | collect_argument(&extra, "stat"); |
| 149 | }else if( strncmp(zCmd, "sync", n)==0 ){ |
| 150 | zCmd = "sync -autourl -R"; |
| 151 | }else if( strncmp(zCmd, "test-integrity", n)==0 ){ |
| 152 | zCmd = "test-integrity"; |
| 153 | }else if( strncmp(zCmd, "changes", n)==0 ){ |
| @@ -213,11 +207,12 @@ | |
| 207 | if( zCmd[0]=='l' ){ |
| 208 | fossil_print("%s\n", zFilename); |
| 209 | continue; |
| 210 | } |
| 211 | zQFilename = quoteFilename(zFilename); |
| 212 | zSyscmd = mprintf("%s %s %s%s", |
| 213 | zFossil, zCmd, zQFilename, blob_str(&extra)); |
| 214 | if( !quiet || testRun ){ |
| 215 | fossil_print("%s\n", zSyscmd); |
| 216 | fflush(stdout); |
| 217 | } |
| 218 | rc = testRun ? 0 : fossil_system(zSyscmd); |
| 219 |