]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
d: Simplify quoting characters in deps_add_target
authorIain Buclaw <ibuclaw@gdcproject.org>
Thu, 24 Dec 2020 21:23:16 +0000 (22:23 +0100)
committerIain Buclaw <ibuclaw@gdcproject.org>
Wed, 30 Dec 2020 10:27:53 +0000 (11:27 +0100)
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.

gcc/d/d-lang.cc

index fb95716f918f4163746c75041c0cf0f8aea25f33..f20d1f00cb34b4823cc7caa897a3d7076ca58736 100644 (file)
@@ -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;
        }