[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: New escape method proposal (was: Re: Possible solution for special c
From: |
Eli Zaretskii |
Subject: |
Re: New escape method proposal (was: Re: Possible solution for special characters in makefile paths) |
Date: |
Mon, 14 Apr 2014 11:26:10 +0300 |
> From: Paul Smith <address@hidden>
> Cc: address@hidden
> Date: Sun, 13 Apr 2014 15:22:02 -0400
>
> Someone wants to convert all spaces in the filenames in a variable into
> dashes or periods, but doesn't want to touch spaces that aren't part of
> a filename. Someone wants to convert the spaces that are NOT part of
> filenames into colons but not touch the spaces that ARE part of
> filenames. Someone wants to add backslashes before colons that are part
> of a filename in a list of filenames separated by colons, but not touch
> colons that are not part of a filename.
>
> Some of the above can be handled by using $(foreach ...) to allow
> operation on a single word at a time (the ones dealing with whitespace).
> Of course, that reduces consecutive whitespace into a single space:
>
> FILES := $[foo bar] $[biz baz]<TAB>boz
>
> CONVERTED := $(foreach F,$(FILES),$(subst $[ ],--,$F))
>
> gives "foo--bar biz--baz boz" as the result; multiple spaces and the TAB
> are lost, and we can't treat TABs and SPACEs separately. Going the
> other way may also lose information:
>
> FILES := $[foo bar] $[biz baz] boz
>
> PATH := $(patsubst %:,%,$(foreach F,$(FILES),$F:))
>
> Here you'd get PATH set to "foo bar:biz baz:boz" but what if you wanted
> this instead: "foo bar::::biz baz:boz" (e.g., convert each individual
> space)? Can't do it. And, I don't see any way to handle the last one:
>
> PATH = $[foo:bar]:$[biz:baz]:boz
>
> # how to make this: foo\:bar:biz\:baz:boz ??
>
>
> There is clearly a loss of capability if we don't have a way for make to
> treat the two different "modes" of characters differently. However, I
> don't know if this is compelling; for example we don't allow you to
> substitute the letter "a" that is part of an escaped filename but not
> letter "a" which is NOT part of an escaped filename: $(subst $[a],-,$X)
> and $(subst a,-,$X) are identical. Why should "$[:]" be different than
> ":", just because colons are special to make?
>
> Whitespace IS clearly different, because whitespace is special
> everywhere. But the $(foreach ...) trick may be sufficient to mitigate
> that. There are things it can't do, as I show above. But are these
> important enough?
Thanks for the explanations.
No, I don't think these are important enough to expose internal
representation of embedded spaces to user-land. Whatever can be done
with $foreach should be enough, and should additional special cases
pop up that we would like to cater to, we could introduce new
functions to allow them.