X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/48b980fed3435926e0b3a8d72ecb58be703a1c7a..729e4ab9bc6618bc3d8a898e575df7f4019e29ca:/icuSources/tools/gencnval/gencnval.c diff --git a/icuSources/tools/gencnval/gencnval.c b/icuSources/tools/gencnval/gencnval.c index f3e12aa2..ccbaf146 100644 --- a/icuSources/tools/gencnval/gencnval.c +++ b/icuSources/tools/gencnval/gencnval.c @@ -1,7 +1,7 @@ /* ******************************************************************************* * -* Copyright (C) 1999-2008, International Business Machines +* Copyright (C) 1999-2009, International Business Machines * Corporation and others. All Rights Reserved. * ******************************************************************************* @@ -142,6 +142,12 @@ static UConverterAliasOptions tableOptions = { 1 /* containsCnvOptionInfo */ }; + +/** + * path to convrtrs.txt + */ +const char *path; + /* prototypes --------------------------------------------------------------- */ static void @@ -212,7 +218,6 @@ static UOption options[]={ extern int main(int argc, char* argv[]) { char pathBuf[512]; - const char *path; FileStream *in; UNewDataMemory *out; UErrorCode errorCode=U_ZERO_ERROR; @@ -276,7 +281,7 @@ main(int argc, char* argv[]) { in=T_FileStream_open(path, "r"); if(in==NULL) { - fprintf(stderr, "gencnval: unable to open input file convrtrs.txt\n"); + fprintf(stderr, "gencnval: unable to open input file %s\n", path); exit(U_FILE_ACCESS_ERROR); } parseFile(in); @@ -337,11 +342,11 @@ parseFile(FileStream *in) { if (validParse || lineSize > 0) { if (isspace(*line)) { - fprintf(stderr, "error(line %d): cannot start an alias with a space\n", lineNum-1); + fprintf(stderr, "%s:%d: error: cannot start an alias with a space\n", path, lineNum-1); exit(U_PARSE_ERROR); } else if (line[0] == '{') { if (!standardTagsUsed && line[lineSize - 1] != '}') { - fprintf(stderr, "error(line %d): alias needs to start with a converter name\n", lineNum); + fprintf(stderr, "%s:%d: error: alias needs to start with a converter name\n", path, lineNum); exit(U_PARSE_ERROR); } addOfficialTaggedStandards(line, lineSize); @@ -351,7 +356,7 @@ parseFile(FileStream *in) { parseLine(line); } else { - fprintf(stderr, "error(line %d): alias table needs to start a list of standard tags\n", lineNum); + fprintf(stderr, "%s:%d: error: alias table needs to start a list of standard tags\n", path, lineNum); exit(U_PARSE_ERROR); } } @@ -492,7 +497,7 @@ parseLine(const char *line) { if (line[pos] == '}') { ++pos; } else { - fprintf(stderr, "error(line %d): Unterminated tag list\n", lineNum); + fprintf(stderr, "%s:%d: Unterminated tag list\n", path, lineNum); exit(U_UNMATCHED_BRACES); } } else { @@ -508,7 +513,7 @@ getTagNumber(const char *tag, uint16_t tagLen) { UBool preferredName = ((tagLen > 0) ? (tag[tagLen - 1] == '*') : (FALSE)); if (tagCount >= MAX_TAG_COUNT) { - fprintf(stderr, "error(line %d): too many tags\n", lineNum); + fprintf(stderr, "%s:%d: too many tags\n", path, lineNum); exit(U_BUFFER_OVERFLOW_ERROR); } @@ -526,7 +531,7 @@ getTagNumber(const char *tag, uint16_t tagLen) { /* we need to add this tag */ if (tagCount >= MAX_TAG_COUNT) { - fprintf(stderr, "error(line %d): too many tags\n", lineNum); + fprintf(stderr, "%s:%d: error: too many tags\n", path, lineNum); exit(U_BUFFER_OVERFLOW_ERROR); } @@ -534,13 +539,13 @@ getTagNumber(const char *tag, uint16_t tagLen) { atag = allocString(&tagBlock, tag, tagLen); if (standardTagsUsed) { - fprintf(stderr, "error(line %d): Tag \"%s\" is not declared at the beginning of the alias table.\n", - lineNum, atag); + fprintf(stderr, "%s:%d: error: Tag \"%s\" is not declared at the beginning of the alias table.\n", + path, lineNum, atag); exit(1); } else if (tagLen > 0 && strcmp(tag, ALL_TAG_STR) != 0) { - fprintf(stderr, "warning(line %d): Tag \"%s\" was added to the list of standards because it was not declared at beginning of the alias table.\n", - lineNum, atag); + fprintf(stderr, "%s:%d: warning: Tag \"%s\" was added to the list of standards because it was not declared at beginning of the alias table.\n", + path, lineNum, atag); } /* add the tag to the tag table */ @@ -564,19 +569,19 @@ addOfficialTaggedStandards(char *line, int32_t lineLen) { static const char WHITESPACE[] = " \t"; if (tagCount > UCNV_NUM_RESERVED_TAGS) { - fprintf(stderr, "error(line %d): official tags already added\n", lineNum); + fprintf(stderr, "%s:%d: error: official tags already added\n", path, lineNum); exit(U_BUFFER_OVERFLOW_ERROR); } tag = strchr(line, '{'); if (tag == NULL) { /* Why were we called? */ - fprintf(stderr, "error(line %d): Missing start of tag group\n", lineNum); + fprintf(stderr, "%s:%d: error: Missing start of tag group\n", path, lineNum); exit(U_PARSE_ERROR); } tag++; endTagExp = strchr(tag, '}'); if (endTagExp == NULL) { - fprintf(stderr, "error(line %d): Missing end of tag group\n", lineNum); + fprintf(stderr, "%s:%d: error: Missing end of tag group\n", path, lineNum); exit(U_PARSE_ERROR); } endTagExp[0] = 0; @@ -607,7 +612,7 @@ addToKnownAliases(const char *alias) { if (knownAliases[idx] != num && uprv_strcmp(alias, GET_ALIAS_STR(knownAliases[idx])) == 0) { - fprintf(stderr, "warning(line %d): duplicate alias %s and %s found\n", + fprintf(stderr, "%s:%d: warning: duplicate alias %s and %s found\n", path, lineNum, alias, GET_ALIAS_STR(knownAliases[idx])); duplicateKnownAliasesCount++; break; @@ -616,7 +621,7 @@ addToKnownAliases(const char *alias) { && ucnv_compareNames(alias, GET_ALIAS_STR(knownAliases[idx])) == 0) { if (verbose) { - fprintf(stderr, "information(line %d): duplicate alias %s and %s found\n", + fprintf(stderr, "%s:%d: information: duplicate alias %s and %s found\n", path, lineNum, alias, GET_ALIAS_STR(knownAliases[idx])); } duplicateKnownAliasesCount++; @@ -625,8 +630,8 @@ addToKnownAliases(const char *alias) { } */ if (knownAliasesCount >= MAX_ALIAS_COUNT) { - fprintf(stderr, "warning(line %d): Too many aliases defined for all converters\n", - lineNum); + fprintf(stderr, "%s:%d: warning: Too many aliases defined for all converters\n", + path, lineNum); exit(U_BUFFER_OVERFLOW_ERROR); } /* TODO: We could try to unlist exact duplicates. */ @@ -644,22 +649,22 @@ addAlias(const char *alias, uint16_t standard, uint16_t converter, UBool default AliasList *aliasList; if(standard>=MAX_TAG_COUNT) { - fprintf(stderr, "error(line %d): too many standard tags\n", lineNum); + fprintf(stderr, "%s:%d: error: too many standard tags\n", path, lineNum); exit(U_BUFFER_OVERFLOW_ERROR); } if(converter>=MAX_CONV_COUNT) { - fprintf(stderr, "error(line %d): too many converter names\n", lineNum); + fprintf(stderr, "%s:%d: error: too many converter names\n", path, lineNum); exit(U_BUFFER_OVERFLOW_ERROR); } aliasList = &tags[standard].aliasList[converter]; if (strchr(alias, '}')) { - fprintf(stderr, "error(line %d): unmatched } found\n", + fprintf(stderr, "%s:%d: error: unmatched } found\n", path, lineNum); } if(aliasList->aliasCount + 1 >= MAX_TC_ALIAS_COUNT) { - fprintf(stderr, "error(line %d): too many aliases for alias %s and converter %s\n", + fprintf(stderr, "%s:%d: error: too many aliases for alias %s and converter %s\n", path, lineNum, alias, GET_ALIAS_STR(converters[converter].converter)); exit(U_BUFFER_OVERFLOW_ERROR); } @@ -696,13 +701,13 @@ addAlias(const char *alias, uint16_t standard, uint16_t converter, UBool default * not just a lenient-match duplicate. */ if (verbose || 0 == uprv_strcmp(alias, GET_ALIAS_STR(aliasNum))) { - fprintf(stderr, "warning(line %d): duplicate aliases %s and %s found for standard %s and converter %s\n", + fprintf(stderr, "%s:%d: warning: duplicate aliases %s and %s found for standard %s and converter %s\n", path, lineNum, alias, GET_ALIAS_STR(aliasNum), GET_TAG_STR(tags[standard].tag), GET_ALIAS_STR(converters[converter].converter)); } } else { - fprintf(stderr, "warning(line %d): duplicate aliases %s and %s found for standard tag %s between converter %s and converter %s\n", + fprintf(stderr, "%s:%d: warning: duplicate aliases %s and %s found for standard tag %s between converter %s and converter %s\n", path, lineNum, alias, GET_ALIAS_STR(aliasNum), GET_TAG_STR(tags[standard].tag), GET_ALIAS_STR(converters[converter].converter), @@ -723,7 +728,7 @@ addAlias(const char *alias, uint16_t standard, uint16_t converter, UBool default if (aliasNum && ucnv_compareNames(alias, GET_ALIAS_STR(aliasNum)) == 0) { - fprintf(stderr, "warning(line %d): duplicate alias %s found for converter %s and standard tag %s\n", + fprintf(stderr, "%s:%d: warning: duplicate alias %s found for converter %s and standard tag %s\n", path, lineNum, alias, GET_ALIAS_STR(converters[converter].converter), GET_TAG_STR(tags[standard].tag)); break; } @@ -742,7 +747,7 @@ addAlias(const char *alias, uint16_t standard, uint16_t converter, UBool default } if (defaultName) { if (aliasList->aliases[0] != 0) { - fprintf(stderr, "error(line %d): Alias %s and %s cannot both be the default alias for standard tag %s and converter %s\n", + fprintf(stderr, "%s:%d: error: Alias %s and %s cannot both be the default alias for standard tag %s and converter %s\n", path, lineNum, alias, GET_ALIAS_STR(aliasList->aliases[0]), @@ -766,13 +771,13 @@ static uint16_t addConverter(const char *converter) { uint32_t idx; if(converterCount>=MAX_CONV_COUNT) { - fprintf(stderr, "error(line %d): too many converters\n", lineNum); + fprintf(stderr, "%s:%d: error: too many converters\n", path, lineNum); exit(U_BUFFER_OVERFLOW_ERROR); } for (idx = 0; idx < converterCount; idx++) { if (ucnv_compareNames(converter, GET_ALIAS_STR(converters[idx].converter)) == 0) { - fprintf(stderr, "error(line %d): duplicate converter %s found!\n", lineNum, converter); + fprintf(stderr, "%s:%d: error: duplicate converter %s found!\n", path, lineNum, converter); exit(U_PARSE_ERROR); break; } @@ -816,7 +821,8 @@ resolveAliasToConverter(uint16_t alias, uint16_t *tagNum, uint16_t *converterNum } *tagNum = UINT16_MAX; *converterNum = UINT16_MAX; - fprintf(stderr, "warning: alias %s not found\n", + fprintf(stderr, "%s: warning: alias %s not found\n", + path, GET_ALIAS_STR(alias)); return; } @@ -916,14 +922,15 @@ createOneAliasList(uint16_t *aliasArrLists, uint32_t tag, uint32_t converter, ui } else { value = 0; if (tag != 0) { /* Only show the warning when it's not the leftover tag. */ - printf("warning: tag %s does not have a default alias for %s\n", + fprintf(stderr, "%s: warning: tag %s does not have a default alias for %s\n", + path, GET_TAG_STR(tags[tag].tag), GET_ALIAS_STR(converters[converter].converter)); } } aliasLists[aliasListsSize++] = value; if (aliasListsSize >= MAX_LIST_SIZE) { - fprintf(stderr, "error: Too many alias lists\n"); + fprintf(stderr, "%s: error: Too many alias lists\n", path); exit(U_BUFFER_OVERFLOW_ERROR); } @@ -1068,7 +1075,7 @@ allocString(StringBlock *block, const char *s, int32_t length) { top=block->top + (uint32_t)((length + 1 + 1) & ~1); if(top >= block->max) { - fprintf(stderr, "error(line %d): out of memory\n", lineNum); + fprintf(stderr, "%s:%d: error: out of memory\n", path, lineNum); exit(U_MEMORY_ALLOCATION_ERROR); } @@ -1082,7 +1089,7 @@ allocString(StringBlock *block, const char *s, int32_t length) { /* check for invariant characters now that we have a NUL-terminated string for easy output */ if(!uprv_isInvariantString(p, length)) { - fprintf(stderr, "error(line %d): the name %s contains not just invariant characters\n", lineNum, p); + fprintf(stderr, "%s:%d: error: the name %s contains not just invariant characters\n", path, lineNum, p); exit(U_INVALID_TABLE_FORMAT); }