/*
*******************************************************************************
*
-* Copyright (C) 1998-2006, International Business Machines
+* Copyright (C) 1998-2008, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
static uint32_t outputdirLength;
static UBool gMakeBinaryCollation = TRUE;
+static UBool gOmitCollationRules = FALSE;
static struct SResource *parseResource(char *tag, const struct UString *comment, UErrorCode *status);
*status = U_ZERO_ERROR;
}
+static void
+cleanupLookahead()
+{
+ uint32_t i;
+ for (i = 0; i < MAX_LOOKAHEAD; i++)
+ {
+ ustr_deinit(&lookahead[i].value);
+ ustr_deinit(&lookahead[i].comment);
+ }
+
+}
+
static enum ETokenType
getToken(struct UString **tokenValue, struct UString* comment, uint32_t *linenumber, UErrorCode *status)
{
*status = U_INVALID_FORMAT_ERROR;
error(line, "expecting %s, got %s", tokenNames[expectedToken], tokenNames[token]);
}
- else /* "else" is added by Jing/GCL */
+ else
{
*status = U_ZERO_ERROR;
}
}
uprv_strcat(filename, cs);
+ if(gOmitCollationRules) {
+ return res_none();
+ }
ucbuf = ucbuf_open(filename, &cp, getShowWarning(),FALSE, status);
#if !UCONFIG_NO_TRANSLITERATION
size = utrans_stripRules(pSource, size, pTarget, status);
#else
- size = 0;
+ size = 0;
fprintf(stderr, " Warning: writing empty transliteration data ( UCONFIG_NO_TRANSLITERATION ) \n");
#endif
result = string_open(bundle, tag, pTarget, size, NULL, status);
result = string_open(bundle, tag, tokenValue->fChars, tokenValue->fLength, comment, status);
if(U_SUCCESS(*status) && result) {
- expect(TOK_CLOSE_BRACE, NULL, NULL, NULL, status);
+ expect(TOK_CLOSE_BRACE, NULL, NULL, NULL, status);
- if (U_FAILURE(*status))
- {
- string_close(result, status);
- return NULL;
- }
+ if (U_FAILURE(*status))
+ {
+ res_close(result);
+ return NULL;
+ }
}
}
if (U_FAILURE(*status))
{
- alias_close(result, status);
+ res_close(result);
return NULL;
}
}
if (token != TOK_STRING)
{
- table_close(result, status);
+ res_close(result);
*status = U_INVALID_FORMAT_ERROR;
if (token == TOK_EOF)
if (U_FAILURE(*status))
{
- table_close(result, status);
+ res_close(result);
return NULL;
}
if (U_FAILURE(*status))
{
- table_close(result, status);
+ res_close(result);
return NULL;
}
#if UCONFIG_NO_COLLATION
warning(line, "Not building collation elements because of UCONFIG_NO_COLLATION, see uconfig.h");
#else
- /* first we add the "Sequence", so that we always have rules */
- table_add(result, member, line, status);
+ /* in order to achieve smaller data files, we can direct genrb */
+ /* to omit collation rules */
+ if(!gOmitCollationRules) {
+ /* first we add the "Sequence", so that we always have rules */
+ table_add(result, member, line, status);
+ }
if(gMakeBinaryCollation) {
UErrorCode intStatus = U_ZERO_ERROR;
if (U_FAILURE(*status))
{
- table_close(result, status);
+ res_close(result);
return NULL;
}
}
if (token != TOK_STRING)
{
- table_close(result, status);
+ res_close(result);
*status = U_INVALID_FORMAT_ERROR;
if (token == TOK_EOF)
if (U_FAILURE(*status))
{
- table_close(result, status);
+ res_close(result);
return NULL;
}
if (U_FAILURE(*status))
{
- table_close(result, status);
+ res_close(result);
return NULL;
}
if (U_FAILURE(*status))
{
- table_close(result, status);
+ res_close(result);
return NULL;
}
table_add(result, member, line, status);
} else {
+ res_close(result);
*status = U_INVALID_FORMAT_ERROR;
return NULL;
}
} else {
+ res_close(result);
*status = U_INVALID_FORMAT_ERROR;
return NULL;
}
if (U_FAILURE(*status))
{
- table_close(result, status);
+ res_close(result);
return NULL;
}
}
if (token != TOK_STRING)
{
- table_close(table, status);
*status = U_INVALID_FORMAT_ERROR;
if (token == TOK_EOF)
} else {
*status = U_INVALID_FORMAT_ERROR;
error(line, "invariant characters required for table keys");
- table_close(table, status);
return NULL;
}
if (U_FAILURE(*status))
{
error(line, "parse error. Stopped parsing with %s", u_errorName(*status));
- table_close(table, status);
return NULL;
}
if (member == NULL || U_FAILURE(*status))
{
error(line, "parse error. Stopped parsing with %s", u_errorName(*status));
- table_close(table, status);
return NULL;
}
if (U_FAILURE(*status))
{
error(line, "parse error. Stopped parsing with %s", u_errorName(*status));
- table_close(table, status);
return NULL;
}
readToken = TRUE;
+ ustr_deinit(&comment);
}
/* not reached */
if (token == TOK_EOF)
{
- array_close(result, status);
+ res_close(result);
*status = U_INVALID_FORMAT_ERROR;
error(startline, "unterminated array");
return NULL;
if (member == NULL || U_FAILURE(*status))
{
- array_close(result, status);
+ res_close(result);
return NULL;
}
if (U_FAILURE(*status))
{
- array_close(result, status);
+ res_close(result);
return NULL;
}
if (U_FAILURE(*status))
{
- array_close(result, status);
+ res_close(result);
return NULL;
}
readToken = TRUE;
}
+ ustr_deinit(&memberComments);
return result;
}
char *string;
int32_t value;
UBool readToken = FALSE;
- /* added by Jing/GCL */
char *stopstring;
uint32_t len;
struct UString memberComments;
if (!readToken) {
warning(startline, "Encountered empty int vector");
}
+ ustr_deinit(&memberComments);
return result;
}
if (U_FAILURE(*status))
{
- intvector_close(result, status);
+ res_close(result);
return NULL;
}
- /* Commented by Jing/GCL */
- /*value = uprv_strtol(string, NULL, 10);
- intvector_add(result, value, status);
-
- uprv_free(string);
-
- token = peekToken(0, NULL, NULL, status);*/
- /* The following is added by Jing/GCL to handle illegal char in the Intvector */
+ /* For handling illegal char in the Intvector */
value = uprv_strtoul(string, &stopstring, 0);/* make intvector support decimal,hexdigit,octal digit ranging from -2^31-2^32-1*/
len=(uint32_t)(stopstring-string);
uprv_free(string);
*status=U_INVALID_CHAR_FOUND;
}
- /* The above is added by Jing/GCL */
if (U_FAILURE(*status))
{
- intvector_close(result, status);
+ res_close(result);
return NULL;
}
uint32_t count;
uint32_t i;
uint32_t line;
- /* added by Jing/GCL */
char *stopstring;
uint32_t len;
struct SResource *result = NULL;
int32_t value;
char *string;
- /* added by Jing/GCL */
char *stopstring;
uint32_t len;
warning(startline, "Encountered empty integer. Default value is 0.");
}
- /* commented by Jing/GCL */
- /* value = uprv_strtol(string, NULL, 10);*/
- /* result = int_open(bundle, tag, value, status);*/
- /* The following is added by Jing/GCL*/
- /* to make integer support hexdecimal, octal digit and decimal*/
- /* to handle illegal char in the integer*/
+ /* Allow integer support for hexdecimal, octal digit and decimal*/
+ /* and handle illegal char in the integer*/
value = uprv_strtoul(string, &stopstring, 0);
len=(uint32_t)(stopstring-string);
if(len==uprv_strlen(string))
/* Open the input file for reading */
if (inputdir == NULL)
{
+#if 1
+ /*
+ * Always save file file name, even if there's
+ * no input directory specified. MIGHT BREAK SOMETHING
+ */
+ int32_t filenameLength = uprv_strlen(filename);
+
+ fullname = (char *) uprv_malloc(filenameLength + 1);
+ uprv_strcpy(fullname, filename);
+#endif
+
file = T_FileStream_open(filename, "rb");
}
else
{"reserved", NULL, NULL}
};
-void initParser(UBool makeBinaryCollation)
+void initParser(UBool omitBinaryCollation, UBool omitCollationRules)
{
uint32_t i;
{
ustr_init(&lookahead[i].value);
}
- gMakeBinaryCollation = makeBinaryCollation;
+ gMakeBinaryCollation = !omitBinaryCollation;
+ gOmitCollationRules = omitCollationRules;
}
static U_INLINE UBool isTable(enum EResourceType type) {
{ :/} => array
{ string , => string array
- commented by Jing/GCL
{ string { => table
- added by Jing/GCL
-
{ string :/{ => table
{ string } => string
*/
return NULL;
}
- /* Commented by Jing/GCL */
- /* if (token == TOK_OPEN_BRACE || token == TOK_COLON )*/
if (token == TOK_OPEN_BRACE || token == TOK_COLON ||token ==TOK_CLOSE_BRACE )
{
resType = RT_ARRAY;
case TOK_COMMA: resType = RT_ARRAY; break;
case TOK_OPEN_BRACE: resType = RT_TABLE; break;
case TOK_CLOSE_BRACE: resType = RT_STRING; break;
- /* added by Jing/GCL to make table work when :table is omitted */
case TOK_COLON: resType = RT_TABLE; break;
default:
*status = U_INVALID_FORMAT_ERROR;
struct UString *tokenValue;
struct UString comment;
uint32_t line;
- /* added by Jing/GCL */
enum EResourceType bundleType;
enum ETokenType token;
bundle_setlocale(bundle, tokenValue->fChars, status);
- /* Commented by Jing/GCL */
- /* expect(TOK_OPEN_BRACE, NULL, &line, status); */
/* The following code is to make Empty bundle work no matter with :table specifer or not */
token = getToken(NULL, NULL, &line, status);
if(token==TOK_COLON) {
error(line, "parse error, did not find open-brace '{' or colon ':', stopped with %s", u_errorName(*status));
}
}
- /* The above is added by Jing/GCL */
if (U_FAILURE(*status))
{
if (U_FAILURE(*status))
{
bundle_close(bundle, status);
- array_close(dependencyArray, status);
+ res_close(dependencyArray);
return NULL;
}
}
}
+ cleanupLookahead();
+ ustr_deinit(&comment);
return bundle;
}
+