]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Fix sed_remove_comments.
authorBruno Haible <bruno@clisp.org>
Thu, 14 Dec 2006 12:32:12 +0000 (12:32 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:14:28 +0000 (12:14 +0200)
gnulib-local/ChangeLog
gnulib-local/build-aux/moopp

index 58e76a131793fadd6169f27f0c5a1428eba96565..628bfca3d8e5144fe772643fa7ddbfad7c4b0317 100644 (file)
@@ -1,3 +1,9 @@
+2006-12-13  Bruno Haible  <bruno@clisp.org>
+
+       * build-aux/moopp (sed_remove_comments): Fix handling of character
+       constants. Example:  '"' /* comment */ '"'
+       (sed_remove_comments_ERE): New variable.
+
 2006-12-13  Bruno Haible  <bruno@clisp.org>
 
        * modules/ostream (Makefile.am): List all generated files in the moopp
index 463e8302aa2e40b77b2c30fbd35356788de9536a..d744f8ba801df28d120293fc6a867fbbea6e042f 100755 (executable)
@@ -83,27 +83,50 @@ esac
 sed_remove_empty_lines='/^$/d'
 
 # A sed expression that removes ANSI C and ISO C99 comments.
-sed_remove_comments='
+sed_remove_comments="
 /[/][/*]/{
   ta
   :a
-  s,^\(\([^"/]\|"\([^\"]\|[\].\)*"\|[/][^"/*]\|[/]"\([^\"]\|[\].\)*"\)*\)//.*,\1,
+  s,^\\(\\([^\"'/]\\|\"\\([^\\\"]\\|[\\].\\)*\"\\|'\\([^\\']\\|[\\].\\)*'\\|[/][^\"'/*]\\|[/]\"\\([^\\\"]\\|[\\].\\)*\"\\|[/]'\\([^\\']\\|[\\].\\)*'\\)*\\)//.*,\\1,
   te
-  s,^\(\([^"/]\|"\([^\"]\|[\].\)*"\|[/][^"/*]\|[/]"\([^\"]\|[\].\)*"\)*\)/[*]\([^*]\|[*][^/*]\)*[*][*]*/,\1 ,
+  s,^\\(\\([^\"'/]\\|\"\\([^\\\"]\\|[\\].\\)*\"\\|'\\([^\\']\\|[\\].\\)*'\\|[/][^\"'/*]\\|[/]\"\\([^\\\"]\\|[\\].\\)*\"\\|[/]'\\([^\\']\\|[\\].\\)*'\\)*\\)/[*]\\([^*]\\|[*][^/*]\\)*[*][*]*/,\\1 ,
   ta
-  /^\([^"/]\|"\([^\"]\|[\].\)*"\|[/][^"/*]\|[/]"\([^\"]\|[\].\)*"\)*[/][*]/{
-    s,^\(\([^"/]\|"\([^\"]\|[\].\)*"\|[/][^"/*]\|[/]"\([^\"]\|[\].\)*"\)*\)/[*].*,\1 ,
+  /^\\([^\"'/]\\|\"\\([^\\\"]\\|[\\].\\)*\"\\|'\\([^\\']\\|[\\].\\)*'\\|[/][^\"'/*]\\|[/]\"\\([^\\\"]\\|[\\].\\)*\"\\|[/]'\\([^\\']\\|[\\].\\)*'\\)*[/][*]/{
+    s,^\\(\\([^\"'/]\\|\"\\([^\\\"]\\|[\\].\\)*\"\\|'\\([^\\']\\|[\\].\\)*'\\|[/][^\"'/*]\\|[/]\"\\([^\\\"]\\|[\\].\\)*\"\\|[/]'\\([^\\']\\|[\\].\\)*'\\)*\\)/[*].*,\\1 ,
     tu
     :u
     n
-    s,^\([^*]\|[*][^/*]\)*[*][*]*/,,
+    s,^\\([^*]\\|[*][^/*]\\)*[*][*]*/,,
     tv
-    s,^.*$,,
+    s,^.*\$,,
     bu
     :v
   }
   :e
-}'
+}"
+# The same thing as an extended regular expression, for use with
+# sed --regexp-extended.
+sed_remove_comments_ERE="
+/[/][/*]/{
+  ta
+  :a
+  s,^(([^\"'/]|\"([^\\\"]|[\\].)*\"|'([^\\']|[\\].)*'|[/][^\"'/*]|[/]\"([^\\\"]|[\\].)*\"|[/]'([^\\']|[\\].)*')*)//.*,\\1,
+  te
+  s,^(([^\"'/]|\"([^\\\"]|[\\].)*\"|'([^\\']|[\\].)*'|[/][^\"'/*]|[/]\"([^\\\"]|[\\].)*\"|[/]'([^\\']|[\\].)*')*)/[*]([^*]|[*][^/*])*[*][*]*/,\\1 ,
+  ta
+  /^([^\"'/]|\"([^\\\"]|[\\].)*\"|'([^\\']|[\\].)*'|[/][^\"'/*]|[/]\"([^\\\"]|[\\].)*\"|[/]'([^\\']|[\\].)*')*[/][*]/{
+    s,^(([^\"'/]|\"([^\\\"]|[\\].)*\"|'([^\\']|[\\].)*'|[/][^\"'/*]|[/]\"([^\\\"]|[\\].)*\"|[/]'([^\\']|[\\].)*')*)/[*].*,\\1 ,
+    tu
+    :u
+    n
+    s,^([^*]|[*][^/*])*[*][*]*/,,
+    tv
+    s,^.*\$,,
+    bu
+    :v
+  }
+  :e
+}"
 
 # func_check_impl_syntax file
 # Check the syntax of the source implementation file.