texinfo-commits
[Top][All Lists]
Advanced

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

[8293] parsetexi free global command arrays


From: gavinsmith0123
Subject: [8293] parsetexi free global command arrays
Date: Tue, 16 Oct 2018 17:24:14 -0400 (EDT)

Revision: 8293
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=8293
Author:   gavin
Date:     2018-10-16 17:24:14 -0400 (Tue, 16 Oct 2018)
Log Message:
-----------
parsetexi free global command arrays

Modified Paths:
--------------
    trunk/tp/Texinfo/XS/parsetexi/handle_commands.c
    trunk/tp/Texinfo/XS/parsetexi/handle_commands.h
    trunk/tp/Texinfo/XS/parsetexi/parser.c
    trunk/tp/Texinfo/XS/parsetexi/parser.h

Modified: trunk/tp/Texinfo/XS/parsetexi/handle_commands.c
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/handle_commands.c     2018-10-16 20:49:34 UTC 
(rev 8292)
+++ trunk/tp/Texinfo/XS/parsetexi/handle_commands.c     2018-10-16 21:24:14 UTC 
(rev 8293)
@@ -81,124 +81,6 @@
   return after_paragraph;
 }
 
-// 1056
-/* Record the information from a command of global effect.
-   TODO: Could we scrap the first argument and use CURRENT->cmd? */
-int
-register_global_command (enum command_id cmd, ELEMENT *current)
-{
-  // TODO: Why even give @author this flag in the first place?
-  if (cmd != CM_author && (command_data(cmd).flags & CF_global))
-    {
-      if (!current->line_nr.line_nr)
-        current->line_nr = line_nr;
-      switch (cmd)
-        {
-#define GLOBAL_CASE(cmx) \
-        case CM_##cmx:   \
-          add_to_contents_as_array (&global_info.cmx, current); \
-          break
-
-        case CM_footnote:
-          add_to_contents_as_array (&global_info.footnotes, current);
-          break;
-
-        GLOBAL_CASE(hyphenation);
-        GLOBAL_CASE(insertcopying);
-        GLOBAL_CASE(printindex);
-        GLOBAL_CASE(subtitle);
-        GLOBAL_CASE(titlefont);
-        GLOBAL_CASE(listoffloats);
-        GLOBAL_CASE(detailmenu);
-        GLOBAL_CASE(part);
-
-        /* from Common.pm %document_settable_at_commands */
-        GLOBAL_CASE(allowcodebreaks);
-        GLOBAL_CASE(clickstyle);
-        GLOBAL_CASE(codequotebacktick);
-        GLOBAL_CASE(codequoteundirected);
-        GLOBAL_CASE(contents);
-        GLOBAL_CASE(deftypefnnewline);
-        GLOBAL_CASE(documentencoding);
-        GLOBAL_CASE(documentlanguage);
-        GLOBAL_CASE(exampleindent);
-        GLOBAL_CASE(firstparagraphindent);
-        GLOBAL_CASE(frenchspacing);
-        GLOBAL_CASE(headings);
-        GLOBAL_CASE(kbdinputstyle);
-        GLOBAL_CASE(paragraphindent);
-        GLOBAL_CASE(shortcontents);
-        GLOBAL_CASE(urefbreakstyle);
-        GLOBAL_CASE(xrefautomaticsectiontitle);
-#undef GLOBAL_CASE
-        }
-      /* TODO: Check if all of these are necessary. */
-      return 1;
-    }
-  else if ((command_data(cmd).flags & CF_global_unique))
-    {
-      ELEMENT **where = 0;
-
-      if (cmd == CM_shortcontents)
-        cmd = CM_summarycontents;
-      if (!current->line_nr.line_nr)
-        current->line_nr = line_nr;
-      switch (cmd)
-        {
-          extern int input_number;
-        case CM_setfilename:
-          /* Check if we are inside an @include, and if so, do nothing. */
-          if (top_file_index () > 0)
-            break;
-          where = &global_info.setfilename;
-          break;
-
-#define GLOBAL_UNIQUE_CASE(cmd) \
-        case CM_##cmd: \
-          where = &global_info.cmd; \
-          break
-
-        GLOBAL_UNIQUE_CASE(settitle);
-        GLOBAL_UNIQUE_CASE(copying);
-        GLOBAL_UNIQUE_CASE(titlepage);
-        GLOBAL_UNIQUE_CASE(top);
-        GLOBAL_UNIQUE_CASE(documentdescription);
-        GLOBAL_UNIQUE_CASE(novalidate);
-        GLOBAL_UNIQUE_CASE(validatemenus);
-        GLOBAL_UNIQUE_CASE(pagesizes);
-        GLOBAL_UNIQUE_CASE(fonttextsize);
-        GLOBAL_UNIQUE_CASE(footnotestyle);
-        GLOBAL_UNIQUE_CASE(setchapternewpage);
-        GLOBAL_UNIQUE_CASE(everyheading);
-        GLOBAL_UNIQUE_CASE(everyfooting);
-        GLOBAL_UNIQUE_CASE(evenheading);
-        GLOBAL_UNIQUE_CASE(evenfooting);
-        GLOBAL_UNIQUE_CASE(oddheading);
-        GLOBAL_UNIQUE_CASE(oddfooting);
-        GLOBAL_UNIQUE_CASE(everyheadingmarks);
-        GLOBAL_UNIQUE_CASE(everyfootingmarks);
-        GLOBAL_UNIQUE_CASE(evenheadingmarks);
-        GLOBAL_UNIQUE_CASE(oddheadingmarks);
-        GLOBAL_UNIQUE_CASE(evenfootingmarks);
-        GLOBAL_UNIQUE_CASE(oddfootingmarks);
-        GLOBAL_UNIQUE_CASE(shorttitlepage);
-        GLOBAL_UNIQUE_CASE(title);
-#undef GLOBAL_UNIQUE_CASE
-        /* NOTE: Same list in api.c:build_global_info2. */
-        }
-      if (where)
-        {
-          if (*where)
-            line_warn ("multiple @%s", command_name(cmd));
-          else
-            *where = current;
-        }
-      return 1;
-    }
-
-  return 0;
-}
-
 /* Line 4289 */
 /* STATUS is set to 1 if we should get a new line after this,
    2 if we should stop processing completely. */

