Paragraph.pm 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. # Copyright 2014, 2015, 2016 Free Software Foundation, Inc.
  2. #
  3. # This program is free software; you can redistribute it and/or modify
  4. # it under the terms of the GNU General Public License as published by
  5. # the Free Software Foundation; either version 3 of the License,
  6. # or (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. package Texinfo::Convert::Paragraph;
  16. # same as texi2any.pl
  17. use 5.00405;
  18. use strict;
  19. use warnings;
  20. our $VERSION = '6.3.90';
  21. use Texinfo::XSLoader;
  22. # Import symbols into the module that is using this one. We don't
  23. # use the Exporter module because its symbols are lost when we override
  24. # this module with Texinfo::XSLoader::init.
  25. sub import {
  26. my @EXPORT = qw(
  27. add_text
  28. add_next
  29. set_space_protection
  30. remove_end_sentence
  31. allow_end_sentence
  32. add_end_sentence
  33. end_line
  34. add_pending_word
  35. get_pending
  36. );
  37. my ($callpkg, $filename, $line) = caller(0);
  38. for my $sym (@EXPORT) {
  39. no strict 'refs';
  40. *{"${callpkg}::$sym"} = \&{"Texinfo::Convert::Paragraph::${sym}"};
  41. }
  42. }
  43. BEGIN {
  44. our $warning_message = undef;
  45. our $fatal_message = undef;
  46. # Check for a UTF-8 locale. Skip the check if the 'locale' command doesn't
  47. # work.
  48. our $a;
  49. if ($^O ne 'MSWin32') {
  50. $a = `locale -a 2>/dev/null`;
  51. }
  52. if ($a and $a !~ /UTF-8/ and $a !~ /utf8/) {
  53. $fatal_message = "couldn't find a UTF-8 locale";
  54. }
  55. if (!$a) {
  56. $warning_message = "couldn't run 'locale -a': skipping check for a UTF-8 locale";
  57. }
  58. # Save reference to subroutine before we do anything.
  59. my $import_fn = \&import;
  60. my $package = Texinfo::XSLoader::init (
  61. "Texinfo::Convert::Paragraph",
  62. "Texinfo::Convert::XSParagraph::XSParagraph",
  63. "Texinfo::Convert::ParagraphNonXS",
  64. "XSParagraph",
  65. 1,
  66. $warning_message,
  67. $fatal_message
  68. );
  69. no strict 'refs';
  70. *{"${package}::import"} = $import_fn;
  71. }
  72. # NB Don't add more functions down here, because this can cause an error
  73. # with some versions of Perl, connected with any typeglob assignments done
  74. # above. ("Can't call mro_method_changed_in() on anonymous symbol table").
  75. #
  76. # See http://perl5.git.perl.org/perl.git/commitdiff/03d9f026ae253e9e69212a3cf6f1944437e9f070?hp=ac73ea1ec401df889d312b067f78b618f7ffecc3
  77. #
  78. # (change to Perl interpreter on 22 Oct 2011)
  79. 1;
  80. __END__