Alexandre Duret-Lutz wrote:
Unfortunatelly, you are not right here. The problem is that second at_patsubst (the one stripping the terminating space) receives argument wrapped in brackets: `[ xxx ]' (note four brackets around $1). My version copies `]' to output while your one fails (does not strip anything). I was not able to put `]' to patterns so I used `.' here.[M-F-T: [EMAIL PROTECTED]]"Martin" == Martin Frydl <[EMAIL PROTECTED]> writes:[...] Martin> I've created a patch which is aware of M4 problem and Martin> separates the task into two expressions - first removes the Martin> terminating space, then strips the leading one and puts brackets Martin> around. [...] Martin> + [at_patsubst(at_patsubst(at_patsubst(at_patsubst([[[[$1]]]], [\\\n]), Martin> + [[\n\t ]+], [ ]), Martin> + [ *\(.\)$],[\1]), Martin> + [^ *\(.*\)], [[\1]])]) This doesn't seem to do what you want. `[ *\(.\)$],[\1]' will leave the last trailing space, or strip non trailing whitespaces. How about something like [at_patsubst(at_patsubst(at_patsubst(at_patsubst([[[[$1]]]], [\\\n]), [[\n\t ]+], [ ]), [ *$]), [^ *\(.*\)], [[\1]])])
I've created a simple test showing these macros in action. The attached script contains simplified tracefile coming from autoconf with three at_flatten versions - original, mine and yours. If you run the script, it will show the results in all three versions (adds `<<' to the end of line so you can see if space is present or not). Note that original version also remains space in place. This is because `.*' is greedy and consumes also all spaces at the end of string so there will remain none to match with following ` *'.
Martin
at_flatten.sh
Description: Bourne shell script