texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Fri, 15 Nov 2024 18:35:54 -0500 (EST)

branch: master
commit 2b5e5ba20957fad26ba15d28b5eb3076f13e260e
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Nov 15 23:36:14 2024 +0100

    * tp/Texinfo/XS/Makefile.am (XS_libtexinfo_convert_sources),
    tp/Texinfo/XS/convert/build_html_perl_state.h,
    tp/Texinfo/XS/convert/build_html_perl_state.c
    (build_html_translated_names, build_html_formatting_state),
    tp/Texinfo/XS/convert/build_html_perl_info.c: recreate
    build_html_perl_state.c, moving build_html_translated_names and
    build_html_formatting_state to the file.
---
 ChangeLog                                       |  10 ++
 tp/Texinfo/XS/Makefile.am                       |   4 +-
 tp/Texinfo/XS/convert/ConvertXS.xs              |   1 +
 tp/Texinfo/XS/convert/build_html_perl_info.c    | 165 +-----------------
 tp/Texinfo/XS/convert/build_html_perl_info.h    |   2 -
 tp/Texinfo/XS/convert/build_html_perl_state.c   | 216 ++++++++++++++++++++++++
 tp/Texinfo/XS/convert/build_html_perl_state.h   |  12 ++
 tp/Texinfo/XS/convert/call_html_perl_function.c |   2 +-
 tp/Texinfo/XS/convert/html_converter_types.h    |   1 +
 tp/Texinfo/XS/convert/html_prepare_converter.h  |   2 -
 10 files changed, 246 insertions(+), 169 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index ada8873b53..a8ea27e9f6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,6 +17,16 @@
        Remove use of LONG_TESTS variable (same change made in
        tp/tests/Makefile.am on 2016-10-23 but this file was missed).
 
+2024-11-15  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/Makefile.am (XS_libtexinfo_convert_sources),
+       tp/Texinfo/XS/convert/build_html_perl_state.h,
+       tp/Texinfo/XS/convert/build_html_perl_state.c
+       (build_html_translated_names, build_html_formatting_state),
+       tp/Texinfo/XS/convert/build_html_perl_info.c: recreate
+       build_html_perl_state.c, moving build_html_translated_names and
+       build_html_formatting_state to the file.
+
 2024-11-15  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/convert/build_html_perl_info.c,
diff --git a/tp/Texinfo/XS/Makefile.am b/tp/Texinfo/XS/Makefile.am
index 485b8b893c..12459b7656 100644
--- a/tp/Texinfo/XS/Makefile.am
+++ b/tp/Texinfo/XS/Makefile.am
@@ -448,8 +448,10 @@ C_libtexinfo_convert_sources = \
 
 # call_html_perl_function.c functions are called in other
 # parts of the code and need to be linked against Perl.
-# build_html_perl_info.c functions are called from call_html_perl_function.c.
+# build_html_perl_state.c functions are called from call_html_perl_function.c.
 XS_libtexinfo_convert_sources = \
+                       convert/build_html_perl_state.h \
+                       convert/build_html_perl_state.c \
                        convert/build_html_perl_info.h \
                        convert/build_html_perl_info.c \
                        convert/call_html_perl_function.h \
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs 
b/tp/Texinfo/XS/convert/ConvertXS.xs
index a707b6a354..2564c86278 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -51,6 +51,7 @@
 #include "converter.h"
 #include "get_perl_info.h"
 #include "build_perl_info.h"
+#include "build_html_perl_state.h"
 #include "get_converter_perl_info.h"
 #include "build_html_perl_info.h"
 #include "html_conversion_state.h"
diff --git a/tp/Texinfo/XS/convert/build_html_perl_info.c 
b/tp/Texinfo/XS/convert/build_html_perl_info.c
index 2e9dd91cbf..455e5a874b 100644
--- a/tp/Texinfo/XS/convert/build_html_perl_info.c
+++ b/tp/Texinfo/XS/convert/build_html_perl_info.c
@@ -54,9 +54,9 @@
 #include "translations.h"
 /* for no_arg_formatted_cmd direction_string_type_names
    direction_string_context_names html_conversion_context_type_names
-   html_argument_formatting_type_names translated_special_unit_info */
+ */
 #include "html_converter_types.h"
-/* for special_unit_info_type_names html_global_unit_direction_names
+/* for html_global_unit_direction_names
    htmlxref_split_type_names html_setup_global_units_direction_names */
 #include "html_prepare_converter.h"
 #include "build_html_perl_info.h"
