ICU-3230 Fix uconv -l --canon
X-SVN-Rev: 12999
This commit is contained in:
parent
3ac583d334
commit
f275652a36
@ -18,6 +18,7 @@
|
||||
|
||||
#include <unicode/utypes.h>
|
||||
#include <unicode/ucnv.h>
|
||||
#include <unicode/uenum.h>
|
||||
#include <unicode/unistr.h>
|
||||
#include <unicode/translit.h>
|
||||
#include <unicode/uclean.h>
|
||||
@ -228,13 +229,22 @@ static int printConverters(const char *pname, const char *lookfor,
|
||||
} else {
|
||||
uint16_t s;
|
||||
|
||||
if (canon) {
|
||||
printf("{ ");
|
||||
}
|
||||
for (s = 0; s < num_stds; ++s) {
|
||||
stds[s] = ucnv_getStandard(s, &err);
|
||||
if (canon) {
|
||||
printf("%s ", stds[s]);
|
||||
}
|
||||
if (U_FAILURE(err)) {
|
||||
u_wmsg(stderr, "cantGetTag", u_wmsg_errorName(err));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (canon) {
|
||||
puts("}");
|
||||
}
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < num; i++) {
|
||||
@ -278,21 +288,33 @@ static int printConverters(const char *pname, const char *lookfor,
|
||||
return -1;
|
||||
}
|
||||
|
||||
printf("%s", alias);
|
||||
/* Print the current alias so that it looks right. */
|
||||
printf("%s%s%s", (canon ? (a == 0? "" : "\t" ) : "") ,
|
||||
alias,
|
||||
(canon ? "" : " "));
|
||||
|
||||
/* Look (slowly, linear searching) for a tag. */
|
||||
|
||||
if (canon) {
|
||||
for (s = t = 0; s < num_stds; ++s) {
|
||||
const char *standard =
|
||||
ucnv_getStandardName(name, stds[s], &err);
|
||||
if (U_SUCCESS(err) && standard) {
|
||||
if (!strcmp(standard, alias)) {
|
||||
if (!t) {
|
||||
printf(" {");
|
||||
t = 1;
|
||||
/* -1 to skip the last standard */
|
||||
for (s = t = 0; s < num_stds-1; ++s) {
|
||||
UEnumeration *nameEnum = ucnv_openStandardNames(name, stds[s], &err);
|
||||
if (U_SUCCESS(err)) {
|
||||
/* List the standard tags */
|
||||
const char *standardName;
|
||||
UBool isFirst = TRUE;
|
||||
UErrorCode enumError = U_ZERO_ERROR;
|
||||
while ((standardName = uenum_next(nameEnum, NULL, &enumError))) {
|
||||
/* See if this alias is supported by this standard. */
|
||||
if (!strcmp(standardName, alias)) {
|
||||
if (!t) {
|
||||
printf(" {");
|
||||
t = 1;
|
||||
}
|
||||
/* Print a * after the default standard name */
|
||||
printf(" %s%s", stds[s], (isFirst ? "*" : ""));
|
||||
}
|
||||
printf(" %s", stds[s]);
|
||||
isFirst = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -300,21 +322,17 @@ static int printConverters(const char *pname, const char *lookfor,
|
||||
printf(" }");
|
||||
}
|
||||
}
|
||||
/* Terminate this entry. */
|
||||
if (canon) {
|
||||
puts("");
|
||||
}
|
||||
|
||||
/* Move on. */
|
||||
|
||||
if (a < num_aliases - 1) {
|
||||
putchar(a || !canon ? ' ' : '\t');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Terminate this entry. */
|
||||
|
||||
if (canon) {
|
||||
putchar('\n');
|
||||
} else if (i < num - 1) {
|
||||
putchar(' ');
|
||||
/* Terminate this entry. */
|
||||
if (!canon) {
|
||||
puts("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user