From 569bed6399545b6fedd47af6470b007d22c3db69 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Tue, 12 Feb 2019 20:26:40 +0100 Subject: [PATCH] Add support for spaces in filenames (3/x) This takes care of dependencies. GNU Make is required for this to work. --- src/makefile.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/makefile.c b/src/makefile.c index 77cc06f..f9f486b 100644 --- a/src/makefile.c +++ b/src/makefile.c @@ -2974,17 +2974,20 @@ static int _makefile_is_phony(Makefile * makefile, char const * target) /* makefile_expand */ static int _makefile_expand(Makefile * makefile, char const * field) { - String * q; int res; + char c; - if((q = string_new(field)) == NULL - || string_replace(&q, ",", " ") != 0) - { - string_delete(q); + if(field == NULL) return -1; + res = _makefile_print(makefile, " "); + while((c = *(field++)) != '\0') + { + if(c == ' ' || c == '\t') + res |= _makefile_print(makefile, "\\"); + else if(c == ',') + c = ' '; + res |= _makefile_print(makefile, "%c", c); } - res = _makefile_print(makefile, " %s", q); - string_delete(q); return (res >= 0) ? 0 : -1; }