[gnu.utils.bug] A problem with <at>D in GNU Make 3.54

tjb@tadtec.uucp (Tim Bissell) (10/04/89)

I think I have found a bug in the @D pseudo-variable in GNU Make version 3.54
and below.  It lops the last character off the directory name it produces.  A
script which shows the problem, and a fix, are given below.

---------------------------------------

glider!wys> cat Makefile

.PHONY: foo/bar
foo/bar:
	@echo 'This should be foo ->' $(@D) '<- should it not?'

glider!wys> ../make -v
GNU Make version 3.54, by Richard Stallman and Roland McGrath.
Copyright (C) 1988, 1989 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.

This should be foo -> fo <- should it not?

---------------------------------------

Here is my fix for what appears to be a simple of-by-one bug.  It seems
to work when I use it but I haven't checked extensively.  Sorry if this
has already been fixed, but 3.54 is the most recent version I have been
able to get hold of.

---------------------------------------

*** commands.c	Fri Sep 29 16:25:11 1989
--- commands.c.~1~	Fri Sep 29 10:17:59 1989
***************
*** 63,69 ****
  #define	LASTSLASH(s)	rindex ((s), '/')
  #define	FILEONLY(s)	(p != 0 ? p + 1 : (s))
  #define	DIRONLY(s)	(p == 0 ? "./" : p == (s) ? "/" \
! 			 : savestring ((s), p - (s) )) /* Removed - 1 */
  
    /* $* is the stem from an implicit or static pattern rule.  */
    if (file->stem == 0)
--- 63,69 ----
  #define	LASTSLASH(s)	rindex ((s), '/')
  #define	FILEONLY(s)	(p != 0 ? p + 1 : (s))
  #define	DIRONLY(s)	(p == 0 ? "./" : p == (s) ? "/" \
! 			 : savestring ((s), p - (s) - 1))
  
    /* $* is the stem from an implicit or static pattern rule.  */
    if (file->stem == 0)

---------------------------------------

Thanks for some wonderful useful products etc. etc.

---------------------------------------

Tim Bissell
( tjb@tadtec.UUCP || {...mcvax!}ukc!tadtec!tjb )
Tadpole Technology plc.
Titan House, Castle Park, Cambridge, England .