texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/XS/main/call_perl_function.c (call_n


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/main/call_perl_function.c (call_nodenamenormalization_unicode_to_transliterate) (call_latex_convert_to_latex_math): convert returned strings to UTF-8. Use strndup instead of strdup using the len set by SvPV* functions.
Date: Sat, 13 Jan 2024 17:48:51 -0500

This is an automated email from the git hooks/post-receive script.

pertusus pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new 6c6fb36ed9 * tp/Texinfo/XS/main/call_perl_function.c 
(call_nodenamenormalization_unicode_to_transliterate) 
(call_latex_convert_to_latex_math): convert returned strings to UTF-8. Use 
strndup instead of strdup using the len set by SvPV* functions.
6c6fb36ed9 is described below

commit 6c6fb36ed9b7b1447d745f6735cd30d15597e9da
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sat Jan 13 23:48:54 2024 +0100

    * tp/Texinfo/XS/main/call_perl_function.c
    (call_nodenamenormalization_unicode_to_transliterate)
    (call_latex_convert_to_latex_math): convert returned strings to UTF-8.
    Use strndup instead of strdup using the len set by SvPV* functions.
    
    * tp/Texinfo/Convert/Texinfo.pm: move functions around.
    
    * tp/Texinfo/XS/convert/ConvertXS.xs (plain_texinfo_convert_tree): set
    warning string get_sv_tree_document argument.
---
 ChangeLog                               | 12 +++++++++
 tp/Texinfo/Convert/Texinfo.pm           | 43 ++++++++++++++++-----------------
 tp/Texinfo/XS/convert/ConvertXS.xs      |  4 +--
 tp/Texinfo/XS/main/call_perl_function.c |  7 +++---
 4 files changed, 38 insertions(+), 28 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c2903d9068..3e8ad598df 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2024-01-13  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/main/call_perl_function.c
+       (call_nodenamenormalization_unicode_to_transliterate)
+       (call_latex_convert_to_latex_math): convert returned strings to UTF-8.
+       Use strndup instead of strdup using the len set by SvPV* functions.
+
+       * tp/Texinfo/Convert/Texinfo.pm: move functions around.
+
+       * tp/Texinfo/XS/convert/ConvertXS.xs (plain_texinfo_convert_tree): set
+       warning string get_sv_tree_document argument.
+
 2024-01-13  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/XS/Makefile.am (ConvertXS_la_SOURCES),
diff --git a/tp/Texinfo/Convert/Texinfo.pm b/tp/Texinfo/Convert/Texinfo.pm
index 0980dbb48e..3d3f221489 100644
--- a/tp/Texinfo/Convert/Texinfo.pm
+++ b/tp/Texinfo/Convert/Texinfo.pm
@@ -97,6 +97,27 @@ for my $a (@ignored_types) {
   $ignored_types{$a} = 1;
 }
 
+# This is used if the document is available for XS, but XS is not
+# used (most likely $TEXINFO_XS_CONVERT is 0).
+sub _convert_tree_with_XS($)
+{
+  my $root = shift;
+
+  return _convert_to_texinfo($root);
+}
+
+sub _convert_to_texinfo($);
+# expand a tree to the corresponding texinfo.
+sub convert_to_texinfo($)
+{
+  my $element = shift;
+
+  if (defined($element->{'tree_document_descriptor'})) {
+    return _convert_tree_with_XS($element);
+  }
+  return _convert_to_texinfo($element);
+}
+
 # TODO document?
 sub link_element_to_texi($)
 {
@@ -182,28 +203,6 @@ sub root_heading_command_to_texinfo($)
 # Following subroutines deal with transforming a texinfo tree into texinfo
 # text.  Should give the text that was used parsed, except for a few cases.
 
-# This is used if the document is available for XS, but XS is not
-# used (most likely $TEXINFO_XS_CONVERT is 0).
-sub _convert_tree_with_XS($)
-{
-  my $root = shift;
-
-  return _convert_to_texinfo($root);
-}
-
-# expand a tree to the corresponding texinfo.
-sub convert_to_texinfo($);
-sub convert_to_texinfo($)
-{
-  my $element = shift;
-
-  if (defined($element->{'tree_document_descriptor'})) {
-    return _convert_tree_with_XS($element);
-  }
-  return _convert_to_texinfo($element);
-}
-
-sub _convert_to_texinfo($);
 sub _convert_to_texinfo($)
 {
   my $element = shift;
diff --git a/tp/Texinfo/XS/convert/ConvertXS.xs 
b/tp/Texinfo/XS/convert/ConvertXS.xs
index f58f0511da..baa63fb51c 100644
--- a/tp/Texinfo/XS/convert/ConvertXS.xs
+++ b/tp/Texinfo/XS/convert/ConvertXS.xs
@@ -288,8 +288,8 @@ plain_texinfo_convert_tree (SV *tree_in)
     PREINIT:
         DOCUMENT *document = 0;
     CODE:
-        /* FIXME warning/error if not found? */
-        document = get_sv_tree_document (tree_in, 0);
+        /* caller checks that there is a descriptor */
+        document = get_sv_tree_document (tree_in, 
"plain_texinfo_convert_tree");
         if (document)
           {
             char *result = convert_to_texinfo (document->tree);
diff --git a/tp/Texinfo/XS/main/call_perl_function.c 
b/tp/Texinfo/XS/main/call_perl_function.c
index 3b41785aff..0c2fe9e87d 100644
--- a/tp/Texinfo/XS/main/call_perl_function.c
+++ b/tp/Texinfo/XS/main/call_perl_function.c
@@ -69,9 +69,8 @@ call_nodenamenormalization_unicode_to_transliterate (char 
*text)
     croak("_unicode_to_transliterate should return 1 item\n");
 
   result_sv = POPs;
-  /* FIXME encoding */
-  result_ret = SvPV (result_sv, len);
-  result = strdup (result_ret);
+  result_ret = SvPVutf8 (result_sv, len);
+  result = strndup (result_ret, len);
 
   PUTBACK;
 
@@ -142,7 +141,7 @@ call_latex_convert_to_latex_math (CONVERTER *self, ELEMENT 
*element)
 
   result_sv = POPs;
   result_ret = SvPVutf8 (result_sv, len);
-  result = strdup (result_ret);
+  result = strndup (result_ret, len);
 
   PUTBACK;
 



reply via email to

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