(More creeping featurism.)
I have to work with files that come from the Windows world. Make
doesn't allow quoting characters in targets. These patches add quoting
as a conditional compile.
Brad
Index: usr.bin/make/config.h
===================================================================
RCS file: /cvs/src/usr.bin/make/config.h,v
retrieving revision 1.18
diff -u usr.bin/make/config.h
--- usr.bin/make/config.h 19 Jul 2010 19:46:44 -0000 1.18
+++ usr.bin/make/config.h 17 Feb 2012 17:35:59 -0000
@@ -135,4 +135,6 @@
*/
#define MAKE_BSIZE 256 /* starting size for expandable
buffers */
+#define PARSEQUOTE 1 /* parse quoted spaces in
dependences */
+
#endif
Index: usr.bin/make/dir.c
===================================================================
RCS file: /cvs/src/usr.bin/make/dir.c,v
retrieving revision 1.59
diff -u usr.bin/make/dir.c
--- usr.bin/make/dir.c 19 Jul 2010 19:46:44 -0000 1.59
+++ usr.bin/make/dir.c 17 Feb 2012 17:36:00 -0000
@@ -447,6 +447,10 @@
uint32_t hv; /* hash value for last component in file name */
char *q; /* Str_dupi(name, ename) */
+#ifdef PARSEQUOTE
+ name = (const char *)escape_dupi(name, ename, "\\ ");
+ ename = name + strlen(name);
+#endif
/* Find the final component of the name and note whether name has a
* slash in it */
basename = Str_rchri(name, ename, '/');
@@ -470,7 +474,11 @@
find_file_hashi(dot, basename, ename, hv) != NULL) {
if (DEBUG(DIR))
printf("in '.'\n");
+#ifdef PARSEQUOTE
+ return (char *)name;
+#else
return Str_dupi(name, ename);
+#endif
}
/* Then, we look through all the directories on path, seeking one
@@ -512,6 +520,9 @@
ename, '/');
if (DEBUG(DIR))
printf("returning %s\n", file);
+#ifdef PARSEQUOTE
+ efree((void *)name);
+#endif
return file;
} else if (hasSlash) {
/* If the file has a leading path component and
that
@@ -524,6 +535,9 @@
if (*p1 == '\0' && p2 == basename - 1) {
if (DEBUG(DIR))
printf("has to be here but
isn't -- returning NULL\n");
+#ifdef PARSEQUOTE
+ efree((void *)name);
+#endif
return NULL;
}
}
@@ -544,6 +558,9 @@
if (!hasSlash) {
if (DEBUG(DIR))
printf("failed.\n");
+#ifdef PARSEQUOTE
+ efree((void *)name);
+#endif
return NULL;
}
@@ -591,6 +608,9 @@
printf("Caching %s for %s\n",
time_to_string(mtime), file);
record_stamp(file, mtime);
+#ifdef PARSEQUOTE
+ efree((void *)name);
+#endif
return file;
} else
free(file);
@@ -604,6 +624,9 @@
* the path, so no point in proceeding... */
if (DEBUG(DIR))
printf("Checked . already, returning
NULL\n");
+#ifdef PARSEQUOTE
+ efree((void *)name);
+#endif
return NULL;
}
}
@@ -619,7 +642,11 @@
* $(FILE) exists in $(INSTALLDIR) but not in the current one.
* When searching for $(FILE), we will find it in $(INSTALLDIR)
* b/c we added it here. This is not good... */
+#ifdef PARSEQUOTE
+ q = (char *)name;
+#else
q = Str_dupi(name, ename);
+#endif
if (DEBUG(DIR))
printf("Looking for \"%s\"...", q);
Index: usr.bin/make/direxpand.c
===================================================================
RCS file: /cvs/src/usr.bin/make/direxpand.c,v
retrieving revision 1.5
diff -u usr.bin/make/direxpand.c
--- usr.bin/make/direxpand.c 19 Jul 2010 19:30:37 -0000 1.5
+++ usr.bin/make/direxpand.c 17 Feb 2012 17:36:00 -0000
@@ -303,6 +303,7 @@
/* XXX: This code is not 100% correct ([^]] fails) */
+/* XXX: doesn't workd for PARSEQUOTE either */
bool
Dir_HasWildcardsi(const char *name, const char *ename)
{
Index: usr.bin/make/parse.c
===================================================================
RCS file: /cvs/src/usr.bin/make/parse.c,v
retrieving revision 1.100
diff -u usr.bin/make/parse.c
--- usr.bin/make/parse.c 26 Dec 2010 13:09:22 -0000 1.100
+++ usr.bin/make/parse.c 17 Feb 2012 17:36:00 -0000
@@ -546,7 +546,13 @@
}
Lst_Destroy(&curTargs, NOFREE);
} else {
+#ifdef PARSEQUOTE
+ char *l = escape_dupi(line, end, "\\ ");
+ add_target_node(l, l + (end-line));
+ efree(l);
+#else
add_target_node(line, end);
+#endif
}
}
@@ -604,6 +610,13 @@
* the initial Var_Subst and we wouldn't be
* here. */
Var_ParseSkip(&cp, NULL);
+#ifdef PARSEQUOTE
+ else if (*cp == '\\') {
+ cp++;
+ if (*cp)
+ cp++;
+ }
+#endif
else {
if (found_delimiter(cp))
break;
@@ -953,6 +966,12 @@
* dollar sign (a dynamic source).
*/
break;
+#ifdef PARSEQUOTE
+ } else if (*cp == '\\') {
+ cp++;
+ if (*cp)
+ cp++;
+#endif
} else {
cp++;
}