[GRASS-dev] Re: Code re-indentation: done.
Glynn Clements
glynn at gclements.plus.com
Mon Aug 11 20:09:21 EDT 2008
Markus Neteler wrote:
> >> btw what to do with messages indented like
> >>
> >> G_message(_
> >> (...));
> >
> > Damn; I thought that not specifying -l would prevent this from
> > happening.
> >
> >> manually fix when fixing/updating code to?
> >>
> >> G_message(_(...));
> >
> > We can fix them automatically:
> >
> > find . -type f -name '*.c' | xargs grep -l '(_$' | \
> > while read file ; do sed -i -e '/(_$/{;N;s/\n[ \t]*//;}' $file ; done
> >
> > [Note: using \t in a character set is a GNU extension; other versions
> > of sed need a literal tab character.]
>
>
> I have added this gettext polishing trick to
> tools/grass_indent.sh
However, this only catches some of the cases; there are also cases
where the underscore isn't preceded by a left parenthesis, e.g. the
->description fields of parser options.
A more general solution, is:
find . -type f -name '*.c' | xargs grep -l '\<_$' | \
while read file ; do sed -i -e '/[( \t]_$/{;N;s/\n[ \t]*//;}' $file ; done
[Almost the same as before, but with different regexps.]
I have made this change to grass_indent.sh, and also committed the
fixed files.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list