texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: * tp/Texinfo/XS/teximakehtml.c (set_from_cmdline)


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/teximakehtml.c (set_from_cmdline): handle "undef" value. Fix variable name.
Date: Mon, 23 Dec 2024 18:20:53 -0500

This is an automated email from the git hooks/post-receive script.

pertusus pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new adf7a4d477 * tp/Texinfo/XS/teximakehtml.c (set_from_cmdline): handle 
"undef" value.  Fix variable name.
adf7a4d477 is described below

commit adf7a4d47733fcb5e35e276098ca70b3e19e6ef1
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Dec 19 00:01:29 2024 +0100

    * tp/Texinfo/XS/teximakehtml.c (set_from_cmdline): handle "undef"
    value.  Fix variable name.
    
    * tp/Texinfo/XS/configure.ac (CONVERTER_CONFIG): pass CONVERTER as
    CONVERTER_CONFIG.
    
    * tp/Texinfo/XS/teximakehtml.c (long_options, main): add version,
    output, footnote-style and split options.
    
    * tp/texi2any.pl ($makeinfo_help): avoid \n in translated strings,
    split each option in a translatable string.  Report from Benno
    Schulenberg.
---
 ChangeLog                    |  15 +++++
 tp/Texinfo/XS/configure.ac   |   4 ++
 tp/Texinfo/XS/teximakehtml.c | 148 +++++++++++++++++++++++++++++++++++++++++--
 tp/texi2any.pl               |  34 +++++-----
 4 files changed, 177 insertions(+), 24 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 2271048591..bf2ea50613 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2024-12-18  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/teximakehtml.c (set_from_cmdline): handle "undef"
+       value.  Fix variable name.
+
+       * tp/Texinfo/XS/configure.ac (CONVERTER_CONFIG): pass CONVERTER as
+       CONVERTER_CONFIG.
+
+       * tp/Texinfo/XS/teximakehtml.c (long_options, main): add version,
+       output, footnote-style and split options.
+
+       * tp/texi2any.pl ($makeinfo_help): avoid \n in translated strings,
+       split each option in a translatable string.  Report from Benno
+       Schulenberg.
+
 2024-12-18  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/teximakehtml.c (set_from_cmdline, _)
