summaryrefslogtreecommitdiffstats
path: root/sys/libkern
diff options
context:
space:
mode:
authorfjoe <fjoe@FreeBSD.org>2003-12-08 08:32:20 +0000
committerfjoe <fjoe@FreeBSD.org>2003-12-08 08:32:20 +0000
commitab0bce9d34117f8a7b96ec8a3c86ed0e86d58ef8 (patch)
tree6ebbe6155fc751cdfa161e601e91e193cd383576 /sys/libkern
parent8a088743dbd2835567a01e9f13b69c3dc4b0d8a9 (diff)
downloadFreeBSD-src-ab0bce9d34117f8a7b96ec8a3c86ed0e86d58ef8.zip
FreeBSD-src-ab0bce9d34117f8a7b96ec8a3c86ed0e86d58ef8.tar.gz
Make msdosfs long filenames matching case insensitive again.
PR: 59765 Submitted by: Ryuichiro Imura <imura@ryu16.org>
Diffstat (limited to 'sys/libkern')
-rw-r--r--sys/libkern/iconv_xlat16.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/sys/libkern/iconv_xlat16.c b/sys/libkern/iconv_xlat16.c
index 6793159..68d468a 100644
--- a/sys/libkern/iconv_xlat16.c
+++ b/sys/libkern/iconv_xlat16.c
@@ -96,11 +96,11 @@ iconv_xlat16_conv(void *d2p, const char **inbuf,
struct iconv_xlat16 *dp = (struct iconv_xlat16*)d2p;
const char *src;
char *dst;
- int ret = 0;
+ int nullin, ret = 0;
size_t in, on, ir, or, inlen;
uint32_t code;
u_char u, l;
- u_int16_t c1, c2;
+ uint16_t c1, c2;
if (inbuf == NULL || *inbuf == NULL || outbuf == NULL || *outbuf == NULL)
return (0);
@@ -146,7 +146,8 @@ iconv_xlat16_conv(void *d2p, const char **inbuf,
}
}
- if ((inlen == 1) && (code & XLAT16_ACCEPT_NULL_IN)) {
+ nullin = (code & XLAT16_ACCEPT_NULL_IN) ? 1 : 0;
+ if (inlen == 1 && nullin) {
/*
* XLAT16_ACCEPT_NULL_IN requires inbuf has 2byte
*/
@@ -157,6 +158,14 @@ iconv_xlat16_conv(void *d2p, const char **inbuf,
/*
* now start translation
*/
+ if ((casetype == KICONV_FROM_LOWER && code & XLAT16_HAS_FROM_LOWER_CASE) ||
+ (casetype == KICONV_FROM_UPPER && code & XLAT16_HAS_FROM_UPPER_CASE)) {
+ c2 = (u_char)(code >> 16);
+ c1 = c2 & 0x80 ? 0x100 : 0;
+ c2 = c2 & 0x80 ? c2 & 0x7f : c2;
+ code = dp->d_table[c1][c2];
+ }
+
u = (u_char)(code >> 8);
l = (u_char)code;
@@ -184,9 +193,6 @@ iconv_xlat16_conv(void *d2p, const char **inbuf,
if ((casetype == KICONV_LOWER && code & XLAT16_HAS_LOWER_CASE) ||
(casetype == KICONV_UPPER && code & XLAT16_HAS_UPPER_CASE))
*dst++ = (u_char)(code >> 16);
- else if ((casetype == KICONV_FROM_LOWER && code & XLAT16_HAS_FROM_LOWER_CASE) ||
- (casetype == KICONV_FROM_UPPER && code & XLAT16_HAS_FROM_UPPER_CASE))
- *dst++ = dp->d_table[0][(u_char)(code >> 16)];
else
*dst++ = l;
or--;
@@ -197,8 +203,7 @@ iconv_xlat16_conv(void *d2p, const char **inbuf,
* there is a case that inbuf char is a single
* byte char while inlen == 2
*/
- if ((u_char)*(src+1) == 0 &&
- (code & XLAT16_ACCEPT_NULL_IN) == 0 ) {
+ if ((u_char)*(src+1) == 0 && !nullin ) {
src++;
ir--;
} else {
OpenPOWER on IntegriCloud