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, 13 Jan 2024 14:34:24 -0500 (EST)

branch: master
commit 882aacbe027abffb56676786b09a0d37e6e452dd
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Fri Jan 12 16:54:09 2024 +0100

    * tp/Texinfo/Convert/HTML.pm (_convert_no_arg_command): use
    letter_no_arg_commands to determine if the command name upper-cased
    string is a command name too.
    
    * tp/Texinfo/XS/convert/converter.c
    (no_brace_command_accent_upper_case): mapping of lower case letter no
    arg commands to the corresponding upper case commands.
    
    * tp/Texinfo/XS/convert/convert_html.c (HTML_COMMAND_STRUCT)
    (convert_no_arg_command, css_string_convert_no_arg_command)
    (html_format_init): add upper case command information in
    HTML_COMMAND_STRUCT based on no_brace_command_accent_upper_case.
---
 ChangeLog                            | 15 ++++++++++
 tp/Texinfo/Convert/HTML.pm           |  2 +-
 tp/Texinfo/XS/convert/convert_html.c | 54 ++++++++++--------------------------
 tp/Texinfo/XS/convert/converter.c    | 13 +++++++++
 tp/Texinfo/XS/convert/converter.h    |  1 +
 5 files changed, 44 insertions(+), 41 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f42defafde..26a1192c84 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2024-01-12  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/Convert/HTML.pm (_convert_no_arg_command): use
+       letter_no_arg_commands to determine if the command name upper-cased
+       string is a command name too.
+
+       * tp/Texinfo/XS/convert/converter.c
+       (no_brace_command_accent_upper_case): mapping of lower case letter no
+       arg commands to the corresponding upper case commands.
+
+       * tp/Texinfo/XS/convert/convert_html.c (HTML_COMMAND_STRUCT)
+       (convert_no_arg_command, css_string_convert_no_arg_command)
+       (html_format_init): add upper case command information in
+       HTML_COMMAND_STRUCT based on no_brace_command_accent_upper_case.
+
 2024-01-12  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/main/document.c
diff --git a/tp/Texinfo/Convert/HTML.pm b/tp/Texinfo/Convert/HTML.pm
index 31f81ccb17..07fd3f5d2c 100644
--- a/tp/Texinfo/Convert/HTML.pm
+++ b/tp/Texinfo/Convert/HTML.pm
@@ -3223,7 +3223,7 @@ sub _convert_no_arg_command($$$)
     }
   }
   if (in_upper_case($self) and $letter_no_arg_commands{$cmdname}
-      and $self->{'no_arg_commands_formatting'}->{uc($cmdname)}) {
+      and $letter_no_arg_commands{uc($cmdname)}) {
     $cmdname = uc($cmdname);
   }
 
diff --git a/tp/Texinfo/XS/convert/convert_html.c 
b/tp/Texinfo/XS/convert/convert_html.c
index 88d177bc98..3350caec98 100644
--- a/tp/Texinfo/XS/convert/convert_html.c
+++ b/tp/Texinfo/XS/convert/convert_html.c
@@ -218,6 +218,7 @@ CMD_VARIETY command_special_unit_variety[] = {
 typedef struct HTML_COMMAND_STRUCT {
     unsigned long flags;
     enum command_id pre_class_cmd;
+    enum command_id upper_case_cmd;
 } HTML_COMMAND_STRUCT;
 
 static HTML_COMMAND_STRUCT html_commands_data[BUILTIN_CMD_NUMBER];
@@ -8305,26 +8306,9 @@ convert_no_arg_command (CONVERTER *self, const enum 
command_id cmd,
     }
 
   if (html_in_upper_case (self)
-      && (builtin_command_data[formatted_cmd].other_flags & CF_letter_no_arg))
+      && html_commands_data[formatted_cmd].upper_case_cmd)
     {
-      const char *command = builtin_command_name (formatted_cmd);
-      char *upper_case_command = strdup (command);
-      char *p;
-      enum command_id upper_case_cmd;
-      for (p = upper_case_command; *p; p++)
-        {
-          *p = toupper (*p);
-        }
-      /* TODO the mapping could be done once for all */
-      upper_case_cmd = lookup_builtin_command (upper_case_command);
-      if (upper_case_cmd)
-        {
-          HTML_COMMAND_CONVERSION *conv_context
-            = self->html_command_conversion[upper_case_cmd];
-          if (conv_context[context].text || conv_context[context].element)
-            formatted_cmd = upper_case_cmd;
-        }
-      free (upper_case_command);
+      formatted_cmd = html_commands_data[formatted_cmd].upper_case_cmd;
     }
 
   specification
