mirror of
https://github.com/TinyCC/tinycc.git
synced 2025-11-16 12:34:45 +00:00
Make sure to escape paths in generated make dependencies
If spaces are not escaped when generating the make dependencies file, then if one of the dependencies has a space it would be interpreted as two separate targets by Make, instead of just one.
This commit is contained in:
19
tcctools.c
19
tcctools.c
@@ -515,10 +515,23 @@ int _dowildcard = 1;
|
|||||||
/* -------------------------------------------------------------- */
|
/* -------------------------------------------------------------- */
|
||||||
/* generate xxx.d file */
|
/* generate xxx.d file */
|
||||||
|
|
||||||
|
static char *escape_target_dep(const char *s) {
|
||||||
|
char *res = tcc_malloc(strlen(s) * 2 + 1);
|
||||||
|
int j;
|
||||||
|
for (j = 0; *s; s++, j++) {
|
||||||
|
if (is_space(*s)) {
|
||||||
|
res[j++] = '\\';
|
||||||
|
}
|
||||||
|
res[j] = *s;
|
||||||
|
}
|
||||||
|
res[j] = '\0';
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
ST_FUNC void gen_makedeps(TCCState *s1, const char *target, const char *filename)
|
ST_FUNC void gen_makedeps(TCCState *s1, const char *target, const char *filename)
|
||||||
{
|
{
|
||||||
FILE *depout;
|
FILE *depout;
|
||||||
char buf[1024];
|
char buf[1024], *escaped_target;
|
||||||
int i, k;
|
int i, k;
|
||||||
|
|
||||||
if (!filename) {
|
if (!filename) {
|
||||||
@@ -540,7 +553,9 @@ ST_FUNC void gen_makedeps(TCCState *s1, const char *target, const char *filename
|
|||||||
for (k = 0; k < i; ++k)
|
for (k = 0; k < i; ++k)
|
||||||
if (0 == strcmp(s1->target_deps[i], s1->target_deps[k]))
|
if (0 == strcmp(s1->target_deps[i], s1->target_deps[k]))
|
||||||
goto next;
|
goto next;
|
||||||
fprintf(depout, " \\\n %s", s1->target_deps[i]);
|
escaped_target = escape_target_dep(s1->target_deps[i]);
|
||||||
|
fprintf(depout, " \\\n %s", escaped_target);
|
||||||
|
tcc_free(escaped_target);
|
||||||
next:;
|
next:;
|
||||||
}
|
}
|
||||||
fprintf(depout, "\n");
|
fprintf(depout, "\n");
|
||||||
|
|||||||
Reference in New Issue
Block a user