texinfo-commits
[Top][All Lists]
Advanced

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

branch master updated: Nuke obsolete XS overrides


From: Gavin D. Smith
Subject: branch master updated: Nuke obsolete XS overrides
Date: Mon, 27 Feb 2023 14:25:13 -0500

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

gavin pushed a commit to branch master
in repository texinfo.

The following commit(s) were added to refs/heads/master by this push:
     new b42fb944bc Nuke obsolete XS overrides
b42fb944bc is described below

commit b42fb944bc5a1b41e24f7131414cd1bc0e331445
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Mon Feb 27 19:25:04 2023 +0000

    Nuke obsolete XS overrides
    
    * tp/Texinfo/XS/MiscXS.xs, tp/Texinfo/XS/misc.c
    (xs_abort_empty_line, xs_merge_text): Remove.
    * tp/Texinfo/ParserNonXS.pm: Remove commented-out code using these.
    
    These would only be used in unusual cases when the XS parser
    couldn't be used but the other XS overrides could still be loaded.
    It means that there are now only two implementations of these
    functions rather than three.  The removed implementations had not
    been changed to match changes in the other two, and it would be
    laborious to keep these up to date.
---
 ChangeLog                 |  15 ++
 tp/Texinfo/ParserNonXS.pm |   7 -
 tp/Texinfo/XS/MiscXS.xs   |  24 +---
 tp/Texinfo/XS/misc.c      | 342 +---------------------------------------------
 tp/Texinfo/XS/miscxs.h    |   2 -
 5 files changed, 17 insertions(+), 373 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b9c01dfc24..3521a9c890 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2023-02-27  Gavin Smith <gavinsmith0123@gmail.com>
+
+       Nuke obsolete XS overrides
+
+       * tp/Texinfo/XS/MiscXS.xs, tp/Texinfo/XS/misc.c
+       (xs_abort_empty_line, xs_merge_text): Remove.
+       * tp/Texinfo/ParserNonXS.pm: Remove commented-out code using these.
+
+       These would only be used in unusual cases when the XS parser
+       couldn't be used but the other XS overrides could still be loaded.
+       It means that there are now only two implementations of these
+       functions rather than three.  The removed implementations had not
+       been changed to match changes in the other two, and it would be
+       laborious to keep these up to date.
+
 2023-02-27  Gavin Smith <gavinsmith0123@gmail.com>
 
        * tp/Texinfo/Convert/Plaintext.pm (%defaults, converter_initialize):
