Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2010-12-06
20:00 • Closed ticket [3085863fff]: tclUniData 9 years old plus 7 other changes artifact: e55fd10d20 user: nijtmans
2010-10-24
14:25 • Ticket [3085863fff]: 4 changes artifact: c911180b70 user: dkf
2010-10-23
14:34 • Ticket [3085863fff]: 5 changes artifact: 4ed714a7d7 user: nijtmans
2010-10-15
22:28 • Ticket [3085863fff]: 4 changes artifact: 16b3d32e2e user: nijtmans
2010-10-14
19:12 • Ticket [3085863fff]: 4 changes artifact: f9c9bdb25d user: lars_h
2010-10-13
22:17 • Ticket [3085863fff]: 4 changes artifact: 46690f6a1e user: nijtmans
22:07 • Ticket [3085863fff]: 4 changes artifact: 1da9224b1e user: nijtmans
22:02 • Ticket [3085863fff]: 4 changes artifact: e4c38a5052 user: nijtmans
22:02 • Add attachment 3085863.patch to ticket [3085863fff] artifact: 173568d47f user: nijtmans
22:02 • Ticket [3085863fff] tclUniData 9 years old status still Open with 4 other ch... artifact: ca82b6d499 user: nijtmans
19:20 • Ticket [3085863fff]: 4 changes artifact: b3962c8ab2 user: lars_h
2010-10-12
22:37 • Ticket [3085863fff]: 5 changes artifact: c0f484af2f user: nijtmans
22:28 • Ticket [3085863fff]: 4 changes artifact: 3e2816915b user: nijtmans
11:52 • New ticket [3085863fff]. artifact: eef87c5f55 user: lars_h

tclUniData 9 years old

Closed / Fixed3085863fffffffffffffffffffffffffffffffffCreated 16 years agoUpdated 16 years ago
Descriptionplain2010-10-12 11:52:18
It seems the tables in tclUniData.c (i.e., what class the various characters belong to) are based on a UnicodeData.txt file that is at least 9 years old, since they have been unchanged for at least that long. This means for example \u0220 (LATIN CAPITAL LETTER N WITH LONG RIGHT LEG) is not considered to be alphabetic by Tcl

% string is alpha \u0220
0

despite it being listed as having class Lu in http://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt.

A possible factor could be that tools/uniParse.tcl states its input should be the file

  ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData-Latest.txt

which doesn't exist anymore; there is only a UnicodeData.txt which presumably serves the same purpose.

Another factor could be worry that updating these tables could reopen the "Unicode beyond \uFFFF" can of worms, but the CVS comments for tclUniData.c v1.4 says it was generated from the UnicodeData.txt for Unicode 3.1.0, and (if I recall it correctly) that is precisely the first version that added non-BMP characters, so we've already jumped that particular bullet.
nijtmansplain2010-10-12 22:28:53
File Added - 389731: 3085863.patch
nijtmansplain2010-10-12 22:37:25
Jeff, I did what Lars suggested, re-generating the necessary files with the latest UnicodeData.txt. The only 'real' thing I had to change is the type static variable
pageMap, from unsigned char to unsigned const, because there are more
than 256 maps now. Here is the patch (after some more manual changes
to regc_locale.c).

All test seem to run fine.
Please evaluate, is there anything I am missing?
lars_hplain2010-10-13 19:20:32
There is something slightly odd here. The current pageMap vector is indexed by an 11-bit integer (11 = 16 - OFFSET_BITS), meaning 2048 distinct elements can be accessed, but the vector has 5886 elements! Presumably it contains data also for non-BMP characters :-), even though Tcl can't access it :-(.

Looking at uniParse.tcl, it indeed does not have any provisions for ignoring data if the codepoint is out of range. And what is perhaps worse: It only uses the first four hex digits as codepoint (the index variable). That's a bug! (So the data for unaccessible characters was probably wrong anyway.)

Suggested fix: Change the lines

scan [lindex $items 0] %4x index
set index [format 0x%0.4x $index]

to

scan [lindex $items 0] %x index
        if {$index > 0xFFFF} then {
            # Ignore non-BMP characters, as long as Tcl doesn't support them
            continue
        }
set index [format 0x%0.4x $index]

I wouldn't be surprised if that solves the more-than-256 groups problem as well.
nijtmansplain2010-10-13 22:02:20
File Deleted - 389731:
nijtmansplain2010-10-13 22:02:59
File Added - 389834: 3085863.patch
nijtmansplain2010-10-13 22:07:08
New attempt. Didn't try your code (which is obvously the right way),
just stripped of the out-of-range characters from UnicodeData.txt
before running the tools. Here is the result, a new patch.
The table has some 2048 elements now, so that looks more
reasonable, but still more than 256.

Is this better?
nijtmansplain2010-10-13 22:17:26
After this patch:
  % string is alpha \u0220
  1

So it looks like it works!
lars_hplain2010-10-14 19:12:05
Changing uni::shift to 6 (is currently 5, but for some reason a 6 is hardcoded in what uniParse.tcl writes to stdout) lets you get by with 208 groups. Each +1 increase in this doubles the length of the groupMap though, so perhaps it's cheaper to let the entries in the pageMap be swell to 16 bits.
nijtmansplain2010-10-15 22:28:08
Checked in in HEAD. Left open because of:
- More tests should be added
- Backport to 8.5/8.4??
But before doing that, I would like to receive
more feedback that this is really OK, not
introducing any problem. I cannot find
anything wrong, but 9 years of changes
is a long time........
nijtmansplain2010-10-23 14:34:45
Added more tests, and backported to 8.5.

Any interest for 8.4 too?
dkfplain2010-10-24 14:25:16
Probably not worth your time. 8.4 is probably EOLed now unless someone finds something seriously wrong with it (security hole or crash-bug).
nijtmansplain2010-12-06 20:00:27
allow_comments - 1

It seems everything is OK, so closing
Log in (anonymous is fine) to add a comment.

Attachments: