Репозитории ALT
S: | 0.39-alt2 |
5.1: | 0.36-alt1 |
4.1: | 0.35.1-alt1 |
4.0: | 0.35.1-alt1 |
3.0: | 0.30-alt1 |
Группа :: Базы Данных
Пакет: lbdb
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: lbdb-0.27-alt-cyrrecode.patch
Скачать
Скачать
diff -Naur lbdb-0.27.orig/m_palm lbdb-0.27/m_palm
--- lbdb-0.27.orig/m_palm 1970-01-01 03:00:00 +0300
+++ lbdb-0.27/m_palm 2003-05-14 16:50:20 +0400
@@ -0,0 +1,34 @@
+#! /bin/bash -posix
+#
+# -*-sh-*-
+#
+# m_palm - Palm address database module for lbdb
+# Copyright (C) 2000 Dave Pearson <davep@davep.org>
+#
+# 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
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+#
+# $Id: m_palm.sh.in,v 1.5 2002/02/11 19:23:53 roland Exp $
+
+prefix=/usr
+exec_prefix=/usr
+libdir=/usr/lib/lbdb
+
+m_palm_query ()
+{
+ palmdatabase_charset=$(fgrep char_set $HOME/.jpilot/jpilot.rc | perl -e '($a = <>) =~ s/^\s*char_set\s*(\d+)\s*$/$1/; print $a == 0 ? "LATIN1" : $a == 1 ? "JAPANESE" : $a == 2 ? "1250" : $a == 3 ? "KOI8-R" : $a == 4 ? "CP1251" : $a == 5 ? "TRADITIONAL_CHINESE" : $a == 6 ? "KOREAN" : $a == 7 ? "1250UTF" : "UNKNOWN"')
+ palmdatabase=${PALM_ADDRESS_DATABASE:-$HOME/.jpilot/AddressDB.pdb}
+ test -f $palmdatabase || return
+ $libdir/palm_lsaddr $palmdatabase $palmdatabase_charset | grep -i "$@"
+}
diff -Naur lbdb-0.27.orig/m_palm.sh.in lbdb-0.27/m_palm.sh.in
--- lbdb-0.27.orig/m_palm.sh.in 2002-02-11 22:23:53 +0300
+++ lbdb-0.27/m_palm.sh.in 2003-05-14 16:51:14 +0400
@@ -29,5 +29,6 @@
{
palmdatabase=${PALM_ADDRESS_DATABASE:-$HOME/.jpilot/AddressDB.pdb}
test -f $palmdatabase || return
- $libdir/palm_lsaddr $palmdatabase | grep -i "$@"
+ palmdatabase_charset=$(fgrep char_set $HOME/.jpilot/jpilot.rc | perl -e '($a = <>) =~ s/^\s*char_set\s*(\d+)\s*$/$1/; print $a == 0 ? "LATIN1" : $a == 1 ? "JAPANESE" : $a == 2 ? "1250" : $a == 3 ? "KOI8-R" : $a == 4 ? "CP1251" : $a == 5 ? "TRADITIONAL_CHINESE" : $a == 6 ? "KOREAN" : $a == 7 ? "1250UTF" : "UNKNOWN"')
+ $libdir/palm_lsaddr $palmdatabase $palmdatabase_charset | grep -i "$@"
}
diff -Naur lbdb-0.27.orig/palm_lsaddr.pl.in lbdb-0.27/palm_lsaddr.pl.in
--- lbdb-0.27.orig/palm_lsaddr.pl.in 2000-08-24 06:14:26 +0400
+++ lbdb-0.27/palm_lsaddr.pl.in 2003-05-14 17:04:24 +0400
@@ -2,6 +2,7 @@
#
# palm_lsaddr - Palm address database helper utility for lbdb
# Copyright (C) 2000 Dave Pearson <davep@davep.org>
+# Patch for windows-1251 <-> koi8-r recoding by Andrey Brindeew <abr@altlinux.ru>
#
# 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
@@ -17,12 +18,16 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+use 5.8.0;
use Palm::PDB;
use Palm::Address;
+use I18N::Langinfo qw(langinfo CODESET);
if ( $#ARGV > -1 )
{
my $pdb = new Palm::PDB;
+ my $pdb_charset = $ARGV[ 1 ] || 'LATIN1';
+ my $usr_charset = langinfo(CODESET());
if ( $pdb )
{
@@ -61,7 +66,7 @@
# the test)
if ( $contact =~ /\@/ )
{
- print "$contact\t$name\t(Palm)\n";
+ print recode_data("$contact\t$name\t(Palm)\n",$pdb_charset,$usr_charset);
}
}
}
@@ -69,3 +74,46 @@
}
}
}
+
+sub win2koi {
+ my (@result) = (@_);
+ foreach (@result) {
+ if (ref) {
+ if (ref eq 'ARRAY') { $_ = [ win2koi(@{$_}) ] }
+ elsif ((ref eq 'SCALAR') or (ref eq 'REF')) { $_ = \scalar(win2koi(${$_})) }
+ }
+ elsif (defined $_) {
+ tr/\xFE\xE0\xE1\xF6\xE4\xE5\xF4\xE3\xF5\xE8-\xEF\xFF\xF0-\xF3\xE6\xE2\xFC\xFB\xE7\xF8\xFD\xF9\xF7\xFA\xDE\xC0\xC1\xD6\xC4\xC5\xD4\xC3\xD5\xC8-\xCF\xDF\xD0-\xD3\xC6\xC2\xDC\xDB\xC7\xD8\xDD\xD9\xD7\xDA/\xC0-\xFF/;
+ tr/\xB8\xA8/\xA3\xB3/;
+ }
+ }
+ return wantarray ? @result : $result[0];
+}
+sub koi2win {
+ my (@result) = (@_);
+ foreach (@result) {
+ if (ref) {
+ if (ref eq 'ARRAY') { $_ = [ koi2win(@{$_}) ] }
+ elsif ((ref eq 'SCALAR') or (ref eq 'REF')) { $_ = \scalar(koi2win(${$_})) }
+ }
+ elsif (defined $_) {
+ tr/\xC0-\xFF/\xFE\xE0\xE1\xF6\xE4\xE5\xF4\xE3\xF5\xE8-\xEF\xFF\xF0-\xF3\xE6\xE2\xFC\xFB\xE7\xF8\xFD\xF9\xF7\xFA\xDE\xC0\xC1\xD6\xC4\xC5\xD4\xC3\xD5\xC8-\xCF\xDF\xD0-\xD3\xC6\xC2\xDC\xDB\xC7\xD8\xDD\xD9\xD7\xDA/;
+ tr/\xA3\xB3/\xB8\xA8/;
+ }
+ }
+ return wantarray ? @result : $result[0];
+}
+
+# Parameters:
+# - data for recoding
+# - .pdb charset
+# - user charset (from locale settings)
+sub recode_data {
+ my ($data, $pdb_ch, $user_ch) = @_;
+ return $data if ($pdb_ch eq $user_ch);
+ return $data if ($pdb_ch eq 'LATIN1'); # Need no conversion
+ return $data if ($pdb_ch ne 'CP1251' and $pdb_ch ne 'KOI8-R'); # Sorry, only russian conversions available at this time
+ return(win2koi($data)) if ($pdb_ch eq 'CP1251' and $user_ch eq 'KOI8-R');
+ return(koi2win($data)) if ($pdb_ch eq 'KOI8-R' and $user_ch eq 'CP1251');
+ return $data; # if all above fails
+}