17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
**
** This file contains code used to implement the "diff" command
*/
#include "config.h"
#include "diffcmd.h"
#include <assert.h>
/*
** Shell-escape the given string. Append the result to a blob.
*/
void shell_escape(Blob *pBlob, const char *zIn){
int n = blob_size(pBlob);
int k = strlen(zIn);
int i, c;
char *z;
for(i=0; (c = zIn[i])!=0; i++){
if( isspace(c) || c=='"' || (c=='\\' && zIn[i+1]!=0) ){
blob_appendf(pBlob, "\"%s\"", zIn);
z = blob_buffer(pBlob);
for(i=n+1; i<=n+k; i++){
if( z[i]=='"' ) z[i] = '_';
}
return;
}
}
blob_append(pBlob, zIn, -1);
}
/*
** This function implements a cross-platform "system()" interface.
*/
int portable_system(const char *zOrigCmd){
int rc;
#ifdef __MINGW32__
/* On windows, we have to put double-quotes around the entire command.
|