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
52
53
54
55
56
|
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
|
/*
** Diff option flags
*/
#define DIFF_NEWFILE 0x01 /* Treat non-existing fails as empty files */
#define DIFF_NOEOLWS 0x02 /* Ignore whitespace at the end of lines */
/*
** This function implements a cross-platform "system()" interface.
*/
int portable_system(const char *zOrigCmd){
int rc;
#if defined(_WIN32)
/* On windows, we have to put double-quotes around the entire command.
** Who knows why - this is just the way windows works.
*/
char *zNewCmd = mprintf("\"%s\"", zOrigCmd);
rc = system(zNewCmd);
free(zNewCmd);
#else
/* On unix, evaluate the command directly.
*/
rc = system(zOrigCmd);
#endif
return rc;
}
/*
** Show the difference between two files, one in memory and one on disk.
**
** The difference is the set of edits needed to transform pFile1 into
** zFile2. The content of pFile1 is in memory. zFile2 exists on disk.
**
** Use the internal diff logic if zDiffCmd is NULL. Otherwise call the
|
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
-
+
|
blob_zero(&cmd);
blob_appendf(&cmd, "%s ", zDiffCmd);
shell_escape(&cmd, blob_str(&nameFile1));
blob_append(&cmd, " ", 1);
shell_escape(&cmd, zFile2);
/* Run the external diff command */
portable_system(blob_str(&cmd));
fossil_system(blob_str(&cmd));
/* Delete the temporary file and clean up memory used */
unlink(blob_str(&nameFile1));
blob_reset(&nameFile1);
blob_reset(&cmd);
}
}
|
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
-
+
|
blob_zero(&cmd);
blob_appendf(&cmd, "%s ", zDiffCmd);
shell_escape(&cmd, zTemp1);
blob_append(&cmd, " ", 1);
shell_escape(&cmd, zTemp2);
/* Run the external diff command */
portable_system(blob_str(&cmd));
fossil_system(blob_str(&cmd));
/* Delete the temporary file and clean up memory used */
unlink(zTemp1);
unlink(zTemp2);
blob_reset(&cmd);
}
}
|