Fossil SCM
Rename the "portable_system()" function to "fossil_system()" and move it from diffcmd.c into main.c.
Commit
d9880a8003d983b350e19d598851edb82e7c27fc
Parent
6dd81a542a0f06f…
7 files changed
+1
-1
+1
-1
+1
-1
+2
-22
+1
-1
+21
+2
-2
+1
-1
| --- src/allrepo.c | ||
| +++ src/allrepo.c | ||
| @@ -138,11 +138,11 @@ | ||
| 138 | 138 | } |
| 139 | 139 | zQFilename = quoteFilename(zFilename); |
| 140 | 140 | zSyscmd = mprintf("%s %s %s", zFossil, zCmd, zQFilename); |
| 141 | 141 | printf("%s\n", zSyscmd); |
| 142 | 142 | fflush(stdout); |
| 143 | - portable_system(zSyscmd); | |
| 143 | + fossil_system(zSyscmd); | |
| 144 | 144 | free(zSyscmd); |
| 145 | 145 | free(zQFilename); |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /* If any repositories whose names appear in the ~/.fossil file could not |
| 149 | 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 | 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 @@ | ||
| 418 | 418 | blob_add_cr(&text); |
| 419 | 419 | #endif |
| 420 | 420 | blob_write_to_file(&text, zFile); |
| 421 | 421 | zCmd = mprintf("%s \"%s\"", zEditor, zFile); |
| 422 | 422 | printf("%s\n", zCmd); |
| 423 | - if( portable_system(zCmd) ){ | |
| 423 | + if( fossil_system(zCmd) ){ | |
| 424 | 424 | fossil_panic("editor aborted"); |
| 425 | 425 | } |
| 426 | 426 | blob_reset(&text); |
| 427 | 427 | blob_read_from_file(&text, zFile); |
| 428 | 428 | blob_remove_cr(&text); |
| 429 | 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( 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 @@ | ||
| 39 | 39 | zRand = db_text(0, "SELECT hex(randomblob(10))"); |
| 40 | 40 | zOut = mprintf("out-%s", zRand); |
| 41 | 41 | zIn = mprintf("in-%z", zRand); |
| 42 | 42 | blob_write_to_file(pIn, zOut); |
| 43 | 43 | zCmd = mprintf("%s %s %s", zBase, zIn, zOut); |
| 44 | - rc = portable_system(zCmd); | |
| 44 | + rc = fossil_system(zCmd); | |
| 45 | 45 | free(zCmd); |
| 46 | 46 | if( rc==0 ){ |
| 47 | 47 | if( pOut==pIn ){ |
| 48 | 48 | blob_reset(pIn); |
| 49 | 49 | } |
| 50 | 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 = 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 @@ | ||
| 25 | 25 | ** Diff option flags |
| 26 | 26 | */ |
| 27 | 27 | #define DIFF_NEWFILE 0x01 /* Treat non-existing fails as empty files */ |
| 28 | 28 | #define DIFF_NOEOLWS 0x02 /* Ignore whitespace at the end of lines */ |
| 29 | 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 | 30 | /* |
| 51 | 31 | ** Show the difference between two files, one in memory and one on disk. |
| 52 | 32 | ** |
| 53 | 33 | ** The difference is the set of edits needed to transform pFile1 into |
| 54 | 34 | ** zFile2. The content of pFile1 is in memory. zFile2 exists on disk. |
| @@ -106,11 +86,11 @@ | ||
| 106 | 86 | shell_escape(&cmd, blob_str(&nameFile1)); |
| 107 | 87 | blob_append(&cmd, " ", 1); |
| 108 | 88 | shell_escape(&cmd, zFile2); |
| 109 | 89 | |
| 110 | 90 | /* Run the external diff command */ |
| 111 | - portable_system(blob_str(&cmd)); | |
| 91 | + fossil_system(blob_str(&cmd)); | |
| 112 | 92 | |
| 113 | 93 | /* Delete the temporary file and clean up memory used */ |
| 114 | 94 | unlink(blob_str(&nameFile1)); |
| 115 | 95 | blob_reset(&nameFile1); |
| 116 | 96 | blob_reset(&cmd); |
| @@ -160,11 +140,11 @@ | ||
| 160 | 140 | shell_escape(&cmd, zTemp1); |
| 161 | 141 | blob_append(&cmd, " ", 1); |
| 162 | 142 | shell_escape(&cmd, zTemp2); |
| 163 | 143 | |
| 164 | 144 | /* Run the external diff command */ |
| 165 | - portable_system(blob_str(&cmd)); | |
| 145 | + fossil_system(blob_str(&cmd)); | |
| 166 | 146 | |
| 167 | 147 | /* Delete the temporary file and clean up memory used */ |
| 168 | 148 | unlink(zTemp1); |
| 169 | 149 | unlink(zTemp2); |
| 170 | 150 | blob_reset(&cmd); |
| 171 | 151 |
| --- 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 |
+1
-1
| --- src/http_transport.c | ||
| +++ src/http_transport.c | ||
| @@ -296,11 +296,11 @@ | ||
| 296 | 296 | char *zCmd; |
| 297 | 297 | fclose(transport.pFile); |
| 298 | 298 | zCmd = mprintf("\"%s\" http \"%s\" \"%s\" \"%s\" 127.0.0.1", |
| 299 | 299 | g.argv[0], g.urlName, transport.zOutFile, transport.zInFile |
| 300 | 300 | ); |
| 301 | - portable_system(zCmd); | |
| 301 | + fossil_system(zCmd); | |
| 302 | 302 | free(zCmd); |
| 303 | 303 | transport.pFile = fopen(transport.zInFile, "rb"); |
| 304 | 304 | } |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 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 | 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 @@ | ||
| 383 | 383 | void *fossil_realloc(void *p, size_t n){ |
| 384 | 384 | p = realloc(p, n); |
| 385 | 385 | if( p==0 ) fossil_panic("out of memory"); |
| 386 | 386 | return p; |
| 387 | 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 | + | |
| 388 | 409 | |
| 389 | 410 | |
| 390 | 411 | /* |
| 391 | 412 | ** Return a name for an SQLite error code |
| 392 | 413 | */ |
| 393 | 414 |
| --- 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 @@ | ||
| 109 | 109 | out = 0; |
| 110 | 110 | sprintf(zCmd, "\"%s\" http \"%s\" %s %s %s%s", |
| 111 | 111 | _pgmptr, g.zRepositoryName, zRequestFName, zReplyFName, |
| 112 | 112 | inet_ntoa(p->addr.sin_addr), p->zNotFound |
| 113 | 113 | ); |
| 114 | - portable_system(zCmd); | |
| 114 | + fossil_system(zCmd); | |
| 115 | 115 | in = fopen(zReplyFName, "rb"); |
| 116 | 116 | if( in ){ |
| 117 | 117 | while( (got = fread(zHdr, 1, sizeof(zHdr), in))>0 ){ |
| 118 | 118 | send(p->s, zHdr, got, 0); |
| 119 | 119 | } |
| @@ -190,11 +190,11 @@ | ||
| 190 | 190 | zTempPrefix = mprintf("fossil_server_P%d_", iPort); |
| 191 | 191 | printf("Listening for HTTP requests on TCP port %d\n", iPort); |
| 192 | 192 | if( zBrowser ){ |
| 193 | 193 | zBrowser = mprintf(zBrowser, iPort); |
| 194 | 194 | printf("Launch webbrowser: %s\n", zBrowser); |
| 195 | - portable_system(zBrowser); | |
| 195 | + fossil_system(zBrowser); | |
| 196 | 196 | } |
| 197 | 197 | printf("Type Ctrl-C to stop the HTTP server\n"); |
| 198 | 198 | for(;;){ |
| 199 | 199 | SOCKET client; |
| 200 | 200 | SOCKADDR_IN client_addr; |
| 201 | 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 | 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 |