Last change
on this file was 2, checked in by bird, 22 years ago |
Initial revision
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
|
File size:
1.5 KB
|
Line | |
---|
1 | // natCollator.cc - Native code for collation.
|
---|
2 |
|
---|
3 | /* Copyright (C) 1999 Free Software Foundation
|
---|
4 |
|
---|
5 | This file is part of libgcj.
|
---|
6 |
|
---|
7 | This software is copyrighted work licensed under the terms of the
|
---|
8 | Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
|
---|
9 | details. */
|
---|
10 |
|
---|
11 | // Written by Tom Tromey <tromey@cygnus.com>.
|
---|
12 |
|
---|
13 | #include <config.h>
|
---|
14 |
|
---|
15 | #include <gcj/cni.h>
|
---|
16 | #include <jvm.h>
|
---|
17 |
|
---|
18 | #include <java/text/Collator.h>
|
---|
19 | #include <java/lang/StringBuffer.h>
|
---|
20 |
|
---|
21 | #include <java-chardecomp.h>
|
---|
22 |
|
---|
23 | void
|
---|
24 | java::text::Collator::decomposeCharacter (jchar c,
|
---|
25 | java::lang::StringBuffer *buf)
|
---|
26 | {
|
---|
27 | if (decmp == NO_DECOMPOSITION)
|
---|
28 | {
|
---|
29 | buf->append(c);
|
---|
30 | return;
|
---|
31 | }
|
---|
32 |
|
---|
33 | const struct decomp_entry *base;
|
---|
34 | int high;
|
---|
35 |
|
---|
36 | if (decmp == FULL_DECOMPOSITION)
|
---|
37 | {
|
---|
38 | base = full_decomposition;
|
---|
39 | high = sizeof (full_decomposition) / sizeof (struct decomp_entry);
|
---|
40 | }
|
---|
41 | else
|
---|
42 | {
|
---|
43 | base = canonical_decomposition;
|
---|
44 | high = sizeof (canonical_decomposition) / sizeof (struct decomp_entry);
|
---|
45 | }
|
---|
46 |
|
---|
47 | // FIXME: this is probably a bit slow for the task at hand.
|
---|
48 | int i = high / 2;
|
---|
49 | int low = 0;
|
---|
50 | while (true)
|
---|
51 | {
|
---|
52 | if (c < base[i].key)
|
---|
53 | high = i;
|
---|
54 | else if (c > base[i].key)
|
---|
55 | low = i;
|
---|
56 | else
|
---|
57 | break;
|
---|
58 |
|
---|
59 | int old = i;
|
---|
60 | i = (high + low) / 2;
|
---|
61 | if (i == old)
|
---|
62 | {
|
---|
63 | // Not in table, so it expands to itself.
|
---|
64 | buf->append(c);
|
---|
65 | return;
|
---|
66 | }
|
---|
67 | }
|
---|
68 |
|
---|
69 | for (int j = 0; base[i].value[j] != '\0'; j += 2)
|
---|
70 | {
|
---|
71 | jchar x = (base[i].value[j] << 8) | (base[i].value[j + 1]);
|
---|
72 | buf->append (x);
|
---|
73 | }
|
---|
74 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.