texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Sun, 10 Dec 2023 05:33:10 -0500 (EST)

branch: master
commit 832063f895d61cec8c6ce87daf84c012eebb4db9
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Dec 10 11:32:58 2023 +0100

    * tp/Texinfo/options_data.txt (PROGRAM_NAME_IN_FOOTER): type is int.
    
    * tp/Texinfo/XS/convert/call_html_perl_function.c
    (call_formatting_function_format_program_string),
    tp/Texinfo/XS/convert/convert_html.c (format_program_string): add.
    
    * tp/Texinfo/XS/convert/get_html_perl_info.
    (html_converter_initialize_sv, html_converter_prepare_output_sv): move
    getting jslicenses information to html_converter_prepare_output_sv.
    
    * tp/Texinfo/XS/convert/call_html_perl_function.c
    (html_default_format_end_file): implement in C.
---
 ChangeLog                                       |  15 +++
 tp/Texinfo/XS/convert/call_html_perl_function.c |  57 +++++++++
 tp/Texinfo/XS/convert/call_html_perl_function.h |   2 +
 tp/Texinfo/XS/convert/convert_html.c            | 106 +++++++++++++++-
 tp/Texinfo/XS/convert/get_html_perl_info.c      | 161 ++++++++++++------------
 tp/Texinfo/options_data.txt                     |   2 +-
 6 files changed, 257 insertions(+), 86 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 389425cf2e..62b3cde6d9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2023-12-10  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/options_data.txt (PROGRAM_NAME_IN_FOOTER): type is int.
+
+       * tp/Texinfo/XS/convert/call_html_perl_function.c
+       (call_formatting_function_format_program_string),
+       tp/Texinfo/XS/convert/convert_html.c (format_program_string): add.
+
+       * tp/Texinfo/XS/convert/get_html_perl_info.
+       (html_converter_initialize_sv, html_converter_prepare_output_sv): move
+       getting jslicenses information to html_converter_prepare_output_sv.
+
+       * tp/Texinfo/XS/convert/call_html_perl_function.c
+       (html_default_format_end_file): implement in C.
+
 2023-12-10  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/convert/convert_html.c (html_finalize_output_state),
diff --git a/tp/Texinfo/XS/convert/call_html_perl_function.c 
b/tp/Texinfo/XS/convert/call_html_perl_function.c
index 98b8206903..2112c2052c 100644
--- a/tp/Texinfo/XS/convert/call_html_perl_function.c
+++ b/tp/Texinfo/XS/convert/call_html_perl_function.c
@@ -694,6 +694,63 @@ call_file_id_setting_external_target_non_split_name 
(CONVERTER *self,
 
 
 
+char *
+call_formatting_function_format_program_string (CONVERTER *self,
+                         const FORMATTING_REFERENCE *formatting_reference)
+{
+  int count;
+  char *result;
+  char *result_ret;
+  STRLEN len;
+  SV *result_sv;
+  SV *formatting_reference_sv;
+
+  dTHX;
+
+  if (!self->hv)
+    return 0;
+
+  formatting_reference_sv = formatting_reference->sv_reference;
+
+  if (self->modified_state)
+    {
+      build_html_formatting_state (self, self->modified_state);
+      self->modified_state = 0;
+    }
+
+  dSP;
+
+  ENTER;
+  SAVETMPS;
+
+  PUSHMARK(SP);
+  EXTEND(SP, 1);
+
+  PUSHs(sv_2mortal (newRV_inc (self->hv)));
+  PUTBACK;
+
+  count = call_sv (formatting_reference_sv,
+                   G_SCALAR);
+
+  SPAGAIN;
+
+  if (count != 1)
+    croak("format_program_string should return 1 item\n");
+
+  result_sv = POPs;
+  result_ret = SvPVutf8 (result_sv, len);
+  result = strdup (result_ret);
+
+  PUTBACK;
+
+  FREETMPS;
+  LEAVE;
+
+  get_shared_conversion_state (self);
+
+  return result;
+}
+
 char *
 call_formatting_function_format_titlepage (CONVERTER *self,
                          const FORMATTING_REFERENCE *formatting_reference)
diff --git a/tp/Texinfo/XS/convert/call_html_perl_function.h 
b/tp/Texinfo/XS/convert/call_html_perl_function.h
index f4e3c1d196..564c774a6a 100644
--- a/tp/Texinfo/XS/convert/call_html_perl_function.h
+++ b/tp/Texinfo/XS/convert/call_html_perl_function.h
@@ -54,6 +54,8 @@ TARGET_FILENAME 
*call_file_id_setting_external_target_non_split_name
                      const char *normalized, const ELEMENT *element,
                      const char *target, const char *file);
 
