/*
*******************************************************************************
*
-* Copyright (C) 1999-2008, International Business Machines
+* Copyright (C) 1999-2009, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
1 /* containsCnvOptionInfo */
};
+
+/**
+ * path to convrtrs.txt
+ */
+const char *path;
+
/* prototypes --------------------------------------------------------------- */
static void
extern int
main(int argc, char* argv[]) {
char pathBuf[512];
- const char *path;
FileStream *in;
UNewDataMemory *out;
UErrorCode errorCode=U_ZERO_ERROR;
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);
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);
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);
}
}
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 {
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);
}
/* 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);
}
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 */
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;
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;
&& 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++;
}
*/
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. */
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);
}
* 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),
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;
}
}
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]),
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;
}
}
*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;
}
} 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);
}
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);
}
/* 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);
}