|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi.
I want to editor some c source files with nested comment like /* COMMENT START /* and following /* and following /* and following /* and following /* COMMENT END */ with following sed script. 1,/\/\*/!{ /\*\//,/\/\*/!s/^/>>/; } but it seems that I can't get the right result like /* COMMENT START ** and following ** and following ** and following ** and following ** COMMENT END */ would you me with this? sorry about my poor English. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
Adam wrote:
> Hi. > I want to editor some c source files with nested comment like > > /* COMMENT START > /* and following > /* and following > /* and following > /* and following > /* COMMENT END */ > > with following sed script. > 1,/\/\*/!{ /\*\//,/\/\*/!s/^/>>/; } > but it seems that I can't get the right result like > > /* COMMENT START > ** and following > ** and following > ** and following > ** and following > ** COMMENT END */ > > would you me with this? > sorry about my poor English. If each set of comments has START in the first line sed '/START/!s/\//\*/' commentfile -- Rob - - - - - - - - - - - - - - - - - - - - - - - - - - - - - http://www.aspir8or.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Geek by nature, Linux by choice! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
sed -e ' # ### fix runaway c-comments # ## Skip noninteresting line, i.e., one that doesnt contain a /* \:/\*:!b ## Now we know that this line has a /*. ## Does it also contain a */ in order to make it a valid inline comment? if yes, then skip it too. \:/\*.*\*/:b ## Now we know that this is a runaway multiline comment ## Gobble up the following lines till u see a */ in a line or u hit EOF, in which case we promptly print ## in the pattern space and quit. :a $q;N \:/\*.*\*/:!ba ## perform the substitution /* ---> ** only for second onwards /* patterns found in the pattern space :b s:/\*:**:2 tb ' yourfile On Sep 10, 10:55 am, Adam <Jiang.A...@gmail.com> wrote: > Hi. > I want to editor some c source files with nested comment like > > /* COMMENT START > /* and following > /* and following > /* and following > /* and following > /* COMMENT END */ > > with following sed script. > 1,/\/\*/!{ /\*\//,/\/\*/!s/^/>>/; } > but it seems that I can't get the right result like > > /* COMMENT START > ** and following > ** and following > ** and following > ** and following > ** COMMENT END */ > > would you me with this? > sorry about my poor English. |
|
![]() |
| Outils de la discussion | |
|
|