diff options
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; } |