diff --git a/tp/Texinfo/XS/configure.ac b/tp/Texinfo/XS/configure.ac
index 3ef1e317f0..eeb8733cde 100644
--- a/tp/Texinfo/XS/configure.ac
+++ b/tp/Texinfo/XS/configure.ac
@@ -265,5 +265,9 @@ AC_DEFINE_UNQUOTED([PACKAGE_URL_CONFIG], ["$PACKAGE_URL"],
 AC_DEFINE_UNQUOTED([PACKAGE_VERSION_CONFIG], ["$PACKAGE_VERSION"],
                    [autoconf PACKAGE_VERSION value])
 
+# Output with the _CONFIG suffix as the original is a type name
+AC_DEFINE_UNQUOTED([CONVERTER_CONFIG], ["$CONVERTER"],
+                   [configure CONVERTER value])
+
 AC_CONFIG_FILES([Makefile gnulib/lib/Makefile])
 AC_OUTPUT
diff --git a/tp/Texinfo/XS/teximakehtml.c b/tp/Texinfo/XS/teximakehtml.c
index faaed14f7c..19e68ca45c 100644
--- a/tp/Texinfo/XS/teximakehtml.c
+++ b/tp/Texinfo/XS/teximakehtml.c
@@ -24,6 +24,7 @@
 #include <unistd.h>
 #include <ctype.h>
 #include <stdarg.h>
+#include <sys/stat.h>
 /* from Gnulib codeset.m4 */
 #ifdef HAVE_LANGINFO_CODESET
 #include <langinfo.h>
@@ -322,11 +323,13 @@ static void
 set_from_cmdline (OPTIONS_LIST *options_list, OPTION *option,
                   const char *value)
 {
-  if (option->type == GOT_integer)
+  if (!strcmp (value, "undef"))
+    clear_option (option);
+  else if (option->type == GOT_integer)
     {
       char *endptr;
       long long_value = strtol (value, &endptr, 10);
-      int int_value = (int) value;
+      int int_value = (int) long_value;
       if (endptr != value && int_value >= 0)
         {
           option_set_conf (option, int_value, 0);
@@ -343,7 +346,8 @@ set_from_cmdline (OPTIONS_LIST *options_list, OPTION 
*option,
       if (!value)
         option_value = strdup ("");
       else if (option->type == GOT_char)
-        option_value = decode_input (value);
+        /* actually const, but constrained by protoypes */
+        option_value = decode_input ((char *) value);
       else
         option_value = strdup (value);
       option_set_conf (option, 0, option_value);
@@ -375,12 +379,12 @@ get_cmdline_customization_option (OPTIONS_LIST 
*options_list,
           if (!strcasecmp (p, "undef"))
             {
               clear_option (option);
+              options_list_add_option_number (options_list, option->number);
             }
           else
             {
               set_from_cmdline (options_list, option, p);
             }
-          options_list_add_option_number (options_list, option->number);
         }
       else
         {
@@ -416,17 +420,32 @@ static int mimick_p;
 static int print_help_p;
 
 #define DOCUMENT_LANGUAGE_OPT 2
+#define NO_SPLIT_OPT 3
+#define SPLIT_OPT 4
+#define FOOTNOTE_STYLE_OPT 5
 
 static struct option long_options[] = {
+  /* next two not in texi2any */
   {"demonstration", 0, &demonstration_p, 1},
+  {"mimick", 0, &mimick_p, 1},
+
   {"document-language", required_argument, 0, DOCUMENT_LANGUAGE_OPT},
   {"error-limit", required_argument, 0, 'e'},
+  {"footnote-style", required_argument, 0, FOOTNOTE_STYLE_OPT},
   {"help", 0, &print_help_p, 'h'},
-  {"mimick", 0, &mimick_p, 1},
+  {"out", required_argument, 0, 'o'},
+  {"output", required_argument, 0, 'o'},
+  {"no-split", 0, 0, NO_SPLIT_OPT},
+  {"split", required_argument, 0, SPLIT_OPT},
   {"set-customization-variable", required_argument, 0, 'c'},
+  {"version", 0, 0, 'V'},
   {NULL, 0, NULL, 0}
 };
 
+static const char *possible_split[] = {
+  "chapter", "section", "node", NULL
+};
+
 int
 main (int argc, char *argv[])
 {
@@ -534,7 +553,7 @@ main (int argc, char *argv[])
     {
       int option_character;
 
-      option_character = getopt_long (argc, argv, "he:c:I:", long_options,
+      option_character = getopt_long (argc, argv, "Vhc:e:I:o:", long_options,
                                       &getopt_long_index);
       if (option_character == -1)
         break;
@@ -555,11 +574,106 @@ main (int argc, char *argv[])
         case 'h':
           print_help_p = 1;
           break;
+        case 'V':
+          {
+            char *encoded_message;
+            char *message
+             = CONVERTER_CONFIG " (GNU texinfo) " PACKAGE_VERSION_CONFIG 
"\n\n";
+            char *formatted_message;
+
+            encoded_message = encode_message (message);
+            printf ("%s", encoded_message);
+            free (encoded_message);
+
+            xasprintf (&formatted_message, _(
+  "Copyright (C) %s Free Software Foundation, Inc.\nLicense GPLv3+: GNU GPL 
version 3 or later <http://gnu.org/licenses/gpl.html>\nThis is free software: 
you are free to change and redistribute it.\nThere is NO WARRANTY, to the 
extent permitted by law."),
+                       "2024");
+            encoded_message = encode_message (formatted_message);
+            free (formatted_message);
+            printf ("%s\n", encoded_message);
+            free (encoded_message);
+
+            exit (EXIT_SUCCESS);
+          }
+          break;
         case DOCUMENT_LANGUAGE_OPT:
           set_from_cmdline(&cmdline_options,
                            &cmdline_options.options->documentlanguage,
                            optarg);
           break;
+        case FOOTNOTE_STYLE_OPT:
+          {
+            /* actually const but constrained by prototypes */
+            char *value = decode_input((char *) optarg);
+            if (!strcmp (value, "end") || !strcmp (value, "separate"))
+              {
+                set_from_cmdline(&cmdline_options,
+                                 &cmdline_options.options->footnotestyle,
+                                 value);
+              }
+            else
+              {
+                char *formatted_message;
+                char *encoded_message;
+
+                xasprintf (&formatted_message,
+        _("%s: --footnote-style arg must be `separate' or `end', not `%s'."),
+                  program_file, value);
+                encoded_message = encode_message (formatted_message);
+                free (formatted_message);
+                fprintf (stderr, "%s\n", encoded_message);
+                free (encoded_message);
+                exit (EXIT_FAILURE);
+              }
+            free (value);
+          }
+          break;
+        case 'o':
+          {
+            OPTION *option = &cmdline_options.options->OUTFILE;
+            /* actually const but constrained by prototypes */
+            char *decoded_string = decode_input ((char *) optarg);
+            if (strcmp (optarg, "-"))
+              {
+                size_t opt_len = strlen (optarg);
+                struct stat finfo;
+
+                if (optarg[opt_len -1] == '/'
+                    || (stat (optarg, &finfo) == 0 && S_ISDIR (finfo.st_mode)))
+                  {
+                    set_from_cmdline (&cmdline_options, option, "undef");
+                    option = &cmdline_options.options->SUBDIR;
+                  }
+              }
+            set_from_cmdline (&cmdline_options, option, decoded_string);
+            free (decoded_string);
+          }
+          break;
+        case NO_SPLIT_OPT:
+          set_from_cmdline (&cmdline_options,
+                            &cmdline_options.options->SPLIT, "");
+          set_from_cmdline (&cmdline_options,
+                            &cmdline_options.options->SPLIT_SIZE, "undef");
+          break;
+        case SPLIT_OPT:
+          {
+            char *split = decode_input (optarg);
+            size_t i;
+            for (i = 0; possible_split[i]; i++)
+              if (!strcmp (possible_split[i], optarg))
+                break;
+            if (!possible_split[i])
+              {
+                document_warn (_("%s is not a valid split possibility"),
+                               split);
+                free (split);
+                split = strdup ("node");
+              }
+            set_from_cmdline (&cmdline_options,
+                              &cmdline_options.options->SPLIT, split);
+            free (split);
+          }
+          break;
           /*
         case '?':
           if (isprint (optopt))
@@ -600,6 +714,28 @@ main (int argc, char *argv[])
       text_append (&help_message,
         _("  -c, --set-customization-variable VAR=VAL  set customization 
variable VAR\n                                to value VAL."));
       text_append_n (&help_message, "\n\n", 2);
+
+      text_append (&help_message, _("General output options:"));
+      text_append_n (&help_message, "\n", 1);
+      text_append (&help_message, _(
+   "      --no-split              suppress any splitting of the output;\n      
                          generate only one output file."));
+      text_append_n (&help_message, "\n", 1);
+      text_append (&help_message, _(
+   "  -o, --output=DEST           output to DEST.\n                            
    With split output, create DEST as a directory\n                             
   and put the output files there.\n                                With 
non-split output, if DEST is already\n                                a 
directory or ends with a /,\n                                put the output 
file there.\n                                Otherwise, DEST names the output 
file."));
+      text_append_n (&help_message, "\n\n", 2);
+
+      text_append (&help_message, _("Options for Info and plain text:"));
+      text_append_n (&help_message, "\n", 1);
+      text_append (&help_message,
+   "      --footnote-style=STYLE  output footnotes in Info according to 
STYLE:\n                                `separate' to put them in their own 
node;\n                                `end' to put them at the end of the 
node, in\n                                which they are defined (this is the 
default).");
+      text_append_n (&help_message, "\n\n", 2);
+
+      text_append (&help_message, _("Options for HTML:"));
+      text_append_n (&help_message, "\n", 1);
+      text_append (&help_message,
+   "      --split=SPLIT           split at SPLIT, where SPLIT may be 
`chapter',\n                                `section' or `node'.");
+      text_append_n (&help_message, "\n\n", 2);
+
       text_append (&help_message, _("Input file options:"));
       text_append_n (&help_message, "\n", 1);
       text_append (&help_message,
diff --git a/tp/texi2any.pl b/tp/texi2any.pl
index 2ecbdef161..5286791137 100755
--- a/tp/texi2any.pl
+++ b/tp/texi2any.pl
@@ -1056,21 +1056,19 @@ the behavior is identical, and does not depend on the 
installed name.\n")
 ."\n",
     _get_converter_default('FILLCOLUMN'),
     _get_converter_default('paragraphindent'),
-    _get_converter_default('SPLIT_SIZE'))
-."\n";
-  # TODO: avoid \n in translated strings, split each option in a translatable
-  # string.  Report from Benno Schulenberg
-  $makeinfo_help .= __("Options for HTML:
-      --css-include=FILE      include FILE in HTML <style> output;
-                                read stdin if FILE is -.
-      --css-ref=URL           generate CSS reference to URL.
-      --internal-links=FILE   produce list of internal links in FILE.
-      --split=SPLIT           split at SPLIT, where SPLIT may be `chapter',
-                                `section' or `node'.
-      --transliterate-file-names  use file names in ASCII transliteration.
-      --node-files            produce redirection files for nodes and 
-                                anchors; default is set only if split.\n")
-."\n";
+    _get_converter_default('SPLIT_SIZE'));
+
+  $makeinfo_help .= __("Options for HTML:")."\n"
+.__("      --css-include=FILE      include FILE in HTML <style> output;
+                                read stdin if FILE is -.")."\n"
+.__("      --css-ref=URL           generate CSS reference to URL.")."\n"
+.__("      --internal-links=FILE   produce list of internal links in 
FILE.")."\n"
+.__("      --split=SPLIT           split at SPLIT, where SPLIT may be 
`chapter',
+                                `section' or `node'.")."\n"
+.__("      --transliterate-file-names  use file names in ASCII 
transliteration.")."\n"
+.__("      --node-files            produce redirection files for nodes and
+                                anchors; default is set only if split.")
+."\n\n";
   # TODO: avoid \n in translated strings.  Report from Benno Schulenberg
   $makeinfo_help .= __("Options for DVI/PS/PDF:
       --Xopt=OPT              pass OPT to texi2dvi; can be repeated.\n")
@@ -1143,7 +1141,7 @@ my $result_options = Getopt::Long::GetOptions (
 "Copyright (C) %s Free Software Foundation, Inc.
 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
 This is free software: you are free to change and redistribute it.
-There is NO WARRANTY, to the extent permitted by law.\n"), "2024");
+There is NO WARRANTY, to the extent permitted by law."), "2024")."\n";
       exit 0;},
  'macro-expand|E=s' => sub { set_from_cmdline('MACRO_EXPAND', $_[1]); },
  'ifhtml!' => sub { set_expansion('html', $_[1]); },
@@ -1167,8 +1165,8 @@ There is NO WARRANTY, to the extent permitted by 
law.\n"), "2024");
     } else {
       die _encode_message(
            sprintf(__(
-          "%s: --footnote-style arg must be `separate' or `end', not `%s'.\n"),
-                  $real_command_name, $value));
+          "%s: --footnote-style arg must be `separate' or `end', not `%s'."),
+                  $real_command_name, $value))."\n";
     }
   },
  'split=s' => sub {  my $split = _decode_input($_[1]);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]