24
1
mirror of https://github.com/processone/ejabberd.git synced 2024-06-02 21:17:12 +02:00

* src/stringprep/uni_norm.c: Regenerated with Unicode 3.2 tables

as required by RFC3454

* src/stringprep/uni_parse2.tcl: Bugfixes

* src/stringprep/stringprep_drv.c: Bugfixes, added hangul
composition

SVN Revision: 342
This commit is contained in:
Alexey Shchepin 2005-05-06 01:38:05 +00:00
parent e2ca6fc7f2
commit 1a4c851c7c
4 changed files with 1143 additions and 1098 deletions

View File

@ -1,3 +1,13 @@
2005-05-06 Alexey Shchepin <alexey@sevcom.net>
* src/stringprep/uni_norm.c: Regenerated with Unicode 3.2 tables
as required by RFC3454
* src/stringprep/uni_parse2.tcl: Bugfixes
* src/stringprep/stringprep_drv.c: Bugfixes, added hangul
composition
2005-05-05 Mickael Remond <mremond@erlang-fr.org> 2005-05-05 Mickael Remond <mremond@erlang-fr.org>
* src/msgs/fr.msg: Added missing version 0.9 fields and removed unused * src/msgs/fr.msg: Added missing version 0.9 fields and removed unused

View File

@ -32,6 +32,18 @@ static void stringprep_erl_stop(ErlDrvData handle)
driver_free((char*)handle); driver_free((char*)handle);
} }
/* Hangul constants */
#define SBase 0xAC00
#define LBase 0x1100
#define VBase 0x1161
#define TBase 0x11A7
#define LCount 19
#define VCount 21
#define TCount 28
#define NCount (VCount * TCount)
#define SCount (LCount * NCount)
/* /*
* "canonical_ordering" and "compose" functions are based on nfkc.c from Gnome * "canonical_ordering" and "compose" functions are based on nfkc.c from Gnome
* library * library
@ -48,7 +60,7 @@ static void canonical_ordering(int *str, int len)
next = GetUniCharCClass(str[i + 1]); next = GetUniCharCClass(str[i + 1]);
if (next != 0 && last > next) if (next != 0 && last > next)
{ {
for(j = i; j > 0; j--) for(j = i; j >= 0; j--)
{ {
if (GetUniCharCClass(str[j]) <= next) if (GetUniCharCClass(str[j]) <= next)
break; break;
@ -67,29 +79,41 @@ static int compose(int ch1, int ch2)
{ {
int info1, info2; int info1, info2;
if (LBase <= ch1 && ch1 < LBase + LCount &&
VBase <= ch2 && ch2 < VBase + VCount) {
return SBase + ((ch1 - LBase) * VCount + (ch2 - VBase)) * TCount;
}
if (SBase <= ch1 && ch1 < SBase + SCount && ((ch1 - SBase) % TCount) == 0 &&
TBase <= ch2 && ch2 < TBase + TCount) {
return ch1 + ch2 - TBase;
}
info1 = GetUniCharCompInfo(ch1); info1 = GetUniCharCompInfo(ch1);
if(info1 != -1) { if (info1 != -1) {
if(info1 & CompSingleMask) { if (info1 & CompSingleMask) {
if (ch2 == compFirstList[info1 & CompMask][0]) { if (ch2 == compFirstList[info1 & CompMask][0]) {
return compFirstList[info1 & CompMask][1]; return compFirstList[info1 & CompMask][1];
} else } else
return 0; return 0;
} }
} else }
return 0;
info2 = GetUniCharCompInfo(ch2); info2 = GetUniCharCompInfo(ch2);
if(info2 != -1) { if (info2 != -1) {
if (info2 & CompSingleMask) { if (info2 & CompSingleMask) {
if (ch1 == compSecondList[info2 & CompMask][0]) { if (ch1 == compSecondList[info2 & CompMask][0]) {
return compSecondList[info2 & CompMask][1]; return compSecondList[info2 & CompMask][1];
} else } else
return 0; return 0;
} }
} else }
return 0;
return compBothList[info1][info2]; if (info1 != -1 && info2 != -1 &&
!(info1 & CompSecondMask) && (info2 & CompSecondMask))
return compBothList[info1][info2 & CompMask];
else
return 0;
} }
@ -162,7 +186,7 @@ static int stringprep_erl_control(ErlDrvData drv_data,
int str32len, str32pos = 0; int str32len, str32pos = 0;
int decomp_len, decomp_shift; int decomp_len, decomp_shift;
int comp_pos, comp_starter_pos; int comp_pos, comp_starter_pos;
int cclass1, cclass2, cclass_prev; int cclass_prev, cclass2;
int ch1, ch2; int ch1, ch2;
size = len + 1; size = len + 1;
@ -266,20 +290,20 @@ static int stringprep_erl_control(ErlDrvData drv_data,
comp_pos = 1; comp_pos = 1;
comp_starter_pos = 0; comp_starter_pos = 0;
ch1 = str32[0]; ch1 = str32[0];
cclass1 = GetUniCharCClass(ch1); cclass_prev = GetUniCharCClass(ch1);
cclass_prev = cclass1; for (i = 1; i < str32pos; i++)
for(i = 1; i < str32pos; i++)
{ {
ch2 = str32[i]; ch2 = str32[i];
cclass2 = GetUniCharCClass(ch2); cclass2 = GetUniCharCClass(ch2);
if(cclass1 == 0 && cclass2 > cclass_prev && (ruc = compose(ch1, ch2))) { if ((cclass_prev == 0 || cclass2 > cclass_prev) &&
(ruc = compose(ch1, ch2))) {
ch1 = ruc; ch1 = ruc;
} else { } else {
if(cclass2 == 0) { if (cclass2 == 0) {
str32[comp_starter_pos] = ch1; str32[comp_starter_pos] = ch1;
comp_starter_pos = comp_pos++; comp_starter_pos = comp_pos++;
ch1 = ch2; ch1 = ch2;
cclass1 = cclass_prev = 0; cclass_prev = 0;
} else { } else {
str32[comp_pos++] = ch2; str32[comp_pos++] = ch2;
cclass_prev = cclass2; cclass_prev = cclass2;

File diff suppressed because it is too large Load Diff

View File

@ -233,15 +233,32 @@ proc uni::buildTables {} {
set decomp_mask [expr {(1 << $decomp_shift) - 1}] set decomp_mask [expr {(1 << $decomp_shift) - 1}]
set comp_mask [expr {(1 << $comp_shift) - 1}] set comp_mask [expr {(1 << $comp_shift) - 1}]
foreach comp [array names comp_map] {
set ch1 [lindex $comp 0]
if {[info exists comp_first($ch1)] && $comp_first($ch1) > 0 && \
[info exists comp_second($ch1)] && $comp_second($ch1) > 0} {
if {[lsearch -exact $comp_x_list $ch1] < 0} {
set i [llength $comp_x_list]
lappend comp_x_list $ch1
set comp_info_map($ch1) $i
lappend comp_y_list $ch1
set comp_info_map($ch1) $i
puts "There should be no symbols which appears on"
puts "both first and second place in composition"
exit
}
}
}
foreach comp [array names comp_map] { foreach comp [array names comp_map] {
set ch1 [lindex $comp 0] set ch1 [lindex $comp 0]
set ch2 [lindex $comp 1] set ch2 [lindex $comp 1]
if {$comp_first($ch1) == 1} { if {$comp_first($ch1) == 1 && ![info exists comp_second($ch1)]} {
set i [llength $comp_first_list] set i [llength $comp_first_list]
lappend comp_first_list [list $ch2 $comp_map($comp)] lappend comp_first_list [list $ch2 $comp_map($comp)]
set comp_info_map($ch1) [expr {$i | (1 << 16)}] set comp_info_map($ch1) [expr {$i | (1 << 16)}]
} elseif {$comp_second($ch2) == 1} { } elseif {$comp_second($ch2) == 1 && ![info exists comp_first($ch2)]} {
set i [llength $comp_second_list] set i [llength $comp_second_list]
lappend comp_second_list [list $ch1 $comp_map($comp)] lappend comp_second_list [list $ch1 $comp_map($comp)]
set comp_info_map($ch2) [expr {$i | (1 << 16)}] set comp_info_map($ch2) [expr {$i | (1 << 16)}]
@ -254,7 +271,7 @@ proc uni::buildTables {} {
if {[lsearch -exact $comp_y_list $ch2] < 0} { if {[lsearch -exact $comp_y_list $ch2] < 0} {
set i [llength $comp_y_list] set i [llength $comp_y_list]
lappend comp_y_list $ch2 lappend comp_y_list $ch2
set comp_info_map($ch2) $i set comp_info_map($ch2) [expr {$i | (1 << 17)}]
} }
} }
} }
@ -283,10 +300,19 @@ proc uni::buildTables {} {
if {[info exists decomp_map($i)]} { if {[info exists decomp_map($i)]} {
set decomp $decomp_map($i) set decomp $decomp_map($i)
#puts -$decomp set b 1
while {[info exists decomp_map([set ch1 [lindex $decomp 0]])]} { while {$b} {
set decomp [concat $decomp_map($ch1) [lreplace $decomp 0 0]] set b 0
#puts +$decomp for {set j 0} {$j < [llength $decomp]} {incr j} {
if {[info exists \
decomp_map([set ch1 [lindex $decomp $j]])]} {
#puts -$decomp
set decomp [eval [list lreplace $decomp $j $j] \
$decomp_map($ch1)]
#puts +$decomp
set b 1
}
}
} }
if {[info exists decomp_used($decomp)]} { if {[info exists decomp_used($decomp)]} {
@ -665,6 +691,7 @@ static int compBothList\[[llength $comp_x_list]\]\[[llength $comp_y_list]\] = {"
#define CompSingleMask (1 << 16) #define CompSingleMask (1 << 16)
#define CompMask ((1 << 16) - 1) #define CompMask ((1 << 16) - 1)
#define CompSecondMask (1 << 17)
" "
close $f close $f