texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Sat, 5 Oct 2024 05:41:30 -0400 (EDT)

branch: master
commit 647377b07bce486141b81bd16c2a6de4e10f1001
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Aug 31 11:11:59 2024 +0200

    * tp/Texinfo/XS/convert/texinfo.c (txi_converter_setup): set PACKAGE_*
    and PACKAGE_*_CONFIG customization variables.
    
    * tp/Texinfo/XS/teximakehtml.c (main): add an option to select either
    a reproducible demonstration mode or texi2any mimicking mode.
---
 ChangeLog                       |  8 ++++
 tp/TODO                         |  2 +
 tp/Texinfo/XS/convert/texinfo.c | 26 +++++++++----
 tp/Texinfo/XS/teximakehtml.c    | 82 +++++++++++++++++++++++++++++++----------
 4 files changed, 91 insertions(+), 27 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 078f6cd96d..b3c2804eef 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-08-31  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/convert/texinfo.c (txi_converter_setup): set PACKAGE_*
+       and PACKAGE_*_CONFIG customization variables.
+
+       * tp/Texinfo/XS/teximakehtml.c (main): add an option to select either
+       a reproducible demonstration mode or texi2any mimicking mode.
+
 2024-08-30  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/Convert/Converter.pm: changes in POD documentation and
diff --git a/tp/TODO b/tp/TODO
index acb6fb0c7e..8d8230b8e1 100644
--- a/tp/TODO
+++ b/tp/TODO
@@ -916,6 +916,8 @@ Setting flags
 # some features are only enabled at -O2, but sometime -O0 is better
 # for debugging with valgrind
 our_CFLAGS='-g -O0 -Wformat-security -Wstrict-prototypes -Wall 
-Wno-parentheses -Wno-missing-braces -Wno-unused-parameter -Wextra'
+# keep cpp expanded files
+# -save-temps
 # Without -Wstack-protector there is no message on functions not protected.
 # All these are in gnulib or gettext for now.
 # -fno-omit-frame-pointer is better for debugging with valgrind, but has
