Hi Stefano, * Stefano Lattarini wrote on Sat, Apr 09, 2011 at 11:38:47AM CEST: > On Friday 08 April 2011, Ralf Wildenhues wrote: > > * Stefano Lattarini wrote on Fri, Apr 08, 2011 at 01:05:53PM CEST: > > > On Wednesday 06 April 2011, Ralf Wildenhues wrote:
> > > > + # makedepend may prepend the VPATH from the source file name to the > > > > object. > > > > + sed_object_re=`echo $object | sed 's/[].[^$\\*|]/\\\\&/g'` > > > > > > > A couple of questions/observations about the sed command: > > > 1. I wasn't sure whether `.', `$', `^' and `*' are to be escaped when > > > used in > > > a bracket expression; however, the POSIX standard at: > > > <http://pubs.opengroup.org/onlinepubs/007908799/xbd/re.html> > > > says they shouldn't be. Also, I couldn't find any reference in the > > > Autoconf manual pointing to a sed implementation that doesn't respect > > > this part of the standard. > > > > Ah, cool. Then I recon we don't need this escaping step at all. > > > Why not? The sed command below: > sed "s|^.*\($sed_object_re *:\)|\1|" "$tmpdepfile" > "$depfile" > doesn't use any bracket, does it? I'm not sure I understand the question. Can you rephrase it? > > The only character I was worried about was $, as it can occur in > > object names now and then (ok, mostly java, and that doesn't use > > depcomp). Any others in the list are pretty much excluded anyway, > > because they will evoke shell expansion errors when used in a > > makefile unquoted. Except for '.', but I'm not afraid of matching > > a bit too broadly here, the final 'o' will take care that we don't > > match any header files. > > > OK, this makes sense (even if I'd err on the safe side w.r.t. the `.' > character), OK, can you come up with a practical example (i.e., a valid object file name) where we would match something wrongly here? 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. > but I don't see how it's related to my observation above. > What am I missing? 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. I observe that no one in their right mind names their object foo[bar.o or foo]bar.o or foo\bar.o (see the various instspc* tests for why they would not work in practice anyway). So I conclude that it is not needed to do regex-escaping for the object file name. > > @@ -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. Thanks, Ralf