[sword-cvs] icu-sword/source/tools/genrb prscmnts.cpp,NONE,1.1 prscmnts.h,NONE,1.1 Makefile.in,1.3,1.4 derb.c,1.1,1.2 derb.vcproj,1.1,1.2 genrb.c,1.4,1.5 genrb.dsp,1.3,1.4 genrb.vcproj,1.1,1.2 parse.c,1.5,1.6 read.c,1.4,1.5 read.h,1.3,1.4 reslist.c,1.4,1.5 reslist.h,1.4,1.5 rle.c,1.1,1.2 ustr.c,1.3,1.4 ustr.h,1.3,1.4 wrtjava.c,1.1,1.2 wrtxml.c,1.1,1.2

sword@www.crosswire.org sword@www.crosswire.org
Tue, 6 Apr 2004 03:10:52 -0700


Update of /cvs/core/icu-sword/source/tools/genrb
In directory www:/tmp/cvs-serv8911/source/tools/genrb

Modified Files:
	Makefile.in derb.c derb.vcproj genrb.c genrb.dsp genrb.vcproj 
	parse.c read.c read.h reslist.c reslist.h rle.c ustr.c ustr.h 
	wrtjava.c wrtxml.c 
Added Files:
	prscmnts.cpp prscmnts.h 
Log Message:
ICU 2.8 sync

--- NEW FILE: prscmnts.cpp ---
/*
*******************************************************************************
*
*   Copyright (C) 2003, International Business Machines
*   Corporation and others.  All Rights Reserved.
*
*******************************************************************************
*
* File prscmnts.cpp
*
* Modification History:
*
*   Date          Name        Description
*   08/22/2003    ram         Creation.
*******************************************************************************
*/
#include "unicode/regex.h"
#include "unicode/unistr.h"
#include "unicode/parseerr.h"
#include "prscmnts.h"
#include <stdio.h>
#include <stdlib.h>

#if UCONFIG_NO_REGULAR_EXPRESSIONS==0 /* donot compile when RegularExpressions not available */

#define MAX_SPLIT_STRINGS 20

const char *patternStrings[UPC_LIMIT]={
    "^translate\\s*?(.*)",
    "^note\\s*?(.*)"
};

U_CFUNC int32_t 
removeText(UChar *source, int32_t srcLen, 
           UnicodeString patString,uint32_t options,  
           UnicodeString replaceText, UErrorCode *status){

    if(status == NULL || U_FAILURE(*status)){
        return 0;
    }

    UnicodeString src(source, srcLen);

    RegexMatcher    myMatcher(patString, src, options, *status);
    if(U_FAILURE(*status)){
        return 0;
    }
    UnicodeString dest;


    dest = myMatcher.replaceAll(replaceText,*status);
    
    
    return dest.extract(source, srcLen, *status);

}
U_CFUNC int32_t
trim(UChar *src, int32_t srcLen, UErrorCode *status){
     srcLen = removeText(src, srcLen, "^[ \\r\\n]+ ", 0, "", status); // remove leading new lines
     srcLen = removeText(src, srcLen, "^\\s+", 0, "", status); // remove leading spaces
     srcLen = removeText(src, srcLen, "\\s+$", 0, "", status); // remvoe trailing spcaes
     return srcLen;
}

U_CFUNC int32_t 
removeCmtText(UChar* source, int32_t srcLen, UErrorCode* status){
    srcLen = trim(source, srcLen, status);
    UnicodeString     patString = "^\\s*?\\*\\s*?";     // remove pattern like " * " at the begining of the line
    srcLen = removeText(source, srcLen, patString, UREGEX_MULTILINE, "", status);
    return removeText(source, srcLen, "[ \\r\\n]+", 0, " ", status);// remove new lines;
}

U_CFUNC int32_t 
getText(const UChar* source, int32_t srcLen,
        UChar** dest, int32_t destCapacity,
        UnicodeString patternString, 
        UErrorCode* status){
    
    if(status == NULL || U_FAILURE(*status)){
        return 0;
    }

    UnicodeString     stringArray[MAX_SPLIT_STRINGS];
    RegexPattern      *pattern = RegexPattern::compile("@", 0, *status);
    UnicodeString src (source,srcLen);
    
    if (U_FAILURE(*status)) {
        return 0;
    }
    pattern->split(src, stringArray, MAX_SPLIT_STRINGS, *status);
    
    RegexMatcher matcher(patternString, UREGEX_DOTALL, *status);
    if (U_FAILURE(*status)) {
        return 0;
    }
    for(int32_t i=0; i<MAX_SPLIT_STRINGS; i++){
        matcher.reset(stringArray[i]);
        if(matcher.lookingAt(*status)){
            UnicodeString out = matcher.group(1, *status);

            return out.extract(*dest, destCapacity,*status);
        }
    }
    return 0;
}


#define AT_SIGN  0x0040

U_CFUNC int32_t
getDescription( const UChar* source, int32_t srcLen,
                UChar** dest, int32_t destCapacity,
                UErrorCode* status){
    if(status == NULL || U_FAILURE(*status)){
        return 0;
    }

    UnicodeString     stringArray[MAX_SPLIT_STRINGS];
    RegexPattern      *pattern = RegexPattern::compile("@", UREGEX_MULTILINE, *status);
    UnicodeString src(source, srcLen);
    
    if (U_FAILURE(*status)) {
        return 0;
    }
    pattern->split(src, stringArray,MAX_SPLIT_STRINGS , *status);

    if(stringArray[0].indexOf((UChar)AT_SIGN)==-1){
        int32_t destLen =  stringArray[0].extract(*dest, destCapacity, *status);
        return trim(*dest, destLen, status);
    }
    return 0;
}

U_CFUNC int32_t
getCount(const UChar* source, int32_t srcLen, 
         UParseCommentsOption option, UErrorCode *status){
    
    if(status == NULL || U_FAILURE(*status)){
        return 0;
    }

    UnicodeString     stringArray[MAX_SPLIT_STRINGS];
    RegexPattern      *pattern = RegexPattern::compile("@", UREGEX_MULTILINE, *status);
    UnicodeString src (source, srcLen);


    if (U_FAILURE(*status)) {
        return 0;
    }
    int32_t retLen = pattern->split(src, stringArray, MAX_SPLIT_STRINGS, *status);
    
    RegexMatcher matcher(patternStrings[option], UREGEX_DOTALL, *status);
    if (U_FAILURE(*status)) {
        return 0;
    } 
    int32_t count = 0;
    for(int32_t i=0; i<retLen; i++){
        matcher.reset(stringArray[i]);
        if(matcher.lookingAt(*status)){
            count++;
        }
    }
    if(option == UPC_TRANSLATE && count > 1){
        fprintf(stderr, "Multiple @translate tags cannot be supported.\n");
        exit(U_UNSUPPORTED_ERROR);
    }
    return count;
}

U_CFUNC int32_t 
getAt(const UChar* source, int32_t srcLen,
        UChar** dest, int32_t destCapacity,
        int32_t index,
        UParseCommentsOption option,
        UErrorCode* status){

    if(status == NULL || U_FAILURE(*status)){
        return 0;
    }

    UnicodeString     stringArray[MAX_SPLIT_STRINGS];
    RegexPattern      *pattern = RegexPattern::compile("@", UREGEX_MULTILINE, *status);
    UnicodeString src (source, srcLen);


    if (U_FAILURE(*status)) {
        return 0;
    }
    int32_t retLen = pattern->split(src, stringArray, MAX_SPLIT_STRINGS, *status);
    
    RegexMatcher matcher(patternStrings[option], UREGEX_DOTALL, *status);
    if (U_FAILURE(*status)) {
        return 0;
    } 
    int32_t count = 0;
    for(int32_t i=0; i<retLen; i++){
        matcher.reset(stringArray[i]);
        if(matcher.lookingAt(*status)){
            if(count == index){
                UnicodeString out = matcher.group(1, *status);
                return out.extract(*dest, destCapacity,*status);
            }
            count++;
            
        }
    }
    return 0;

}

U_CFUNC int32_t
getTranslate( const UChar* source, int32_t srcLen,
              UChar** dest, int32_t destCapacity,
              UErrorCode* status){
    UnicodeString     notePatternString = "^translate\\s*?(.*)"; 
    
    int32_t destLen = getText(source, srcLen, dest, destCapacity, notePatternString, status);
    return trim(*dest, destLen, status);
}

U_CFUNC int32_t 
getNote(const UChar* source, int32_t srcLen,
        UChar** dest, int32_t destCapacity,
        UErrorCode* status){

    UnicodeString     notePatternString = "^note\\s*?(.*)"; 
    int32_t destLen =  getText(source, srcLen, dest, destCapacity, notePatternString, status);
    return trim(*dest, destLen, status);

}

#endif /* UCONFIG_NO_REGULAR_EXPRESSIONS */


--- NEW FILE: prscmnts.h ---
/*
*******************************************************************************
*
*   Copyright (C) 1998-2003, International Business Machines
*   Corporation and others.  All Rights Reserved.
*
*******************************************************************************
*
* File read.h
*
* Modification History:
*
*   Date        Name        Description
*   05/26/99    stephen     Creation.
*   5/10/01     Ram         removed ustdio dependency
*******************************************************************************
*/

#ifndef PRSCMNTS_H
#define PRSCMNTS_H 1

#if UCONFIG_NO_REGULAR_EXPRESSIONS==0 /* donot compile when no RegularExpressions are available */

enum UParseCommentsOption {
    UPC_TRANSLATE,
    UPC_NOTE,
    UPC_LIMIT
};

typedef enum UParseCommentsOption UParseCommentsOption;

U_CFUNC int32_t 
getNote(const UChar* source, int32_t srcLen,
        UChar** dest, int32_t destCapacity,
        UErrorCode* status);
U_CFUNC int32_t 
removeCmtText(UChar* source, int32_t srcLen, UErrorCode* status);

U_CFUNC int32_t
getDescription( const UChar* source, int32_t srcLen,
                UChar** dest, int32_t destCapacity,
                UErrorCode* status);
U_CFUNC int32_t
getTranslate( const UChar* source, int32_t srcLen,
              UChar** dest, int32_t destCapacity,
              UErrorCode* status);

U_CFUNC int32_t
getAt(const UChar* source, int32_t srcLen,
        UChar** dest, int32_t destCapacity,
        int32_t index,
        UParseCommentsOption option,
        UErrorCode* status);

U_CFUNC int32_t
getCount(const UChar* source, int32_t srcLen, 
         UParseCommentsOption option, UErrorCode *status);

