From d57ec34ac25107950537c3af60145e9e386f464a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 26 Nov 2012 02:23:18 +0100 Subject: tools/sed-enums: allow first step to allow reading anonymous enums, do not loop till enum define name is found --- tools/sed-enums | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tools/sed-enums b/tools/sed-enums index 46d236d..3a07671 100644 --- a/tools/sed-enums +++ b/tools/sed-enums @@ -21,14 +21,24 @@ T next;H;b attrs :next # try again if } not found /^\s*\}/ ! b attrs -# read enumeration name +# read enumeration name if any s/^\s*}\s*(\w+).*$/ } \1;/ t finish :close +n +# eat all comments +/^\s*\/\*/ { + :comment2 + /\*\/\s*$/ { n; b nocomment2 } + n; b comment2 +} +:nocomment2 +# eat empty lines +/^\s*$/ b close # read the enum typedef s/^\s*typedef\s+enum\s+\w+\s+(\w+)\s*;/ } \1/ -# leave if substitution works, or read next line and retry -t finish;n;b close +# finish if substitution fail +T :finish # append pattern, exchange hold space and pattern space H;x -- cgit v1.1-2-g2b99