Re: Can I do it with sed?
From: Charles Demas (demas_at_TheWorld.com)
Date: 08/27/03
- Next message: Teggy P Veerapen: "Re: Solaris make to process recursive macro"
- Previous message: Alan Connor: "Re: Can I do it with sed?"
- In reply to: Bill Campbell: "Can I do it with sed?"
- Next in thread: Edgar Allen: "Re: Can I do it with sed?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 27 Aug 2003 17:44:53 +0000 (UTC)
In article <8303333e.0308270856.7d54c9b8@posting.google.com>,
Bill Campbell <campbell@nrlmry.navy.mil> wrote:
>I'm trying to insert a fixed set of comment lines after the end of a
>subroutine declaration in a Fortran program. Subroutine declarations
>can either be on one line, vis.
>
> subroutine not_too_many_args(arg1,arg2)
>c Here's where I want the comment to go
>
> integer :: it(10)
>c ... but not here, or anywhere else in the file
>
>... or they can span several lines, vis.
>
> subroutine why_so_many_args(arg1,arg2,
> & arg3,arg4,
> x arg5,arg6,
> 3 arg7)
>c Here's where I want the comment to go
>
> integer :: not_here(20)
>c ... but not here
> ,or_here(30)
>c ... or here, or there, I do not want it anywhere.
>
>What I have is a sed script that does not work:
>
>/subroutine/,/)/s/)/)\
>c Here is the comment\
>c and furthermore/
>
>The first pattern matches the first line, but the second pattern
>matches some later line in the first case (one-line subroutine
>declaration), while it works nicely in the second case (multi-line
>subroutine declaration). I guess I could use grep and split up the
>separate cases (I have several hundred subroutines to update), but I
>was hoping for a more elegant solution, ideally just using sed (what
>can I say, I like sed).
Just treat the two cases separately.
You can combine the two in a sed script, or on the command line.
Chuck Demas
-- Eat Healthy | _ _ | Nothing would be done at all, Stay Fit | @ @ | If a man waited to do it so well, Die Anyway | v | That no one could find fault with it. demas@theworld.com | \___/ | http://world.std.com/~cpd
- Next message: Teggy P Veerapen: "Re: Solaris make to process recursive macro"
- Previous message: Alan Connor: "Re: Can I do it with sed?"
- In reply to: Bill Campbell: "Can I do it with sed?"
- Next in thread: Edgar Allen: "Re: Can I do it with sed?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]