Quoth
jose.luis...@gmail.com:
>
> Perhaps this is possible. Given this pattern:
>
> <<snip>>
> {
> {
> ....
> }
>
> {
> ....
>
> {
> ...
> }
>
> ....
>
> }
> }
> <<snip>>
>
> Is there and easy way to get the text between the external braces?
You can match matched braces with the (?R) construct introduced in perl
5.10, but you have to be careful about braces inside quotes and
comments. (You can probably ignore the possibility of unmatched braces
inside macro definitions and expansions.)
If you can assume the C is 'properly' formatted, of course, it becomes
much easier: the only time you get an open brace in the first column is
when it is starting a function, and the end of the function is the next
close brace which is also in the first column. Depending on what you're
trying to do you could consider running the C through indent(1) with
some appropriate set of options, since that has something approximating
a C parser.
Ben