texinfo-commits
[Top][All Lists]
Advanced

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

[no subject]


From: Patrice Dumas
Date: Thu, 14 Nov 2024 16:50:19 -0500 (EST)

branch: master
commit 73762370b058daa849e92122b5e04ebe0ba19665
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Thu Nov 14 22:26:39 2024 +0100

    * tp/Texinfo/XS/XSParagraph.xs (xspara_new), tp/Texinfo/XS/xspara.c
    (SET_CONF), tp/Texinfo/XS/xspara.h (SET_CONF): instead of passing all
    the configuration variables in one function, setup a function per
    variable using the SET_CONF macro in xspara.c and xspara.h.  Remove
    xspara_init_state.
---
 ChangeLog                    |  8 ++++++++
 tp/Texinfo/XS/XSParagraph.xs | 22 +-------------------
 tp/Texinfo/XS/xspara.c       | 46 ++++++++++++++++++++----------------------
 tp/Texinfo/XS/xspara.h       | 48 +++++++++++++++++++++++++++++++++++++++-----
 4 files changed, 74 insertions(+), 50 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f7a8cf60fe..f1b02431f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,14 @@
        in the sources which can cause problems on some unusual platforms.
        Report from Eli.
 
+2024-11-14  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/XSParagraph.xs (xspara_new), tp/Texinfo/XS/xspara.c
+       (SET_CONF), tp/Texinfo/XS/xspara.h (SET_CONF): instead of passing all
+       the configuration variables in one function, setup a function per
+       variable using the SET_CONF macro in xspara.c and xspara.h.  Remove
+       xspara_init_state.
+
 2024-11-14  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/convert/convert_html.c (html_do_js_files): set
diff --git a/tp/Texinfo/XS/XSParagraph.xs b/tp/Texinfo/XS/XSParagraph.xs
index 3a85df5f73..ea66c61b57 100644
--- a/tp/Texinfo/XS/XSParagraph.xs
+++ b/tp/Texinfo/XS/XSParagraph.xs
@@ -37,24 +37,9 @@ xspara_new (class, ...)
         HV *conf = 0;
         int id;
         SV **val;
-        int end_sentence = -1;
-        int max = -1;
-        int indent_length = -1;
-        int indent_length_next = -1;
-        int counter = -1;
-        int word_counter = -1;
-        int lines_counter = -1;
-        int end_line_count = -1;
-        int no_break = -1;
-        int ignore_columns = -1;
-        int keep_end_lines = -1;
-        int frenchspacing = -1;
-        int unfilled = -1;
-        int no_final_newline = -1;
-        int add_final_space = -1;
 #define FETCH(key) hv_fetch (conf, key, strlen (key), 0)
 #define FETCH_INT(variable) { val = FETCH(#variable); \
-                               if (val) { variable = SvIV (*val); } }
+                if (val) { xspara_set_conf_##variable (SvIV (*val)); } }
     CODE:
         items--;
         if (items > 0)
@@ -81,11 +66,6 @@ xspara_new (class, ...)
             FETCH_INT(unfilled)
             FETCH_INT(no_final_newline)
             FETCH_INT(add_final_space)
-            xspara_init_state (end_sentence, max, indent_length,
-                               indent_length_next, counter, word_counter,
-                               lines_counter, end_line_count, no_break,
-                               ignore_columns, keep_end_lines, frenchspacing,
-                               unfilled, no_final_newline, add_final_space);
           }
 
         /* Create an integer, which the other functions
diff --git a/tp/Texinfo/XS/xspara.c b/tp/Texinfo/XS/xspara.c
index b5b0a6cf7d..6041311dcb 100644
--- a/tp/Texinfo/XS/xspara.c
+++ b/tp/Texinfo/XS/xspara.c
@@ -199,32 +199,30 @@ xspara_set_state (int paragraph)
   xspara__switch_state (paragraph);
 }
 
-#define SET_CONF(variable) \
-  if (variable != -1) {state.variable = variable;}
+/* set a function to set the state for each of the possible configuration
+   variables */
 
-void
-xspara_init_state (int end_sentence, int max, int indent_length,
-                   int indent_length_next, int counter, int word_counter,
-                   int lines_counter, int end_line_count, int no_break,
-                   int ignore_columns, int keep_end_lines, int frenchspacing,
-                   int unfilled, int no_final_newline, int add_final_space)
-{
-  SET_CONF(end_sentence)
-  SET_CONF(max)
-  SET_CONF(indent_length)
-  SET_CONF(indent_length_next)
-  SET_CONF(counter)
-  SET_CONF(word_counter)
-  SET_CONF(lines_counter)
-  SET_CONF(end_line_count)
-  SET_CONF(no_break)
-  SET_CONF(ignore_columns)
-  SET_CONF(keep_end_lines)
-  SET_CONF(frenchspacing)
-  SET_CONF(unfilled)
-  SET_CONF(no_final_newline)
-  SET_CONF(add_final_space)
+#define SET_CONF(variable) \
+void xspara_set_conf_##variable (int variable) { \
+  state.variable = variable; \
 }
+
+SET_CONF(end_sentence)
+SET_CONF(max)
+SET_CONF(indent_length)
+SET_CONF(indent_length_next)
+SET_CONF(counter)
+SET_CONF(word_counter)
+SET_CONF(lines_counter)
+SET_CONF(end_line_count)
+SET_CONF(no_break)
+SET_CONF(ignore_columns)
+SET_CONF(keep_end_lines)
+SET_CONF(frenchspacing)
+SET_CONF(unfilled)
+SET_CONF(no_final_newline)
+SET_CONF(add_final_space)
+
 #undef SET_CONF
 
 /************************************************************************/
diff --git a/tp/Texinfo/XS/xspara.h b/tp/Texinfo/XS/xspara.h
index 4cc260a27a..5e06ea40bb 100644
--- a/tp/Texinfo/XS/xspara.h
+++ b/tp/Texinfo/XS/xspara.h
@@ -1,11 +1,47 @@
+/* xspara.h - declarations for xspara.c */
+#ifndef XSPARA_H
+#define XSPARA_H
+
+/* 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 "main/text.h"
 
 int xspara_new (void);
-void xspara_init_state (int end_sentence, int max, int indent_length,
-                   int indent_length_next, int counter, int word_counter,
-                   int lines_counter, int end_line_count, int no_break,
-                   int ignore_columns, int keep_end_lines, int french_spacing,
-                   int unfilled, int no_final_newline, int add_final_space);
+
+#define SET_CONF(variable) \
+void xspara_set_conf_##variable (int variable);
+
+SET_CONF(end_sentence)
+SET_CONF(max)
+SET_CONF(indent_length)
+SET_CONF(indent_length_next)
+SET_CONF(counter)
+SET_CONF(word_counter)
+SET_CONF(lines_counter)
+SET_CONF(end_line_count)
+SET_CONF(no_break)
+SET_CONF(ignore_columns)
+SET_CONF(keep_end_lines)
+SET_CONF(frenchspacing)
+SET_CONF(unfilled)
+SET_CONF(no_final_newline)
+SET_CONF(add_final_space)
+
+#undef SET_CONF
+
 void xspara_set_state (int paragraph);
 TEXT xspara_add_next (char *, int, int transparent);
 TEXT xspara_add_text (char *, int);
@@ -21,3 +57,5 @@ void xspara_remove_end_sentence (void);
 void xspara_add_end_sentence (int value);
 int xspara_end_line_count (void);
 int xspara_counter (void);
+
+#endif



reply via email to

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