@@ -8356,26 +8340,9 @@ css_string_convert_no_arg_command (CONVERTER *self,
     }
 
   if (html_in_upper_case (self)
-      && (builtin_command_data[formatted_cmd].other_flags & CF_letter_no_arg))
+      && html_commands_data[formatted_cmd].upper_case_cmd)
     {
-      const char *command = builtin_command_name (formatted_cmd);
-      char *upper_case_command = strdup (command);
-      char *p;
-      enum command_id upper_case_cmd;
-      for (p = upper_case_command; *p; p++)
-        {
-          *p = toupper (*p);
-        }
-      /* TODO the mapping could be done once for all */
-      upper_case_cmd = lookup_builtin_command (upper_case_command);
-      free (upper_case_command);
-      if (upper_case_cmd)
-        {
-          HTML_COMMAND_CONVERSION *conv_context
-            = self->html_command_conversion[upper_case_cmd];
-          if (conv_context[HCC_type_css_string].text)
-            formatted_cmd = upper_case_cmd;
-        }
+      formatted_cmd = html_commands_data[formatted_cmd].upper_case_cmd;
     }
 
   text_append (result,
@@ -15768,7 +15735,7 @@ void
 html_format_init (void)
 {
   int i;
-  int nr_default_commands
+  int nr_default_commands_args
     = sizeof (default_commands_args) / sizeof (default_commands_args[0]);
   int max_args = MAX_COMMAND_ARGS_NR;
 
@@ -15776,7 +15743,7 @@ html_format_init (void)
     CM_example, CM_display, CM_lisp, 0
   };
 
-  for (i = 0; i < nr_default_commands; i++)
+  for (i = 0; i < nr_default_commands_args; i++)
     {
       /* we file the status for specified commands, to distinguish them
          but it is not actually used in the code, as we default to
@@ -15806,6 +15773,13 @@ html_format_init (void)
         html_commands_data[small_cmd].flags |= HF_indented_preformatted;
     }
 
+  for (i = 0; no_brace_command_accent_upper_case[i][0]; i++)
+    {
+      enum command_id cmd = no_brace_command_accent_upper_case[i][0];
+      enum command_id upper_case_cmd = 
no_brace_command_accent_upper_case[i][1];
+      html_commands_data[cmd].upper_case_cmd = upper_case_cmd;
+    }
+
   for (i = 1; i < BUILTIN_CMD_NUMBER; i++)
     {
       if (builtin_command_data[i].flags & CF_block
diff --git a/tp/Texinfo/XS/convert/converter.c 
b/tp/Texinfo/XS/convert/converter.c
index 37308d0250..7d3ce3cfa6 100644
--- a/tp/Texinfo/XS/convert/converter.c
+++ b/tp/Texinfo/XS/convert/converter.c
@@ -40,6 +40,19 @@
 #include "unicode.h"
 #include "converter.h"
 
+/* associate lower case no brace accent command to the upper case
+   corresponding commands */
+enum command_id no_brace_command_accent_upper_case[][2] = {
+  {CM_aa, CM_AA},
+  {CM_ae, CM_AE},
+  {CM_dh, CM_DH},
+  {CM_l, CM_L},
+  {CM_o, CM_O},
+  {CM_oe, CM_OE},
+  {CM_th, CM_TH},
+  {0, 0},
+};
+
 static CONVERTER **converter_list;
 static size_t converter_number;
 static size_t converter_space;
diff --git a/tp/Texinfo/XS/convert/converter.h 
b/tp/Texinfo/XS/convert/converter.h
index 90c52d0fcc..a9a3730368 100644
--- a/tp/Texinfo/XS/convert/converter.h
+++ b/tp/Texinfo/XS/convert/converter.h
@@ -73,6 +73,7 @@ typedef struct FLOAT_CAPTION_PREPENDED_ELEMENT {
     ELEMENT *prepended;
 } FLOAT_CAPTION_PREPENDED_ELEMENT;
 
+extern enum command_id no_brace_command_accent_upper_case[][2];
 
 CONVERTER *retrieve_converter (int converter_descriptor);
 size_t new_converter(void);



reply via email to

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