Fossil SCM

Avoid the use of stdarg.h in the "all" command, since it was causing problems for reasons I do not understand.

drh 2012-10-31 00:11 trunk
Commit ec4c9352235ee6b468aa2d08a8b330b831aae7a1
1 file changed +21 -26
+21 -26
--- src/allrepo.c
+++ src/allrepo.c
@@ -50,32 +50,19 @@
5050
/*
5151
** Build a string that contains all of the command-line options
5252
** specified as arguments. If the option name begins with "+" then
5353
** it takes an argument. Without the "+" it does not.
5454
*/
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);
7764
}
7865
}
7966
8067
8168
/*
@@ -119,11 +106,11 @@
119106
Stmt q;
120107
const char *zCmd;
121108
char *zSyscmd;
122109
char *zFossil;
123110
char *zQFilename;
124
- const char *zExtra = "";
111
+ Blob extra;
125112
int useCheckouts = 0;
126113
int quiet = 0;
127114
int testRun = 0;
128115
int stopOnError = find_option("dontstop",0,0)==0;
129116
int rc;
@@ -138,10 +125,11 @@
138125
if( g.argc<3 ){
139126
usage("changes|list|ls|pull|push|rebuild|sync");
140127
}
141128
n = strlen(g.argv[2]);
142129
db_open_config(1);
130
+ blob_zero(&extra);
143131
zCmd = g.argv[2];
144132
if( strncmp(zCmd, "list", n)==0 || strncmp(zCmd,"ls",n)==0 ){
145133
zCmd = "list";
146134
useCheckouts = find_option("ckout","c",0)!=0;
147135
}else if( strncmp(zCmd, "push", n)==0 ){
@@ -148,12 +136,18 @@
148136
zCmd = "push -autourl -R";
149137
}else if( strncmp(zCmd, "pull", n)==0 ){
150138
zCmd = "pull -autourl -R";
151139
}else if( strncmp(zCmd, "rebuild", n)==0 ){
152140
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");
155149
}else if( strncmp(zCmd, "sync", n)==0 ){
156150
zCmd = "sync -autourl -R";
157151
}else if( strncmp(zCmd, "test-integrity", n)==0 ){
158152
zCmd = "test-integrity";
159153
}else if( strncmp(zCmd, "changes", n)==0 ){
@@ -213,11 +207,12 @@
213207
if( zCmd[0]=='l' ){
214208
fossil_print("%s\n", zFilename);
215209
continue;
216210
}
217211
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));
219214
if( !quiet || testRun ){
220215
fossil_print("%s\n", zSyscmd);
221216
fflush(stdout);
222217
}
223218
rc = testRun ? 0 : fossil_system(zSyscmd);
224219
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button