This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [fixincludes] work around non-GNU sed


Gerald Pfeifer wrote:
> I am not proud of this patch, but -- it works, and gets us rid of
> a bogus test failure on FreeBSD since it only revolves around the 
> replacement text we inject, not the actual fixing.
> 
> Tested on i386-unknown-freebsd6.4.
> 
> And for the record, multi-line sed expressions like this _do_ make
> my head hurt, too. ;-)

*I* think it's great!  Also, be glad you're not playing with the original
multiple-10's-of-lines of sed hackery in the middle of millions of lines
of obtuse shell script (viz. the fixincludes script of 10 years ago....)

Anyway, I got to looking at this sed script and am wondering, "why use
sed at all?"

Fundamentally, you are replacing this:
> struct wedge {
>    Widget       old, new; /* fixinc check FAILS ON BSD */
> };
> extern Wedged( Widget new, Widget old );

with this:
> struct wedge {
> #ifdef __cplusplus
>         Widget  old, c_new;
> #else
>    Widget       old, new; /* fixinc check FAILS ON BSD */
> #endif
> };
> extern Wedged( Widget c_new, Widget old );

Which seems much more easily accomplished with two fixes:

select = "^([ \t]+Widget[ \t]+old,[ \t]+)(new;.*)\n";
c-fix  = format;
c-fix-arg = <<- _EOF_
	#ifdef __cplusplus
	%1c_%2
	#else
	%0
	#endif

	_EOF_;

select = "(Widget[ \t].*[, \t])(new[^a-zA-Z0-9_])";
c-fix  = format;
c-fix-arg = '%1c_%2';

It's two fixes, but avoids the fork and exec of sed, plus the
issues with incompatible sed programs.  :)

I haven't tested this 'cuz I'm at my day job, but it looks like
it'd work to me....
Either is  fine by me since neither will fire unless there's work
to be done.

Cheers - Bruce


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]