Fossil SCM

Change more system() calls into portable_system() in an effort to fix path quoting problems on windows.

drh 2009-09-16 21:29 trunk
Commit 0eb08b860c5b851c074113fd459d1cd0671f4805
+1 -1
--- src/allrepo.c
+++ src/allrepo.c
@@ -127,11 +127,11 @@
127127
}
128128
zQFilename = quoteFilename(zFilename);
129129
zSyscmd = mprintf("%s %s %s", zFossil, zCmd, zQFilename);
130130
printf("%s\n", zSyscmd);
131131
fflush(stdout);
132
- system(zSyscmd);
132
+ portable_system(zSyscmd);
133133
free(zSyscmd);
134134
free(zQFilename);
135135
}
136136
137137
/* If any repositories hows names appear in the ~/.fossil file could not
138138
--- src/allrepo.c
+++ src/allrepo.c
@@ -127,11 +127,11 @@
127 }
128 zQFilename = quoteFilename(zFilename);
129 zSyscmd = mprintf("%s %s %s", zFossil, zCmd, zQFilename);
130 printf("%s\n", zSyscmd);
131 fflush(stdout);
132 system(zSyscmd);
133 free(zSyscmd);
134 free(zQFilename);
135 }
136
137 /* If any repositories hows names appear in the ~/.fossil file could not
138
--- src/allrepo.c
+++ src/allrepo.c
@@ -127,11 +127,11 @@
127 }
128 zQFilename = quoteFilename(zFilename);
129 zSyscmd = mprintf("%s %s %s", zFossil, zCmd, zQFilename);
130 printf("%s\n", zSyscmd);
131 fflush(stdout);
132 portable_system(zSyscmd);
133 free(zSyscmd);
134 free(zQFilename);
135 }
136
137 /* If any repositories hows names appear in the ~/.fossil file could not
138
+1 -1
--- src/checkin.c
+++ src/checkin.c
@@ -290,11 +290,11 @@
290290
blob_add_cr(&text);
291291
#endif
292292
blob_write_to_file(&text, zFile);
293293
zCmd = mprintf("%s \"%s\"", zEditor, zFile);
294294
printf("%s\n", zCmd);
295
- if( system(zCmd) ){
295
+ if( portable_system(zCmd) ){
296296
fossil_panic("editor aborted");
297297
}
298298
blob_reset(&text);
299299
blob_read_from_file(&text, zFile);
300300
blob_remove_cr(&text);
301301
--- src/checkin.c
+++ src/checkin.c
@@ -290,11 +290,11 @@
290 blob_add_cr(&text);
291 #endif
292 blob_write_to_file(&text, zFile);
293 zCmd = mprintf("%s \"%s\"", zEditor, zFile);
294 printf("%s\n", zCmd);
295 if( system(zCmd) ){
296 fossil_panic("editor aborted");
297 }
298 blob_reset(&text);
299 blob_read_from_file(&text, zFile);
300 blob_remove_cr(&text);
301
--- src/checkin.c
+++ src/checkin.c
@@ -290,11 +290,11 @@
290 blob_add_cr(&text);
291 #endif
292 blob_write_to_file(&text, zFile);
293 zCmd = mprintf("%s \"%s\"", zEditor, zFile);
294 printf("%s\n", zCmd);
295 if( portable_system(zCmd) ){
296 fossil_panic("editor aborted");
297 }
298 blob_reset(&text);
299 blob_read_from_file(&text, zFile);
300 blob_remove_cr(&text);
301
+1 -1
--- src/clearsign.c
+++ src/clearsign.c
@@ -45,11 +45,11 @@
4545
zRand = db_text(0, "SELECT hex(randomblob(10))");
4646
zOut = mprintf("out-%s", zRand);
4747
zIn = mprintf("in-%z", zRand);
4848
blob_write_to_file(pIn, zOut);
4949
zCmd = mprintf("%s %s %s", zBase, zIn, zOut);
50
- rc = system(zCmd);
50
+ rc = portable_system(zCmd);
5151
free(zCmd);
5252
if( rc==0 ){
5353
if( pOut==pIn ){
5454
blob_reset(pIn);
5555
}
5656
--- src/clearsign.c
+++ src/clearsign.c
@@ -45,11 +45,11 @@
45 zRand = db_text(0, "SELECT hex(randomblob(10))");
46 zOut = mprintf("out-%s", zRand);
47 zIn = mprintf("in-%z", zRand);
48 blob_write_to_file(pIn, zOut);
49 zCmd = mprintf("%s %s %s", zBase, zIn, zOut);
50 rc = system(zCmd);
51 free(zCmd);
52 if( rc==0 ){
53 if( pOut==pIn ){
54 blob_reset(pIn);
55 }
56
--- src/clearsign.c
+++ src/clearsign.c
@@ -45,11 +45,11 @@
45 zRand = db_text(0, "SELECT hex(randomblob(10))");
46 zOut = mprintf("out-%s", zRand);
47 zIn = mprintf("in-%z", zRand);
48 blob_write_to_file(pIn, zOut);
49 zCmd = mprintf("%s %s %s", zBase, zIn, zOut);
50 rc = portable_system(zCmd);
51 free(zCmd);
52 if( rc==0 ){
53 if( pOut==pIn ){
54 blob_reset(pIn);
55 }
56
+7 -5
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -100,11 +100,11 @@
100100
zPathname
101101
);
102102
shell_escape(&cmd, zFullName);
103103
printf("%s\n", blob_str(&cmd));
104104
fflush(stdout);
105
- system(blob_str(&cmd));
105
+ portable_system(blob_str(&cmd));
106106
}
107107
free(zFullName);
108108
}
109109
db_finalize(&q);
110110
}
@@ -221,19 +221,21 @@
221221
}
222222
223223
/*
224224
** This function implements a cross-platform "system()" interface.
225225
*/
226
-void portable_system(char *zOrigCmd){
226
+int portable_system(char *zOrigCmd){
227
+ int rc;
227228
#ifdef __MINGW32__
228229
/* On windows, we have to put double-quotes around the entire command.
229230
** Who knows why - this is just the way windows works.
230231
*/
231232
char *zNewCmd = mprintf("\"%s\"", zOrigCmd);
232
- system(zNewCmd);
233
+ rc = system(zNewCmd);
233234
free(zNewCmd);
234235
#else
235236
/* On unix, evaluate the command directly.
236237
*/
237
- system(zOrigCmd);
238
-#endif
238
+ rc = system(zOrigCmd);
239
+#endif
240
+ return rc;
239241
}
240242
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -100,11 +100,11 @@
100 zPathname
101 );
102 shell_escape(&cmd, zFullName);
103 printf("%s\n", blob_str(&cmd));
104 fflush(stdout);
105 system(blob_str(&cmd));
106 }
107 free(zFullName);
108 }
109 db_finalize(&q);
110 }
@@ -221,19 +221,21 @@
221 }
222
223 /*
224 ** This function implements a cross-platform "system()" interface.
225 */
226 void portable_system(char *zOrigCmd){
 
227 #ifdef __MINGW32__
228 /* On windows, we have to put double-quotes around the entire command.
229 ** Who knows why - this is just the way windows works.
230 */
231 char *zNewCmd = mprintf("\"%s\"", zOrigCmd);
232 system(zNewCmd);
233 free(zNewCmd);
234 #else
235 /* On unix, evaluate the command directly.
236 */
237 system(zOrigCmd);
238 #endif
 
239 }
240
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -100,11 +100,11 @@
100 zPathname
101 );
102 shell_escape(&cmd, zFullName);
103 printf("%s\n", blob_str(&cmd));
104 fflush(stdout);
105 portable_system(blob_str(&cmd));
106 }
107 free(zFullName);
108 }
109 db_finalize(&q);
110 }
@@ -221,19 +221,21 @@
221 }
222
223 /*
224 ** This function implements a cross-platform "system()" interface.
225 */
226 int portable_system(char *zOrigCmd){
227 int rc;
228 #ifdef __MINGW32__
229 /* On windows, we have to put double-quotes around the entire command.
230 ** Who knows why - this is just the way windows works.
231 */
232 char *zNewCmd = mprintf("\"%s\"", zOrigCmd);
233 rc = system(zNewCmd);
234 free(zNewCmd);
235 #else
236 /* On unix, evaluate the command directly.
237 */
238 rc = system(zOrigCmd);
239 #endif
240 return rc;
241 }
242
--- src/http_transport.c
+++ src/http_transport.c
@@ -163,11 +163,10 @@
163163
fclose(transport.pFile);
164164
zCmd = mprintf("\"%s\" http \"%s\" \"%s\" \"%s\" 127.0.0.1",
165165
g.argv[0], g.urlName, transport.zOutFile, transport.zInFile
166166
);
167167
portable_system(zCmd);
168
- system(zCmd);
169168
free(zCmd);
170169
transport.pFile = fopen(transport.zInFile, "rb");
171170
}
172171
}
173172
174173
--- src/http_transport.c
+++ src/http_transport.c
@@ -163,11 +163,10 @@
163 fclose(transport.pFile);
164 zCmd = mprintf("\"%s\" http \"%s\" \"%s\" \"%s\" 127.0.0.1",
165 g.argv[0], g.urlName, transport.zOutFile, transport.zInFile
166 );
167 portable_system(zCmd);
168 system(zCmd);
169 free(zCmd);
170 transport.pFile = fopen(transport.zInFile, "rb");
171 }
172 }
173
174
--- src/http_transport.c
+++ src/http_transport.c
@@ -163,11 +163,10 @@
163 fclose(transport.pFile);
164 zCmd = mprintf("\"%s\" http \"%s\" \"%s\" \"%s\" 127.0.0.1",
165 g.argv[0], g.urlName, transport.zOutFile, transport.zInFile
166 );
167 portable_system(zCmd);
 
168 free(zCmd);
169 transport.pFile = fopen(transport.zInFile, "rb");
170 }
171 }
172
173

Keyboard Shortcuts

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