|
From: <jgr...@us...> - 2003-09-22 13:27:26
|
Update of /cvsroot/popfile/engine/UI
In directory sc8-pr-cvs1:/tmp/cvs-serv21997/UI
Modified Files:
HTML.pm
Log Message:
Merge patch that makes POPFile work well with the Japanese language
Index: HTML.pm
===================================================================
RCS file: /cvsroot/popfile/engine/UI/HTML.pm,v
retrieving revision 1.205
retrieving revision 1.206
diff -C2 -d -r1.205 -r1.206
*** HTML.pm 22 Sep 2003 13:06:39 -0000 1.205
--- HTML.pm 22 Sep 2003 13:27:22 -0000 1.206
***************
*** 44,47 ****
--- 44,61 ----
my $seconds_per_day = 60 * 60 * 24;
+ # These are used for Japanese support
+
+ # ASCII characters
+ my $ascii = '[\x00-\x7F]';
+
+ # EUC-JP 2 byte characters
+ my $two_bytes_euc_jp = '(?:[\x8E\xA1-\xFE][\xA1-\xFE])';
+
+ # EUC-JP 3 byte characters
+ my $three_bytes_euc_jp = '(?:\x8F[\xA1-\xFE][\xA1-\xFE])';
+
+ # EUC-JP characters
+ my $euc_jp = "(?:$ascii|$two_bytes_euc_jp|$three_bytes_euc_jp)";
+
#----------------------------------------------------------------------------
# new
***************
*** 1340,1373 ****
my @words = $self->{classifier__}->get_stopword_list();
! for my $word (sort @words) {
! $word =~ /^(.)/;
! if ( $1 ne $last ) {
! if (! $firstRow) {
! $body .= "</td></tr>\n";
! } else {
! $firstRow = 0;
! }
! $body .= "<tr><th scope=\"row\" class=\"advancedAlphabet";
! if ($groupCounter == $groupSize) {
! $body .= "GroupSpacing";
}
! $body .= "\"><b>$1</b></th>\n";
! $body .= "<td class=\"advancedWords";
! if ($groupCounter == $groupSize) {
! $body .= "GroupSpacing";
! $groupCounter = 0;
}
! $body .= "\">";
! $last = $1;
! $need_comma = 0;
! $groupCounter += 1;
! }
! if ( $need_comma == 1 ) {
! $body .= ", $word";
! } else {
! $body .= $word;
! $need_comma = 1;
}
}
--- 1354,1430 ----
my @words = $self->{classifier__}->get_stopword_list();
! # In Japanese mode, disable locale.
! # Sorting Japanese with "use locale" is memory and time consuming,
! # and may cause perl crash.
!
! if ( $self->config_( 'language' ) eq 'Nihongo' ) {
! no locale;
! for my $word (sort @words) {
!
! # First character of stop word is EUC-JP in Japanese mode
!
! $word =~ /^($euc_jp)/;
!
! if ( $1 ne $last ) {
! if ( !$firstRow ) {
! $body .= "</td></tr>\n";
! } else {
! $firstRow = 0;
! }
! $body .= "<tr><th scope=\"row\" class=\"advancedAlphabet";
! if ( $groupCounter == $groupSize ) {
! $body .= "GroupSpacing";
! }
! $body .= "\"><b>$1</b></th>\n";
! $body .= "<td class=\"advancedWords";
! if ( $groupCounter == $groupSize ) {
! $body .= "GroupSpacing";
! $groupCounter = 0;
! }
! $body .= "\">";
! $last = $1;
! $need_comma = 0;
! $groupCounter += 1;
}
! if ( $need_comma == 1 ) {
! $body .= ", $word";
! } else {
! $body .= $word;
! $need_comma = 1;
}
! }
! } else {
! for my $word (sort @words) {
! $word =~ /^(.)/;
!
! if ( $1 ne $last ) {
! if (! $firstRow) {
! $body .= "</td></tr>\n";
! } else {
! $firstRow = 0;
! }
! $body .= "<tr><th scope=\"row\" class=\"advancedAlphabet";
! if ($groupCounter == $groupSize) {
! $body .= "GroupSpacing";
! }
! $body .= "\"><b>$1</b></th>\n";
! $body .= "<td class=\"advancedWords";
! if ($groupCounter == $groupSize) {
! $body .= "GroupSpacing";
! $groupCounter = 0;
! }
! $body .= "\">";
! $last = $1;
! $need_comma = 0;
! $groupCounter += 1;
! }
! if ( $need_comma == 1 ) {
! $body .= ", $word";
! } else {
! $body .= $word;
! $need_comma = 1;
! }
}
}
***************
*** 2571,2580 ****
my $from = '';
my $subject = '';
if ( open MAIL, '<'. $self->global_config_( 'msgdir' ) . $file ) {
while ( <MAIL> ) {
last if ( /^(\r\n|\r|\n)/ );
! $from = $1 if ( /^From: *(.*)/i );
! $subject = $1 if ( /^Subject: *(.*)/i );
last if ( ( $from ne '' ) && ( $subject ne '' ) );
}
--- 2628,2661 ----
my $from = '';
my $subject = '';
+ my $long_header = '';
if ( open MAIL, '<'. $self->global_config_( 'msgdir' ) . $file ) {
while ( <MAIL> ) {
last if ( /^(\r\n|\r|\n)/ );
!
! # Support long header that has more than 2 lines by JI
!
! if(/^[\t ]+(=\?[\w-]+\?[BQ]\?.*\?=.*)/){
! if($long_header eq 'from'){
! $from .= $1;
! next;
! }
! if($long_header eq 'subject'){
! $subject .= $1;
! next;
! }
! }else{
! if(/^From: *(.*)/i){
! $long_header = 'from';
! $from = $1;
! next;
! }elsif (/^Subject: *(.*)/i){
! $long_header = 'subject';
! $subject = $1;
! next;
! }
! $long_header = '';
! }
!
last if ( ( $from ne '' ) && ( $subject ne '' ) );
}
|