* Stefano Lattarini wrote on Sat, Apr 09, 2011 at 12:29:43PM CEST: > On Saturday 09 April 2011, Ralf Wildenhues wrote: > > I guess then I don't understand your observation then. Your observation > > tells me that object file names of the form foo^bar.o and foo$baz.o are > > not problematic. > > > No. It just tells that sed regular expressions like [ab.^$0-9] are not > problematic, because `.' and `$' are *not* recognized as metacharacters > in *bracket expression*, and `^' is recognized as a metacharacter in a > bracket expression only when used as *first* character there. Which > simply means that your original command: > sed_object_re=`echo $object | sed 's/[].[^$\\*|]/\\\\&/g'` > was fully correct, and didn't lack any required escaping (while, on the > first impression, I had *erronously* thought it did).
OK. But independently of bracket expressions, Posix also specifies that ^ and $ are not special when they are not first or last characters in a regex, respectively. This is what makes object file names of the form foo^bar.o and foo$bar.o acceptable. Even ^foo.o, since our sed regex does not start with $object. > But re-reading what I wrote in my first reply, I must admit it sounded > like I was adding something new to the discussion, while in fact I was > just saying "hey, at first I wasn't sure that this change of yours was > correct, but by reading the standards/manuals more carefully, I realized > you are indeed completely right". Miscommunication on my part -- sorry > for the noise and the time I made us loose. Naah, it's better to be picky and find out we're safe after all, than the other way round. > > Remember the input > > file only contains lines of the form > > $object: header header... > > $object: header \ > > header header... > > While somebody might arguably name their header foo.o, I do think they > > deserve what they get. > > > Agreed. Especially because, to cause a spurious match, they would have to > *also* have a `:' character in the header name, i.e., have an header named > like "foo.o:bar.h" or "foo.obj:bar.h" -- in which case they probably do > deserve to suffer a bit. Right. > > > > @@ -503,7 +503,8 @@ makedepend) > > > > touch "$tmpdepfile" > > > > ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" > > > > rm -f "$depfile" > > > > - cat < "$tmpdepfile" > "$depfile" > > > > + # makedepend may prepend the VPATH from the source file name to the > > > > object. > > > > > > > I'd add a comment here telling why there's no need to escape $object for > > > the > > > sed commmand just below. > > > > I will, after I've understood your remaining comments. > > > Hope this reply is clearer than the previous ones. Yup. I'm adding the following. Thanks, Ralf Clarify regex code in depcomp. * lib/depcomp: Add comment why we don't need regex-escaping here. Suggested by Stefano Lattarini. diff --git a/lib/depcomp b/lib/depcomp index ce9419c..8097c19 100755 --- a/lib/depcomp +++ b/lib/depcomp @@ -1,7 +1,7 @@ #! /bin/sh # depcomp - compile a program generating dependencies as side-effects -scriptversion=2011-04-08-18; # UTC +scriptversion=2011-04-09-11; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2011, # Free Software Foundation, Inc. @@ -504,6 +504,7 @@ makedepend) ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" # makedepend may prepend the VPATH from the source file name to the object. + # No need to regex-escape $object, excess matching of '.' is harmless. sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" sed '1,2d' "$tmpdepfile" | tr ' ' ' ' | \