diff --git a/tp/Texinfo/ParserNonXS.pm b/tp/Texinfo/ParserNonXS.pm
index 1545b23981..f9b2406772 100644
--- a/tp/Texinfo/ParserNonXS.pm
+++ b/tp/Texinfo/ParserNonXS.pm
@@ -96,13 +96,6 @@ use vars qw($VERSION @ISA @EXPORT_OK %EXPORT_TAGS);
 our $module_loaded = 0;
 sub import {
   if (!$module_loaded) {
-    # not loaded because it uses the abort_empty_line XS override
-    # TODO and not up to date with the changes for source marks
-    #Texinfo::XSLoader::override ("Texinfo::Parser::_merge_text",
-    #  "Texinfo::MiscXS::merge_text");
-    # TODO not up to date with the changes for source marks
-    #Texinfo::XSLoader::override ("Texinfo::Parser::_abort_empty_line",
-    #  "Texinfo::MiscXS::abort_empty_line");
     Texinfo::XSLoader::override ("Texinfo::Parser::_parse_texi_regex",
       "Texinfo::MiscXS::parse_texi_regex");
     $module_loaded = 1;
diff --git a/tp/Texinfo/XS/MiscXS.xs b/tp/Texinfo/XS/MiscXS.xs
index 53daf92df3..e4849b51f1 100644
--- a/tp/Texinfo/XS/MiscXS.xs
+++ b/tp/Texinfo/XS/MiscXS.xs
@@ -13,7 +13,7 @@
 
 MODULE = Texinfo::MiscXS  PACKAGE = Texinfo::MiscXS  PREFIX = xs_
 
-#  Copyright 2016-2022 Free Software Foundation, Inc.
+#  Copyright 2016-2023 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
@@ -30,28 +30,6 @@ MODULE = Texinfo::MiscXS  PACKAGE = Texinfo::MiscXS  PREFIX 
= xs_
 
 PROTOTYPES: DISABLE
 
-int
-xs_abort_empty_line (self, current, ...)
-     HV *self
-     HV *current
-PREINIT:
-     SV *additional_text = 0;
-CODE:
-     items -= 2;
-     if (items > 0 && SvOK(ST(2)))
-       {
-         additional_text = ST(2);
-       }
-     RETVAL = xs_abort_empty_line (self, current, additional_text);
-OUTPUT:
-     RETVAL
-
-HV *
-xs_merge_text (self, current, text_in)
-     HV *self
-     HV *current
-     SV *text_in
-
 SV *
 xs_process_text (text_in)
      SV *text_in
diff --git a/tp/Texinfo/XS/misc.c b/tp/Texinfo/XS/misc.c
index dfac8665ca..d81725ded1 100644
--- a/tp/Texinfo/XS/misc.c
+++ b/tp/Texinfo/XS/misc.c
@@ -1,4 +1,4 @@
-/* Copyright 2010-2022 Free Software Foundation, Inc.
+/* Copyright 2010-2023 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
@@ -45,346 +45,6 @@
 
 const char *whitespace_chars = " \t\f\v\r\n";
 
-/* currently not used as it is not up to date with the changes
-   for source marks */
-int
-xs_abort_empty_line (HV *self, HV *current, SV *additional_spaces_in)
-{
-  char *additional_spaces;
-  AV *contents_array;
-  SV **svp;
-  int contents_num;
-  HV *spaces_elt;
-
-  char *type;
-  SV *existing_text_sv;
-
-  dTHX;
-
-  /* Get additional text in UTF-8. */
-  if (additional_spaces_in)
-    {
-      STRLEN len;
-      static char *new_string;
-      additional_spaces = SvPV (additional_spaces_in, len);
-      if (!SvUTF8 (additional_spaces_in))
-        {
-          free (new_string);
-          new_string = bytes_to_utf8 (additional_spaces, &len);
-          additional_spaces = new_string;
-        }
-    }
-  else
-    additional_spaces = "";
-
-  svp = hv_fetch (current, "contents", strlen("contents"), 0);
-  if (!svp)
-    return 0;
-  contents_array = (AV *)SvRV(*svp);
-
-  contents_num = av_len(contents_array) + 1;
-  if (contents_num == 0)
-    return 0;
-
-  spaces_elt = (HV *) SvRV (*av_fetch (contents_array, contents_num - 1, 0));
-
-  svp = hv_fetch (spaces_elt, "type", strlen ("type"), 0);
-  if (!svp)
-    return 0;
-
-  type = SvPV_nolen (*svp);
-  if (!type)
-    return 0;
-
-  /* Must be one of these types to continue. */
-  if (strcmp (type, "empty_line")
-       && strcmp (type, "ignorable_spaces_after_command")
-       && strcmp (type, "internal_spaces_after_command")
-       && strcmp (type, "internal_spaces_before_argument")
-       && strcmp (type, "spaces_after_close_brace"))
-    {
-      return 0;
-    }
-  
-  //fprintf (stderr, "ABORT EMPTY\n");
-
-  svp = hv_fetch (spaces_elt, "text", strlen ("text"), 0);
-  if (!svp)
-    return 0; /* or create it? change last arg from 0 to 1 */
-  existing_text_sv = *svp;
-
-  /* Append the 'additional_spaces' argument. */
-  sv_utf8_upgrade (existing_text_sv);
-  sv_catpv (existing_text_sv, additional_spaces);
-
-  if (!*SvPV_nolen (existing_text_sv)) /* existing text is empty */
-    {
-      /* Remove spaces_elt */
-      av_pop (contents_array);
-      if (av_len(contents_array) + 1 == 0)
-        hv_delete (current, "contents", strlen ("contents"), G_DISCARD);
-    }
-  else if (!strcmp (type, "empty_line"))
-    {
-      char *current_type;
-      AV *context_stack;
-      SV *top_context_sv;
-      char *top_context;
-      int top_index;
-      
-      svp = hv_fetch (current, "type", strlen ("type"), 0);
-      if (!svp)
-        current_type = 0;
-      else
-        current_type = SvPV_nolen (*svp);
-
-      /* "Types with paragraphs".  Remove the type unless we are inside
-         one of these types. */
-      if (current_type
-          && strcmp (current_type, "before_item")
-          && strcmp (current_type, "before_node_section")
-          && strcmp (current_type, "document_root")
-          && strcmp (current_type, "brace_command_context"))
-        goto delete_type;
-
-      /* Check the context stack. */
-      svp = hv_fetch (self, "context_stack", strlen ("context_stack"), 0);
-      if (!svp)
-        goto delete_type; /* shouldn't happen */
-      context_stack = (AV *) SvRV (*svp);
-      top_index = av_len (context_stack);
-      if (top_index < 0)
-        goto delete_type; /* shouldn't happen */
-      svp = av_fetch (context_stack, top_index, 0);
-      if (!svp)
-        goto delete_type; /* shouldn't happen */
-      top_context_sv = *svp;
-      top_context = SvPV_nolen (top_context_sv);
-
-      /* Change type to "spaces_before_paragraph" unless we are in
-         one of these contexts. */
-      if (strcmp (top_context, "ct_math")
-          && strcmp (top_context, "ct_menu")
-          && strcmp (top_context, "ct_preformatted")
-          && strcmp (top_context, "ct_rawpreformatted")
-          && strcmp (top_context, "ct_def")
-          && strcmp (top_context, "ct_inlineraw"))
-        {
-          hv_store (spaces_elt, "type", strlen ("type"),
-                    newSVpv ("spaces_before_paragraph", 0), 0);
-        }
-      else
-        {
-delete_type:
-          hv_delete (spaces_elt, "type", strlen ("type"), G_DISCARD);
-        }
-    }
-  else if (!strcmp (type, "internal_spaces_after_command")
-           || !strcmp (type, "internal_spaces_before_argument"))
-    {
-      STRLEN len;
-      HV *owning_elt = 0;
-      HV *command_info = 0;
-      HV *test_extra = 0;
-      char *ptr;
-
-      /* Remove spaces_elt */
-      av_pop (contents_array);
-      if (av_len(contents_array) + 1 == 0)
-        hv_delete (current, "contents", strlen ("contents"), G_DISCARD);
-
-      /* add spaces to associated element info "spaces_before_argument" */
-      svp = hv_fetch (spaces_elt, "extra", strlen ("extra"), 0);
-      test_extra = (HV *) SvRV (*svp);
-      svp = hv_fetch (test_extra, "spaces_associated_command",
-                      strlen ("spaces_associated_command"), 0);
-      owning_elt = (HV *) SvRV (*svp);
-
-      svp = hv_fetch (owning_elt, "info", strlen ("info"), 0);
-      if (svp)
-        command_info = (HV *) SvRV (*svp);
-      else
-        {
-          command_info = newHV ();
-          hv_store (owning_elt, "info", strlen ("info"),
-                    newRV_inc((SV *)command_info), 0);
-        }
-
-      ptr = SvPV(existing_text_sv, len);
-      hv_store (command_info,
-                "spaces_before_argument",
-                strlen ("spaces_before_argument"),
-                newSVpv(ptr, len),
-                0);
-    }
-  return 1;
-}
-
-/* currently not used as it calls xs_abort_empty_line
-   and also because it is not up to date with the changes
-   for source marks (new merged_marks_element argument) */
-HV *
-xs_merge_text (HV *self, HV *current, SV *text_in)
-{
-  AV *contents_array;
-
-  int no_merge_with_following_text = 0;
-  char *text;
-  int leading_spaces;
-  SV *leading_spaces_sv = 0;
-  int call_ret;
-  SV *returned_sv;
-
-  SV *contents_ref;
-  int contents_num;
-  HV *last_elt;
-  SV *existing_text_sv;
-  char *existing_text;
-  SV **svp;
-
-  dTHX;
-
-  dSP;
-
-  /* Get text in UTF-8. */
-  {
-    STRLEN len;
-    static char *new_string;
-    text = SvPV (text_in, len);
-    if (!SvUTF8 (text_in))
-      {
-        free (new_string);
-        new_string = bytes_to_utf8 (text, &len);
-        text = new_string;
-      }
-  }
-
-  leading_spaces = strspn (text, whitespace_chars);
-  if (text[leading_spaces])
-    {
-      int contents_num;
-
-      if (leading_spaces > 0)
-        {
-          leading_spaces_sv = newSVpv (text, leading_spaces);
-        }
-
-      svp = hv_fetch (current, "contents", strlen ("contents"), 0);
-      if (svp)
-        {
-          contents_array = (AV *)SvRV(*svp);
-          
-          contents_num = av_len(contents_array) + 1;
-          if (contents_num > 0)
-            {
-              HV *last_elt;
-              char *type = 0;
-
-              last_elt = (HV *)
-                SvRV (*av_fetch (contents_array, contents_num - 1, 0));
-
-              svp = hv_fetch (last_elt, "type", strlen ("type"), 0);
-              if (svp)
-                type = SvPV_nolen (*svp);
-              if (type
-                  && (!strcmp (type, "ignorable_spaces_after_command")
-                      || !strcmp (type, "internal_spaces_after_command")
-                      || !strcmp (type, "internal_spaces_before_argument")
-                      || !strcmp (type, "spaces_after_close_brace")))
-                {
-                  no_merge_with_following_text = 1;
-                }
-            }
-        }
-
-      if (xs_abort_empty_line(self, current, leading_spaces_sv))
-        {
-          text += leading_spaces;
-        }
-
-      /************************/
-      /* See 'perlcall' man page. */
-      ENTER;
-      SAVETMPS;
-
-
-      PUSHMARK(SP);
-      XPUSHs(sv_2mortal(newRV_inc((SV *)self)));
-      XPUSHs(sv_2mortal(newRV_inc((SV *)current)));
-      PUTBACK;
-
-      call_ret = call_pv ("Texinfo::Parser::_begin_paragraph", G_SCALAR);
-
-      SPAGAIN;
-
-      returned_sv = POPs;
-
-      /************************/
-
-      if (returned_sv && SvRV(returned_sv))
-        {
-          current = (HV *)SvRV(returned_sv);
-        }
-
-      FREETMPS;
-      LEAVE;
-    }
-
-  svp = hv_fetch (current, "contents", strlen ("contents"), 0);
-  if (!svp)
-    {
-      contents_array = newAV ();
-      contents_ref = newRV_inc ((SV *) contents_array);
-      hv_store (current, "contents", strlen ("contents"),
-                contents_ref, 0);
-      /* fprintf (stderr, "NEW CONTENTS %p\n", contents_array); */
-      goto NEW_TEXT;
-    }
-  else
-    {
-      contents_ref = *svp;
-      contents_array = (AV *)SvRV(contents_ref);
-    }
-
-  if (no_merge_with_following_text)
-    goto NEW_TEXT;
-
-  contents_num = av_len(contents_array) + 1;
-  if (contents_num == 0)
-    goto NEW_TEXT;
-
-  last_elt = (HV *)
-    SvRV (*av_fetch (contents_array, contents_num - 1, 0));
-  svp = hv_fetch (last_elt, "text", strlen ("text"), 0);
-  if (!svp)
-    goto NEW_TEXT;
-  existing_text_sv = *svp;
-  existing_text = SvPV_nolen (existing_text_sv);
-  if (strchr (existing_text, '\n'))
-    goto NEW_TEXT;
-
-MERGED_TEXT:
-  sv_catpv (existing_text_sv, text);
-  //fprintf (stderr, "MERGED TEXT: %s|||\n", text);
-
-  if (0)
-    {
-      HV *hv;
-      SV *sv;
-NEW_TEXT:
-      hv = newHV ();
-      sv = newSVpv (text, 0);
-      hv_store (hv, "text", strlen ("text"), sv, 0);
-      SvUTF8_on (sv);
-      hv_store (hv, "parent", strlen ("parent"),
-                newRV_inc ((SV *)current), 0);
-      av_push (contents_array, newRV_inc ((SV *)hv));
-      //fprintf (stderr, "NEW TEXT: %s|||\n", text);
-    }
-
-  return current;
-}
-
 char *
 xs_process_text (char *text)
 {
diff --git a/tp/Texinfo/XS/miscxs.h b/tp/Texinfo/XS/miscxs.h
index bce4f46564..9928595d8c 100644
--- a/tp/Texinfo/XS/miscxs.h
+++ b/tp/Texinfo/XS/miscxs.h
@@ -1,8 +1,6 @@
 char *xs_unicode_text (char *, int);
 char *xs_entity_text (char *);
 char *xs_process_text (char *text);
-HV *xs_merge_text (HV *self, HV *current, SV *text_in);
-int xs_abort_empty_line (HV *self, HV *current, SV *additional_text);
 void xs_parse_texi_regex (SV *text,
                           char **,
                           char **,



reply via email to

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