summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorapnadkarni <apnmbx-wits@yahoo.com>2024-06-19 03:13:52 (GMT)
committerapnadkarni <apnmbx-wits@yahoo.com>2024-06-19 03:13:52 (GMT)
commitffc7a3702f13883ee95a09b3cd99138b70055c0f (patch)
treef52dba75dc377f301c306db4f11a09225de43043
parentda5eb644cc630adedbb1d3986b579146dac787c3 (diff)
downloadtcl-ffc7a3702f13883ee95a09b3cd99138b70055c0f.zip
tcl-ffc7a3702f13883ee95a09b3cd99138b70055c0f.tar.gz
tcl-ffc7a3702f13883ee95a09b3cd99138b70055c0f.tar.bz2
Handle ambiguous ICU encoding name aliases
-rw-r--r--generic/tclIcu.c8
-rw-r--r--library/icu.tcl16
2 files changed, 18 insertions, 6 deletions
diff --git a/generic/tclIcu.c b/generic/tclIcu.c
index 05da7ca..7c1bace 100644
--- a/generic/tclIcu.c
+++ b/generic/tclIcu.c
@@ -23,7 +23,8 @@ typedef enum UBreakIteratorTypex {
} UBreakIteratorTypex;
typedef enum UErrorCodex {
- U_ZERO_ERRORZ = 0 /**< No error, no warning. */
+ U_AMBIGUOUS_ALIAS_WARNING = -122,
+ U_ZERO_ERRORZ = 0, /**< No error, no warning. */
} UErrorCodex;
#define U_SUCCESS(x) ((x)<=U_ZERO_ERRORZ)
@@ -416,7 +417,7 @@ IcuConverterAliasesObjCmd (
const char *name = Tcl_GetString(objv[1]);
UErrorCodex status = U_ZERO_ERRORZ;
uint16_t count = ucnv_countAliases(name, &status);
- if (U_FAILURE(status)) {
+ if (status != U_AMBIGUOUS_ALIAS_WARNING && U_FAILURE(status)) {
return IcuError(interp, "Could not get aliases.", status);
}
if (count <= 0) {
@@ -425,8 +426,9 @@ IcuConverterAliasesObjCmd (
Tcl_Obj *resultObj = Tcl_NewListObj(count, NULL);
uint16_t i;
for (i = 0; i < count; ++i) {
+ status = U_ZERO_ERRORZ; /* Reset in case U_AMBIGUOUS_ALIAS_WARNING */
const char *aliasName = ucnv_getAlias(name, i, &status);
- if (U_FAILURE(status)) {
+ if (status != U_AMBIGUOUS_ALIAS_WARNING && U_FAILURE(status)) {
status = U_ZERO_ERRORZ; /* Reset error for next iteration */
continue;
}
diff --git a/library/icu.tcl b/library/icu.tcl
index c256d00..827fd04 100644
--- a/library/icu.tcl
+++ b/library/icu.tcl
@@ -21,10 +21,13 @@ namespace eval ::tcl::unsupported::icu {
variable tclToIcu
variable icuToTcl
+ proc LogError {message} {
+ puts stderr $message
+ }
+
proc Init {} {
variable tclToIcu
variable icuToTcl
-
# There are some special cases where names do not line up
# at all. Map Tcl -> ICU
array set specialCases {
@@ -37,9 +40,14 @@ namespace eval ::tcl::unsupported::icu {
}
# Ignore all errors. Do not want to hold up Tcl
# if ICU not available
- catch {
+ if {[catch {
foreach tclName [encoding names] {
- set icuNames [aliases $tclName]
+ if {[catch {
+ set icuNames [aliases $tclName]
+ } erMsg]} {
+ LogError "Could not get aliases for $tclName: $erMsg"
+ continue
+ }
if {[llength $icuNames] == 0} {
# E.g. macGreek -> x-MacGreek
set icuNames [aliases x-$tclName]
@@ -62,6 +70,8 @@ namespace eval ::tcl::unsupported::icu {
lappend icuToTcl($icuName) $tclName
}
}
+ } errMsg]} {
+ LogError $errMsg
}
array default set tclToIcu ""
array default set icuToTcl ""