From: Bruno Haible Date: Wed, 11 Sep 2024 12:09:24 +0000 (+0200) Subject: xgettext: Ruby: Make the --omit-header option work. X-Git-Tag: v0.23~138 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0d8116e3e87cf105e73a5557be156a1fb29b23fc;p=thirdparty%2Fgettext.git xgettext: Ruby: Make the --omit-header option work. * 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. --- diff --git a/gettext-tools/src/x-ruby.c b/gettext-tools/src/x-ruby.c index 451962e9b..72b94e6ee 100644 --- a/gettext-tools/src/x-ruby.c +++ b/gettext-tools/src/x-ruby.c @@ -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); + } }