diff options
author | John-Mark Bell <jmb@netsurf-browser.org> | 2013-01-13 02:05:46 +0000 |
---|---|---|
committer | John-Mark Bell <jmb@netsurf-browser.org> | 2013-01-13 02:05:46 +0000 |
commit | 9c8a4ff7e117ba052b2957c7e3f2e8751e8f8970 (patch) | |
tree | ab5e21285a92db1f77e57741c1be20b1acdbd958 /build | |
parent | 23deb46db03c3e7a2884a49edcf882d933315e70 (diff) | |
download | iconv-9c8a4ff7e117ba052b2957c7e3f2e8751e8f8970.tar.gz iconv-9c8a4ff7e117ba052b2957c7e3f2e8751e8f8970.tar.bz2 |
Transliteration fixes:
* Clear any substitution if codec reset has been requested.
* Don't report memory exhaustion when failing to allocate space
for the test conversion in translit_try_sequence: there's
nothing the caller can do, so treat it as if the substitution
cannot be converted to the target character set.
* Correctly report success if we run out of input immediately
following a flush of a substitution.
Additional tests for transliteration.
Diffstat (limited to 'build')
-rw-r--r-- | build/tools/gentranstab.pl | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/build/tools/gentranstab.pl b/build/tools/gentranstab.pl index 0e9205a..1b1ccad 100644 --- a/build/tools/gentranstab.pl +++ b/build/tools/gentranstab.pl @@ -48,12 +48,18 @@ static int translit_try_sequence(struct encoding_context *e, size_t orig_tmplen, tmplen, index; int ret = 1; - /* First, determine if sequence can be written to target encoding */ + /* Determine if sequence can be written to target encoding */ /* Worst case: conversion to UTF-8 (needing 6 bytes per character) */ orig_tmplen = tmplen = (seqlen + 1) * 6; ptmpbuf = tmpbuf = malloc(tmplen); - if (tmpbuf == NULL) - return 0; + if (tmpbuf == NULL) { + /* Consider lack of memory an inability to write the output. + * We cannot report memory exhaustion from here, as it will + * result in the caller thinking that the output buffer is + * too small, which isn't actually the case. As + * transliteration is best-effort anyway, this should be ok. */ + return -1; + } /* Reset the transout codec */ if (e->transout != NULL) { @@ -102,6 +108,8 @@ int translit_flush_replacement(struct encoding_context *e) size_t substlen = e->substlen; int ret = 1; + LOG(("Flushing %zd characters", substlen)); + while (substlen > 0) { UCS4 c = substitution[0]; @@ -118,6 +126,8 @@ int translit_flush_replacement(struct encoding_context *e) e->substitution = substitution; e->substlen = substlen; + LOG(("%zd characters remaining", substlen)); + return ret; } |