texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: * tp/Texinfo/XS/misc.c (xs_parse_texi_regex): ret


From: Patrice Dumas
Subject: branch master updated: * tp/Texinfo/XS/misc.c (xs_parse_texi_regex): return early if there is a NUL in the string, and do not set any output variable.
Date: Sun, 01 Dec 2024 16:40:39 -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 9904ded304 * tp/Texinfo/XS/misc.c (xs_parse_texi_regex): return early 
if there is a NUL in the string, and do not set any output variable.
9904ded304 is described below

commit 9904ded30414182aba0754ff74e8e4be4fe71dca
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Sun Dec 1 22:40:28 2024 +0100

    * tp/Texinfo/XS/misc.c (xs_parse_texi_regex): return early if there is
    a NUL in the string, and do not set any output variable.
    
    * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line): handle
    better NUL characters in $line, which can happen with
    _parse_texi_regex XS override.
---
 ChangeLog                 | 11 ++++++++++-
 tp/Texinfo/ParserNonXS.pm | 10 ++++++++++
 tp/Texinfo/XS/misc.c      |  5 +++++
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 9190518f9f..1eed014590 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,8 +1,17 @@
+2024-12-01  Patrice Dumas  <pertusus@free.fr>
+
+       * tp/Texinfo/XS/misc.c (xs_parse_texi_regex): return early if there is
+       a NUL in the string, and do not set any output variable.
+
+       * tp/Texinfo/ParserNonXS.pm (_process_remaining_on_line): handle
+       better NUL characters in $line, which can happen with
+       _parse_texi_regex XS override.
+
 2024-12-01  Patrice Dumas  <pertusus@free.fr>
 
        * tp/Texinfo/ParserNonXS.pm (_end_line_starting_block)
        (_process_remaining_on_line): check if a command name is defined
-       instead of testing if it is true, to catche the case of a command name
+       instead of testing if it is true, to catch the case of a command name
        or alias being '0'.
 
        * tp/Makefile.tres, tp/t/02coverage.t (command_zero), tp/t/58alias.t
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 2d88322efc..e1997e3729 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -7641,6 +7641,16 @@ sub _process_remaining_on_line($$$$)
           if ($self->{'conf'}->{'DEBUG'});
     if ($line =~ s/^(\n)//) {
       $current = _merge_text($self, $current, $1);
+    } elsif ($line =~ s/^\0+//) {
+      # NOTE this does not happen with _parse_texi_regex Perl implementation
+      # as a NUL byte ends up in misc_text.  The XS override cannot pass
+      # NUL as strings and cannot therefore put NUL in misc_text, therefore
+      # if there are NUL in string we end up here.
+      # Also we could have called _merge_text instead of discarding the NUL
+      # to be more like _parse_texi_regex Perl, but it should not matter as
+      # NUL in input is invalid.  In addition the XS Parser, in general, does
+      # something different with NUL.
+      return ($current, $line, $source_info, $retval);
     } else {
       $self->_bug_message("Should be at end of line but have `$line'",
                           $source_info, $current);
diff --git a/tp/Texinfo/XS/misc.c b/tp/Texinfo/XS/misc.c
index f6bc46c7dc..f199feb3ce 100644
--- a/tp/Texinfo/XS/misc.c
+++ b/tp/Texinfo/XS/misc.c
@@ -320,6 +320,11 @@ void xs_parse_texi_regex (char *text,
     {
       *comma = ",";
     }
+  /* return now, otherwise strchr just below would match */
+  else if (!*text)
+    {
+      return;
+    }
   else if (strchr (":\t.", *text))
     {
       static char a[2];



reply via email to

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