bugmake - Bugs: bug #7267, $(subst) example from "Syntax...

 
 

bug #7267: $(subst) example from "Syntax of Functions" manual section does not work

Submitted by:  Tristan Miller <psychonaut>
Submitted on:  Thu 15 Jan 2004 09:45:31 AM UTC  
 
Severity: 3 - NormalItem Group: Bug
Status: Not A BugPrivacy: Public
Assigned to: Paul D. Smith <psmith>Open/Closed: Closed
Component Version: 3.80Operating System: POSIX-Based
Fixed Release: NoneTriage Status: None

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Wed 21 Jan 2004 03:02:58 AM UTC, comment #3:

I posted something to the mailing list about this. The problem is in your makefile. Apparently the info file viewer you are using is using special characters for some types of whitespace. When you cut and paste that text into a makefile, those special characters remain. When you look at the file it looks like spaces, but if you use an editor or viewer that shows non-ASCII characters (try less, for example) you'll see that they are not spaces but rather some other character.

GNU make only recognizes actual spaces (or tab, in some cases) as word delimiters, so your makefile is not doing anything close to what you think it is.

Paul D. Smith <psmith>
Project AdministratorIn charge of this item.
Mon 19 Jan 2004 10:58:20 AM UTC, comment #2:

I'm running SuSE 9.0 with kernel 2.4.21-166-athlon. My version of Gnu BASH is 2.05b.0(1). I'm not really sure what other information I could give that would help. I don't seem to have any Make-specific environment variables set (e.g., MAKEFILES) which might be causing unexpected behaviour.

Following your example, I also downloaded a vanilla copy of 3.80 from ftp.gnu.org to test:

[psy@port-3106 /tmp]$ snarf ftp://ftp.gnu.org/pub/gnu/make/make-3.80.tar.bz2
ftp://ftp.gnu.org/pub/gnu/make/make-3.80.tar.bz2 (899K)
make-3.80.tar.bz2 [########################] 899K | 402.72K/s
920645 bytes transferred in 2.23 sec (402.70k/sec)
[psy@port-3106 /tmp]$ tar xjf make-3.80.tar.bz2
(stdin): done
[psy@port-3106 /tmp]$ cd make-3.80/
[psy@port-3106 /tmp/make-3.80]$ ./configure >/dev/null
[psy@port-3106 /tmp/make-3.80]$ make >/dev/null
[psy@port-3106 /tmp/make-3.80]$ cat /tmp/Makefile
comma:= ,
empty:=
space:= $(empty) $(empty)
foo:= a b c
bar:= $(subst $(space),$(comma),$(foo))

all:
echo "$(bar)"
[psy@port-3106 /tmp/make-3.80]$ ./make -f /tmp/Makefile
echo " "

[psy@port-3106 /tmp/make-3.80]$

If you can think of anything else I should try, please let me know.

Tristan Miller <psychonaut>
Mon 19 Jan 2004 02:45:21 AM UTC, comment #1:

I've tried this with a vanilla copy of 3.80 I grabbed from ftp.gnu.org, and it worked fine for me. This is on a GNU/Linux system (Debian).

Can you provide details on your OS, or other information that might help reproduce the problem?

Paul D. Smith <psmith>
Project AdministratorIn charge of this item.
Thu 15 Jan 2004 09:45:31 AM UTC, original submission:

I need to convert a string of space-separated text to comma-separated text. The "Syntax of Functions" section of the manual provides an example of how to do this using the $(subst) function. However, copying this code verbatim into a Makefile does not work for me:

[psy@port-3106 /tmp]$ make --version
GNU Make 3.80
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
[psy@port-3106 /tmp]$ cat Makefile
comma:= ,
empty:=
space:= $(empty) $(empty)
foo:= a b c
bar:= $(subst $(space),$(comma),$(foo))

all:
echo "$(bar)"
[psy@port-3106 /tmp]$ make
echo " "

[psy@port-3106 /tmp]$

I think the example is correct because a fellow user reports that it works for him (GNU Make version 3.79.1, i386-pc-msdosdjgpp). Perhaps it's a bug in 3.80/Unix...?

Regards,
Tristan

Tristan Miller <psychonaut>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

Follow 4 latest changes.

Date Changed By Updated Field Previous Value => Replaced By
Wed 21 Jan 2004 03:02:58 AM UTCpsmithStatusWorks for me=>Not A Bug
  Open/ClosedOpen=>Closed
Mon 19 Jan 2004 02:45:21 AM UTCpsmithStatusNone=>Works for me
  Assigned toNone=>psmith

Back to the top


Powered by Savane 3.1-cleanup1