mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Reini Urban <rurban@cpan.org>
To: musl@lists.openwall.com
Subject: [PATCH] towupper/towlower: Update to Unicode 9.0
Date: Wed, 13 Sep 2017 10:25:18 +0200	[thread overview]
Message-ID: <FD4E73D2-3AD7-43F3-901D-E8437FB54E25@cpan.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 88 bytes --]

taken from my safeclib (MIT licensed) and cross-checked with the perl unicode tables


[-- Attachment #2: 0001-towupper-towlower-Update-to-Unicode-9.0.patch --]
[-- Type: application/octet-stream, Size: 2358 bytes --]

From c810e57fa5935c2802eb133e0495cfe5f7087195 Mon Sep 17 00:00:00 2001
From: Reini Urban <rurban@cpan.org>
Date: Wed, 13 Sep 2017 10:09:03 +0200
Subject: [PATCH] towupper/towlower: Update to Unicode 9.0

taken from safeclib and cross-checked with the perl unicode tables
---
 src/ctype/towctrans.c | 37 +++++++++++++++++++++++++++++++++++--
 1 file changed, 35 insertions(+), 2 deletions(-)

diff --git src/ctype/towctrans.c src/ctype/towctrans.c
index cf13a86..59beddd 100644
--- src/ctype/towctrans.c
+++ src/ctype/towctrans.c
@@ -82,10 +82,26 @@ static const struct {
 	CASELACE(0xa790,0xa792),
 	CASELACE(0xa7a0,0xa7a8),
 
+	CASELACE(0xa7b4,0xa7b6), /* Unicode 8 */
+
 	CASEMAP(0xff21,0xff3a,0xff41),
 	{ 0,0,0 }
 };
 
+static const struct {
+	unsigned int upper;
+	signed char lower;
+	unsigned char len;
+} casemapsl[] = {
+	CASEMAP(0x10400,0x10427,0x10428),
+
+	CASEMAP(0x104b0,0x104d3,0x104d8), /* Unicode 9 */
+	CASEMAP(0x10c80,0x10cb2,0x10cc0), /* Unicode 8 */
+	CASEMAP(0x118a0,0x118bf,0x118c0), /* Unicode 7 */
+	CASEMAP(0x1e900,0x1e921,0x1e922), /* Unicode 9 */
+	{ 0,0,0 }
+};
+
 static const unsigned short pairs[][2] = {
 	{ 'I',    0x0131 },
 	{ 'S',    0x017f },
@@ -201,6 +217,17 @@ static const unsigned short pairs[][2] = {
 	{ 0xa78d, 0x265 },
 	{ 0xa7aa, 0x266 },
 
+	{ 0xa7ab, 0x25c }, /* Unicode 7.0 */
+	{ 0xa7ac, 0x261 }, /* Unicode 7.0 */
+	{ 0xa7ad, 0x26c }, /* Unicode 7.0 */
+	{ 0xa7ae, 0x26a }, /* Unicode 9.0 */
+	{ 0xa7b0, 0x29e }, /* Unicode 7.0 */
+	{ 0xa7b1, 0x287 }, /* Unicode 7.0 */
+	{ 0xa7b2, 0x29d }, /* Unicode 7.0 */
+	{ 0xa7b3, 0xab53 }, /* Unicode 8.0 */
+	{ 0xa7b4, 0xa7b5 }, /* Unicode 8.0 */
+	{ 0xa7b6, 0xa7b7 }, /* Unicode 8.0 */
+
 	{ 0x10c7, 0x2d27 },
 	{ 0x10cd, 0x2d2d },
 
@@ -250,8 +277,14 @@ static wchar_t __towcase(wchar_t wc, int lower)
 		if (pairs[i][1-lower] == wc)
 			return pairs[i][lower];
 	}
-	if ((unsigned)wc - (0x10428 - 0x28*lower) < 0x28)
-		return wc - 0x28 + 0x50*lower;
+	for (i=0; casemapsl[i].len; i++) {
+		int base = casemapsl[i].upper + (lmask & casemapsl[i].lower);
+		if ((unsigned)wc-base < casemapsl[i].len) {
+			if (casemapsl[i].lower == 1)
+				return wc + lower - ((wc-casemapsl[i].upper)&1);
+			return wc + lmul*casemapsl[i].lower;
+		}
+	}
 	return wc;
 }
 
-- 
2.8.4 (Apple Git-73)


[-- Attachment #3: Type: text/plain, Size: 33 bytes --]



Reini Urban
rurban@cpan.org




             reply	other threads:[~2017-09-13  8:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-13  8:25 Reini Urban [this message]
2017-09-13 10:05 ` Reini Urban
2017-09-13 18:13   ` Rich Felker
2017-10-20  9:00     ` Reini Urban
2017-10-25 18:38       ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=FD4E73D2-3AD7-43F3-901D-E8437FB54E25@cpan.org \
    --to=rurban@cpan.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).