[sword-cvs] icu-sword/source/tools/genbrk genbrk.cpp,1.1,1.2 genbrk.vcproj,1.1,1.2

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


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

Modified Files:
	genbrk.cpp genbrk.vcproj 
Log Message:
ICU 2.8 sync

Index: genbrk.cpp
===================================================================
RCS file: /cvs/core/icu-sword/source/tools/genbrk/genbrk.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- genbrk.cpp	10 Sep 2003 02:42:55 -0000	1.1
+++ genbrk.cpp	6 Apr 2004 10:10:00 -0000	1.2
@@ -52,11 +52,22 @@
     { "rules", NULL, NULL, NULL, 'r', UOPT_REQUIRES_ARG, 0 },   /* 3 */
     { "out",   NULL, NULL, NULL, 'o', UOPT_REQUIRES_ARG, 0 },   /* 4 */
     UOPTION_ICUDATADIR,         /* 5 */
-    UOPTION_DESTDIR             /* 6 */
+    UOPTION_DESTDIR,            /* 6 */
+    UOPTION_COPYRIGHT,          /* 7 */
 };
 
 void usageAndDie(int retCode) {
-        printf("Usage: %s [-v] -r rule-file -o output-file\n", progName);
+        printf("Usage: %s [-v] [-options] -r rule-file -o output-file\n", progName);
+        printf("\tRead in break iteration rules text and write out the binary data\n"
+            "options:\n"
+            "\t-h or -? or --help  this usage text\n"
+            "\t-V or --version     show a version message\n"
+            "\t-c or --copyright   include a copyright notice\n"
+            "\t-v or --verbose     turn on verbose output\n"
+            "\t-i or --icudatadir  directory for locating any needed intermediate data files,\n"
+            "\t                    followed by path, defaults to %s\n"
+            "\t-d or --destdir     destination directory, followed by the path\n",
+            u_getDataDirectory());
         exit (retCode);
 }
 
@@ -97,8 +108,8 @@
         0,                          //     reserved
 
     { 0x42, 0x72, 0x6b, 0x20 },     //     dataFormat="Brk "
-    { 2, 1, 0, 0 },                 //     formatVersion
-        { 3, 1, 0, 0 }                //   dataVersion (Unicode version)
+    { 3, 0, 0, 0 },                 //     formatVersion
+        { 4, 0, 0, 0 }                //   dataVersion (Unicode version)
     }};
 
 #endif
@@ -113,8 +124,7 @@
     const char *ruleFileName;
     const char *outFileName;
     const char *outDir = NULL;
-    char *outFullFileName;
-    int32_t outFullFileNameLen;
+    const char *copyright = NULL;
 
     //
     // Pick up and check the command line arguments,
@@ -140,24 +150,27 @@
     }
     ruleFileName = options[3].value;
     outFileName  = options[4].value;
-    outFullFileNameLen = strlen(outFileName);
 
     if (options[5].doesOccur) {
         u_setDataDirectory(options[5].value);
     }
 
+    /* Initialize ICU */
+    u_init(&status);
+    if (U_FAILURE(status)) {
+        fprintf(stderr, "%s: can not initialize ICU.  status = %s\n",
+            argv[0], u_errorName(status));
+        exit(1);
+    }
+    status = U_ZERO_ERROR;
+
     /* Combine the directory with the file name */
     if(options[6].doesOccur) {
         outDir = options[6].value;
-        outFullFileNameLen += strlen(outDir);
     }
-    outFullFileName = (char*)malloc(outFullFileNameLen + 2);
-    outFullFileName[0] = 0;
-    if (outDir) {
-        strcpy(outFullFileName, outDir);
-        strcat(outFullFileName, U_FILE_SEP_STRING);
+    if (options[7].doesOccur) {
+        copyright = U_COPYRIGHT_STRING;
     }
-    strcat(outFullFileName, outFileName);
 
 #if UCONFIG_NO_BREAK_ITERATION
 
@@ -200,7 +213,7 @@
     //
     //  Read in the rule source file
     //
-    int         result;
+    long        result;
     long        ruleFileSize;
     FILE        *file;
     char        *ruleBufferC;
@@ -215,7 +228,7 @@
     fseek(file, 0, SEEK_SET);
     ruleBufferC = new char[ruleFileSize+10];
 
-    result = fread(ruleBufferC, 1, ruleFileSize, file);
+    result = (long)fread(ruleBufferC, 1, ruleFileSize, file);
     if (result != ruleFileSize)  {
         fprintf(stderr, "Error reading file \"%s\"\n", ruleFileName);
         exit (-1);
@@ -310,28 +323,30 @@
     //  Create the output file
     //
     size_t bytesWritten;
-    file = fopen(outFullFileName, "wb");
-    if (file == 0) {
-        fprintf(stderr, "Could not open output file \"%s\"\n", outFullFileName);
-        exit(-1);
+    UNewDataMemory *pData;
+    pData = udata_create(outDir, NULL, outFileName, &(dh.info), copyright, &status);
+    if(U_FAILURE(status)) {
+        fprintf(stderr, "genbrk: Could not open output file \"%s\", \"%s\"\n", 
+                         outFileName, u_errorName(status));
+        exit(status);
     }
-
-    bytesWritten = fwrite(&dh, 1, sizeof(DataHeader), file);
-
-    //
     //  Write the data itself.
-    //
-    bytesWritten = fwrite(outData, 1, outDataSize, file);
+    udata_writeBlock(pData, outData, outDataSize);
+    // finish up 
+    bytesWritten = udata_finish(pData, &status);
+    if(U_FAILURE(status)) {
+        fprintf(stderr, "genbrk: error %d writing the output file\n", status);
+        exit(status);
+    }
+    
     if (bytesWritten != outDataSize) {
-        fprintf(stderr, "Error writing to output file \"%s\"\n", outFullFileName);
+        fprintf(stderr, "Error writing to output file \"%s\"\n", outFileName);
         exit(-1);
     }
 
-    fclose(file);
     delete bi;
     delete[] ruleSourceU;
     delete[] ruleBufferC;
-    free(outFullFileName);
     u_cleanup();
 
 
@@ -340,3 +355,4 @@
 
 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
 }
+

Index: genbrk.vcproj
===================================================================
RCS file: /cvs/core/icu-sword/source/tools/genbrk/genbrk.vcproj,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- genbrk.vcproj	10 Sep 2003 02:42:55 -0000	1.1
+++ genbrk.vcproj	6 Apr 2004 10:10:00 -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="genbrk"
 	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"
@@ -66,7 +66,13 @@
 			<Tool
 				Name="VCWebServiceProxyGeneratorTool"/>
 			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
 				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
 		</Configuration>
 		<Configuration
 			Name="Debug|Win32"
@@ -97,9 +103,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"
@@ -127,9 +133,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"