summaryrefslogtreecommitdiff
path: root/codepage
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2010-02-04 17:56:03 -0800
committerH. Peter Anvin <hpa@zytor.com>2010-02-04 17:56:03 -0800
commit117a72aa41edea84a734db09c89d09ca2efb5bf7 (patch)
tree72f204fa86060ee354cc4e3110da0a2e2653d247 /codepage
parentc6a97d80b49101e0ab98a77ece46d36597411b90 (diff)
downloadsyslinux-117a72aa41edea84a734db09c89d09ca2efb5bf7.tar.gz
codepage: add a lower-case table
Add a lower-case table; necessary for readdir on FAT in the presence of WinNT case flags. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'codepage')
-rwxr-xr-xcodepage/cptable.pl40
1 files changed, 35 insertions, 5 deletions
diff --git a/codepage/cptable.pl b/codepage/cptable.pl
index 05cfc3eb..e29cf006 100755
--- a/codepage/cptable.pl
+++ b/codepage/cptable.pl
@@ -82,7 +82,7 @@ open(CPOUT, '>', $cpout)
# Magic number, in anticipation of being able to load these
# files dynamically...
#
-print CPOUT pack("VV", 0x8fad232b, 0x9c295319);
+print CPOUT pack("VV", 0x58a8b3d4, 0x51d21eb1);
# Header fields available for future use...
print CPOUT pack("VVVVVV", 0, 0, 0, 0, 0, 0);
@@ -97,6 +97,7 @@ print CPOUT pack("VVVVVV", 0, 0, 0, 0, 0, 0);
# ... where @ytab is console codepage -> Unicode and
# %tabx is Unicode -> filesystem codepage.
#
+@uctab = (undef) x 256;
for ($i = 0; $i < 256; $i++) {
$uuc = $ucase{$ytab[$i]}; # Unicode upper case
if (defined($tabx{$uuc})) {
@@ -106,15 +107,44 @@ for ($i = 0; $i < 256; $i++) {
# Upper case equivalent stripped of accents
$u = $tabx{${$decomp{$uuc}}[0]};
} else {
- # No equivalent at all found. Set this to zero, which should
- # prevent shortname matching altogether (still making longname
- # matching possible, of course.)
- $u = 0;
+ # No equivalent at all found. Assume it is a lower-case-only
+ # character, like greek alpha in CP437.
+ $u = $i;
}
+ $uctab[$i] = $u;
print CPOUT pack("C", $u);
}
#
+# Self (shortname) lowercase table.
+# This depends both on the console codepage and the filesystem codepage;
+# the logical transcoding operation is:
+#
+# $taby{$lcase{$xtab[$i]}}
+#
+# ... where @ytab is console codepage -> Unicode and
+# %tabx is Unicode -> filesystem codepage.
+#
+@lctab = (undef) x 256;
+for ($i = 0; $i < 256; $i++) {
+ $llc = $lcase{$xtab[$i]}; # Unicode lower case
+ if (defined($l = $taby{$llc}) && $uctab[$l] == $i) {
+ # Straight-forward conversion
+ } elsif (defined($l = $tabx{${$decomp{$llc}}[0]}) && $uctab[$l] == $i) {
+ # Lower case equivalent stripped of accents
+ } else {
+ # No equivalent at all found. Find *anything* that matches the
+ # bijection criterion...
+ for ($l = 0; $l < 256; $l++) {
+ last if ($uctab[$l] == $i);
+ }
+ $l = $i if ($l == 256); # If nothing, we're screwed anyway...
+ }
+ $lctab[$i] = $l;
+ print CPOUT pack("C", $l);
+}
+
+#
# Unicode (longname) matching table.
# This only depends on the console codepage.
#