+char *call_formatting_function_format_program_string (CONVERTER *self,
+                         const FORMATTING_REFERENCE *formatting_reference);
 char *call_formatting_function_format_titlepage (CONVERTER *self,
                          const FORMATTING_REFERENCE *formatting_reference);
 char *call_formatting_function_format_title_titlepage (CONVERTER *self,
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 33206fa493..bc0b4b0092 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -5467,7 +5467,7 @@ format_element_footer (CONVERTER *self,
   if (formatting_reference->status == FRS_status_default_set)
     {
       html_default_format_element_footer (self, unit_type, output_unit,
-                                          content, element, result)
+                                          content, element, result);
     }
   else
 */
@@ -5482,13 +5482,113 @@ format_element_footer (CONVERTER *self,
    }
 }
 
+void
+format_program_string (CONVERTER *self, TEXT *result)
+{
+  FORMATTING_REFERENCE *formatting_reference
+   = &self->current_formatting_references[FR_format_program_string];
+
 /*
+  if (formatting_reference->status == FRS_status_default_set)
+    {
+      html_default_format_program_string (self, result);
+    }
+  else
+*/
+   {
+     char *program_string
+       = call_formatting_function_format_program_string (self,
+                                            formatting_reference);
+     text_append (result, program_string);
+     free (program_string);
+   }
+}
+
+static char *program_in_footer_array[] = {"program-in-footer"};
+static const STRING_LIST program_in_footer_classes
+   = {program_in_footer_array, 1, 1};
+
 char *
 html_default_format_end_file (CONVERTER *self, const char *filename,
                               const OUTPUT_UNIT *output_unit)
 {
+  TEXT result;
+
+  text_init (&result);
+  text_append (&result, "");
+
+  if (self->conf->PROGRAM_NAME_IN_FOOTER > 0)
+    {
+      char *open;
+      size_t open_len;
+      text_append_n (&result, "<p>\n  ",  6);
+      open = html_attribute_class (self, "span", &program_in_footer_classes);
+      open_len = strlen (open);
+      if (open_len > 0)
+        {
+          text_append (&result, open);
+          text_append_n (&result, ">", 1);
+        }
+
+      format_program_string (self, &result);
+
+      if (open_len > 0)
+        text_append_n (&result, "</span>", 7);
+      text_append_n (&result, "\n</p>", 5);
+    }
+  text_append_n (&result, "\n\n", 2);
+
+  if (self->conf->PRE_BODY_CLOSE)
+    text_append (&result, self->conf->PRE_BODY_CLOSE);
+
+  if (self->jslicenses.number)
+    {
+      int infojs_jslicenses_file_nr = 0;
+      int mathjax_jslicenses_file_nr = 0;
+      int i;
+      int status;
+      for (i = 0; i < self->jslicenses.number; i++)
+        {
+          JSLICENSE_FILE_INFO_LIST *jslicences_files_info
+            = &self->jslicenses.list[i];
+          if (!strcmp (jslicences_files_info->category, "infojs"))
+            infojs_jslicenses_file_nr = jslicences_files_info->number;
+          else if (!strcmp (jslicences_files_info->category, "mathjax"))
+            mathjax_jslicenses_file_nr = jslicences_files_info->number;
+        }
+      if (infojs_jslicenses_file_nr > 0
+          || ((html_get_file_information (self, "mathjax",
+                                          filename, &status) > 0
+               || (!self->conf->SPLIT || !strlen (self->conf->SPLIT)))
+              && mathjax_jslicenses_file_nr > 0))
+        {
+          if (self->conf->JS_WEBLABELS_FILE
+              && (self->conf->JS_WEBLABELS
+                  && (!strcmp (self->conf->JS_WEBLABELS, "generate")
+                      || !strcmp (self->conf->JS_WEBLABELS, "reference"))))
+            {
+              ELEMENT *tree;
+              char *js_path = url_protect_url_text (self,
+                                          self->conf->JS_WEBLABELS_FILE);
+              text_append_n (&result, "<a href=\"", 9);
+              text_append (&result, js_path);
+              free (js_path);
+              text_append_n (&result, "\" rel=\"jslicense\"><small>", 25);
+
+              tree = html_gdt_tree ("JavaScript license information",
+                                     self->document,
+                                     self, 0, 0, 0);
+              add_to_element_list (&self->tree_to_build, tree);
+              convert_to_html_internal (self, tree, &result, 0);
+              remove_element_from_list (&self->tree_to_build, tree);
+
+              text_append_n (&result, "</small></a>", 12);
+            }
+        }
+    }
+  text_append_n (&result, "\n</body>\n</html>\n", 17);
+  return result.text;
 }
