From b855f868858a20cac10e4eaaf9acaeccb7081b18 Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Fri, 26 Jul 2019 10:10:03 -0300 Subject: [PATCH] Import Upstream version 0.0.24 --- docs/Changelog.htag | 3 +++ docs/INSTALL | 4 ++-- docs/README | 2 +- htag.pl | 4 ++-- plugins/15merge | 34 +++++++++++++++++++++++++++++++--- 5 files changed, 39 insertions(+), 8 deletions(-) diff --git a/docs/Changelog.htag b/docs/Changelog.htag index 83f3557..b75c941 100644 --- a/docs/Changelog.htag +++ b/docs/Changelog.htag @@ -1,6 +1,9 @@ HISTORY +2008-05-22 + Fix 15merge to use Encode and deal with UTF-8 taglines and + signatures correctly. 2003-06-18 Oops, 25asktag always asked for a tag regardless of $cfg{'asktag'} Thanks to Jasper Spaans for pointing that out. diff --git a/docs/INSTALL b/docs/INSTALL index dea01d7..484393f 100644 --- a/docs/INSTALL +++ b/docs/INSTALL @@ -1,5 +1,5 @@ -htag-0.0.23 -18th June 2003 +htag-0.0.24 +22nd May 2008 1. Plugins ========== diff --git a/docs/README b/docs/README index fd09d3e..55c3911 100644 --- a/docs/README +++ b/docs/README @@ -1,4 +1,4 @@ -htag.pl 0.0.23 +htag.pl 0.0.24 Simon Huggins Description diff --git a/htag.pl b/htag.pl index 5972d89..898e88c 100755 --- a/htag.pl +++ b/htag.pl @@ -34,7 +34,7 @@ if ($< == 0 or $> == 0 or $( == 0 or $) == 0) { # HtagPlugin lying around the system then uncomment the following with the # path to your local copy of HtagPlugin -# use lib '/home/huggie/perl/huggietag/htag-0.0.23/HtagPlugin'; +# use lib '/home/huggie/perl/huggietag/htag-0.0.24/HtagPlugin'; use HtagPlugin 0.6; use Getopt::Long; @@ -56,7 +56,7 @@ my $cfgdebug=0; my $infinity = 80; ### Defines -$override{'VERSION'} = $cfg{'VERSION'} = "0.0.23"; +$override{'VERSION'} = $cfg{'VERSION'} = "0.0.24"; $override{'HOME'} = $cfg{'HOME'} = $ENV{"HOME"} || $ENV{"LOGDIR"} || (getpwuid($<))[7]; $cfg{'nicedie'} = 1; diff --git a/plugins/15merge b/plugins/15merge index 801bcf0..53f3b82 100644 --- a/plugins/15merge +++ b/plugins/15merge @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -# Copyright (C) 2000-2003 Simon Huggins +# Copyright (C) 2000-2008 Simon Huggins # merge merges the sig and the tag but also merges the sig and the new style # plugin things (i.e. all those silly files in $cfg{'tmpdir'} @@ -20,11 +20,38 @@ use strict; use Text::Wrap; +use Encode; $Text::Wrap::columns=defined $cfg{'maxlinelen'} ? $cfg{'maxlinelen'} : 72; $cfg{'first'} ||= ""; $cfg{'leader'} ||= ""; +# Work out the correct locale to use if there is one otherwise we assume +# UTF-8 which shouldn't kill ascii people and anyone else should have +# correctly set locale. +my $fromcharset = 'UTF-8'; +my $tocharset = 'UTF-8'; + +my @all_encodings = Encode->encodings(":all"); +my $locale; +if (defined $ENV{'LC_ALL'}) { + $locale = $ENV{'LC_ALL'}; +} elsif (defined $ENV{'LC_CTYPE'}) { + $locale = $ENV{'LC_CTYPE'}; +} elsif (defined $ENV{'LANG'}) { + $locale = $ENV{'LANG'}; +} +if ($locale) { + $locale =~ s/.*\.//; + $locale = lc $locale; + foreach (@all_encodings) { + if ($locale eq lc $_) { + $tocharset = $fromcharset = $_; + last; + } + } +} + my $anal_merge_debug=0; sub remove_space($) { @@ -163,7 +190,7 @@ sub getplugin($) { my ($tag,$sig,$newsig); open(SIG, "<$cfg{'tmpsigfile'}") or htagdie "$0: Could not open $cfg{'tmpsigfile'}: $!\n"; while() { - $sig .= $_; + $sig .= decode($fromcharset, $_); } close(SIG); my $ret = 0; @@ -174,7 +201,7 @@ if (grep { /\@NOTAG\@/ } $sig) { } else { open(TAG, "<$cfg{'tmptagfile'}") or htagdie "$1: Could not open $cfg{'tmptagfile'}: $!\n"; while() { - $tag .= $_; + $tag .= decode($fromcharset, $_); } close(TAG); } @@ -187,6 +214,7 @@ if (defined $sig and $sig =~ /@[A-Za-z]?\*|(?:[1-9][0-9]*)[RC]?@/) { $cfg{'notag'} = 0; } if (defined $sig) { + $sig = encode($tocharset, $sig); open(SIG, ">$cfg{'tmpsigfile'}") or htagdie "$0: Could not open $cfg{'tmpsigfile'}: $!\n"; print SIG "\n" while $cfg{'newline'}--; print SIG $sig; -- 2.39.2