public inbox for newlib-cvs@sourceware.org help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org> To: newlib-cvs@sourceware.org Subject: [newlib-cygwin] comments to document struct caseconv_entry Date: Mon, 26 Mar 2018 10:22:00 -0000 [thread overview] Message-ID: <20180326102221.15595.qmail@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=fc59da00c85de5307ff74e043ec2d802a3ec4655 commit fc59da00c85de5307ff74e043ec2d802a3ec4655 Author: Thomas Wolff <towo@towo.net> Date: Mon Mar 26 11:46:40 2018 +0200 comments to document struct caseconv_entry explain design of compact (packed) struct caseconv_entry, in case it needs to be modified for future Unicode versions Diff: --- newlib/libc/ctype/towctrans_l.c | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/newlib/libc/ctype/towctrans_l.c b/newlib/libc/ctype/towctrans_l.c index ca7e89f..9759cf7 100644 --- a/newlib/libc/ctype/towctrans_l.c +++ b/newlib/libc/ctype/towctrans_l.c @@ -4,8 +4,36 @@ //#include <errno.h> #include "local.h" -enum {EVENCAP, ODDCAP}; +/* + struct caseconv_entry describes the case conversion behaviour + of a range of Unicode characters. + It was designed to be compact for a minimal table size. + The range is first...first + diff. + Conversion behaviour for a character c in the respective range: + mode == TOLO towlower (c) = c + delta + mode == TOUP towupper (c) = c + delta + mode == TOBOTH (titling case characters) + towlower (c) = c + 1 + towupper (c) = c - 1 + mode == TO1 capital/small letters are alternating + delta == EVENCAP even codes are capital + delta == ODDCAP odd codes are capital + (this correlates with an even/odd first range value + as of Unicode 10.0 but we do not rely on this) + As of Unicode 10.0, the following field lengths are sufficient + first: 17 bits + diff: 8 bits + delta: 17 bits + mode: 2 bits + The reserve of 4 bits (to limit the struct to 6 bytes) + is currently added to the 'first' field; + should a future Unicode version make it necessary to expand the others, + the 'first' field could be reduced as needed, or larger ranges could + be split up (reduce limit max=255 e.g. to max=127 or max=63 in + script mkcaseconv, check increasing table size). + */ enum {TO1, TOLO, TOUP, TOBOTH}; +enum {EVENCAP, ODDCAP}; static struct caseconv_entry { unsigned int first: 21; unsigned short diff: 8; @@ -71,6 +99,7 @@ toulower (wint_t c) default: break; } + return c; } @@ -102,9 +131,10 @@ touupper (wint_t c) default: break; } - default: - break; + default: + break; } + return c; }
reply other threads:[~2018-03-26 10:22 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20180326102221.15595.qmail@sourceware.org \ --to=corinna@sourceware.org \ --cc=newlib-cvs@sourceware.org \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).