#endif /* UCONFIG_NO_REGULAR_EXPRESSIONS */

#endif


Index: Makefile.in
===================================================================
RCS file: /cvs/core/icu-sword/source/tools/genrb/Makefile.in,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Makefile.in	10 Sep 2003 02:42:58 -0000	1.3
+++ Makefile.in	6 Apr 2004 10:10:08 -0000	1.4
@@ -30,7 +30,7 @@
 LIBS = $(LIBICUI18N) $(LIBICUTOOLUTIL) $(LIBICUUC) $(DEFAULT_LIBS) $(LIB_M)
 
 OBJECTS = errmsg.o genrb.o parse.o read.o reslist.o ustr.o util.o \
-wrtjava.o rle.o wrtxml.o
+wrtjava.o rle.o wrtxml.o prscmnts.o
 DERB_OBJ = derb.o
 
 DEPS = $(OBJECTS:.o=.d)
@@ -75,7 +75,7 @@
 	 && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
 
 $(TARGET) : $(OBJECTS)
-	$(LINK.c) $(OUTOPT)$@ $^ $(LIBS) 
+	$(LINK.cc) $(OUTOPT)$@ $^ $(LIBS) 
 
 $(DERB) : $(DERB_OBJ)
 	$(LINK.c) $(OUTOPT)$@ $^ $(LIBS) 

Index: derb.c
===================================================================
RCS file: /cvs/core/icu-sword/source/tools/genrb/derb.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- derb.c	10 Sep 2003 02:42:58 -0000	1.1
+++ derb.c	6 Apr 2004 10:10:09 -0000	1.2
@@ -328,7 +328,7 @@
             if (locale) {
                 printCString(out, converter, locale, -1);
             } else {
-                printCString(out, converter, filename, ext - filename);
+                printCString(out, converter, filename, (int32_t)(ext - filename));
                 printString(out, converter, sp, (int32_t)(sizeof(sp)/sizeof(*sp)));
             }
             printOutBundle(out, converter, bundle, 0, pname, &status);
@@ -422,7 +422,7 @@
         ucnv_toUnicode(defaultConverter, &bufp, bufend, &str, strEnd, 0, 0, &err);
         *bufp = 0;
 
-        printString(out, converter, buf, bufp - buf);
+        printString(out, converter, buf, (int32_t)(bufp - buf));
     } while (str < strEnd);
 }
 

Index: derb.vcproj
===================================================================
RCS file: /cvs/core/icu-sword/source/tools/genrb/derb.vcproj,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- derb.vcproj	10 Sep 2003 02:42:58 -0000	1.1
+++ derb.vcproj	6 Apr 2004 10:10:09 -0000	1.2
@@ -1,7 +1,7 @@
-<?xml version="1.0" encoding = "Windows-1252"?>
+<?xml version="1.0" encoding="Windows-1252"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="7.00"
+	Version="7.10"
 	Name="derb"
 	SccProjectName=""
 	SccLocalPath="">
@@ -37,9 +37,9 @@
 				CompileAs="0"/>
 			<Tool
 				Name="VCCustomBuildTool"
-				CommandLine="copy $(TargetPath) ..\..\..\bin
+				CommandLine="copy &quot;$(TargetPath)&quot; ..\..\..\bin
 "
-				Outputs="..\..\..\bin\$(InputName).exe"/>
+				Outputs="..\..\..\bin\$(TargetFileName)"/>
 			<Tool
 				Name="VCLinkerTool"
 				AdditionalOptions="/MACHINE:I386"
@@ -70,7 +70,13 @@
 			<Tool
 				Name="VCWebServiceProxyGeneratorTool"/>
 			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
 				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
 		</Configuration>
 		<Configuration
 			Name="Debug|Win32"
@@ -100,9 +106,9 @@
 				CompileAs="0"/>
 			<Tool
 				Name="VCCustomBuildTool"
-				CommandLine="copy $(TargetPath) ..\..\..\bin
+				CommandLine="copy &quot;$(TargetPath)&quot; ..\..\..\bin
 "
-				Outputs="..\..\..\bin\$(InputName).exe"/>
+				Outputs="..\..\..\bin\$(TargetFileName)"/>
 			<Tool
 				Name="VCLinkerTool"
 				AdditionalOptions="/MACHINE:I386"
@@ -134,9 +140,17 @@
 			<Tool
 				Name="VCWebServiceProxyGeneratorTool"/>
 			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
 				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
 		</Configuration>
 	</Configurations>
+	<References>
+	</References>
 	<Files>
 		<Filter
 			Name="Source Files"

Index: genrb.c
===================================================================
RCS file: /cvs/core/icu-sword/source/tools/genrb/genrb.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- genrb.c	10 Sep 2003 02:42:58 -0000	1.4
+++ genrb.c	6 Apr 2004 10:10:09 -0000	1.5
@@ -17,17 +17,18 @@
 */
 
 #include "genrb.h"
+#include "unicode/uclean.h"
 
 /* Protos */
 static void  processFile(const char *filename, const char* cp, const char *inputDir, const char *outputDir, const char *packageName, UErrorCode *status);
-static char *make_res_filename(const char *filename, const char *outputDir, 
+static char *make_res_filename(const char *filename, const char *outputDir,
                                const char *packageName, UErrorCode *status);
 
 /* File suffixes */
 #define RES_SUFFIX ".res"
 #define COL_SUFFIX ".col"
 
-static char theCurrentFileName[4096];
+static char theCurrentFileName[2048];
 const char *gCurrentFileName = theCurrentFileName;
 #ifdef XP_MAC_CONSOLE
 #include <console.h>
@@ -48,7 +49,7 @@
     COPYRIGHT,
     PACKAGE_NAME,
     BUNDLE_NAME,
-    WRITE_XML,
+    WRITE_XLIFF,
     TOUCHFILE,
     STRICT,
     NO_BINARY_COLLATION,
@@ -70,7 +71,7 @@
                       UOPTION_COPYRIGHT,
                       UOPTION_PACKAGE_NAME,
                       UOPTION_BUNDLE_NAME,
-                      UOPTION_DEF( "write-xml", 'x', UOPT_NO_ARG),
+                      UOPTION_DEF( "write-xliff", 'x', UOPT_OPTIONAL_ARG),
                       UOPTION_DEF( "touchfile", 't', UOPT_NO_ARG),
                       UOPTION_DEF( "strict",    'k', UOPT_NO_ARG), /* 14 */
                       UOPTION_DEF( "noBinaryCollation", 'C', UOPT_NO_ARG),/* 15 */
@@ -79,14 +80,14 @@
                   };
 
 static     UBool       write_java = FALSE;
-static     UBool       write_xml = FALSE;
+static     UBool       write_xliff = FALSE;
 static     UBool       touchfile = FALSE;
 static     const char* outputEnc ="";
 static     const char* gPackageName=NULL;
 static     const char* bundleName=NULL;
 /*added by Jing*/
 static     const char* language = NULL;
-
+static     const char* xliffOutputFileName = NULL;
 int
 main(int argc,
      char* argv[])
@@ -97,7 +98,7 @@
     const char *inputDir  = NULL;
     const char *encoding  = "";
     int         i;
-    
+
     U_MAIN_INIT_ARGS(argc, argv);
 
     argc = u_parseArgs(argc, argv, (int32_t)(sizeof(options)/sizeof(options[0])), options);
@@ -146,15 +147,15 @@
                 "\t                         defaults to ASCII and \\uXXXX format.\n"
                 "\t-p or --package-name     For ICU4J: package name for writing the ListResourceBundle for ICU4J,\n"
                 "\t                         defaults to com.ibm.icu.impl.data\n"
-                "\t                         For ICU4C: Package name on output. Specfiying\n"
+                "\t                         For ICU4C: Package name for the .res files on output. Specfiying\n"
                 "\t                         'ICUDATA' defaults to the current ICU4C data name.\n");
         fprintf(stderr,
                 "\t-b or --bundle-name      bundle name for writing the ListResourceBundle for ICU4J,\n"
                 "\t                         defaults to LocaleElements\n"
-                "\t-x or --write-xml        write a XML file for the resource bundle.\n"
+                "\t-x or --write-xliff      write a XLIFF file for the resource bundle. Followed by an optional output file name.\n"
                 "\t-k or --strict           use pedantic parsing of syntax\n"
                 /*added by Jing*/
-                "\t-l or --language         language code compliant with ISO 639.\n");
+                "\t-l or --language         For XLIFF: language code compliant with ISO 639.\n");
 
         return argc < 0 ? U_ILLEGAL_ARGUMENT_ERROR : U_ZERO_ERROR;
     }
@@ -194,7 +195,7 @@
 
     if(options[TOUCHFILE].doesOccur) {
         if(gPackageName == NULL) {
-            fprintf(stderr, "%s: Don't use touchfile (-t) option with no package.\n", 
+            fprintf(stderr, "%s: Don't use touchfile (-t) option with no package.\n",
                     argv[0]);
             return -1;
         }
@@ -208,6 +209,18 @@
     if(options[ICUDATADIR].doesOccur) {
         u_setDataDirectory(options[ICUDATADIR].value);
     }
+    /* Initialize ICU */
+    u_init(&status);
+    if (U_FAILURE(status) && status != U_FILE_ACCESS_ERROR) {
+        /* Note: u_init() will try to open ICU property data.
+         *       failures here are expected when building ICU from scratch.
+         *       ignore them.
+        */
+        fprintf(stderr, "%s: can not initialize ICU.  status = %s\n",
+            argv[0], u_errorName(status));
+        exit(1);
+    }
+    status = U_ZERO_ERROR;
     if(options[WRITE_JAVA].doesOccur) {
         write_java = TRUE;
         outputEnc = options[WRITE_JAVA].value;
@@ -217,8 +230,11 @@
         bundleName = options[BUNDLE_NAME].value;
     }
 
-    if(options[WRITE_XML].doesOccur) {
-        write_xml = TRUE;
+    if(options[WRITE_XLIFF].doesOccur) {
+        write_xliff = TRUE;
+        if(options[WRITE_XLIFF].value != NULL){
+            xliffOutputFileName = options[WRITE_XLIFF].value;
+        }
     }
 
     if(options[NO_BINARY_COLLATION].doesOccur) {
@@ -226,7 +242,7 @@
     } else {
       initParser(TRUE);
     }
-    
+
     /*added by Jing*/
     if(options[LANGUAGE].doesOccur) {
         language = options[LANGUAGE].value;
@@ -236,7 +252,7 @@
     for(i = 1; i < argc; ++i) {
         status = U_ZERO_ERROR;
         arg    = getLongPathname(argv[i]);
-        
+
         if (inputDir) {
             uprv_strcpy(theCurrentFileName, inputDir);
             uprv_strcat(theCurrentFileName, U_FILE_SEP_STRING);
@@ -265,10 +281,10 @@
     char           *inputDirBuf  = NULL;
 
     char           outputFileName[256];
-    
+
     int32_t dirlen  = 0;
     int32_t filelen = 0;
-    
+
     if (status==NULL || U_FAILURE(*status)) {
         return;
     }
@@ -284,12 +300,12 @@
         openFileName[0] = '\0';
         if (filenameBegin != NULL) {
             /*
-             * When a filename ../../../data/root.txt is specified, 
+             * When a filename ../../../data/root.txt is specified,
              * we presume that the input directory is ../../../data
              * This is very important when the resource file includes
              * another file, like UCARules.txt or thaidict.brk.
              */
-            int32_t filenameSize = filenameBegin - filename + 1;
+            int32_t filenameSize = (int32_t)(filenameBegin - filename + 1);
             inputDirBuf = uprv_strncpy((char *)uprv_malloc(filenameSize), filename, filenameSize);
 
             /* test for NULL */
@@ -316,7 +332,7 @@
 
             openFileName[0] = '\0';
             /*
-             * append the input dir to openFileName if the first char in 
+             * append the input dir to openFileName if the first char in
              * filename is not file seperation char and the last char input directory is  not '.'.
              * This is to support :
              * genrb -s. /home/icu/data
@@ -341,16 +357,16 @@
             }
 
             uprv_strcpy(openFileName, inputDir);
-        
+
         }
     }
 
     uprv_strcat(openFileName, filename);
 
     ucbuf = ucbuf_open(openFileName, &cp,getShowWarning(),TRUE, status);
-    
+
     if(*status == U_FILE_ACCESS_ERROR) {
-        
+
         fprintf(stderr, "couldn't open file %s\n", openFileName == NULL ? filename : openFileName);
         goto finish;
     }
@@ -396,12 +412,12 @@
             }
             else
             {
-                T_FileStream_write(q, msg, uprv_strlen(msg));
+                T_FileStream_write(q, msg, (int32_t)uprv_strlen(msg));
                 T_FileStream_close(q);
             }
             uprv_free(tfname);
         }
-        
+
     }
     if(U_FAILURE(*status)) {
         fprintf(stderr, "couldn't make the res fileName for  bundle %s. Error:%s\n", filename,u_errorName(*status));
@@ -409,8 +425,8 @@
     }
     if(write_java== TRUE){
         bundle_write_java(data,outputDir,outputEnc, outputFileName, sizeof(outputFileName),packageName,bundleName,status);
-    }else if(write_xml ==TRUE){
-        bundle_write_xml(data,outputDir,outputEnc, filename, outputFileName, sizeof(outputFileName),language, packageName,status);
+    }else if(write_xliff ==TRUE){
+        bundle_write_xml(data,outputDir,outputEnc, filename, outputFileName, sizeof(outputFileName),language, xliffOutputFileName,status);
     }else{
         /* Write the data to the file */
         bundle_write(data, outputDir, packageName, outputFileName, sizeof(outputFileName), status);
@@ -457,7 +473,7 @@
 
     if(packageName != NULL)
     {
-        pkgLen = 1 + uprv_strlen(packageName);
+        pkgLen = (int32_t)(1 + uprv_strlen(packageName));
     }
 
     /* setup */

Index: genrb.dsp
===================================================================
RCS file: /cvs/core/icu-sword/source/tools/genrb/genrb.dsp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- genrb.dsp	10 Sep 2003 02:42:58 -0000	1.3
+++ genrb.dsp	6 Apr 2004 10:10:09 -0000	1.4
@@ -195,6 +195,10 @@
 # End Source File
 # Begin Source File
 
+SOURCE=.\prscmnts.cpp
+# End Source File
+# Begin Source File
+
 SOURCE=.\read.c
 # End Source File
 # Begin Source File
@@ -236,6 +240,10 @@
 # Begin Source File
 
 SOURCE=.\parse.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\prscmnts.h
 # End Source File
 # Begin Source File
 

Index: genrb.vcproj
===================================================================
RCS file: /cvs/core/icu-sword/source/tools/genrb/genrb.vcproj,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- genrb.vcproj	10 Sep 2003 02:42:58 -0000	1.1
+++ genrb.vcproj	6 Apr 2004 10:10:09 -0000	1.2
@@ -1,7 +1,7 @@
-<?xml version="1.0" encoding = "Windows-1252"?>
+<?xml version="1.0" encoding="Windows-1252"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="7.00"
+	Version="7.10"
 	Name="genrb"
 	SccProjectName=""
 	SccLocalPath="">
@@ -35,9 +35,9 @@
 				CompileAs="0"/>
 			<Tool
 				Name="VCCustomBuildTool"
-				CommandLine="copy $(TargetPath) ..\..\..\bin
+				CommandLine="copy &quot;$(TargetPath)&quot; ..\..\..\bin
 "
-				Outputs="..\..\..\bin\$(InputName).exe"/>
+				Outputs="..\..\..\bin\$(TargetFileName)"/>
 			<Tool
 				Name="VCLinkerTool"
 				AdditionalOptions="/MACHINE:I386"
@@ -64,7 +64,13 @@
 			<Tool
 				Name="VCWebServiceProxyGeneratorTool"/>
 			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
 				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
 		</Configuration>
 		<Configuration
 			Name="Debug|Win32"
@@ -95,9 +101,9 @@
 				CompileAs="0"/>
 			<Tool
 				Name="VCCustomBuildTool"
-				CommandLine="copy $(TargetPath) ..\..\..\bin
+				CommandLine="copy &quot;$(TargetPath)&quot; ..\..\..\bin
 "
-				Outputs="..\..\..\bin\$(InputName).exe"/>
+				Outputs="..\..\..\bin\$(TargetFileName)"/>
 			<Tool
 				Name="VCLinkerTool"
 				AdditionalOptions="/MACHINE:I386"
@@ -125,9 +131,17 @@
 			<Tool
 				Name="VCWebServiceProxyGeneratorTool"/>
 			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
 				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
 		</Configuration>
 	</Configurations>
+	<References>
+	</References>
 	<Files>
 		<Filter
 			Name="Source Files"
@@ -142,6 +156,9 @@
 				RelativePath=".\parse.c">
 			</File>
 			<File
+				RelativePath=".\prscmnts.cpp">
+			</File>
+			<File
 				RelativePath=".\read.c">
 			</File>
 			<File
@@ -174,6 +191,9 @@
 			</File>
 			<File
 				RelativePath=".\parse.h">
+			</File>
+			<File
+				RelativePath=".\prscmnts.h">
 			</File>
 			<File
 				RelativePath=".\read.h">

Index: parse.c
===================================================================
RCS file: /cvs/core/icu-sword/source/tools/genrb/parse.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- parse.c	10 Sep 2003 02:42:58 -0000	1.5
+++ parse.c	6 Apr 2004 10:10:10 -0000	1.6
@@ -31,7 +31,7 @@
 #include "unicode/putil.h"
 
 /* Number of tokens to read ahead of the current stream position */
-#define MAX_LOOKAHEAD   2
+#define MAX_LOOKAHEAD   3
 
 #define U_ICU_UNIDATA   "unidata"
 #define CR               0x000D
@@ -90,12 +90,13 @@
 struct Lookahead
 {
[...982 lines suppressed...]
     if(token==TOK_COLON)
     {
@@ -1512,7 +1671,7 @@
 
         if(bundleType==RT_TABLE)
         {
-            expect(TOK_OPEN_BRACE, NULL, &line, status);
+            expect(TOK_OPEN_BRACE, NULL, NULL, &line, status);
         }
         else
         {
@@ -1547,7 +1706,7 @@
         return NULL;
     }
 
-    if (getToken(NULL, &line, status) != TOK_EOF)
+    if (getToken(NULL, NULL, &line, status) != TOK_EOF)
     {
         warning(line, "extraneous text after resource bundle (perhaps unmatched braces)");
         if(isStrict()){

Index: read.c
===================================================================
RCS file: /cvs/core/icu-sword/source/tools/genrb/read.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- read.c	10 Sep 2003 02:42:58 -0000	1.4
+++ read.c	6 Apr 2004 10:10:13 -0000	1.5
@@ -30,7 +30,9 @@
 #define SPACE        0x0020
 #define COLON        0x003A
 #define BADBOM       0xFFFE
-
+#define CR           0x000D
+#define LF           0x000A
+               
 static int32_t lineCount;
 
 /* Protos */
@@ -39,9 +41,9 @@
                                       struct UString *token,
                                       UErrorCode *status);
 
-static UChar32 getNextChar           (UCHARBUF *buf, UBool skipwhite, UErrorCode *status);
-static void    seekUntilNewline      (UCHARBUF *buf, UErrorCode *status);
-static void    seekUntilEndOfComment (UCHARBUF *buf, UErrorCode *status);
+static UChar32 getNextChar           (UCHARBUF *buf, UBool skipwhite, struct UString *token, UErrorCode *status);
+static void    seekUntilNewline      (UCHARBUF *buf, struct UString *token, UErrorCode *status);
+static void    seekUntilEndOfComment (UCHARBUF *buf, struct UString *token, UErrorCode *status);
 static UBool   isWhitespace          (UChar32 c);
 static UBool   isNewline             (UChar32 c);
 
@@ -60,6 +62,7 @@
 enum ETokenType getNextToken(UCHARBUF* buf,
                              struct UString *token,
                              uint32_t *linenumber, /* out: linenumber of token */
+                             struct UString *comment,
                              UErrorCode *status) {
     enum ETokenType result;
     UChar32         c;
@@ -69,7 +72,7 @@
     }
 
     /* Skip whitespace */
-    c = getNextChar(buf, TRUE, status);
+    c = getNextChar(buf, TRUE, comment, status);
 
     if (U_FAILURE(*status)) {
         return TOK_ERROR;
@@ -120,6 +123,8 @@
     UChar    *pTarget   = target;
     int      len=0;
     UBool    isFollowingCharEscaped=FALSE;
+    UBool    isNLUnescaped = FALSE;
+    UChar32  prevC=0;
 
     /* We are guaranteed on entry that initialChar is not a whitespace
        character. If we are at the EOF, or have some other problem, it
@@ -175,6 +180,9 @@
                     if (c == U_ERR) {
                         return TOK_ERROR;
                     }
+                    if(c == CR || c == LF){
+                        isNLUnescaped = TRUE;
+                    }
                 }               
 
                 if(c==ESCAPE && !isFollowingCharEscaped){
@@ -185,11 +193,18 @@
                     ustr_uscat(token, pTarget,len, status);
                     isFollowingCharEscaped = FALSE;
                     len=0;
+                    if(c == CR || c == LF){
+                        if(isNLUnescaped == FALSE && prevC!=CR){
+                            lineCount++;
+                        }
+                        isNLUnescaped = FALSE;
+                    }
                 }
                 
                 if (U_FAILURE(*status)) {
                     return TOK_ERROR;
                 }
+                prevC = c;
             }
         } else {
             if (token->fLength > 0) {
@@ -232,14 +247,14 @@
             pTarget = target;
             ustr_uscat(token, pTarget,len, status);
             len=0;
-
+            
             if (U_FAILURE(*status)) {
                 return TOK_ERROR;
             }
 
             for (;;) {
                 /* DON'T skip whitespace */
-                c = getNextChar(buf, FALSE, status);
+                c = getNextChar(buf, FALSE, NULL, status);
 
                 /* EOF reached */
                 if (c == U_EOF) {
@@ -284,7 +299,7 @@
         }
 
         /* DO skip whitespace */
-        c = getNextChar(buf, TRUE, status);
+        c = getNextChar(buf, TRUE, NULL, status);
 
         if (U_FAILURE(*status)) {
             return TOK_STRING;
@@ -297,12 +312,13 @@
     }
 }
 
-/* Retrieve the next character, ignoring comments.  If skipwhite is
+/* Retrieve the next character.  If skipwhite is
    true, whitespace is skipped as well. */
 static UChar32 getNextChar(UCHARBUF* buf,
                            UBool skipwhite,
+                           struct UString *token,
                            UErrorCode *status) {
-    UChar32 c;
+    UChar32 c, c2;
 
     if (U_FAILURE(*status)) {
         return U_EOF;
@@ -332,11 +348,18 @@
 
         switch (c) {
         case SLASH:
-            seekUntilNewline(buf, status);
+            seekUntilNewline(buf, NULL, status);
             break;
 
         case ASTERISK:
-            seekUntilEndOfComment(buf, status);
+            c2 = ucbuf_getc(buf, status);
+            if(c2== ASTERISK){
+                /* parse multi-line comment and store it in token*/
+                seekUntilEndOfComment(buf, token, status);
+            }else{
+                ucbuf_ungetc(c, buf);
+                seekUntilEndOfComment(buf, NULL, status);
+            }
             break;
 
         default:
@@ -344,10 +367,12 @@
             /* If get() failed this is a NOP */
             return SLASH;
         }
+
     }
 }
 
 static void seekUntilNewline(UCHARBUF* buf,
+                             struct UString *token,
                              UErrorCode *status) {
     UChar32 c;
 
@@ -357,10 +382,15 @@
 
     do {
         c = ucbuf_getc(buf,status);
+        /* add the char to token */
+        if(token!=NULL){
+            ustr_u32cat(token, c, status);
+        }
     } while (!isNewline(c) && c != U_EOF && *status == U_ZERO_ERROR);
 }
 
 static void seekUntilEndOfComment(UCHARBUF *buf,
+                                  struct UString *token,
                                   UErrorCode *status) {
     UChar32  c, d;
     uint32_t line;
@@ -383,6 +413,13 @@
                 break;
             }
         }
+        /* add the char to token */
+        if(token!=NULL){
+            ustr_u32cat(token, c, status);
+        }
+        /* increment the lineCount */
+        isNewline(c);
+
     } while (c != U_EOF && *status == U_ZERO_ERROR);
 
     if (c == U_EOF) {

Index: read.h
===================================================================
RCS file: /cvs/core/icu-sword/source/tools/genrb/read.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- read.h	10 Sep 2003 02:42:58 -0000	1.3
+++ read.h	6 Apr 2004 10:10:13 -0000	1.4
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 1998-2000, International Business Machines
+*   Copyright (C) 1998-2003, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
@@ -45,6 +45,7 @@
 enum ETokenType getNextToken(UCHARBUF *buf,
                  struct UString *token,
                  uint32_t *linenumber, /* out: linenumber of token */
+                 struct UString *comment,
                  UErrorCode *status);
 
 #endif

Index: reslist.c
===================================================================
RCS file: /cvs/core/icu-sword/source/tools/genrb/reslist.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- reslist.c	10 Sep 2003 02:42:58 -0000	1.4
+++ reslist.c	6 Apr 2004 10:10:13 -0000	1.5
@@ -16,6 +16,7 @@
 */
 
 #include <assert.h>
+#include <stdio.h>
 #include "reslist.h"
 #include "unewdata.h"
 #include "unicode/ures.h"
@@ -38,7 +39,7 @@
     0,
 
     {0x52, 0x65, 0x73, 0x42},     /* dataFormat="resb" */
-    {1, 0, 0, 0},                 /* formatVersion */
+    {1, 1, 0, 0},                 /* formatVersion */
     {1, 4, 0, 0}                  /* dataVersion take a look at version inside parsed resb*/
 };
 
@@ -171,7 +172,8 @@
                             uint32_t usedOffset, UErrorCode *status) {
     uint8_t   pad       = 0;
     uint32_t  i         = 0;
-    uint16_t *keys      = NULL;
+    uint16_t *keys16    = NULL;
+    int32_t  *keys32    = NULL;
     uint32_t *resources = NULL;
 
     struct SResource *current = NULL;
@@ -183,17 +185,25 @@
     pad = calcPadding(res->fSize);
 
     if (res->u.fTable.fCount > 0) {
-        keys = (uint16_t *) uprv_malloc(sizeof(uint16_t) * res->u.fTable.fCount);
-
-        if (keys == NULL) {
-            *status = U_MEMORY_ALLOCATION_ERROR;
-            return 0;
+        if(res->fType == URES_TABLE) {
+            keys16 = (uint16_t *) uprv_malloc(sizeof(uint16_t) * res->u.fTable.fCount);
+            if (keys16 == NULL) {
+                *status = U_MEMORY_ALLOCATION_ERROR;
+                return 0;
+            }
+        } else {
+            keys32 = (int32_t *) uprv_malloc(sizeof(int32_t) * res->u.fTable.fCount);
+            if (keys32 == NULL) {
+                *status = U_MEMORY_ALLOCATION_ERROR;
+                return 0;
+            }
         }
 
         resources = (uint32_t *) uprv_malloc(sizeof(uint32_t) * res->u.fTable.fCount);
 
         if (resources == NULL) {
-            uprv_free(keys);
+            uprv_free(keys16);
+            uprv_free(keys32);
             *status = U_MEMORY_ALLOCATION_ERROR;
             return 0;
         }
@@ -204,8 +214,12 @@
         while (current != NULL) {
             assert(i < res->u.fTable.fCount);
 
-            /* where the key is plus root pointer */
-            keys[i] = (uint16_t) (current->fKey + sizeof(uint32_t));
+            /* where the key is */
+            if(res->fType == URES_TABLE) {
+                keys16[i] = (uint16_t) current->fKey;
+            } else {
+                keys32[i] = current->fKey;
+            }
 
             if (current->fType == URES_INT) {
                 resources[i] = (current->fType << 28) | (current->u.fIntValue.fValue & 0xFFFFFFF);
@@ -225,18 +239,30 @@
             current = current->fNext;
         }
 
-        udata_write16(mem, res->u.fTable.fCount);
+        if(res->fType == URES_TABLE) {
+            udata_write16(mem, (uint16_t)res->u.fTable.fCount);
+
+            udata_writeBlock(mem, keys16, sizeof(uint16_t) * res->u.fTable.fCount);
+            udata_writePadding(mem, pad);
+        } else {
+            udata_write32(mem, res->u.fTable.fCount);
+
+            udata_writeBlock(mem, keys32, sizeof(int32_t) * res->u.fTable.fCount);
+        }
 
-        udata_writeBlock(mem, keys, sizeof(uint16_t) * res->u.fTable.fCount);
-        udata_writePadding(mem, pad);
         udata_writeBlock(mem, resources, sizeof(uint32_t) * res->u.fTable.fCount);
 
-        uprv_free(keys);
+        uprv_free(keys16);
+        uprv_free(keys32);
         uprv_free(resources);
     } else {
         /* table is empty */
-        udata_write16(mem, 0);
-        udata_writePadding(mem, pad);
+        if(res->fType == URES_TABLE) {
+            udata_write16(mem, 0);
+            udata_writePadding(mem, pad);
+        } else {
+            udata_write32(mem, 0);
+        }
     }
 
     return usedOffset;
@@ -263,6 +289,7 @@
         case URES_ARRAY:
             return array_write     (mem, res, usedOffset, status);
         case URES_TABLE:
+        case URES_TABLE32:
             return table_write     (mem, res, usedOffset, status);
 
         default:
@@ -279,7 +306,9 @@
     uint8_t         pad        = 0;
     uint32_t        root       = 0;
     uint32_t        usedOffset = 0;
+    uint32_t        top, size;
     char            dataName[1024];
+    int32_t         indexes[URES_INDEX_TOP];
 
     if (writtenFilename && writtenFilenameLen) {
         *writtenFilename = 0;
@@ -306,7 +335,7 @@
                if(outputPkg != NULL)
                {
                    uprv_strcpy(writtenFilename+off, outputPkg);
-                   off += uprv_strlen(outputPkg);
+                   off += (int32_t)uprv_strlen(outputPkg);
                    writtenFilename[off] = '_';
                    ++off;
                }
@@ -345,23 +374,53 @@
     }
     pad = calcPadding(bundle->fKeyPoint);
 
-    usedOffset = sizeof(uint32_t) + bundle->fKeyPoint + pad ; /*this is how much root and keys are taking up*/
+    usedOffset = bundle->fKeyPoint + pad ; /* top of the strings */
 
-    root = ((usedOffset + bundle->fRoot->u.fTable.fChildrenSize) >> 2) | (URES_TABLE << 28); /* we're gonna put the main table at the end */
+    /* we're gonna put the main table at the end */
+    top = usedOffset + bundle->fRoot->u.fTable.fChildrenSize;
+    root = (top) >> 2 | (bundle->fRoot->fType << 28);
 
+    /* write the root item */
     udata_write32(mem, root);
 
-    udata_writeBlock(mem, bundle->fKeys, bundle->fKeyPoint);
+    /* add to top the size of the root item */
+    top += bundle->fRoot->fSize;
+    top += calcPadding(top);
+
+    /*
+     * formatVersion 1.1 (ICU 2.8):
+     * write int32_t indexes[] after root and before the strings
+     * to make it easier to parse resource bundles in icuswap or from Java etc.
+     */
+    indexes[URES_INDEX_LENGTH]=             URES_INDEX_TOP;
+    indexes[URES_INDEX_STRINGS_TOP]=        (int32_t)(usedOffset>>2);
+    indexes[URES_INDEX_RESOURCES_TOP]=      (int32_t)(top>>2);
+    indexes[URES_INDEX_BUNDLE_TOP]=         indexes[URES_INDEX_RESOURCES_TOP];
+    indexes[URES_INDEX_MAX_TABLE_LENGTH]=   bundle->fMaxTableLength;
+
+    /* write the indexes[] */
+    udata_writeBlock(mem, indexes, sizeof(indexes));
 
+    /* write the table key strings */
+    udata_writeBlock(mem, bundle->fKeys+URES_STRINGS_BOTTOM,
+                          bundle->fKeyPoint-URES_STRINGS_BOTTOM);
+
+    /* write the padding bytes after the table key strings */
     udata_writePadding(mem, pad);
 
+    /* write all of the bundle contents: the root item and its children */
     usedOffset = res_write(mem, bundle->fRoot, usedOffset, status);
 
-    udata_finish(mem, status);
+    size = udata_finish(mem, status);
+    if(top != size) {
+        fprintf(stderr, "genrb error: wrote %u bytes but counted %u\n",
+                size, top);
+        *status = U_INTERNAL_PROGRAM_ERROR;
+    }
 }
 
 /* Opening Functions */
-struct SResource* table_open(struct SRBRoot *bundle, char *tag, UErrorCode *status) {
+struct SResource* res_open(const struct UString* comment, UErrorCode* status){
     struct SResource *res;
 
     if (U_FAILURE(*status)) {
@@ -374,16 +433,40 @@
         *status = U_MEMORY_ALLOCATION_ERROR;
         return NULL;
     }
+    uprv_memset(res, 0, sizeof(struct SResource));
+
+    res->fComment = NULL;
+    if(comment != NULL){
+        res->fComment = (struct UString *) uprv_malloc(sizeof(struct UString));
+        if(res->fComment == NULL){
+            *status = U_MEMORY_ALLOCATION_ERROR;
+            return NULL;
+        }
+        ustr_init(res->fComment);
+        ustr_cpy(res->fComment, comment, status);
+    }
+    return res;
+
+}
+struct SResource* table_open(struct SRBRoot *bundle, char *tag,  const struct UString* comment, UErrorCode *status) {
+
+    struct SResource *res = res_open(comment, status);
 
-    res->fType = URES_TABLE;
     res->fKey  = bundle_addtag(bundle, tag, status);
 
     if (U_FAILURE(*status)) {
+        uprv_free(res->fComment);
         uprv_free(res);
         return NULL;
     }
 
     res->fNext = NULL;
+
+    /*
+     * always open a table not a table32 in case it remains empty -
+     * try to use table32 only when necessary
+     */
+    res->fType = URES_TABLE;
     res->fSize = sizeof(uint16_t);
 
     res->u.fTable.fCount        = 0;
@@ -394,17 +477,11 @@
     return res;
 }
 
-struct SResource* array_open(struct SRBRoot *bundle, char *tag, UErrorCode *status) {
-    struct SResource *res;
-
-    if (U_FAILURE(*status)) {
-        return NULL;
-    }
+struct SResource* array_open(struct SRBRoot *bundle, char *tag, const struct UString* comment, UErrorCode *status) {
 
-    res = (struct SResource *) uprv_malloc(sizeof(struct SResource));
+    struct SResource *res = res_open(comment, status);
 
-    if (res == NULL) {
-        *status = U_MEMORY_ALLOCATION_ERROR;
+    if (U_FAILURE(*status)) {
         return NULL;
     }
 
@@ -412,6 +489,7 @@
     res->fKey  = bundle_addtag(bundle, tag, status);
 
     if (U_FAILURE(*status)) {
+        uprv_free(res->fComment);
         uprv_free(res);
         return NULL;
     }
@@ -427,24 +505,18 @@
     return res;
 }
 
-struct SResource *string_open(struct SRBRoot *bundle, char *tag, const UChar *value, int32_t len, UErrorCode *status) {
-    struct SResource *res;
+struct SResource *string_open(struct SRBRoot *bundle, char *tag, const UChar *value, int32_t len, const struct UString* comment, UErrorCode *status) {
+    struct SResource *res = res_open(comment, status);
 
     if (U_FAILURE(*status)) {
         return NULL;
     }
 
-    res = (struct SResource *) uprv_malloc(sizeof(struct SResource));
-
-    if (res == NULL) {
-        *status = U_MEMORY_ALLOCATION_ERROR;
-        return NULL;
-    }
-
     res->fType = URES_STRING;
     res->fKey  = bundle_addtag(bundle, tag, status);
 
     if (U_FAILURE(*status)) {
+        uprv_free(res->fComment);
         uprv_free(res);
         return NULL;
     }
@@ -467,24 +539,18 @@
 }
 
 /* TODO: make alias_open and string_open use the same code */
-struct SResource *alias_open(struct SRBRoot *bundle, char *tag, UChar *value, int32_t len, UErrorCode *status) {
-    struct SResource *res;
+struct SResource *alias_open(struct SRBRoot *bundle, char *tag, UChar *value, int32_t len, const struct UString* comment, UErrorCode *status) {
+    struct SResource *res = res_open(comment, status);
 
     if (U_FAILURE(*status)) {
         return NULL;
     }
 
-    res = (struct SResource *) uprv_malloc(sizeof(struct SResource));
-
-    if (res == NULL) {
-        *status = U_MEMORY_ALLOCATION_ERROR;
-        return NULL;
-    }
-
     res->fType = URES_ALIAS;
     res->fKey  = bundle_addtag(bundle, tag, status);
 
     if (U_FAILURE(*status)) {
+        uprv_free(res->fComment);
         uprv_free(res);
         return NULL;
     }
@@ -507,24 +573,18 @@
 }
 
 
-struct SResource* intvector_open(struct SRBRoot *bundle, char *tag, UErrorCode *status) {
-    struct SResource *res;
+struct SResource* intvector_open(struct SRBRoot *bundle, char *tag, const struct UString* comment, UErrorCode *status) {
+    struct SResource *res = res_open(comment, status);
 
     if (U_FAILURE(*status)) {
         return NULL;
     }
 
-    res = (struct SResource *) uprv_malloc(sizeof(struct SResource));
-
-    if (res == NULL) {
-        *status = U_MEMORY_ALLOCATION_ERROR;
-        return NULL;
-    }
-
     res->fType = URES_INT_VECTOR;
     res->fKey  = bundle_addtag(bundle, tag, status);
 
     if (U_FAILURE(*status)) {
+        uprv_free(res->fComment);
         uprv_free(res);
         return NULL;
     }
@@ -544,24 +604,18 @@
     return res;
 }
 
-struct SResource *int_open(struct SRBRoot *bundle, char *tag, int32_t value, UErrorCode *status) {
-    struct SResource *res;
+struct SResource *int_open(struct SRBRoot *bundle, char *tag, int32_t value, const struct UString* comment, UErrorCode *status) {
+    struct SResource *res = res_open(comment, status);
 
     if (U_FAILURE(*status)) {
         return NULL;
     }
 
-    res = (struct SResource *) uprv_malloc(sizeof(struct SResource));
-
-    if (res == NULL) {
-        *status = U_MEMORY_ALLOCATION_ERROR;
-        return NULL;
-    }
-
     res->fType = URES_INT;
     res->fKey  = bundle_addtag(bundle, tag, status);
 
     if (U_FAILURE(*status)) {
+        uprv_free(res->fComment);
         uprv_free(res);
         return NULL;
     }
@@ -573,28 +627,22 @@
     return res;
 }
 
-struct SResource *bin_open(struct SRBRoot *bundle, const char *tag, uint32_t length, uint8_t *data,const char* fileName,UErrorCode *status) {
-    struct SResource *res;
+struct SResource *bin_open(struct SRBRoot *bundle, const char *tag, uint32_t length, uint8_t *data, const char* fileName, const struct UString* comment, UErrorCode *status) {
+    struct SResource *res = res_open(comment, status);
 
     if (U_FAILURE(*status)) {
         return NULL;
     }
 
-    res = (struct SResource *) uprv_malloc(sizeof(struct SResource));
-
-    if (res == NULL) {
-        *status = U_MEMORY_ALLOCATION_ERROR;
-        return NULL;
-    }
-
     res->fType = URES_BINARY;
     res->fKey  = bundle_addtag(bundle, tag, status);
 
     if (U_FAILURE(*status)) {
+        uprv_free(res->fComment);
         uprv_free(res);
         return NULL;
     }
-    
+
     res->fNext = NULL;
 
     res->u.fBinaryValue.fLength = length;
@@ -623,7 +671,7 @@
     return res;
 }
 
-struct SRBRoot *bundle_open(UErrorCode *status) {
+struct SRBRoot *bundle_open(const struct UString* comment, UErrorCode *status) {
     struct SRBRoot *bundle = NULL;
 
     if (U_FAILURE(*status)) {
@@ -636,10 +684,16 @@
         *status = U_MEMORY_ALLOCATION_ERROR;
         return 0;
     }
+    uprv_memset(bundle, 0, sizeof(struct SRBRoot));
 
     bundle->fLocale   = NULL;
-    bundle->fKeyPoint = 0;
+
     bundle->fKeys     = (char *) uprv_malloc(sizeof(char) * KEY_SPACE_SIZE);
+    bundle->fKeysCapacity = KEY_SPACE_SIZE;
+
+    if(comment != NULL){
+
+    }
 
     if (bundle->fKeys == NULL) {
         *status = U_MEMORY_ALLOCATION_ERROR;
@@ -647,11 +701,17 @@
         return NULL;
     }
 
+    /* formatVersion 1.1: start fKeyPoint after the root item and indexes[] */
+    bundle->fKeyPoint = URES_STRINGS_BOTTOM;
+    uprv_memset(bundle->fKeys, 0, URES_STRINGS_BOTTOM);
+
     bundle->fCount = 0;
-    bundle->fRoot  = table_open(bundle, NULL, status);
+    bundle->fRoot  = table_open(bundle, NULL, comment, status);
 
     if (bundle->fRoot == NULL || U_FAILURE(*status)) {
-        *status = U_MEMORY_ALLOCATION_ERROR;
+        if (U_SUCCESS(*status)) {
+            *status = U_MEMORY_ALLOCATION_ERROR;
+        }
 
         uprv_free(bundle->fKeys);
         uprv_free(bundle);
@@ -747,7 +807,8 @@
         case URES_ARRAY:
             array_close(res, status);
             break;
-        case URES_TABLE :
+        case URES_TABLE:
+        case URES_TABLE32:
             table_close(res, status);
             break;
         default:
@@ -803,12 +864,31 @@
     /* here we need to traverse the list */
     list = &(table->u.fTable);
 
+    if(table->fType == URES_TABLE && res->fKey > 0xffff) {
+        /* this table straddles the 64k strings boundary, update to a table32 */
+        table->fType = URES_TABLE32;
+
+        /*
+         * increase the size because count and each string offset
+         * increase from uint16_t to int32_t
+         */
+        table->fSize += (1 + list->fCount) * 2;
+    }
+
     ++(list->fCount);
-    table->fSize += sizeof(uint32_t) + sizeof(uint16_t);
+    if(list->fCount > (uint32_t)list->fRoot->fMaxTableLength) {
+        list->fRoot->fMaxTableLength = list->fCount;
+    }
+
+    /*
+     * URES_TABLE:   6 bytes = 1 uint16_t key string offset + 1 uint32_t Resource
+     * URES_TABLE32: 8 bytes = 1 int32_t key string offset + 1 uint32_t Resource
+     */
+    table->fSize += table->fType == URES_TABLE ? 6 : 8;
 
     table->u.fTable.fChildrenSize += res->fSize + calcPadding(res->fSize);
 
-    if (res->fType == URES_TABLE) {
+    if (res->fType == URES_TABLE || res->fType == URES_TABLE32) {
         table->u.fTable.fChildrenSize += res->u.fTable.fChildrenSize;
     } else if (res->fType == URES_ARRAY) {
         table->u.fTable.fChildrenSize += res->u.fArray.fChildrenSize;
@@ -870,7 +950,7 @@
     array->fSize += sizeof(uint32_t);
     array->u.fArray.fChildrenSize += res->fSize + calcPadding(res->fSize);
 
-    if (res->fType == URES_TABLE) {
+    if (res->fType == URES_TABLE || res->fType == URES_TABLE32) {
         array->u.fArray.fChildrenSize += res->u.fTable.fChildrenSize;
     } else if (res->fType == URES_ARRAY) {
         array->u.fArray.fChildrenSize += res->u.fArray.fChildrenSize;
@@ -912,27 +992,35 @@
 
 }
 
-uint16_t bundle_addtag(struct SRBRoot *bundle, const char *tag, UErrorCode *status) {
-    uint16_t keypos;
+
+int32_t
+bundle_addtag(struct SRBRoot *bundle, const char *tag, UErrorCode *status) {
+    int32_t keypos, length;
 
     if (U_FAILURE(*status)) {
-        return (uint16_t) - 1;
+        return -1;
     }
 
     if (tag == NULL) {
-        return (uint16_t) - 1;
+        /* do not set an error: the root table has a NULL tag */
+        return -1;
     }
 
-    keypos = (uint16_t)bundle->fKeyPoint;
+    keypos = bundle->fKeyPoint;
 
-    bundle->fKeyPoint += (uint16_t) (uprv_strlen(tag) + 1);
+    bundle->fKeyPoint += length = (int32_t) (uprv_strlen(tag) + 1);
 
-    if (bundle->fKeyPoint > KEY_SPACE_SIZE) {
-        *status = U_MEMORY_ALLOCATION_ERROR;
-        return (uint16_t) - 1;
+    if (bundle->fKeyPoint >= bundle->fKeysCapacity) {
+        /* overflow - resize the keys buffer */
+        bundle->fKeysCapacity += KEY_SPACE_SIZE;
+        bundle->fKeys = uprv_realloc(bundle->fKeys, bundle->fKeysCapacity);
+        if(bundle->fKeys == NULL) {
+            *status = U_MEMORY_ALLOCATION_ERROR;
+            return -1;
+        }
     }
 
-    uprv_strcpy(bundle->fKeys + keypos, tag);
+    uprv_memcpy(bundle->fKeys + keypos, tag, length);
 
     return keypos;
 }

Index: reslist.h
===================================================================
RCS file: /cvs/core/icu-sword/source/tools/genrb/reslist.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- reslist.h	10 Sep 2003 02:42:58 -0000	1.4
+++ reslist.h	6 Apr 2004 10:10:13 -0000	1.5
@@ -18,7 +18,7 @@
 #ifndef RESLIST_H
 #define RESLIST_H
 
-#define KEY_SPACE_SIZE 65532
+#define KEY_SPACE_SIZE 65536
 #define RESLIST_MAX_INT_VECTOR 2048
 
 #include "unicode/utypes.h"
@@ -28,19 +28,22 @@
 #include "cmemory.h"
 #include "cstring.h"
 #include "unewdata.h"
+#include "ustr.h"
 
 U_CDECL_BEGIN
 
 /* Resource bundle root table */
 struct SRBRoot {
   char *fLocale;
-  uint32_t fKeyPoint;
+  int32_t fKeyPoint;
   char *fKeys;
+  int32_t fKeysCapacity;
   int32_t fCount;
-  struct SResource *fRoot; 
+  struct SResource *fRoot;
+  int32_t fMaxTableLength;
 };
 
-struct SRBRoot *bundle_open(UErrorCode *status);
+struct SRBRoot *bundle_open(const struct UString* comment, UErrorCode *status);
 void bundle_write(struct SRBRoot *bundle, const char *outputDir, const char *outputPkg, char *writtenFilename, int writtenFilenameLen, UErrorCode *status);
 
 /* write a java resource file */
@@ -58,18 +61,19 @@
 
 void bundle_close(struct SRBRoot *bundle, UErrorCode *status);
 void bundle_setlocale(struct SRBRoot *bundle, UChar *locale, UErrorCode *status);
-uint16_t bundle_addtag(struct SRBRoot *bundle, const char *tag, UErrorCode *status);
+int32_t bundle_addtag(struct SRBRoot *bundle, const char *tag, UErrorCode *status);
 
 /* Various resource types */
+struct SResource* res_open(const struct UString* comment, UErrorCode* status);
 
 struct SResTable {
-    uint16_t fCount;
+    uint32_t fCount;
     uint32_t fChildrenSize;
     struct SResource *fFirst;
     struct SRBRoot *fRoot;
 };
 
-struct SResource* table_open(struct SRBRoot *bundle, char *tag, UErrorCode *status);
+struct SResource* table_open(struct SRBRoot *bundle, char *tag, const struct UString* comment, UErrorCode *status);
 void table_close(struct SResource *table, UErrorCode *status);
 void table_add(struct SResource *table, struct SResource *res, int linenumber, UErrorCode *status);
 
@@ -80,7 +84,7 @@
     struct SResource *fLast;
 };
 
-struct SResource* array_open(struct SRBRoot *bundle, char *tag, UErrorCode *status);
+struct SResource* array_open(struct SRBRoot *bundle, char *tag, const struct UString* comment, UErrorCode *status);
 void array_close(struct SResource *array, UErrorCode *status);
 void array_add(struct SResource *array, struct SResource *res, UErrorCode *status);
 
@@ -89,10 +93,10 @@
     UChar *fChars;
 };
 
-struct SResource *string_open(struct SRBRoot *bundle, char *tag, const UChar *value, int32_t len, UErrorCode *status);
+struct SResource *string_open(struct SRBRoot *bundle, char *tag, const UChar *value, int32_t len, const struct UString* comment, UErrorCode *status);
 void string_close(struct SResource *string, UErrorCode *status);
 
-struct SResource *alias_open(struct SRBRoot *bundle, char *tag, UChar *value, int32_t len, UErrorCode *status);
+struct SResource *alias_open(struct SRBRoot *bundle, char *tag, UChar *value, int32_t len, const struct UString* comment, UErrorCode *status);
 void alias_close(struct SResource *string, UErrorCode *status);
 
 struct SResIntVector {
@@ -100,7 +104,7 @@
     uint32_t *fArray;
 };
 
-struct SResource* intvector_open(struct SRBRoot *bundle, char *tag, UErrorCode *status);
+struct SResource* intvector_open(struct SRBRoot *bundle, char *tag,  const struct UString* comment, UErrorCode *status);
 void intvector_close(struct SResource *intvector, UErrorCode *status);
 void intvector_add(struct SResource *intvector, int32_t value, UErrorCode *status);
 
@@ -108,7 +112,7 @@
     uint32_t fValue;
 };
 
-struct SResource *int_open(struct SRBRoot *bundle, char *tag, int32_t value, UErrorCode *status);
+struct SResource *int_open(struct SRBRoot *bundle, char *tag, int32_t value, const struct UString* comment, UErrorCode *status);
 void int_close(struct SResource *intres, UErrorCode *status);
 
 struct SResBinary {
@@ -117,17 +121,18 @@
     char* fFileName; /* file name for binary or import binary tags if any */
 };
 
-struct SResource *bin_open(struct SRBRoot *bundle, const char *tag, uint32_t length, uint8_t *data, const char* fileName, UErrorCode *status);
+struct SResource *bin_open(struct SRBRoot *bundle, const char *tag, uint32_t length, uint8_t *data, const char* fileName, const struct UString* comment, UErrorCode *status);
 void bin_close(struct SResource *binres, UErrorCode *status);
 
 /* Resource place holder */
 
 struct SResource {
     UResType fType;
-    uint16_t fKey;
+    int32_t  fKey;
     uint32_t fSize; /* Size in bytes outside the header part */
     int      line;  /* used internally to report duplicate keys in tables */
     struct SResource *fNext; /*This is for internal chaining while building*/
+    struct UString *fComment;
     union {
         struct SResTable fTable;
         struct SResArray fArray;

Index: rle.c
===================================================================
RCS file: /cvs/core/icu-sword/source/tools/genrb/rle.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- rle.c	10 Sep 2003 02:42:58 -0000	1.1
+++ rle.c	6 Apr 2004 10:10:13 -0000	1.2
@@ -90,22 +90,22 @@
 }
 
 #define APPEND( buffer, bufLimit, value, num, status){  \
-    if(buffer<bufLimit){								\
-        *buffer++=(value);								\
-    }else{												\
-        *status = U_BUFFER_OVERFLOW_ERROR;				\
-    }													\
-    num++;												\
+    if(buffer<bufLimit){					\
+        *buffer++=(value);					\
+    }else{									\
+        *status = U_BUFFER_OVERFLOW_ERROR;	\
+    }										\
+    num++;									\
 }
 
 /**
  * Encode a run, possibly a degenerate run (of < 4 values).
  * @param length The length of the run; must be > 0 && <= 0xFFFF.
  */
-static uint16_t* 
+static uint16_t*
 encodeRunShort(uint16_t* buffer,uint16_t* bufLimit, uint16_t value, int32_t length,UErrorCode* status) {
     int32_t num=0;
-	if (length < 4) {
+    if (length < 4) {
         int j=0;
         for (; j<length; ++j) {
             if (value == (int32_t) ESCAPE){
@@ -144,10 +144,10 @@
  * The ESCAPE value is chosen so as not to collide with commonly
  * seen values.
  */
-int32_t 
+int32_t
 usArrayToRLEString(const uint16_t* src,int32_t srcLen,uint16_t* buffer, int32_t bufLen,UErrorCode* status) {
     uint16_t* bufLimit =  buffer+bufLen;
-	uint16_t* saveBuffer = buffer;
+    uint16_t* saveBuffer = buffer;
     if(buffer < bufLimit){
         *buffer++ =  (uint16_t)(srcLen>>16);
         if(buffer<bufLimit){
@@ -173,7 +173,7 @@
     }else{
         *status = U_BUFFER_OVERFLOW_ERROR;
     }
-    return (buffer - saveBuffer);
+    return (int32_t)(buffer - saveBuffer);
 }
 
 /**
@@ -252,7 +252,7 @@
         return 2;
     }
     length = (((int32_t) src[0]) << 16) | ((int32_t) src[1]);
-    
+
     if(target == NULL){
         return length;
     }
@@ -284,7 +284,7 @@
     if (ai != length){
         *status = U_INTERNAL_PROGRAM_ERROR;
     }
-        
+
     return length;
 }
 
@@ -313,7 +313,7 @@
         return 2;
     }
     length = (((int32_t) src[0]) << 16) | ((int32_t) src[1]);
-    
+
     if(target == NULL){
         return length;
     }
@@ -321,7 +321,7 @@
         *status = U_BUFFER_OVERFLOW_ERROR;
         return length;
     }
-        
+
     for (; ai<tgtLen; ) {
        /* This part of the loop places the next byte into the local
         * variable 'b' each time through the loop.  It keeps the
@@ -393,7 +393,7 @@
         return 0;
     }
 
-        
+
     if (i != srcLen){
         /*("Excess data in RLE byte array string");*/
         *status = U_INTERNAL_PROGRAM_ERROR;

Index: ustr.c
===================================================================
RCS file: /cvs/core/icu-sword/source/tools/genrb/ustr.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ustr.c	10 Sep 2003 02:42:58 -0000	1.3
+++ ustr.c	6 Apr 2004 10:10:13 -0000	1.4
@@ -1,7 +1,7 @@
 /*
 *******************************************************************************
 *
-*   Copyright (C) 1998-2000, International Business Machines
+*   Copyright (C) 1998-2003, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 *******************************************************************************
@@ -85,7 +85,9 @@
         if(U_FAILURE(*status))
             return;
     }
-
+    if(src->fChars == NULL || dst->fChars == NULL){
+        return;
+    }
     uprv_memcpy(dst->fChars, src->fChars, sizeof(UChar) * src->fLength);
     dst->fLength = src->fLength;
     dst->fChars[dst->fLength] = 0x0000;
@@ -157,7 +159,19 @@
     dst->fLength += 1;
     dst->fChars[dst->fLength] = 0x0000;
 }
-
+void 
+ustr_u32cat(struct UString *dst, UChar32 c, UErrorCode *status){
+    if(c > 0x10FFFF){
+        *status = U_ILLEGAL_CHAR_FOUND;
+        return;
+    }
+    if(c >0xFFFF){
+        ustr_ucat(dst, U16_LEAD(c), status);
+        ustr_ucat(dst, U16_TRAIL(c), status);
+    }else{
+        ustr_ucat(dst, (UChar) c, status);
+    }
+}
 void
 ustr_uscat(struct UString *dst,
       const UChar* src,int len,

Index: ustr.h
===================================================================
RCS file: /cvs/core/icu-sword/source/tools/genrb/ustr.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ustr.h	10 Sep 2003 02:42:58 -0000	1.3
+++ ustr.h	6 Apr 2004 10:10:13 -0000	1.4
@@ -61,5 +61,6 @@
            int32_t n, UErrorCode *status);
 
 void ustr_ucat(struct UString *dst, UChar c, UErrorCode *status);
+void ustr_u32cat(struct UString *dst, UChar32 c, UErrorCode *status);
 void ustr_uscat(struct UString *dst, const UChar* src,int len,UErrorCode *status);
 #endif

Index: wrtjava.c
===================================================================
RCS file: /cvs/core/icu-sword/source/tools/genrb/wrtjava.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- wrtjava.c	10 Sep 2003 02:42:58 -0000	1.1
+++ wrtjava.c	6 Apr 2004 10:10:13 -0000	1.2
@@ -33,7 +33,7 @@
 void res_write_java(struct SResource *res,UErrorCode *status);
 
 
-static const char copyRight[] = 
+static const char copyRight[] =
     "/* \n"
     " *******************************************************************************\n"
     " *\n"
@@ -46,7 +46,7 @@
     " * $" "Revision:  $ \n"
     " *******************************************************************************\n"
     " */\n\n";
-static const char warningMsg[] = 
+static const char warningMsg[] =
     "/*********************************************************************\n"
     "######################################################################\n"
     "\n"
@@ -64,7 +64,7 @@
 static const char* javaClass =  "import java.util.ListResourceBundle;\n"
                                 "import com.ibm.icu.impl.ICUListResourceBundle;\n\n"
                                 "public class ";
- 
+
 static const char* javaClass1=  " extends ICUListResourceBundle {\n\n"
                                 "    /**\n"
                                 "     * Overrides ListResourceBundle \n"
@@ -93,10 +93,14 @@
         T_FileStream_write(os,"    ",4);
     }
 }
+
+#define ZERO 0x30
+
 static const char* enc ="";
 static UConverter* conv = NULL;
+static char NUMBER = ZERO;
 
-static int32_t 
+static int32_t
 uCharsToChars( char* target,int32_t targetLen, UChar* source, int32_t sourceLen,UErrorCode* status){
     int i=0, j=0;
     char str[30]={'\0'};
@@ -119,7 +123,7 @@
                 }
                 j+=2;
             }else if(source[i-1]!='\\'){
-                     
+
                 if(j+2<targetLen){
                     uprv_strcat(target,"\\");
                     target[j+1]= (char)source[i];
@@ -169,7 +173,7 @@
             if(j<targetLen){
                 target[j] = (char) source[i];
             }
-            j++;            
+            j++;
         }else{
             if(*enc =='\0' || source[i]==0x0000){
                 uprv_strcpy(str,"\\u");
@@ -196,7 +200,7 @@
 }
 
 
-static uint32_t 
+static uint32_t
 strrch(const char* source,uint32_t sourceLen,char find){
     const char* tSourceEnd =source + (sourceLen-1);
     while(tSourceEnd>= source){
@@ -227,7 +231,7 @@
     uint32_t length = srcLen*8;
     uint32_t bufLen = 0;
     char* buf = (char*) malloc(sizeof(char)*length);
-    
+
     uint32_t columnCount = getColumnCount(srcLen);
 
     /* test for NULL */
@@ -235,9 +239,9 @@
         *status = U_MEMORY_ALLOCATION_ERROR;
         return;
     }
-    
+
     memset(buf,0,length);
-  
+
     bufLen = uCharsToChars(buf,length,src,srcLen,status);
 
     if(printEndLine) write_tabs(out);
@@ -245,7 +249,7 @@
     if(U_FAILURE(*status)){
         return;
     }
-    
+
     if(bufLen+(tabCount*4) > columnCount  ){
         uint32_t len = 0;
         char* current = buf;
@@ -297,12 +301,9 @@
     }
 }
 
-/* Writing Functions */
-static void 
-string_write_java(struct SResource *res,UErrorCode *status) {       
-    if(uprv_strcmp(srBundle->fKeys+res->fKey,"%%UCARULES")==0 ){
+static void
+write_utf8_file(struct SResource *res, const char *file, UErrorCode *status){
         char fileName[1024] ={0};
-        const char* file = "UCARules.utf8";
         FileStream* datFile = NULL;
         const char* type = "new ICUListResourceBundle.ResourceString(";
         char* dest  = (char*) uprv_malloc( 8 * res->u.fString.fLength);
@@ -314,7 +315,7 @@
             }
         }
         uprv_strcat(fileName,file);/* UCARULES.utf8 UTF-8 file */
-        
+
         write_tabs(out);
 
         T_FileStream_write(out, type, (int32_t)uprv_strlen(type));
@@ -322,11 +323,11 @@
         T_FileStream_write(out, file, (int32_t)uprv_strlen(file));
         T_FileStream_write(out, "\")\n", 3);
         datFile=T_FileStream_open(fileName,"w");
-        
+
         if(!dest){
             *status=U_MEMORY_ALLOCATION_ERROR;
         }
-        
+
         u_strToUTF8(dest,8*res->u.fString.fLength,&len,res->u.fString.fChars,res->u.fString.fLength,status);
         if(U_FAILURE(*status)){
             T_FileStream_close(datFile);
@@ -336,32 +337,49 @@
         T_FileStream_write(datFile,dest,len);
         T_FileStream_close(datFile);
         uprv_free(dest);
-           
+}
+#define MAX_SEQUENCE_LENGTH 30000
+/* Writing Functions */
+static void
+string_write_java(struct SResource *res,UErrorCode *status) {
+    if(res->fKey > 0 && uprv_strcmp(srBundle->fKeys+res->fKey,"%%UCARULES")==0 ){
+
+        const char* file = "UCARules.utf8";
+        write_utf8_file(res, file, status);
+    }else if(res->fKey > 0 && uprv_strcmp(srBundle->fKeys+res->fKey,"Sequence")==0
+             && res->fType == RES_STRING
+             && res->u.fString.fLength > MAX_SEQUENCE_LENGTH){
+        char file[1024] = {0};
+        uprv_strcpy(file, "CollationSequence_");
+        uprv_strcat(file, srBundle->fLocale);
+        uprv_strcat(file, ".utf8");
+        write_utf8_file(res, file, status);
+
     }else{
         str_write_java(res->u.fString.fChars,res->u.fString.fLength,TRUE,status);
 
-        if(uprv_strcmp(srBundle->fKeys+res->fKey,"Rule")==0){
+        if(res->fKey > 0 && uprv_strcmp(srBundle->fKeys+res->fKey,"Rule")==0){
             UChar* buf = (UChar*) uprv_malloc(sizeof(UChar)*res->u.fString.fLength);
-            uprv_memcpy(buf,res->u.fString.fChars,res->u.fString.fLength);      
+            uprv_memcpy(buf,res->u.fString.fChars,res->u.fString.fLength);
             uprv_free(buf);
         }
     }
 
 }
 
-static void 
+static void
 alias_write_java(struct SResource *res,UErrorCode *status) {
     static const char str[] = "new ICUListResourceBundle.Alias(";
     write_tabs(out);
-    T_FileStream_write(out,str,uprv_strlen(str));
-    
+    T_FileStream_write(out,str,(int32_t)uprv_strlen(str));
+
     /*str_write_java(res->u.fString.fChars,res->u.fString.fLength,FALSE,status);*/
     /*if(*res->u.fString.fChars == RES_PATH_SEPARATOR) {*/
-        /* there is a path included 
+        /* there is a path included
         locale = u_strchr(res->u.fString.fChars +1, RES_PATH_SEPARATOR);
         *locale = 0;
         locale++;
-        
+
         T_FileStream_write(out,"\"/",2);
         T_FileStream_write(out,apName,(int32_t)uprv_strlen(apName));
         T_FileStream_write(out,"/",1);
@@ -371,13 +389,13 @@
     } else {
         str_write_java(res->u.fString.fChars,res->u.fString.fLength,FALSE,status);
     }*/
-    
+
     str_write_java(res->u.fString.fChars,res->u.fString.fLength,FALSE,status);
-    
+
     T_FileStream_write(out,"),\n",3);
 }
 
-static void 
+static void
 array_write_java( struct SResource *res, UErrorCode *status) {
 
     uint32_t  i         = 0;
@@ -435,24 +453,24 @@
 
     } else {
         write_tabs(out);
-        T_FileStream_write(out,arr,uprv_strlen(arr));
+        T_FileStream_write(out,arr,(int32_t)uprv_strlen(arr));
         write_tabs(out);
         T_FileStream_write(out,"},\n",3);
     }
 }
 
-static void 
+static void
 intvector_write_java( struct SResource *res, UErrorCode *status) {
     uint32_t i = 0;
     const char* intArr = "new Integer[] {\n";
     const char* intC   = "new Integer(";
-    const char* stringArr = "new String[]{\n"; 
+    const char* stringArr = "new String[]{\n";
     char buf[100];
     int len =0;
     buf[0]=0;
     write_tabs(out);
 
-    if(uprv_strcmp(srBundle->fKeys+res->fKey,"DateTimeElements")==0){
+    if(res->fKey > 0 && uprv_strcmp(srBundle->fKeys+res->fKey,"DateTimeElements")==0){
         T_FileStream_write(out, stringArr, (int32_t)uprv_strlen(stringArr));
         tabCount++;
         for(i = 0; i<res->u.fIntVector.fCount; i++) {
@@ -480,7 +498,7 @@
     T_FileStream_write(out,"},\n",3);
 }
 
-static void 
+static void
 int_write_java(struct SResource *res,UErrorCode *status) {
     const char* intC   =  "new Integer(";
     char buf[100];
@@ -496,7 +514,7 @@
 
 }
 
-static void 
+static void
 bin_write_java( struct SResource *res, UErrorCode *status) {
     const char* type = "new ICUListResourceBundle.CompressedBinary(";
     const char* ext;
@@ -507,7 +525,7 @@
         uint16_t* saveTarget = NULL;
         int32_t tgtLen = 0;
 
-        if(uprv_strcmp(srBundle->fKeys+res->fKey,"%%CollationBin")==0 || uprv_strcmp(srBundle->fKeys+res->fKey,"BreakDictionaryData")==0){
+        if(res->fKey > 0 && (uprv_strcmp(srBundle->fKeys+res->fKey,"%%CollationBin")==0 || uprv_strcmp(srBundle->fKeys+res->fKey,"BreakDictionaryData")==0)){
             char fileName[1024] ={0};
             char fn[1024] =  {0};
             FileStream* datFile = NULL;
@@ -521,8 +539,13 @@
             if(uprv_strcmp(srBundle->fLocale,"root")!=0){
                 uprv_strcat(fileName,"_");
                 uprv_strcat(fileName,srBundle->fLocale);
+                if(NUMBER > ZERO){
+                    uprv_strcat(fileName, "_");
+                    uprv_strcat(fileName, &NUMBER);
+                }
+                NUMBER++;
             }
-            
+
             uprv_strcat(fileName,ext);
             if(outDir ){
                 uprv_strcat(fn,outDir);
@@ -564,7 +587,7 @@
                     /* test for NULL */
                     if(myTarget == NULL) {
                         *status = U_MEMORY_ALLOCATION_ERROR;
-                        return; 
+                        return;
                     }
 
                     int i=0;
@@ -604,10 +627,10 @@
             free(target);
 
         }
-    
+
    }else{
         write_tabs(out);
-        T_FileStream_write(out,type,uprv_strlen(type));
+        T_FileStream_write(out,type,(int32_t)uprv_strlen(type));
         T_FileStream_write(out,"null),\n",7);
    }
 
@@ -616,7 +639,7 @@
 
 static UBool start = TRUE;
 
-static void 
+static void
 table_write_java(struct SResource *res, UErrorCode *status) {
     uint32_t  i         = 0;
     UBool allStrings =TRUE;
@@ -627,7 +650,7 @@
     if (U_FAILURE(*status)) {
         return ;
     }
-    
+
     if (res->u.fTable.fCount > 0) {
         if(start==FALSE){
             write_tabs(out);
@@ -642,7 +665,7 @@
         while (current != NULL) {
             assert(i < res->u.fTable.fCount);
             write_tabs(out);
-            
+
             T_FileStream_write(out, openBrace, 2);
 
 
@@ -650,14 +673,14 @@
             allStrings=FALSE;
 
             write_tabs(out);
+            if(current->fKey > 0){
+                T_FileStream_write(out, "\"", 1);
+                T_FileStream_write(out, srBundle->fKeys+current->fKey,
+                                   (int32_t)uprv_strlen(srBundle->fKeys+current->fKey));
+                T_FileStream_write(out, "\",\n", 2);
 
-            T_FileStream_write(out, "\"", 1);
-            T_FileStream_write(out, srBundle->fKeys+current->fKey,
-                               (int32_t)uprv_strlen(srBundle->fKeys+current->fKey));
-            T_FileStream_write(out, "\",\n", 2);
-
-            T_FileStream_write(out, "\n", 1);
-           
+                T_FileStream_write(out, "\n", 1);
+            }
             res_write_java(current, status);
             if(U_FAILURE(*status)){
                 return;
@@ -676,7 +699,7 @@
 
     } else {
         write_tabs(out);
-        T_FileStream_write(out,obj,uprv_strlen(obj));
+        T_FileStream_write(out,obj,(int32_t)uprv_strlen(obj));
 
         write_tabs(out);
         T_FileStream_write(out,"},\n",3);
@@ -685,9 +708,9 @@
 
 }
 
-void 
+void
 res_write_java(struct SResource *res,UErrorCode *status) {
-    
+
     if (U_FAILURE(*status)) {
         return ;
     }
@@ -713,6 +736,7 @@
              array_write_java     (res, status);
              return;
         case URES_TABLE:
+        case URES_TABLE32:
              table_write_java     (res, status);
              return;
 
@@ -724,21 +748,21 @@
     *status = U_INTERNAL_PROGRAM_ERROR;
 }
 
-void 
-bundle_write_java(struct SRBRoot *bundle, const char *outputDir,const char* outputEnc, 
-                  char *writtenFilename, int writtenFilenameLen, 
+void
+bundle_write_java(struct SRBRoot *bundle, const char *outputDir,const char* outputEnc,
+                  char *writtenFilename, int writtenFilenameLen,
                   const char* packageName, const char* bundleName,
                   UErrorCode *status) {
 
     char fileName[256] = {'\0'};
     char className[256]={'\0'};
-    char constructor[1000] = { 0 };    
+    char constructor[1000] = { 0 };
     UBool j1 =FALSE;
     outDir = outputDir;
 
     bName = (bundleName==NULL) ? "LocaleElements" : bundleName;
     pName = (packageName==NULL)? "com.ibm.icu.impl.data" : packageName;
-    
+
     uprv_strcpy(className, bName);
     srBundle = bundle;
     if(uprv_strcmp(srBundle->fLocale,"root")!=0){
@@ -764,7 +788,7 @@
     if (U_FAILURE(*status)) {
         return;
     }
-    
+
     out= T_FileStream_open(fileName,"w");
 
     if(out==NULL){

Index: wrtxml.c
===================================================================
RCS file: /cvs/core/icu-sword/source/tools/genrb/wrtxml.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- wrtxml.c	10 Sep 2003 02:42:58 -0000	1.1
+++ wrtxml.c	6 Apr 2004 10:10:14 -0000	1.2
@@ -28,6 +28,8 @@
 #include "uresimp.h"
 #include "unicode/ustring.h"
 #include "unicode/uchar.h"
+#include "ustr.h"
+#include "prscmnts.h"
 #include <time.h>
 
 static int tabCount = 0;
@@ -53,7 +55,7 @@
 
 /*get ID for each element. ID is globally unique.*/
[...1331 lines suppressed...]
     tabCount--;
     write_tabs(out);
-    T_FileStream_write(out,fileEnd, uprv_strlen(fileEnd));
+    T_FileStream_write(out,fileEnd, (int32_t)uprv_strlen(fileEnd));
     tabCount--;
     write_tabs(out);
-    T_FileStream_write(out,bundleEnd,uprv_strlen(bundleEnd));
+    T_FileStream_write(out,bundleEnd,(int32_t)uprv_strlen(bundleEnd));
     T_FileStream_close(out);
 
     ucnv_close(conv);
@@ -1171,6 +1468,6 @@
     }
     if(outputFileName != NULL){
         uprv_free(outputFileName);
-        pid = NULL;    
-    }    
+        pid = NULL;
+    }
 }