Escape spaces in depfile with backslashes.
This matches how Linux escapes spaces in paths.
The same syntax is also used by other build tools that output depfiles,
e.g. edd36eba5e/src/cargo/core/compiler/output_depinfo.rs (L19)
Signed-off-by: Colin Finck <mail@colinfinck.de>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
main
parent
f9968fa069
commit
18aa49a9f6
4
dtc.c
4
dtc.c
|
@ -289,7 +289,9 @@ int main(int argc, char *argv[])
|
||||||
if (!depfile)
|
if (!depfile)
|
||||||
die("Couldn't open dependency file %s: %s\n", depname,
|
die("Couldn't open dependency file %s: %s\n", depname,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
fprintf(depfile, "%s:", outname);
|
|
||||||
|
fprint_path_escaped(depfile, outname);
|
||||||
|
fputc(':', depfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inform == NULL)
|
if (inform == NULL)
|
||||||
|
|
6
srcpos.c
6
srcpos.c
|
@ -160,8 +160,10 @@ FILE *srcfile_relative_open(const char *fname, char **fullnamep)
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (depfile)
|
if (depfile) {
|
||||||
fprintf(depfile, " %s", fullname);
|
fputc(' ', depfile);
|
||||||
|
fprint_path_escaped(depfile, fullname);
|
||||||
|
}
|
||||||
|
|
||||||
if (fullnamep)
|
if (fullnamep)
|
||||||
*fullnamep = fullname;
|
*fullnamep = fullname;
|
||||||
|
|
16
util.c
16
util.c
|
@ -23,6 +23,22 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "version_gen.h"
|
#include "version_gen.h"
|
||||||
|
|
||||||
|
void fprint_path_escaped(FILE *fp, const char *path)
|
||||||
|
{
|
||||||
|
const char *p = path;
|
||||||
|
|
||||||
|
while (*p) {
|
||||||
|
if (*p == ' ') {
|
||||||
|
fputc('\\', fp);
|
||||||
|
fputc(' ', fp);
|
||||||
|
} else {
|
||||||
|
fputc(*p, fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
char *xstrdup(const char *s)
|
char *xstrdup(const char *s)
|
||||||
{
|
{
|
||||||
int len = strlen(s) + 1;
|
int len = strlen(s) + 1;
|
||||||
|
|
5
util.h
5
util.h
|
@ -42,6 +42,11 @@ static inline void NORETURN PRINTF(1, 2) die(const char *str, ...)
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes path to fp, escaping spaces with a backslash.
|
||||||
|
*/
|
||||||
|
void fprint_path_escaped(FILE *fp, const char *path);
|
||||||
|
|
||||||
static inline void *xmalloc(size_t len)
|
static inline void *xmalloc(size_t len)
|
||||||
{
|
{
|
||||||
void *new = malloc(len);
|
void *new = malloc(len);
|
||||||
|
|
Loading…
Reference in New Issue