Modified: trunk/tp/Texinfo/XS/parsetexi/handle_commands.h
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/handle_commands.h     2018-10-16 20:49:34 UTC 
(rev 8292)
+++ trunk/tp/Texinfo/XS/parsetexi/handle_commands.h     2018-10-16 21:24:14 UTC 
(rev 8293)
@@ -9,7 +9,6 @@
                                enum command_id cmd_id,
                                enum command_id invalid_parent);
 int check_no_text (ELEMENT *current);
-int register_global_command (enum command_id cmd, ELEMENT *current);
 
 void clear_expanded_formats (void);
 void add_expanded_format (char *format);

Modified: trunk/tp/Texinfo/XS/parsetexi/parser.c
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/parser.c      2018-10-16 20:49:34 UTC (rev 
8292)
+++ trunk/tp/Texinfo/XS/parsetexi/parser.c      2018-10-16 21:24:14 UTC (rev 
8293)
@@ -123,6 +123,124 @@
   global_documentlanguage = value;
 }
 
+// 1056
+/* Record the information from a command of global effect.
+   TODO: Could we scrap the first argument and use CURRENT->cmd? */
+int
+register_global_command (enum command_id cmd, ELEMENT *current)
+{
+  if (command_data(cmd).flags & CF_global)
+    {
+      if (!current->line_nr.line_nr)
+        current->line_nr = line_nr;
+      switch (cmd)
+        {
+#define GLOBAL_CASE(cmx) \
+        case CM_##cmx:   \
+          add_to_contents_as_array (&global_info.cmx, current); \
+          break
+
+        case CM_footnote:
+          add_to_contents_as_array (&global_info.footnotes, current);
+          break;
+
+        GLOBAL_CASE(hyphenation);
+        GLOBAL_CASE(insertcopying);
+        GLOBAL_CASE(printindex);
+        GLOBAL_CASE(subtitle);
+        GLOBAL_CASE(titlefont);
+        GLOBAL_CASE(listoffloats);
+        GLOBAL_CASE(detailmenu);
+        GLOBAL_CASE(part);
+
+        /* from Common.pm %document_settable_at_commands */
+        GLOBAL_CASE(allowcodebreaks);
+        GLOBAL_CASE(clickstyle);
+        GLOBAL_CASE(codequotebacktick);
+        GLOBAL_CASE(codequoteundirected);
+        GLOBAL_CASE(contents);
+        GLOBAL_CASE(deftypefnnewline);
+        GLOBAL_CASE(documentencoding);
+        GLOBAL_CASE(documentlanguage);
+        GLOBAL_CASE(exampleindent);
+        GLOBAL_CASE(firstparagraphindent);
+        GLOBAL_CASE(frenchspacing);
+        GLOBAL_CASE(headings);
+        GLOBAL_CASE(kbdinputstyle);
+        GLOBAL_CASE(paragraphindent);
+        GLOBAL_CASE(shortcontents);
+        GLOBAL_CASE(urefbreakstyle);
+        GLOBAL_CASE(xrefautomaticsectiontitle);
+#undef GLOBAL_CASE
+        }
+      /* TODO: Check if all of these are necessary. */
+      return 1;
+    }
+  else if ((command_data(cmd).flags & CF_global_unique))
+    {
+      ELEMENT **where = 0;
+
+      if (cmd == CM_shortcontents)
+        cmd = CM_summarycontents;
+      if (!current->line_nr.line_nr)
+        current->line_nr = line_nr;
+      switch (cmd)
+        {
+          extern int input_number;
+        case CM_setfilename:
+          /* Check if we are inside an @include, and if so, do nothing. */
+          if (top_file_index () > 0)
+            break;
+          where = &global_info.setfilename;
+          break;
+
+#define GLOBAL_UNIQUE_CASE(cmd) \
+        case CM_##cmd: \
+          where = &global_info.cmd; \
+          break
+
+        GLOBAL_UNIQUE_CASE(settitle);
+        GLOBAL_UNIQUE_CASE(copying);
+        GLOBAL_UNIQUE_CASE(titlepage);
+        GLOBAL_UNIQUE_CASE(top);
+        GLOBAL_UNIQUE_CASE(documentdescription);
+        GLOBAL_UNIQUE_CASE(novalidate);
+        GLOBAL_UNIQUE_CASE(validatemenus);
+        GLOBAL_UNIQUE_CASE(pagesizes);
+        GLOBAL_UNIQUE_CASE(fonttextsize);
+        GLOBAL_UNIQUE_CASE(footnotestyle);
+        GLOBAL_UNIQUE_CASE(setchapternewpage);
+        GLOBAL_UNIQUE_CASE(everyheading);
+        GLOBAL_UNIQUE_CASE(everyfooting);
+        GLOBAL_UNIQUE_CASE(evenheading);
+        GLOBAL_UNIQUE_CASE(evenfooting);
+        GLOBAL_UNIQUE_CASE(oddheading);
+        GLOBAL_UNIQUE_CASE(oddfooting);
+        GLOBAL_UNIQUE_CASE(everyheadingmarks);
+        GLOBAL_UNIQUE_CASE(everyfootingmarks);
+        GLOBAL_UNIQUE_CASE(evenheadingmarks);
+        GLOBAL_UNIQUE_CASE(oddheadingmarks);
+        GLOBAL_UNIQUE_CASE(evenfootingmarks);
+        GLOBAL_UNIQUE_CASE(oddfootingmarks);
+        GLOBAL_UNIQUE_CASE(shorttitlepage);
+        GLOBAL_UNIQUE_CASE(title);
+#undef GLOBAL_UNIQUE_CASE
+        /* NOTE: Same list in api.c:build_global_info2 and wipe_global_info. */
+        }
+      if (where)
+        {
+          if (*where)
+            line_warn ("multiple @%s", command_name(cmd));
+          else
+            *where = current;
+        }
+      return 1;
+    }
+
+  return 0;
+}
+
+
 void
 wipe_global_info (void)
 {
@@ -129,6 +247,37 @@
   global_clickstyle = "arrow";
   global_kbdinputstyle = kbd_distinct;
   global_documentlanguage = "";
+
+#define GLOBAL_CASE(cmx) \
+  free (global_info.cmx.contents.list)
+
+  GLOBAL_CASE(hyphenation);
+  GLOBAL_CASE(insertcopying);
+  GLOBAL_CASE(printindex);
+  GLOBAL_CASE(subtitle);
+  GLOBAL_CASE(titlefont);
+  GLOBAL_CASE(listoffloats);
+  GLOBAL_CASE(detailmenu);
+  GLOBAL_CASE(part);
+  GLOBAL_CASE(allowcodebreaks);
+  GLOBAL_CASE(clickstyle);
+  GLOBAL_CASE(codequotebacktick);
+  GLOBAL_CASE(codequoteundirected);
+  GLOBAL_CASE(contents);
+  GLOBAL_CASE(deftypefnnewline);
+  GLOBAL_CASE(documentencoding);
+  GLOBAL_CASE(documentlanguage);
+  GLOBAL_CASE(exampleindent);
+  GLOBAL_CASE(firstparagraphindent);
+  GLOBAL_CASE(frenchspacing);
+  GLOBAL_CASE(headings);
+  GLOBAL_CASE(kbdinputstyle);
+  GLOBAL_CASE(paragraphindent);
+  GLOBAL_CASE(shortcontents);
+  GLOBAL_CASE(urefbreakstyle);
+  GLOBAL_CASE(xrefautomaticsectiontitle);
+
+#undef GLOBAL_CASE
   memset (&global_info, 0, sizeof (global_info));
 }
 

Modified: trunk/tp/Texinfo/XS/parsetexi/parser.h
===================================================================
--- trunk/tp/Texinfo/XS/parsetexi/parser.h      2018-10-16 20:49:34 UTC (rev 
8292)
+++ trunk/tp/Texinfo/XS/parsetexi/parser.h      2018-10-16 21:24:14 UTC (rev 
8293)
@@ -86,6 +86,7 @@
 enum kbd_enum {kbd_none, kbd_code, kbd_example, kbd_distinct };
 extern enum kbd_enum global_kbdinputstyle;
 
+int register_global_command (enum command_id cmd, ELEMENT *current);
 void wipe_global_info (void);
 
 #include "macro.h"




reply via email to

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