@@ -624,167 +624,6 @@ html_pass_output_units_global_targets (CONVERTER *self, 
SV *output_units_sv,
     }
 }
 
-static void
-build_html_translated_names (HV *hv, CONVERTER *converter)
-{
-  int j;
-  SV **directions_strings_sv;
-  HV *directions_strings_hv;
-  SV **special_unit_info_sv;
-  HV *special_unit_info_hv;
-  SV **no_arg_commands_formatting_sv;
-  HV *direction_string_hv;
-
-  dTHX;
-
-  /* reset with empty hash */
-#define FETCH(key) key##_sv = hv_fetch (hv, #key, strlen (#key), 0);
-  FETCH(directions_strings);
-  directions_strings_hv = (HV *) SvRV (*directions_strings_sv);
-#define tds_type(name) \
-  direction_string_hv = newHV (); \
-  hv_store (directions_strings_hv, #name, strlen (#name), \
-               newRV_noinc ((SV *) direction_string_hv), 0);
-   TDS_TRANSLATED_TYPES_LIST
-#undef tds_type
-
-  FETCH(special_unit_info);
-  special_unit_info_hv = (HV *) SvRV (*special_unit_info_sv);
-
-  /* reset with empty hash */
-  for (j = 0; translated_special_unit_info[j].tree_type != SUIT_type_none; j++)
-    {
-      enum special_unit_info_type string_type
-        = translated_special_unit_info[j].string_type;
-      const char *type_name = special_unit_info_type_names[string_type];
-      char *key;
-      HV *special_unit_hv = newHV ();
-      key = perl_only_malloc (strlen (type_name) + strlen ("_tree") + 1);
-      sprintf (key, "%s_tree", type_name);
-      hv_store (special_unit_info_hv, key, strlen (key),
-                newRV_noinc ((SV *) special_unit_hv), 0);
-      perl_only_free (key);
-    }
-
-  /* pass all the information for each context for translated commands */
-  if (converter->no_arg_formatted_cmd_translated.number)
-    {
-      size_t j;
-      HV *no_arg_commands_formatting_hv;
-      FETCH(no_arg_commands_formatting);
-      no_arg_commands_formatting_hv
-        = (HV *) SvRV (*no_arg_commands_formatting_sv);
-      for (j = 0; j < converter->no_arg_formatted_cmd_translated.number; j++)
-        {
-          int k;
-          enum command_id cmd
-            = converter->no_arg_formatted_cmd_translated.list[j];
-          const char *cmdname = builtin_command_data[cmd].cmdname;
-          SV **no_arg_command_sv
-             = hv_fetch (no_arg_commands_formatting_hv,
-                         cmdname, strlen (cmdname), 0);
-          HV *no_arg_command_hv = (HV *) SvRV (*no_arg_command_sv);
-          for (k = 0; k < NO_ARG_COMMAND_CONTEXT_NR; k++)
-            {
-              HTML_NO_ARG_COMMAND_CONVERSION *no_arg_cmd_context
-                  = &converter->html_no_arg_command_conversion[cmd][k];
-
-              const char *context_name = html_conversion_context_type_names[k];
-              SV **context_sv = hv_fetch (no_arg_command_hv,
-                                 context_name, strlen (context_name), 0);
-              HV *context_hv = (HV *) SvRV (*context_sv);
-
- #define REPLACE_STR(key) \
-              if (no_arg_cmd_context->key) \
-                {               \
-                  hv_store (context_hv, #key, strlen (#key), \
-                            newSVpv_utf8 (no_arg_cmd_context->key, 0), 0); \
-                }   \
-              else if (hv_exists (context_hv, #key, strlen (#key))) \
-                hv_delete (context_hv, #key, strlen (#key), G_DISCARD);
-
-              REPLACE_STR(text)
-              REPLACE_STR(translated_converted)
-              REPLACE_STR(translated_to_convert)
- #undef REPLACE_STR
-
-              if (no_arg_cmd_context->translated_tree)
-                {
-                  ELEMENT *translated_tree
-                    = no_arg_cmd_context->translated_tree;
-                  if (!translated_tree->hv)
-                    element_to_perl_hash (translated_tree, 1);
-                  hv_store (context_hv, "translated_tree",
-                            strlen ("translated_tree"),
-                            newRV_inc ((SV *) translated_tree->hv), 0);
-                }
-              else if (hv_exists (context_hv, "translated_tree",
-                                  strlen ("translated_tree")))
-                hv_delete (context_hv, "translated_tree",
-                           strlen ("translated_tree"), G_DISCARD);
-            }
-        }
-
-      memset (converter->no_arg_formatted_cmd_translated.list, 0,
-              converter->no_arg_formatted_cmd_translated.number
-                   * sizeof (enum command_id));
-      converter->no_arg_formatted_cmd_translated.number = 0;
-    }
-
-#undef FETCH
-
-}
-
-void
-build_html_formatting_state (CONVERTER *converter)
-{
-  HV *hv;
-  unsigned long flags;
-
-  dTHX;
-
-  flags = converter->modified_state;
-
-  if (!flags)
-    return;
-
-  if (converter->external_references_number <= 0 || !converter->hv)
-    {
-      converter->modified_state = 0;
-      return;
-    }
-
-
-  hv = converter->hv;
-
-#define STORE(key, value) hv_store (hv, key, strlen (key), value, 0)
-
-  if (flags & HMSF_current_root)
-    {
-      if (!converter->current_root_command)
-        STORE("current_root_command", newSV (0));
-      else
-        STORE("current_root_command",
-          newRV_inc ((SV *) converter->current_root_command->hv));
-    }
-
-  if (flags & HMSF_current_node)
-    {
-      if (!converter->current_node)
-        STORE("current_node", newSV (0));
-      else
-        STORE("current_node",
-           newRV_inc ((SV *) converter->current_node->hv));
-    }
-
-#undef STORE
-
-  if (flags & HMSF_translations)
-    build_html_translated_names (hv, converter);
-
-  converter->modified_state = 0;
-}
-
 SV *
 build_replaced_substrings (NAMED_STRING_ELEMENT_LIST *replaced_substrings)
 {
diff --git a/tp/Texinfo/XS/convert/build_html_perl_info.h 
b/tp/Texinfo/XS/convert/build_html_perl_info.h
index d93c3e6a92..d8377cb114 100644
--- a/tp/Texinfo/XS/convert/build_html_perl_info.h
+++ b/tp/Texinfo/XS/convert/build_html_perl_info.h
@@ -43,8 +43,6 @@ void pass_html_global_units_directions (SV *converter_sv,
 void pass_html_elements_in_file_count (SV *converter_sv,
                    FILE_NAME_PATH_COUNTER_LIST *output_unit_files);
 
-void build_html_formatting_state (CONVERTER *converter);
-
 SV *build_replaced_substrings (NAMED_STRING_ELEMENT_LIST *replaced_substrings);
 
 void build_pending_footnotes (AV *av, HTML_PENDING_FOOTNOTE_STACK *stack);
diff --git a/tp/Texinfo/XS/convert/build_html_perl_state.c 
b/tp/Texinfo/XS/convert/build_html_perl_state.c
new file mode 100644
index 0000000000..f956e1800b
--- /dev/null
+++ b/tp/Texinfo/XS/convert/build_html_perl_state.c
@@ -0,0 +1,216 @@
+/* Copyright 2010-2024 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>. */
+
+#include <config.h>
+
+#include <stdio.h>
+
+/* Avoid namespace conflicts. */
+#define context perl_context
+
+#define PERL_NO_GET_CONTEXT
+#include "EXTERN.h"
+#include "perl.h"
+#if defined _WIN32 && !defined __CYGWIN__
+/* See comment in Parsetexi.xs for why we #undef free. */
+  #undef free
+#endif
+#include "XSUB.h"
+
+#undef context
+
+#include "html_conversion_data.h"
+#include "tree_types.h"
+#include "converter_types.h"
+/* for builtin_command_data */
+#include "builtin_commands.h"
+/* for HMSF_* */
+#include "utils.h"
+/* next two could be interesting for debugging */
+/*
+#include "debug.h"
+#include "convert_to_texinfo.h"
+ */
+/* newSVpv_utf8 element_to_perl_hash perl_only_* wrappers */
+#include "build_perl_info.h"
+/* for html_conversion_context_type_names translated_special_unit_info
+   special_unit_info_type_names */
+#include "html_converter_types.h"
+#include "build_html_perl_state.h"
+
+ /* See the NOTE in build_perl_info.c on use of functions related to
+    memory allocation */
+
+static void
+build_html_translated_names (HV *hv, CONVERTER *converter)
+{
+  int j;
+  SV **directions_strings_sv;
+  HV *directions_strings_hv;
+  SV **special_unit_info_sv;
+  HV *special_unit_info_hv;
+  SV **no_arg_commands_formatting_sv;
+  HV *direction_string_hv;
+
+  dTHX;
+
+  /* reset with empty hash */
+#define FETCH(key) key##_sv = hv_fetch (hv, #key, strlen (#key), 0);
+  FETCH(directions_strings);
+  directions_strings_hv = (HV *) SvRV (*directions_strings_sv);
+#define tds_type(name) \
+  direction_string_hv = newHV (); \
+  hv_store (directions_strings_hv, #name, strlen (#name), \
+               newRV_noinc ((SV *) direction_string_hv), 0);
+   TDS_TRANSLATED_TYPES_LIST
+#undef tds_type
+
+  FETCH(special_unit_info);
+  special_unit_info_hv = (HV *) SvRV (*special_unit_info_sv);
+
+  /* reset with empty hash */
+  for (j = 0; translated_special_unit_info[j].tree_type != SUIT_type_none; j++)
+    {
+      enum special_unit_info_type string_type
+        = translated_special_unit_info[j].string_type;
+      const char *type_name = special_unit_info_type_names[string_type];
+      char *key;
+      HV *special_unit_hv = newHV ();
+      key = perl_only_malloc (strlen (type_name) + strlen ("_tree") + 1);
+      sprintf (key, "%s_tree", type_name);
+      hv_store (special_unit_info_hv, key, strlen (key),
+                newRV_noinc ((SV *) special_unit_hv), 0);
+      perl_only_free (key);
+    }
+
+  /* pass all the information for each context for translated commands */
+  if (converter->no_arg_formatted_cmd_translated.number)
+    {
+      size_t j;
+      HV *no_arg_commands_formatting_hv;
+      FETCH(no_arg_commands_formatting);
+      no_arg_commands_formatting_hv
+        = (HV *) SvRV (*no_arg_commands_formatting_sv);
+      for (j = 0; j < converter->no_arg_formatted_cmd_translated.number; j++)
+        {
+          int k;
+          enum command_id cmd
+            = converter->no_arg_formatted_cmd_translated.list[j];
+          const char *cmdname = builtin_command_data[cmd].cmdname;
+          SV **no_arg_command_sv
+             = hv_fetch (no_arg_commands_formatting_hv,
+                         cmdname, strlen (cmdname), 0);
+          HV *no_arg_command_hv = (HV *) SvRV (*no_arg_command_sv);
+          for (k = 0; k < NO_ARG_COMMAND_CONTEXT_NR; k++)
+            {
+              HTML_NO_ARG_COMMAND_CONVERSION *no_arg_cmd_context
+                  = &converter->html_no_arg_command_conversion[cmd][k];
+
+              const char *context_name = html_conversion_context_type_names[k];
+              SV **context_sv = hv_fetch (no_arg_command_hv,
+                                 context_name, strlen (context_name), 0);
+              HV *context_hv = (HV *) SvRV (*context_sv);
+
+ #define REPLACE_STR(key) \
+              if (no_arg_cmd_context->key) \
+                {               \
+                  hv_store (context_hv, #key, strlen (#key), \
+                            newSVpv_utf8 (no_arg_cmd_context->key, 0), 0); \
+                }   \
+              else if (hv_exists (context_hv, #key, strlen (#key))) \
+                hv_delete (context_hv, #key, strlen (#key), G_DISCARD);
+
+              REPLACE_STR(text)
+              REPLACE_STR(translated_converted)
+              REPLACE_STR(translated_to_convert)
+ #undef REPLACE_STR
+
+              if (no_arg_cmd_context->translated_tree)
+                {
+                  ELEMENT *translated_tree
+                    = no_arg_cmd_context->translated_tree;
+                  if (!translated_tree->hv)
+                    element_to_perl_hash (translated_tree, 1);
+                  hv_store (context_hv, "translated_tree",
+                            strlen ("translated_tree"),
+                            newRV_inc ((SV *) translated_tree->hv), 0);
+                }
+              else if (hv_exists (context_hv, "translated_tree",
+                                  strlen ("translated_tree")))
+                hv_delete (context_hv, "translated_tree",
+                           strlen ("translated_tree"), G_DISCARD);
+            }
+        }
+
+      memset (converter->no_arg_formatted_cmd_translated.list, 0,
+              converter->no_arg_formatted_cmd_translated.number
+                   * sizeof (enum command_id));
+      converter->no_arg_formatted_cmd_translated.number = 0;
+    }
+
+#undef FETCH
+
+}
+
+void
+build_html_formatting_state (CONVERTER *converter)
+{
+  HV *hv;
+  unsigned long flags;
+
+  dTHX;
+
+  flags = converter->modified_state;
+
+  if (!flags)
+    return;
+
+  if (converter->external_references_number <= 0 || !converter->hv)
+    {
+      converter->modified_state = 0;
+      return;
+    }
+
+
+  hv = converter->hv;
+
+#define STORE(key, value) hv_store (hv, key, strlen (key), value, 0)
+
+  if (flags & HMSF_current_root)
+    {
+      if (!converter->current_root_command)
+        STORE("current_root_command", newSV (0));
+      else
+        STORE("current_root_command",
+          newRV_inc ((SV *) converter->current_root_command->hv));
+    }
+
+  if (flags & HMSF_current_node)
+    {
+      if (!converter->current_node)
+        STORE("current_node", newSV (0));
+      else
+        STORE("current_node",
+           newRV_inc ((SV *) converter->current_node->hv));
+    }
+
+#undef STORE
+
+  if (flags & HMSF_translations)
+    build_html_translated_names (hv, converter);
+
+  converter->modified_state = 0;
+}
+
diff --git a/tp/Texinfo/XS/convert/build_html_perl_state.h 
b/tp/Texinfo/XS/convert/build_html_perl_state.h
new file mode 100644
index 0000000000..783d71ba70
--- /dev/null
+++ b/tp/Texinfo/XS/convert/build_html_perl_state.h
@@ -0,0 +1,12 @@
+/* build_html_perl_state.h - declarations for build_html_perl_state.c */
+#ifndef BUILD_HTML_PERL_STATE_H
+#define BUILD_HTML_PERL_STATE_H
+
+#include "EXTERN.h"
+#include "perl.h"
+
+#include "converter_types.h"
+
+void build_html_formatting_state (CONVERTER *converter);
+
+#endif
diff --git a/tp/Texinfo/XS/convert/call_html_perl_function.c 
b/tp/Texinfo/XS/convert/call_html_perl_function.c
index e839af1aa4..2d8591d7d3 100644
--- a/tp/Texinfo/XS/convert/call_html_perl_function.c
+++ b/tp/Texinfo/XS/convert/call_html_perl_function.c
@@ -49,7 +49,7 @@
 /* for newSVpv_utf8 build_tree_to_build */
 #include "build_perl_info.h"
 /* build_html_formatting_state */
-#include "build_html_perl_info.h"
+#include "build_html_perl_state.h"
 #include "call_html_perl_function.h"
 
  /* See the NOTE in build_perl_info.c on use of functions related to
diff --git a/tp/Texinfo/XS/convert/html_converter_types.h 
b/tp/Texinfo/XS/convert/html_converter_types.h
index 678370dbac..d3927e6b8a 100644
--- a/tp/Texinfo/XS/convert/html_converter_types.h
+++ b/tp/Texinfo/XS/convert/html_converter_types.h
@@ -77,6 +77,7 @@ typedef struct COMMAND_ARGS_SPECIFICATION {
 
 /* in conversion_data.c */
 extern const TRANSLATED_SUI_ASSOCIATION translated_special_unit_info[];
+extern const char *special_unit_info_type_names[SUI_type_heading + 1];
 
 /* in format_html.c */
 extern const char *direction_string_type_names[];
diff --git a/tp/Texinfo/XS/convert/html_prepare_converter.h 
b/tp/Texinfo/XS/convert/html_prepare_converter.h
index b357b05e9f..6571addac7 100644
--- a/tp/Texinfo/XS/convert/html_prepare_converter.h
+++ b/tp/Texinfo/XS/convert/html_prepare_converter.h
@@ -10,8 +10,6 @@
         html_conversion_api.h */
 
 /* in conversion_data.c */
-extern const char *special_unit_info_type_names[SUI_type_heading + 1];
-
 extern const char *html_global_unit_direction_names[];
 
 extern const char *html_formatting_reference_names[];



reply via email to

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