From: Iain Buclaw Date: Thu, 24 Dec 2020 21:23:16 +0000 (+0100) Subject: d: Simplify quoting characters in deps_add_target X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=209da90b40fca1be964e25c48352712d519c4dc2;p=gcc.git d: Simplify quoting characters in deps_add_target The implementation in d-lang.cc was based on what was present in libcpp. This synchronizes the escaping logic to match the current version. gcc/d/ChangeLog: * d-lang.cc (deps_add_target): Handle quoting ':' character. Reimplement backslash tracking. --- diff --git a/gcc/d/d-lang.cc b/gcc/d/d-lang.cc index fb95716f918..f20d1f00cb3 100644 --- a/gcc/d/d-lang.cc +++ b/gcc/d/d-lang.cc @@ -114,26 +114,35 @@ deps_add_target (const char *target, bool quoted) } /* Quote characters in target which are significant to Make. */ + unsigned slashes = 0; + for (const char *p = target; *p != '\0'; p++) { switch (*p) { + case '\\': + slashes++; + break; + case ' ': case '\t': - for (const char *q = p - 1; target <= q && *q == '\\'; q--) + while (slashes--) obstack_1grow (&buffer, '\\'); obstack_1grow (&buffer, '\\'); - break; + goto Ldef; case '$': obstack_1grow (&buffer, '$'); - break; + goto Ldef; case '#': + case ':': obstack_1grow (&buffer, '\\'); - break; + goto Ldef; default: + Ldef: + slashes = 0; break; }