diff --git a/tp/Texinfo/XS/convert/texinfo.c b/tp/Texinfo/XS/convert/texinfo.c
index 87d2c44277..8ae7e11ec7 100644
--- a/tp/Texinfo/XS/convert/texinfo.c
+++ b/tp/Texinfo/XS/convert/texinfo.c
@@ -295,6 +295,12 @@ txi_converter_setup (const char *format_str,
     = find_format_name_converter_format (format_str);
   CONVERTER_INITIALIZATION_INFO *conf;
   CONVERTER *self;
+  const char *configured_version = PACKAGE_VERSION_CONFIG;
+  const char *configured_package = PACKAGE_CONFIG;
+  const char *configured_name = PACKAGE_NAME_CONFIG;
+  const char *configured_url = PACKAGE_URL_CONFIG;
+  const char *configured_name_version
+    = PACKAGE_NAME_CONFIG " " PACKAGE_VERSION_CONFIG;
 
   conf = new_converter_initialization_info ();
 
@@ -317,15 +323,19 @@ txi_converter_setup (const char *format_str,
 
   /* similar to options coming from texi2any */
   add_option_string_value (&conf->conf, txi_base_sorted_options,
-   /*
-    */
                            "PROGRAM", 0, program_file);
-  /* comment the line above and uncomment below to compare with
-     texi2any output
-                           "PROGRAM", 0, "texi2any");
-  add_option_string_value (&conf->conf, txi_base_sorted_options,
-                      "PACKAGE_AND_VERSION", 0, "Texinfo 7.1.90+dev");
-   */
+#define set_configured_information(varname,postfix) \
+  add_option_string_value (&conf->conf, txi_base_sorted_options, \
+                           #varname, 0, configured_ ## postfix); \
+  add_option_string_value (&conf->conf, txi_base_sorted_options, \
+                           #varname "_CONF", 0, configured_ ## postfix);
+  set_configured_information(PACKAGE_VERSION, version)
+  set_configured_information(PACKAGE, package)
+  set_configured_information(PACKAGE_NAME, name)
+  set_configured_information(PACKAGE_AND_VERSION, name_version)
+  set_configured_information(PACKAGE_URL, url)
+#undef set_configured_information
+
   add_option_string_value (&conf->conf, txi_base_sorted_options,
                         "COMMAND_LINE_ENCODING", 0, locale_encoding);
   add_option_string_value (&conf->conf, txi_base_sorted_options,
diff --git a/tp/Texinfo/XS/teximakehtml.c b/tp/Texinfo/XS/teximakehtml.c
index aacf5a1a12..8a1a212f24 100644
--- a/tp/Texinfo/XS/teximakehtml.c
+++ b/tp/Texinfo/XS/teximakehtml.c
@@ -21,6 +21,8 @@
 #include <stddef.h>
 #include <stdio.h>
 #include <string.h>
+#include <unistd.h>
+#include <ctype.h>
 #include <langinfo.h>
 #include <locale.h>
 #ifdef ENABLE_NLS
@@ -106,6 +108,14 @@ main (int argc, char *argv[])
   char *home_dir;
   const char *curdir = ".";
 
+  /* there are two modes, depending on test value.
+      - if test is set, the output is setup to test specific output
+        options, use the true program name and try to generate
+        reproducible output.
+      - if test is unset, the program tries to mimic texi2any.
+   */
+  int test = 0;
+
   /*
   const char *texinfo_text;
    */
@@ -123,8 +133,41 @@ main (int argc, char *argv[])
 
   locale_encoding = nl_langinfo (CODESET);
 
-  if (argc <= 1)
-    exit (1);
+  parse_file_path (argv[0], program_file_name_and_directory);
+  program_file = program_file_name_and_directory[0];
+  input_directory = program_file_name_and_directory[1];
+
+  while (1)
+    {
+      int option_character;
+
+      option_character = getopt (argc, argv, "t");
+      if (option_character == -1)
+        break;
+
+      switch (option_character)
+        {
+        case 't':
+          test = 1;
+          break;
+          /*
+        case '?':
+          if (isprint (optopt))
+            fprintf (stderr, "Unknown option `-%c'\n", optopt);
+          else
+            fprintf (stderr,
+                     "Unknown option character `\\x%x'\n",
+                     optopt);
+          break;
+           */
+        default:
+          fprintf (stderr, "Usage: %s [-t] input_file\n", program_file);
+          exit (EXIT_FAILURE);
+        }
+    }
+
+  if (optind >= argc)
+    exit (EXIT_FAILURE);
 
   txi_setup (LOCALEDIR, 0, 0, 0, 0);
 
@@ -149,10 +192,6 @@ main (int argc, char *argv[])
     add_string (DATADIR "/texinfo", &texinfo_language_config_dirs);
 
 
-  parse_file_path (argv[0], program_file_name_and_directory);
-  program_file = program_file_name_and_directory[0];
-  input_directory = program_file_name_and_directory[1];
-
 /*
  if ($^O eq 'MSWin32') {
   $main_program_set_options->{'DOC_ENCODING_FOR_INPUT_FILE_NAME'} = 0;
@@ -160,7 +199,7 @@ main (int argc, char *argv[])
 */
 
   /* Texinfo file parsing */
-  input_file_path = argv[1];
+  input_file_path = argv[optind];
 
   initialize_options_list (&parser_options, 2);
   /*
@@ -183,7 +222,7 @@ main (int argc, char *argv[])
     {
       txi_handle_parser_error_messages (document, 0, 1, locale_encoding);
       txi_remove_document (document);
-      exit (1);
+      exit (EXIT_FAILURE);
     }
 
   errors_nr
@@ -212,18 +251,23 @@ main (int argc, char *argv[])
   /* conversion initialization */
   initialize_options_list (&convert_options, 2);
 
-  /* customize buttons.  It is a bit silly to use link buttons for
-     footer, it is for the demonstration */
-  custom_node_footer_buttons = new_base_links_buttons (0);
-  add_new_button_option (&convert_options,
+  if (test)
+    {
+      /* customize buttons.  It is a bit silly to use link buttons for
+         footer, it is for the demonstration */
+      custom_node_footer_buttons = new_base_links_buttons (0);
+      add_new_button_option (&convert_options,
                      "NODE_FOOTER_BUTTONS", custom_node_footer_buttons);
-  add_new_option_value (&convert_options, GOT_integer,
+      add_new_option_value (&convert_options, GOT_integer,
                            "PROGRAM_NAME_IN_FOOTER", 1, 0);
-  /*
-   */
-  /* this is set to help with comparison with previous invokations */
-  add_new_option_value (&convert_options, GOT_integer,
-                           "TEST", 1, 0);
+      /* this is set to help with comparison with previous invokations */
+      add_new_option_value (&convert_options, GOT_integer,
+                            "TEST", 1, 0);
+    }
+  else
+    {
+      program_file = strdup ("texi2any");
+    }
   /*
   add_new_option_value (&convert_options, GOT_integer,
                         "CHECK_HTMLXREF", 1, 0);
@@ -271,5 +315,5 @@ main (int argc, char *argv[])
   txi_remove_document (document);
 
   if (errors_count > 0)
-    exit (1);
+    exit (EXIT_FAILURE);
 }



reply via email to

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