[svn:parrot] r47829 - in branches/gsoc_nfg: src/string src/string/encoding t/op
darbelo at svn.parrot.org
darbelo at svn.parrot.org
Fri Jun 25 07:06:14 UTC 2010
Author: darbelo
Date: Fri Jun 25 07:06:13 2010
New Revision: 47829
URL: https://trac.parrot.org/parrot/changeset/47829
Log:
Add some null table handling to grapheme_table_capacity and use that to simplify the iterator code a bit.
Modified:
branches/gsoc_nfg/src/string/encoding/nfg.c
branches/gsoc_nfg/src/string/grapheme.c
branches/gsoc_nfg/t/op/string_nfg.t
Modified: branches/gsoc_nfg/src/string/encoding/nfg.c
==============================================================================
--- branches/gsoc_nfg/src/string/encoding/nfg.c Fri Jun 25 06:56:37 2010 (r47828)
+++ branches/gsoc_nfg/src/string/encoding/nfg.c Fri Jun 25 07:06:13 2010 (r47829)
@@ -548,15 +548,15 @@
}
else {
UErrorCode err = U_ZERO_ERROR;
+ UChar src[3];
int dst_len = 1;
- int src_len = 1;
- UChar src[2];
UChar dst[2];
src[0] = s[pos - 1];
src[1] = s[pos];
+ src[2] = 0;
/* Delegate composition to ICU. */
- dst_len = unorm_normalize(src, src_len, UNORM_DEFAULT, 0,
+ dst_len = unorm_normalize(src, -1 , UNORM_DEFAULT, 0,
dst, dst_len, &err);
if (U_SUCCESS(err)) {
@@ -566,11 +566,6 @@
}
/* Composition failed, we need a dynamic codepoint. */
- if (table == NULL) {
- table = create_grapheme_table(interp, 1);
- i->str->extra = table;
- }
-
g.len = 2;
g.hash = 0xffff;
g.codepoints = mem_gc_allocate_n_typed(interp, g.len, UChar32);
Modified: branches/gsoc_nfg/src/string/grapheme.c
==============================================================================
--- branches/gsoc_nfg/src/string/grapheme.c Fri Jun 25 06:56:37 2010 (r47828)
+++ branches/gsoc_nfg/src/string/grapheme.c Fri Jun 25 07:06:13 2010 (r47829)
@@ -18,7 +18,9 @@
grapheme_table_capacity(PARROT_INTERP, grapheme_table *table)
{
ASSERT_ARGS(grapheme_table_capacity)
- return table->size - table->used;
+ if (table)
+ return table->size - table->used;
+ return 0;
}
grapheme_table *
Modified: branches/gsoc_nfg/t/op/string_nfg.t
==============================================================================
--- branches/gsoc_nfg/t/op/string_nfg.t Fri Jun 25 06:56:37 2010 (r47828)
+++ branches/gsoc_nfg/t/op/string_nfg.t Fri Jun 25 07:06:13 2010 (r47829)
@@ -49,11 +49,11 @@
is($I0, $I1, "Bufused is the same.")
# Do the same thing again, without dynamic codepoints.
- $S2 = utf16:unicode:"O\u0308"
+ $S2 = utf16:unicode:"n\u0303"
$I0 = find_encoding 'nfg'
$S2 = trans_encoding $S2, $I0
- $S3 = nfg:unicode:"O\u0308"
+ $S3 = nfg:unicode:"n\u0303"
$I0 = stringinfo $S2, .STRINGINFO_STRLEN
$I1 = stringinfo $S3, .STRINGINFO_STRLEN
More information about the parrot-commits
mailing list