make-alpha
[Top][All Lists]
Advanced

[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: Paul Smith
Subject: Re: New escape method proposal (was: Re: Possible solution for special characters in makefile paths)
Date: Sun, 13 Apr 2014 15:22:02 -0400

On Sun, 2014-04-13 at 20:28 +0300, Eli Zaretskii wrote:
> > From: Paul Smith <address@hidden>
> > Cc: address@hidden
> > Date: Sun, 13 Apr 2014 12:09:11 -0400
> > 
> > On Sun, 2014-04-13 at 08:22 +0300, Eli Zaretskii wrote:
> > > > Any blurring of the lines between these two characters would lead to
> > > > more confusion than the alternative, IMO.
> > > 
> > > I'm questioning the need to have this distinction exposed to
> > > user-land.
> > 
> > There are situations (as shown in my previous emails) where the user
> > wants to treat the escaped characters in a string differently from
> > unescaped characters.  In this case the distinction must be exposed.
> > 
> > How should we make that possible?
> 
> I'm sorry, it is hard to remember those situations from the distance
> of few weeks.  Could you perhaps recap?

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?


One potential ADVANTAGE to having "$[ ]" == " " is it gives people a way
to substitute spaces without having to do the whole "empty variable"
trick; e.g., instead of this, which we have to do now:

  # Make $S contain a single space
  E =
  S = $E $E

  FOO = $(subst $S,--,$(BAR))

You can just write:

  FOO = $(subst $[ ],--,$(BAR))

So, I'm not sure about this.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]