]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
xgettext: Ruby: Make the --omit-header option work.
authorBruno Haible <bruno@clisp.org>
Wed, 11 Sep 2024 12:09:24 +0000 (14:09 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 11 Sep 2024 12:09:24 +0000 (14:09 +0200)
* gettext-tools/src/x-ruby.c (is_not_header): New function.
(extract_ruby): If --omit-header is specified, remove the header entry at the
end.

gettext-tools/src/x-ruby.c

index 451962e9b42a5c8739fb77beb8627883fb2e73f8..72b94e6ee0d4eed146c6657898641fe756e93f92 100644 (file)
@@ -45,6 +45,7 @@
 #define _(str) gettext (str)
 
 /* The Ruby syntax is defined in
+   https://en.wikibooks.org/wiki/Ruby_Programming/Syntax
    https://ruby-doc.org/core-2.7.1/doc/syntax_rdoc.html
    https://ruby-doc.org/core-2.7.1/doc/syntax/comments_rdoc.html
    https://ruby-doc.org/core-2.7.1/doc/syntax/literals_rdoc.html
@@ -75,6 +76,12 @@ init_flag_table_ruby (void)
 
 /* ========================= Extracting strings.  ========================== */
 
+static bool
+is_not_header (const message_ty *mp)
+{
+  return !is_header (mp);
+}
+
 void
 extract_ruby (const char *found_in_dir, const char *real_filename,
               const char *logical_filename,
@@ -247,4 +254,11 @@ extract_ruby (const char *found_in_dir, const char *real_filename,
   msgdomain_list_free (mdlp2);
 
   free (dummy_filename);
+
+  if (xgettext_omit_header)
+    {
+      /* Remove the header entry.  */
+      if (mdlp->nitems > 0)
+        message_list_remove_if_not (mdlp->item[0]->messages, is_not_header);
+    }
 }