# 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;
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;
#!/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'}
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($) {
my ($tag,$sig,$newsig);
open(SIG, "<$cfg{'tmpsigfile'}") or htagdie "$0: Could not open $cfg{'tmpsigfile'}: $!\n";
while(<SIG>) {
- $sig .= $_;
+ $sig .= decode($fromcharset, $_);
}
close(SIG);
my $ret = 0;
} else {
open(TAG, "<$cfg{'tmptagfile'}") or htagdie "$1: Could not open $cfg{'tmptagfile'}: $!\n";
while(<TAG>) {
- $tag .= $_;
+ $tag .= decode($fromcharset, $_);
}
close(TAG);
}
$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;