Fossil SCM

Rename the "portable_system()" function to "fossil_system()" and move it from diffcmd.c into main.c.

drh 2010-11-06 21:04 trunk
Commit d9880a8003d983b350e19d598851edb82e7c27fc
+1 -1
--- src/allrepo.c
+++ src/allrepo.c
@@ -138,11 +138,11 @@
138138
}
139139
zQFilename = quoteFilename(zFilename);
140140
zSyscmd = mprintf("%s %s %s", zFossil, zCmd, zQFilename);
141141
printf("%s\n", zSyscmd);
142142
fflush(stdout);
143
- portable_system(zSyscmd);
143
+ fossil_system(zSyscmd);
144144
free(zSyscmd);
145145
free(zQFilename);
146146
}
147147
148148
/* If any repositories whose names appear in the ~/.fossil file could not
149149
--- src/allrepo.c
+++ src/allrepo.c
@@ -138,11 +138,11 @@
138 }
139 zQFilename = quoteFilename(zFilename);
140 zSyscmd = mprintf("%s %s %s", zFossil, zCmd, zQFilename);
141 printf("%s\n", zSyscmd);
142 fflush(stdout);
143 portable_system(zSyscmd);
144 free(zSyscmd);
145 free(zQFilename);
146 }
147
148 /* If any repositories whose names appear in the ~/.fossil file could not
149
--- src/allrepo.c
+++ src/allrepo.c
@@ -138,11 +138,11 @@
138 }
139 zQFilename = quoteFilename(zFilename);
140 zSyscmd = mprintf("%s %s %s", zFossil, zCmd, zQFilename);
141 printf("%s\n", zSyscmd);
142 fflush(stdout);
143 fossil_system(zSyscmd);
144 free(zSyscmd);
145 free(zQFilename);
146 }
147
148 /* If any repositories whose names appear in the ~/.fossil file could not
149
+1 -1
--- src/checkin.c
+++ src/checkin.c
@@ -418,11 +418,11 @@
418418
blob_add_cr(&text);
419419
#endif
420420
blob_write_to_file(&text, zFile);
421421
zCmd = mprintf("%s \"%s\"", zEditor, zFile);
422422
printf("%s\n", zCmd);
423
- if( portable_system(zCmd) ){
423
+ if( fossil_system(zCmd) ){
424424
fossil_panic("editor aborted");
425425
}
426426
blob_reset(&text);
427427
blob_read_from_file(&text, zFile);
428428
blob_remove_cr(&text);
429429
--- src/checkin.c
+++ src/checkin.c
@@ -418,11 +418,11 @@
418 blob_add_cr(&text);
419 #endif
420 blob_write_to_file(&text, zFile);
421 zCmd = mprintf("%s \"%s\"", zEditor, zFile);
422 printf("%s\n", zCmd);
423 if( portable_system(zCmd) ){
424 fossil_panic("editor aborted");
425 }
426 blob_reset(&text);
427 blob_read_from_file(&text, zFile);
428 blob_remove_cr(&text);
429
--- src/checkin.c
+++ src/checkin.c
@@ -418,11 +418,11 @@
418 blob_add_cr(&text);
419 #endif
420 blob_write_to_file(&text, zFile);
421 zCmd = mprintf("%s \"%s\"", zEditor, zFile);
422 printf("%s\n", zCmd);
423 if( fossil_system(zCmd) ){
424 fossil_panic("editor aborted");
425 }
426 blob_reset(&text);
427 blob_read_from_file(&text, zFile);
428 blob_remove_cr(&text);
429
+1 -1
--- src/clearsign.c
+++ src/clearsign.c
@@ -39,11 +39,11 @@
3939
zRand = db_text(0, "SELECT hex(randomblob(10))");
4040
zOut = mprintf("out-%s", zRand);
4141
zIn = mprintf("in-%z", zRand);
4242
blob_write_to_file(pIn, zOut);
4343
zCmd = mprintf("%s %s %s", zBase, zIn, zOut);
44
- rc = portable_system(zCmd);
44
+ rc = fossil_system(zCmd);
4545
free(zCmd);
4646
if( rc==0 ){
4747
if( pOut==pIn ){
4848
blob_reset(pIn);
4949
}
5050
--- src/clearsign.c
+++ src/clearsign.c
@@ -39,11 +39,11 @@
39 zRand = db_text(0, "SELECT hex(randomblob(10))");
40 zOut = mprintf("out-%s", zRand);
41 zIn = mprintf("in-%z", zRand);
42 blob_write_to_file(pIn, zOut);
43 zCmd = mprintf("%s %s %s", zBase, zIn, zOut);
44 rc = portable_system(zCmd);
45 free(zCmd);
46 if( rc==0 ){
47 if( pOut==pIn ){
48 blob_reset(pIn);
49 }
50
--- src/clearsign.c
+++ src/clearsign.c
@@ -39,11 +39,11 @@
39 zRand = db_text(0, "SELECT hex(randomblob(10))");
40 zOut = mprintf("out-%s", zRand);
41 zIn = mprintf("in-%z", zRand);
42 blob_write_to_file(pIn, zOut);
43 zCmd = mprintf("%s %s %s", zBase, zIn, zOut);
44 rc = fossil_system(zCmd);
45 free(zCmd);
46 if( rc==0 ){
47 if( pOut==pIn ){
48 blob_reset(pIn);
49 }
50
+2 -22
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -25,30 +25,10 @@
2525
** Diff option flags
2626
*/
2727
#define DIFF_NEWFILE 0x01 /* Treat non-existing fails as empty files */
2828
#define DIFF_NOEOLWS 0x02 /* Ignore whitespace at the end of lines */
2929
30
-/*
31
-** This function implements a cross-platform "system()" interface.
32
-*/
33
-int portable_system(const char *zOrigCmd){
34
- int rc;
35
-#if defined(_WIN32)
36
- /* On windows, we have to put double-quotes around the entire command.
37
- ** Who knows why - this is just the way windows works.
38
- */
39
- char *zNewCmd = mprintf("\"%s\"", zOrigCmd);
40
- rc = system(zNewCmd);
41
- free(zNewCmd);
42
-#else
43
- /* On unix, evaluate the command directly.
44
- */
45
- rc = system(zOrigCmd);
46
-#endif
47
- return rc;
48
-}
49
-
5030
/*
5131
** Show the difference between two files, one in memory and one on disk.
5232
**
5333
** The difference is the set of edits needed to transform pFile1 into
5434
** zFile2. The content of pFile1 is in memory. zFile2 exists on disk.
@@ -106,11 +86,11 @@
10686
shell_escape(&cmd, blob_str(&nameFile1));
10787
blob_append(&cmd, " ", 1);
10888
shell_escape(&cmd, zFile2);
10989
11090
/* Run the external diff command */
111
- portable_system(blob_str(&cmd));
91
+ fossil_system(blob_str(&cmd));
11292
11393
/* Delete the temporary file and clean up memory used */
11494
unlink(blob_str(&nameFile1));
11595
blob_reset(&nameFile1);
11696
blob_reset(&cmd);
@@ -160,11 +140,11 @@
160140
shell_escape(&cmd, zTemp1);
161141
blob_append(&cmd, " ", 1);
162142
shell_escape(&cmd, zTemp2);
163143
164144
/* Run the external diff command */
165
- portable_system(blob_str(&cmd));
145
+ fossil_system(blob_str(&cmd));
166146
167147
/* Delete the temporary file and clean up memory used */
168148
unlink(zTemp1);
169149
unlink(zTemp2);
170150
blob_reset(&cmd);
171151
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -25,30 +25,10 @@
25 ** Diff option flags
26 */
27 #define DIFF_NEWFILE 0x01 /* Treat non-existing fails as empty files */
28 #define DIFF_NOEOLWS 0x02 /* Ignore whitespace at the end of lines */
29
30 /*
31 ** This function implements a cross-platform "system()" interface.
32 */
33 int portable_system(const char *zOrigCmd){
34 int rc;
35 #if defined(_WIN32)
36 /* On windows, we have to put double-quotes around the entire command.
37 ** Who knows why - this is just the way windows works.
38 */
39 char *zNewCmd = mprintf("\"%s\"", zOrigCmd);
40 rc = system(zNewCmd);
41 free(zNewCmd);
42 #else
43 /* On unix, evaluate the command directly.
44 */
45 rc = system(zOrigCmd);
46 #endif
47 return rc;
48 }
49
50 /*
51 ** Show the difference between two files, one in memory and one on disk.
52 **
53 ** The difference is the set of edits needed to transform pFile1 into
54 ** zFile2. The content of pFile1 is in memory. zFile2 exists on disk.
@@ -106,11 +86,11 @@
106 shell_escape(&cmd, blob_str(&nameFile1));
107 blob_append(&cmd, " ", 1);
108 shell_escape(&cmd, zFile2);
109
110 /* Run the external diff command */
111 portable_system(blob_str(&cmd));
112
113 /* Delete the temporary file and clean up memory used */
114 unlink(blob_str(&nameFile1));
115 blob_reset(&nameFile1);
116 blob_reset(&cmd);
@@ -160,11 +140,11 @@
160 shell_escape(&cmd, zTemp1);
161 blob_append(&cmd, " ", 1);
162 shell_escape(&cmd, zTemp2);
163
164 /* Run the external diff command */
165 portable_system(blob_str(&cmd));
166
167 /* Delete the temporary file and clean up memory used */
168 unlink(zTemp1);
169 unlink(zTemp2);
170 blob_reset(&cmd);
171
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -25,30 +25,10 @@
25 ** Diff option flags
26 */
27 #define DIFF_NEWFILE 0x01 /* Treat non-existing fails as empty files */
28 #define DIFF_NOEOLWS 0x02 /* Ignore whitespace at the end of lines */
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30 /*
31 ** Show the difference between two files, one in memory and one on disk.
32 **
33 ** The difference is the set of edits needed to transform pFile1 into
34 ** zFile2. The content of pFile1 is in memory. zFile2 exists on disk.
@@ -106,11 +86,11 @@
86 shell_escape(&cmd, blob_str(&nameFile1));
87 blob_append(&cmd, " ", 1);
88 shell_escape(&cmd, zFile2);
89
90 /* Run the external diff command */
91 fossil_system(blob_str(&cmd));
92
93 /* Delete the temporary file and clean up memory used */
94 unlink(blob_str(&nameFile1));
95 blob_reset(&nameFile1);
96 blob_reset(&cmd);
@@ -160,11 +140,11 @@
140 shell_escape(&cmd, zTemp1);
141 blob_append(&cmd, " ", 1);
142 shell_escape(&cmd, zTemp2);
143
144 /* Run the external diff command */
145 fossil_system(blob_str(&cmd));
146
147 /* Delete the temporary file and clean up memory used */
148 unlink(zTemp1);
149 unlink(zTemp2);
150 blob_reset(&cmd);
151
--- src/http_transport.c
+++ src/http_transport.c
@@ -296,11 +296,11 @@
296296
char *zCmd;
297297
fclose(transport.pFile);
298298
zCmd = mprintf("\"%s\" http \"%s\" \"%s\" \"%s\" 127.0.0.1",
299299
g.argv[0], g.urlName, transport.zOutFile, transport.zInFile
300300
);
301
- portable_system(zCmd);
301
+ fossil_system(zCmd);
302302
free(zCmd);
303303
transport.pFile = fopen(transport.zInFile, "rb");
304304
}
305305
}
306306
307307
--- src/http_transport.c
+++ src/http_transport.c
@@ -296,11 +296,11 @@
296 char *zCmd;
297 fclose(transport.pFile);
298 zCmd = mprintf("\"%s\" http \"%s\" \"%s\" \"%s\" 127.0.0.1",
299 g.argv[0], g.urlName, transport.zOutFile, transport.zInFile
300 );
301 portable_system(zCmd);
302 free(zCmd);
303 transport.pFile = fopen(transport.zInFile, "rb");
304 }
305 }
306
307
--- src/http_transport.c
+++ src/http_transport.c
@@ -296,11 +296,11 @@
296 char *zCmd;
297 fclose(transport.pFile);
298 zCmd = mprintf("\"%s\" http \"%s\" \"%s\" \"%s\" 127.0.0.1",
299 g.argv[0], g.urlName, transport.zOutFile, transport.zInFile
300 );
301 fossil_system(zCmd);
302 free(zCmd);
303 transport.pFile = fopen(transport.zInFile, "rb");
304 }
305 }
306
307
+21
--- src/main.c
+++ src/main.c
@@ -383,10 +383,31 @@
383383
void *fossil_realloc(void *p, size_t n){
384384
p = realloc(p, n);
385385
if( p==0 ) fossil_panic("out of memory");
386386
return p;
387387
}
388
+
389
+/*
390
+** This function implements a cross-platform "system()" interface.
391
+*/
392
+int fossil_system(const char *zOrigCmd){
393
+ int rc;
394
+#if defined(_WIN32)
395
+ /* On windows, we have to put double-quotes around the entire command.
396
+ ** Who knows why - this is just the way windows works.
397
+ */
398
+ char *zNewCmd = mprintf("\"%s\"", zOrigCmd);
399
+ rc = system(zNewCmd);
400
+ free(zNewCmd);
401
+#else
402
+ /* On unix, evaluate the command directly.
403
+ */
404
+ rc = system(zOrigCmd);
405
+#endif
406
+ return rc;
407
+}
408
+
388409
389410
390411
/*
391412
** Return a name for an SQLite error code
392413
*/
393414
--- src/main.c
+++ src/main.c
@@ -383,10 +383,31 @@
383 void *fossil_realloc(void *p, size_t n){
384 p = realloc(p, n);
385 if( p==0 ) fossil_panic("out of memory");
386 return p;
387 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
388
389
390 /*
391 ** Return a name for an SQLite error code
392 */
393
--- src/main.c
+++ src/main.c
@@ -383,10 +383,31 @@
383 void *fossil_realloc(void *p, size_t n){
384 p = realloc(p, n);
385 if( p==0 ) fossil_panic("out of memory");
386 return p;
387 }
388
389 /*
390 ** This function implements a cross-platform "system()" interface.
391 */
392 int fossil_system(const char *zOrigCmd){
393 int rc;
394 #if defined(_WIN32)
395 /* On windows, we have to put double-quotes around the entire command.
396 ** Who knows why - this is just the way windows works.
397 */
398 char *zNewCmd = mprintf("\"%s\"", zOrigCmd);
399 rc = system(zNewCmd);
400 free(zNewCmd);
401 #else
402 /* On unix, evaluate the command directly.
403 */
404 rc = system(zOrigCmd);
405 #endif
406 return rc;
407 }
408
409
410
411 /*
412 ** Return a name for an SQLite error code
413 */
414
+2 -2
--- src/winhttp.c
+++ src/winhttp.c
@@ -109,11 +109,11 @@
109109
out = 0;
110110
sprintf(zCmd, "\"%s\" http \"%s\" %s %s %s%s",
111111
_pgmptr, g.zRepositoryName, zRequestFName, zReplyFName,
112112
inet_ntoa(p->addr.sin_addr), p->zNotFound
113113
);
114
- portable_system(zCmd);
114
+ fossil_system(zCmd);
115115
in = fopen(zReplyFName, "rb");
116116
if( in ){
117117
while( (got = fread(zHdr, 1, sizeof(zHdr), in))>0 ){
118118
send(p->s, zHdr, got, 0);
119119
}
@@ -190,11 +190,11 @@
190190
zTempPrefix = mprintf("fossil_server_P%d_", iPort);
191191
printf("Listening for HTTP requests on TCP port %d\n", iPort);
192192
if( zBrowser ){
193193
zBrowser = mprintf(zBrowser, iPort);
194194
printf("Launch webbrowser: %s\n", zBrowser);
195
- portable_system(zBrowser);
195
+ fossil_system(zBrowser);
196196
}
197197
printf("Type Ctrl-C to stop the HTTP server\n");
198198
for(;;){
199199
SOCKET client;
200200
SOCKADDR_IN client_addr;
201201
--- src/winhttp.c
+++ src/winhttp.c
@@ -109,11 +109,11 @@
109 out = 0;
110 sprintf(zCmd, "\"%s\" http \"%s\" %s %s %s%s",
111 _pgmptr, g.zRepositoryName, zRequestFName, zReplyFName,
112 inet_ntoa(p->addr.sin_addr), p->zNotFound
113 );
114 portable_system(zCmd);
115 in = fopen(zReplyFName, "rb");
116 if( in ){
117 while( (got = fread(zHdr, 1, sizeof(zHdr), in))>0 ){
118 send(p->s, zHdr, got, 0);
119 }
@@ -190,11 +190,11 @@
190 zTempPrefix = mprintf("fossil_server_P%d_", iPort);
191 printf("Listening for HTTP requests on TCP port %d\n", iPort);
192 if( zBrowser ){
193 zBrowser = mprintf(zBrowser, iPort);
194 printf("Launch webbrowser: %s\n", zBrowser);
195 portable_system(zBrowser);
196 }
197 printf("Type Ctrl-C to stop the HTTP server\n");
198 for(;;){
199 SOCKET client;
200 SOCKADDR_IN client_addr;
201
--- src/winhttp.c
+++ src/winhttp.c
@@ -109,11 +109,11 @@
109 out = 0;
110 sprintf(zCmd, "\"%s\" http \"%s\" %s %s %s%s",
111 _pgmptr, g.zRepositoryName, zRequestFName, zReplyFName,
112 inet_ntoa(p->addr.sin_addr), p->zNotFound
113 );
114 fossil_system(zCmd);
115 in = fopen(zReplyFName, "rb");
116 if( in ){
117 while( (got = fread(zHdr, 1, sizeof(zHdr), in))>0 ){
118 send(p->s, zHdr, got, 0);
119 }
@@ -190,11 +190,11 @@
190 zTempPrefix = mprintf("fossil_server_P%d_", iPort);
191 printf("Listening for HTTP requests on TCP port %d\n", iPort);
192 if( zBrowser ){
193 zBrowser = mprintf(zBrowser, iPort);
194 printf("Launch webbrowser: %s\n", zBrowser);
195 fossil_system(zBrowser);
196 }
197 printf("Type Ctrl-C to stop the HTTP server\n");
198 for(;;){
199 SOCKET client;
200 SOCKADDR_IN client_addr;
201

Keyboard Shortcuts

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