[Mesa-dev] [PATCH v2] configure.ac: Use POSIX word boundary regex.
Eric Engestrom
eric at engestrom.ch
Sun Mar 19 15:19:49 UTC 2017
On Sunday, 2017-03-19 13:44:30 +0000, Jan Beich wrote:
> Vinson Lee <vlee at freedesktop.org> writes:
>
> > - -e 's/[[[:space:]]]+-DNDEBUG\>//g' \
> > - -e 's/[[[:space:]]]+-D_GNU_SOURCE\>//g' \
> > - -e 's/[[[:space:]]]+-pedantic\>//g' \
> > + -e 's/[[[:space:]]]+-DNDEBUG[[[:space:]]]//g' \
> > + -e 's/[[[:space:]]]+-D_GNU_SOURCE[[[:space:]]]//g' \
> > + -e 's/[[[:space:]]]+-pedantic[[[:space:]]]//g' \
>
> If you always expect whitespace on both sides but trim it the RE
> may not match with more than one occurence in sequence e.g.,
>
> $ echo ' -D_GNU_SOURCE -DNDEBUG ' |
> sed -E -e 's/[[:space:]]+-DNDEBUG[[:space:]]//g' \
> -e 's/[[:space:]]+-D_GNU_SOURCE[[:space:]]//g'
> -D_GNU_SOURCE
>
> vs. (restore some whitespace)
>
> $ echo ' -D_GNU_SOURCE -DNDEBUG ' |
> sed -E -e 's/[[:space:]]+-DNDEBUG[[:space:]]/ /g' \
> -e 's/[[:space:]]+-D_GNU_SOURCE[[:space:]]/ /g'
>
Oh yes, very good point there!
My r-b now stands with this fix applied :)
This will lead to a bunch of unnecessary whitespace in the middle, but
I'm not sure I'd recommend addressing this:
A simple 's/[[[:space:]]]+/ /g' at the end should trivially fix this,
but I'm not sure we can rely on multi-spaces being always no-ops. One
example that comes to mind (but I have no idea where this would be used)
is to have something like `-DFOO="^I "` (ie. the tab and the space chars)
in a string passed in a parameter.
Too easy to break. Too hard to get right. Hard to notice when it breaks
far away (code-wise). Just don't try :)
Cheers,
Eric
More information about the mesa-dev
mailing list