texinfo-commits
[Top][All Lists]
Advanced

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

[7731] move code from UNITCHECK to import method


From: gavinsmith0123
Subject: [7731] move code from UNITCHECK to import method
Date: Sat, 15 Apr 2017 15:56:27 -0400 (EDT)

Revision: 7731
          http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7731
Author:   gavin
Date:     2017-04-15 15:56:27 -0400 (Sat, 15 Apr 2017)
Log Message:
-----------
move code from UNITCHECK to import method

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/tp/Texinfo/Convert/Plaintext.pm
    trunk/tp/Texinfo/Convert/Unicode.pm
    trunk/tp/Texinfo/Parser.pm

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2017-04-15 08:34:47 UTC (rev 7730)
+++ trunk/ChangeLog     2017-04-15 19:56:27 UTC (rev 7731)
@@ -1,3 +1,13 @@
+2017-04-15  Gavin Smith  <address@hidden>
+
+       * tp/Texinfo/Convert/Plaintext.pm,
+       * tp/Texinfo/Parser.pm,
+       * tp/Texinfo/Convert/Unicode.pm:
+       Move calls to Texinfo::XSLoader::override to a custom 'import'
+       method, wrapping the one from the Exporter module, instead of 
+       occurring inside a UNITCHECK block.  This is to try to work
+       on older versions of Perl where UNITCHECK didn't exist.
+
 2017-04-14  Gavin Smith  <address@hidden>
 
        * tp/Texinfo/Convert/XSParagraph: Run gnulib-tool --add-import.

Modified: trunk/tp/Texinfo/Convert/Plaintext.pm
===================================================================
--- trunk/tp/Texinfo/Convert/Plaintext.pm       2017-04-15 08:34:47 UTC (rev 
7730)
+++ trunk/tp/Texinfo/Convert/Plaintext.pm       2017-04-15 19:56:27 UTC (rev 
7731)
@@ -37,8 +37,22 @@
 
 require Exporter;
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
address@hidden = qw(Exporter Texinfo::Convert::Converter);
address@hidden = qw(Texinfo::Convert::Converter);
 
+# Some extra initialization for the first time this module is loaded.
+# This could be done in a UNITCHECK block, introduced in Perl 5.10.
+our $module_loaded = 0;
+sub import {
+  if (!$module_loaded) {
+    Texinfo::XSLoader::override(
+      "Texinfo::Convert::Plaintext::_process_text_internal",
+      "Texinfo::MiscXS::process_text");
+    $module_loaded = 1;
+  }
+  # The usual import method
+  goto &Exporter::import;
+}
+
 # Items to export into callers namespace by default. Note: do not export
 # names by default without a very good reason. Use EXPORT_OK instead.
 # Do not simply export all your public functions/methods/constants.
@@ -533,12 +547,6 @@
   return $text;
 }
 
-UNITCHECK {
-  Texinfo::XSLoader::override(
-    "Texinfo::Convert::Plaintext::_process_text_internal",
-    "Texinfo::MiscXS::process_text");
-}
-
 sub _process_text_internal {
   my ($text) = @_;
 

Modified: trunk/tp/Texinfo/Convert/Unicode.pm
===================================================================
--- trunk/tp/Texinfo/Convert/Unicode.pm 2017-04-15 08:34:47 UTC (rev 7730)
+++ trunk/tp/Texinfo/Convert/Unicode.pm 2017-04-15 19:56:27 UTC (rev 7731)
@@ -1,6 +1,6 @@
 # Unicode.pm: handle conversion to unicode.
 #
-# Copyright 2010, 2011, 2012 Free Software Foundation, Inc.
+# Copyright 2010, 2011, 2012, 2015, 2016, 2017 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
@@ -32,14 +32,21 @@
 
 require Exporter;
 use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
address@hidden = qw(Exporter);
 
 use Texinfo::MiscXS;
 
-# Override subroutines after this module has been loaded.
-UNITCHECK {
-  Texinfo::XSLoader::override("Texinfo::Convert::Unicode::unicode_text",
-                              "Texinfo::MiscXS::unicode_text");
+# Some extra initialization for the first time this module is loaded.
+# This could be done in a UNITCHECK block, but they were introduced in
+# Perl 5.10.
+our $module_loaded = 0;
+sub import {
+  if (!$module_loaded) {
+    Texinfo::XSLoader::override("Texinfo::Convert::Unicode::unicode_text",
+                                "Texinfo::MiscXS::unicode_text");
+    $module_loaded = 1;
+  }
+  # The usual import method.
+  goto &Exporter::import;
 }
 
 

Modified: trunk/tp/Texinfo/Parser.pm
===================================================================
--- trunk/tp/Texinfo/Parser.pm  2017-04-15 08:34:47 UTC (rev 7730)
+++ trunk/tp/Texinfo/Parser.pm  2017-04-15 19:56:27 UTC (rev 7731)
@@ -64,6 +64,23 @@
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 @ISA = qw(Exporter Texinfo::Report);
 
+our $module_loaded = 0;
+sub import {
+  if (!$module_loaded) {
+    Texinfo::XSLoader::override ("Texinfo::Parser::_merge_text",
+      "Texinfo::MiscXS::merge_text");
+    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;
+  }
+  # The usual import method
+  goto &Exporter::import;
+}
+
+
+
 # Items to export into callers namespace by default. Note: do not export
 # names by default without a very good reason. Use EXPORT_OK instead.
 # Do not simply export all your public functions/methods/constants.
@@ -1809,13 +1826,6 @@
   return ($closed_element, $current);
 }
 
-UNITCHECK {
-   Texinfo::XSLoader::override ("Texinfo::Parser::_merge_text",
-     "Texinfo::MiscXS::merge_text");
-   Texinfo::XSLoader::override ("Texinfo::Parser::_abort_empty_line",
-     "Texinfo::MiscXS::abort_empty_line");
-}
-
 # begin paragraph if needed.  If not try to merge with the previous
 # content if it is also some text.
 sub _merge_text {
@@ -3528,11 +3538,6 @@
   }
 }
 
-UNITCHECK {
-   Texinfo::XSLoader::override ("Texinfo::Parser::_parse_texi_regex",
-     "Texinfo::MiscXS::parse_texi_regex");
-}
-
 # This combines several regular expressions used in '_parse_texi' to
 # look at what is next on the remaining part of the line.
 sub _parse_texi_regex {




reply via email to

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