-*/
 
 char *
 format_end_file (CONVERTER *self, const char *filename,
@@ -5496,13 +5596,11 @@ format_end_file (CONVERTER *self, const char *filename,
 {
   FORMATTING_REFERENCE *formatting_reference
    = &self->current_formatting_references[FR_format_end_file];
-/*
   if (formatting_reference->status == FRS_status_default_set)
     {
       return html_default_format_end_file (self, filename, output_unit);
     }
   else
-*/
     {
       return call_formatting_function_format_end_file (self,
                                                      formatting_reference,
diff --git a/tp/Texinfo/XS/convert/get_html_perl_info.c 
b/tp/Texinfo/XS/convert/get_html_perl_info.c
index 74240f6c9b..9080f06f0c 100644
--- a/tp/Texinfo/XS/convert/get_html_perl_info.c
+++ b/tp/Texinfo/XS/convert/get_html_perl_info.c
@@ -141,7 +141,6 @@ html_converter_initialize_sv (SV *converter_sv,
   HV *default_css_string_types_conversion_hv;
   HV *default_output_units_conversion_hv;
   SV **htmlxref_sv;
-  SV **jslicenses_sv;
   SV **formatting_function_sv;
   SV **sorted_special_unit_varieties_sv;
   SV **no_arg_commands_formatting_sv;
@@ -227,86 +226,6 @@ html_converter_initialize_sv (SV *converter_sv,
         }
     }
 
-  FETCH(jslicenses)
-
-  if (jslicenses_sv)
-    {
-      I32 hv_number;
-      I32 i;
-
-      HV *jslicenses_hv = (HV *)SvRV (*jslicenses_sv);
-
-      hv_number = hv_iterinit (jslicenses_hv);
-
-      converter->jslicenses.number = hv_number;
-      converter->jslicenses.list = (JSLICENSE_FILE_INFO_LIST *)
-       malloc (hv_number * sizeof (JSLICENSE_FILE_INFO_LIST));
-      memset (converter->jslicenses.list, 0,
-              hv_number * sizeof (JSLICENSE_FILE_INFO_LIST));
-
-      for (i = 0; i < hv_number; i++)
-        {
-          I32 hv_files_number;
-          I32 j;
-          HE *next = hv_iternext (jslicenses_hv);
-          SV *category_sv = hv_iterkeysv (next);
-          char *category = (char *) SvPVutf8_nolen (category_sv);
-          SV *files_info_sv = HeVAL(next);
-          HV *files_info_hv = (HV *)SvRV (files_info_sv);
-
-          JSLICENSE_FILE_INFO_LIST *jslicences_files_info
-            = &converter->jslicenses.list[i];
-
-          jslicences_files_info->category = strdup (category);
-
-          hv_files_number = hv_iterinit (files_info_hv);
-          jslicences_files_info->number = hv_files_number;
-          jslicences_files_info->list = (JSLICENSE_FILE_INFO *)
-            malloc (hv_files_number * sizeof (JSLICENSE_FILE_INFO));
-          memset (jslicences_files_info->list, 0,
-                  hv_files_number * sizeof (JSLICENSE_FILE_INFO));
-
-          for (j = 0; j < hv_files_number; j++)
-            {
-              HE *next_file = hv_iternext (files_info_hv);
-              SV *filename_sv = hv_iterkeysv (next);
-              char *filename = (char *) SvPVutf8_nolen (filename_sv);
-              SV *file_info_sv = HeVAL(next_file);
-              AV *file_info_av = (AV *)SvRV (file_info_sv);
-              SSize_t file_info_nr;
-              SV **license_sv;
-              SV **url_sv;
-              SV **source_sv;
-
-              JSLICENSE_FILE_INFO *jslicense_file_info
-                = &jslicences_files_info->list[j];
-              jslicense_file_info->filename = strdup (filename);
-
-              file_info_nr = av_top_index (file_info_av) +1;
-              if (file_info_nr != 3)
-                {
-                  fprintf (stderr,
-                           "BUG: %s: %s: jslicence file needs 3 item: %zu\n",
-                           category, filename, file_info_nr);
-                  continue;
-                }
-              license_sv = av_fetch (file_info_av, 0, 0);
-              if (license_sv && SvOK (*license_sv))
-                jslicense_file_info->license
-                  = strdup ((char *) SvPVutf8_nolen (*license_sv));
-              url_sv = av_fetch (file_info_av, 0, 0);
-              if (url_sv && SvOK (*url_sv))
-                jslicense_file_info->url
-                  = strdup ((char *) SvPVutf8_nolen (*url_sv));
-              source_sv = av_fetch (file_info_av, 0, 0);
-              if (source_sv && SvOK (*source_sv))
-                jslicense_file_info->source
-                  = strdup ((char *) SvPVutf8_nolen (*source_sv));
-            }
-
-        }
-    }
-
   FETCH(formatting_function);
 
   /* no need to check if it exists */
@@ -920,6 +839,7 @@ html_converter_prepare_output_sv (SV *converter_sv, 
CONVERTER *converter)
 {
   HV *converter_hv;
   SV **css_element_class_styles_sv;
+  SV **jslicenses_sv;
 
   dTHX;
 
@@ -956,6 +876,85 @@ html_converter_prepare_output_sv (SV *converter_sv, 
CONVERTER *converter)
         }
     }
 
+  FETCH(jslicenses)
+
+  if (jslicenses_sv)
+    {
+      I32 hv_number;
+      I32 i;
+
+      HV *jslicenses_hv = (HV *)SvRV (*jslicenses_sv);
+
+      hv_number = hv_iterinit (jslicenses_hv);
+
+      converter->jslicenses.number = hv_number;
+      converter->jslicenses.list = (JSLICENSE_FILE_INFO_LIST *)
+       malloc (hv_number * sizeof (JSLICENSE_FILE_INFO_LIST));
+      memset (converter->jslicenses.list, 0,
+              hv_number * sizeof (JSLICENSE_FILE_INFO_LIST));
+
+      for (i = 0; i < hv_number; i++)
+        {
+          I32 hv_files_number;
+          I32 j;
+          HE *next = hv_iternext (jslicenses_hv);
+          SV *category_sv = hv_iterkeysv (next);
+          char *category = (char *) SvPVutf8_nolen (category_sv);
+          SV *files_info_sv = HeVAL(next);
+          HV *files_info_hv = (HV *)SvRV (files_info_sv);
+
+          JSLICENSE_FILE_INFO_LIST *jslicences_files_info
+            = &converter->jslicenses.list[i];
+
+          jslicences_files_info->category = strdup (category);
+
+          hv_files_number = hv_iterinit (files_info_hv);
+          jslicences_files_info->number = hv_files_number;
+          jslicences_files_info->list = (JSLICENSE_FILE_INFO *)
+            malloc (hv_files_number * sizeof (JSLICENSE_FILE_INFO));
+          memset (jslicences_files_info->list, 0,
+                  hv_files_number * sizeof (JSLICENSE_FILE_INFO));
+
+          for (j = 0; j < hv_files_number; j++)
+            {
+              HE *next_file = hv_iternext (files_info_hv);
+              SV *filename_sv = hv_iterkeysv (next);
+              char *filename = (char *) SvPVutf8_nolen (filename_sv);
+              SV *file_info_sv = HeVAL(next_file);
+              AV *file_info_av = (AV *)SvRV (file_info_sv);
+              SSize_t file_info_nr;
+              SV **license_sv;
+              SV **url_sv;
+              SV **source_sv;
+
+              JSLICENSE_FILE_INFO *jslicense_file_info
+                = &jslicences_files_info->list[j];
+              jslicense_file_info->filename = strdup (filename);
+
+              file_info_nr = av_top_index (file_info_av) +1;
+              if (file_info_nr != 3)
+                {
+                  fprintf (stderr,
+                           "BUG: %s: %s: jslicence file needs 3 item: %zu\n",
+                           category, filename, file_info_nr);
+                  continue;
+                }
+              license_sv = av_fetch (file_info_av, 0, 0);
+              if (license_sv && SvOK (*license_sv))
+                jslicense_file_info->license
+                  = strdup ((char *) SvPVutf8_nolen (*license_sv));
+              url_sv = av_fetch (file_info_av, 0, 0);
+              if (url_sv && SvOK (*url_sv))
+                jslicense_file_info->url
+                  = strdup ((char *) SvPVutf8_nolen (*url_sv));
+              source_sv = av_fetch (file_info_av, 0, 0);
+              if (source_sv && SvOK (*source_sv))
+                jslicense_file_info->source
+                  = strdup ((char *) SvPVutf8_nolen (*source_sv));
+            }
+        }
+    }
+
   html_converter_prepare_output (converter);
 }
 
diff --git a/tp/Texinfo/options_data.txt b/tp/Texinfo/options_data.txt
index aa78235617..1491a3e945 100644
--- a/tp/Texinfo/options_data.txt
+++ b/tp/Texinfo/options_data.txt
@@ -288,7 +288,7 @@ PRE_BODY_CLOSE                     converter_customization 
undef   char *
 PREFIX                             converter_customization undef   char *
 PROGRAM                            converter_customization undef   char *
 PROGRAM_NAME_IN_ABOUT              converter_customization undef   char *
-PROGRAM_NAME_IN_FOOTER             converter_customization undef   char *
+PROGRAM_NAME_IN_FOOTER             converter_customization undef   int
 SECTION_NAME_IN_TITLE              converter_customization undef   char *
 SHORT_TOC_LINK_TO_TOC              converter_customization undef   int
 SHOW_TITLE                         converter_customization undef   int



reply via email to

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