From 8067293d35c5316b032b254c1419069802538109 Mon Sep 17 00:00:00 2001
From: Markus Scherer <markus.icu@gmail.com>
Date: Sat, 11 Jan 2014 00:28:53 +0000
Subject: [PATCH] ICU-10043 ignore the genrb --omitCollationRules flag while
 importing rules

X-SVN-Rev: 34874
---
 icu4c/source/tools/genrb/genrb.c   |  7 ++++---
 icu4c/source/tools/genrb/parse.cpp | 18 ++++++++----------
 icu4c/source/tools/genrb/parse.h   |  6 +++---
 3 files changed, 15 insertions(+), 16 deletions(-)

--- a/source/tools/genrb/genrb.c
+++ b/source/tools/genrb/genrb.c
@@ -280,7 +280,7 @@
         }
     }
 
-    initParser(options[NO_COLLATION_RULES].doesOccur);
+    initParser();
 
     /*added by Jing*/
     if(options[LANGUAGE].doesOccur) {
@@ -557,7 +557,8 @@
         printf("autodetected encoding %s\n", cp);
     }
     /* Parse the data into an SRBRoot */
-    data = parse(ucbuf, inputDir, outputDir, !omitBinaryCollation, status);
+    data = parse(ucbuf, inputDir, outputDir,
+                 !omitBinaryCollation, options[NO_COLLATION_RULES].doesOccur, status);
 
     if (data == NULL || U_FAILURE(*status)) {
         fprintf(stderr, "couldn't parse the file %s. Error:%s\n", filename,u_errorName(*status));

--- a/source/tools/genrb/parse.cpp
+++ b/source/tools/genrb/parse.cpp
@@ -90,10 +90,9 @@
     const char     *outputdir;
     uint32_t        outputdirLength;
     UBool           makeBinaryCollation;
+    UBool           omitCollationRules;
 } ParseState;
 
-static UBool gOmitCollationRules  = FALSE;
-
 typedef struct SResource *
 ParseResourceFunction(ParseState* state, char *tag, uint32_t startline, const struct UString* comment, UErrorCode *status);
 
@@ -328,7 +327,7 @@
     }
     uprv_strcat(filename, cs);
 
-    if(gOmitCollationRules) {
+    if(state->omitCollationRules) {
         return res_none();
     }
 
@@ -776,7 +775,7 @@
     }
 
     /* Parse the data into an SRBRoot */
-    data = parse(ucbuf, genrbdata->inputDir, genrbdata->outputDir, FALSE, status);
+    data = parse(ucbuf, genrbdata->inputDir, genrbdata->outputDir, FALSE, FALSE, status);
 
     root = data->fRoot;
     collations = resLookup(root, "collations");
@@ -1012,7 +1011,7 @@
 #endif
             /* in order to achieve smaller data files, we can direct genrb */
             /* to omit collation rules */
-            if(gOmitCollationRules) {
+            if(state->omitCollationRules) {
                 bundle_closeString(state->bundle, member);
             } else {
                 table_add(result, member, line, status);
@@ -1844,7 +1843,7 @@
     {"reserved", NULL, NULL}
 };
 
-void initParser(UBool omitCollationRules)
+void initParser()
 {
     U_STRING_INIT(k_type_string,    "string",    6);
     U_STRING_INIT(k_type_binary,    "binary",    6);
@@ -1863,8 +1862,6 @@
     U_STRING_INIT(k_type_plugin_collation,      "process(collation)",        18);
     U_STRING_INIT(k_type_plugin_transliterator, "process(transliterator)",   23);
     U_STRING_INIT(k_type_plugin_dependency,     "process(dependency)",       19);
-
-    gOmitCollationRules = omitCollationRules;
 }
 
 static inline UBool isTable(enum EResourceType type) {
@@ -2044,8 +2041,8 @@
 
 /* parse the top-level resource */
 struct SRBRoot *
-parse(UCHARBUF *buf, const char *inputDir, const char *outputDir, UBool makeBinaryCollation,
-      UErrorCode *status)
+parse(UCHARBUF *buf, const char *inputDir, const char *outputDir,
+      UBool makeBinaryCollation, UBool omitCollationRules, UErrorCode *status)
 {
     struct UString    *tokenValue;
     struct UString    comment;
@@ -2069,6 +2066,7 @@
     state.outputdir       = outputDir;
     state.outputdirLength = (state.outputdir != NULL) ? (uint32_t)uprv_strlen(state.outputdir) : 0;
     state.makeBinaryCollation = makeBinaryCollation;
+    state.omitCollationRules = omitCollationRules;
 
     ustr_init(&comment);
     expect(&state, TOK_STRING, &tokenValue, &comment, NULL, status);
diff -Nura c/source/tools/genrb/parse.h d/source/tools/genrb/parse.h
--- c/source/tools/genrb/parse.h	2013-10-05 04:49:36.000000000 +0800
+++ d/source/tools/genrb/parse.h	2025-06-25 22:16:55.601840816 +0800
@@ -24,11 +24,11 @@
 
 U_CDECL_BEGIN
 /* One time parser initalisation */
-void initParser(UBool omitCollationRules);
+void initParser();
 
 /* Parse a ResourceBundle text file */
 struct SRBRoot* parse(UCHARBUF *buf, const char* inputDir, const char* outputDir,
-                      UBool omitBinaryCollation, UErrorCode *status);
+                      UBool makeBinaryCollation, UBool omitCollationRules, UErrorCode *status);
 
 U_CDECL_END
 
