mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@aerifal.cx>
To: musl@lists.openwall.com
Subject: Re: Help establishing wctype character classes
Date: Sun, 22 Apr 2012 23:51:04 -0400	[thread overview]
Message-ID: <20120423035104.GL14673@brightrain.aerifal.cx> (raw)
In-Reply-To: <20120423014414.GK14673@brightrain.aerifal.cx>

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

And here's a quick implementation of the iswalnum set generator. At
this point it just generates a dumb lookup table without doing any
multi-level table optimizations or compression, and dumps the table to
stdout in a visual form. I need to run some analysis on the table to
determine the best way to get it down to a reasonable size.

Rich

[-- Attachment #2: gen_ctype_alpha.c --]
[-- Type: text/plain, Size: 1046 bytes --]

#include <stdio.h>

int main()
{
	char *set = calloc(0x110000,1);
	char buf[128], dummy;
	int a, b;
	FILE *f;

	/* Alphabetic property */
	f = fopen("DerivedCoreProperties.txt", "rb");
	while (fgets(buf, sizeof buf, f)) {
		if (sscanf(buf, "%x..%x ; Alphabetic%c", &a, &b, &dummy)==3)
			for (; a<=b; a++) set[a]=1;
		else if (sscanf(buf, "%x ; Alphabetic%c", &a, &dummy)==2)
			set[a] = 1;
	}
	fclose(f);

	/* Plus Nd category */
	f = fopen("UnicodeData.txt", "rb");
	while (fgets(buf, sizeof buf, f)) {
		if (sscanf(buf, "%x;%*[^;];Nd%c", &a, &dummy)==2)
			set[a] = 1;
	}
	fclose(f);

	/* Fix misclassified Thai characters */
	set[0xe2f] = set[0xe46] = 0;

	/* Fill in elided CJK ranges */
	for (a=0x3400; a<=0x4db5; a++) set[a]=1;
	for (a=0x4e00; a<=0x9fcc; a++) set[a]=1;
	for (a=0xac00; a<=0xd7a3; a++) set[a]=1;
	for (a=0x20000; a<=0x2a6d6; a++) set[a]=1;
	for (a=0x2a700; a<=0x2b734; a++) set[a]=1;
	for (a=0x2b740; a<=0x2b81d; a++) set[a]=1;

	for (a=0; a<0x110000; a++) {
		putchar(set[a]?'*':'.');
		if (!(a+1&63)) putchar('\n');
	}
}

      reply	other threads:[~2012-04-23  3:51 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-22 20:41 Rich Felker
2012-04-23  1:44 ` Rich Felker
2012-04-23  3:51   ` Rich Felker [this message]

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=20120423035104.GL14673@brightrain.aerifal.cx \
    --to=dalias@aerifal.cx \
    --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).