[GRASS-dev] d.legend uses a static buffer for `map='

Glynn Clements glynn at gclements.plus.com
Wed Jan 16 17:24:51 EST 2008


Ivan Shmakov wrote:

>  >> It much more a problem to get them changed automatically than to get
>  >> them identified.
> 
>  > I don't think that an entirely automatic solution is desirable.
>  > Trying to produce something which is robust enough not to introduce
>  > bugs in some cases would probably take more time than making the
>  > changes manually.
> 
> 	Does changing the every occurence of (the whitespace was
> 	inserted for the sake of readability):
> 
> ^([[:blank:]]+) sprintf [[:blank:]]*
>                     \(([[:alpha:]][[:alnum:]_]),
>                       (("[^"]*") | _\(("[^"]*"))\)
>                       [[:blank:]]* (,[[:blank:]]*[^)]+)?
>                       \);
>                 [[:blank:]]*
>                 (G_(warning|fatal_error|([[:alpha:]_]*_)?message))
>                     [[:blank:]]*
>                     \(\2\);
> 
> 	with:
> 
> \1 \7 (_(\4\5), \6);
> 
> 	sound reasonable to you?

Nope. I'm not saying that there's anything wrong with regexp, just
that the amount of time required to understand it and predict the
consequences is likely to exceed the time taken for a manual solution.

For a start, there's no need to construct a regexp which accurately
matches all candidates. You can use -Wformat-nonliteral to get a
precise list of cases where the format string isn't a literal (which
will also eliminate false positives where the format string is a macro
which evaluates to a string literal). Also, bear in mind that most
G_fatal_error() format strings are encapsulated within the _() macro
for NLS; -Wformat-nonliteral will handle this, as it's looking at the
output from the pre-processor.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list