[sword-cvs] icu-sword/source/tools/gencnval Makefile.in,1.4,1.5 gencnval.c,1.3,1.4 gencnval.vcproj,1.1,1.2

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


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

Modified Files:
	Makefile.in gencnval.c gencnval.vcproj 
Log Message:
ICU 2.8 sync

Index: Makefile.in
===================================================================
RCS file: /cvs/core/icu-sword/source/tools/gencnval/Makefile.in,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- Makefile.in	10 Sep 2003 02:42:56 -0000	1.4
+++ Makefile.in	6 Apr 2004 10:10:01 -0000	1.5
@@ -19,7 +19,7 @@
 SECTION = 1
 
 MANX_FILES = $(TARGET:$(EXEEXT)=).$(SECTION)
-MAN5_FILES = convrtrs.txt.5 $(srcdir)/cnvalias.dat.5
+MAN5_FILES = convrtrs.txt.5
 
 GENERATED_MAN_FILES = $(TARGET).$(SECTION) convrtrs.txt.5
 

Index: gencnval.c
===================================================================
RCS file: /cvs/core/icu-sword/source/tools/gencnval/gencnval.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- gencnval.c	10 Sep 2003 02:42:56 -0000	1.3
+++ gencnval.c	6 Apr 2004 10:10:02 -0000	1.4
@@ -29,6 +29,7 @@
 #include "cmemory.h"
 #include "cstring.h"
 #include "filestrm.h"
+#include "unicode/uclean.h"
 #include "unewdata.h"
 #include "uoptions.h"
 
@@ -156,7 +157,7 @@
 addConverter(const char *converter);
 
 static char *
-allocString(StringBlock *block, uint32_t length);
+allocString(StringBlock *block, const char *s, int32_t length);
 
 static uint16_t
 addToKnownAliases(const char *alias);
@@ -213,7 +214,7 @@
     U_MAIN_INIT_ARGS(argc, argv);
 
     /* preset then read command line options */
-    options[3].value=options[4].value=u_getDataDirectory();
+    options[DESTDIR].value=options[SOURCEDIR].value=u_getDataDirectory();
     argc=u_parseArgs(argc, argv, sizeof(options)/sizeof(options[0]), options);
 
     /* error handling, printing usage message */
@@ -243,10 +244,12 @@
     if(argc>=2) {
         path=argv[1];
     } else {
-        path=options[4].value;
+        path=options[SOURCEDIR].value;
         if(path!=NULL && *path!=0) {
-            char *end = pathBuf+uprv_strlen(pathBuf);
+            char *end;
+
             uprv_strcpy(pathBuf, path);
+            end = uprv_strchr(pathBuf, 0);
             if(*(end-1)!=U_FILE_SEP_CHAR) {
                 *(end++)=U_FILE_SEP_CHAR;
             }
@@ -274,8 +277,8 @@
     T_FileStream_close(in);
 
     /* create the output file */
-    out=udata_create(options[3].value, DATA_TYPE, U_ICUDATA_NAME "_" DATA_NAME, &dataInfo,
-                     options[2].doesOccur ? U_COPYRIGHT_STRING : NULL, &errorCode);
+    out=udata_create(options[DESTDIR].value, DATA_TYPE, U_ICUDATA_NAME "_" DATA_NAME, &dataInfo,
+                     options[COPYRIGHT].doesOccur ? U_COPYRIGHT_STRING : NULL, &errorCode);
     if(U_FAILURE(errorCode)) {
         fprintf(stderr, "gencnval: unable to open output file - error %s\n", u_errorName(errorCode));
         exit(errorCode);
@@ -307,7 +310,7 @@
     /* Add the empty tag, which is for untagged aliases */
     getTagNumber("", 0);
     getTagNumber(ALL_TAG_STR, 3);
-    allocString(&stringBlock, 1);
+    allocString(&stringBlock, "", 0);
 
     /* read the list of aliases */
     while (validParse) {
@@ -410,9 +413,7 @@
 
     /* store the converter name */
     length=(uint16_t)(limit-start);
-    converter=allocString(&stringBlock, length+1);
-    uprv_memcpy(converter, line+start, length);
-    converter[length]=0;
+    converter=allocString(&stringBlock, line+start, length);
 
     /* add the converter to the converter table */
     cnv=addConverter(converter);
@@ -448,9 +449,7 @@
             addAlias(alias, ALL_TAG_NUM, cnv, TRUE);
         }
         else {
-            alias=allocString(&stringBlock, length+1);
-            uprv_memcpy(alias, line+start, length);
-            alias[length]=0;
+            alias=allocString(&stringBlock, line+start, length);
             addAlias(alias, ALL_TAG_NUM, cnv, FALSE);
         }
         addToKnownAliases(alias);
@@ -526,9 +525,7 @@
     }
 
     /* allocate a new entry in the tag table */
-    atag = allocString(&tagBlock, tagLen + 1);
-    uprv_memcpy(atag, tag, tagLen);
-    atag[tagLen] = 0;
+    atag = allocString(&tagBlock, tag, tagLen);
 
     if (standardTagsUsed) {
         fprintf(stderr, "error(line %d): Tag \"%s\" is not declared at the beginning of the alias table.\n",
@@ -557,7 +554,6 @@
 addOfficialTaggedStandards(char *line, int32_t lineLen) {
     char *atag;
     char *tag = strchr(line, '{') + 1;
-    uint16_t tagSize;
     static const char WHITESPACE[] = " \t";
 
     if (tagCount > UCNV_NUM_RESERVED_TAGS) {
@@ -570,11 +566,8 @@
     while (tag != NULL) {
 /*        printf("Adding original tag \"%s\"\n", tag);*/
 
-        tagSize = strlen(tag) + 1;
         /* allocate a new entry in the tag table */
-
-        atag = allocString(&tagBlock, tagSize);
-        uprv_memcpy(atag, tag, tagSize);
+        atag = allocString(&tagBlock, tag, -1);
 
         /* add the tag to the tag table */
         tags[tagCount++].tag = (uint16_t)((atag - tagStore) >> 1);
@@ -990,16 +983,40 @@
 }
 
 static char *
-allocString(StringBlock *block, uint32_t length) {
-    /* The (length&1) is used to keep the addresses on a 16-bit boundary */
-    uint32_t top=block->top + length + (length&1);
+allocString(StringBlock *block, const char *s, int32_t length) {
+    uint32_t top;
     char *p;
 
+    if(length<0) {
+        length=(int32_t)uprv_strlen(s);
+    }
+
+    /*
+     * add 1 for the terminating NUL
+     * and round up (+1 &~1)
+     * to keep the addresses on a 16-bit boundary
+     */
+    top=block->top + (uint32_t)((length + 1 + 1) & ~1);
+
     if(top >= block->max) {
         fprintf(stderr, "error(line %d): out of memory\n", lineNum);
         exit(U_MEMORY_ALLOCATION_ERROR);
     }
+
+    /* get the pointer and copy the string */
     p = block->store + block->top;
+    uprv_memcpy(p, s, length);
+    p[length] = 0; /* NUL-terminate it */
+    if((length & 1) == 0) {
+        p[length + 1] = 0; /* set the padding byte */
+    }
+
+    /* check for invariant characters now that we have a NUL-terminated string for easy output */
+    if(!uprv_isInvariantString(p, length)) {
+        fprintf(stderr, "error(line %d): the name %s contains not just invariant characters\n", lineNum, p);
+        exit(U_INVALID_TABLE_FORMAT);
+    }
+
     block->top = top;
     return p;
 }
@@ -1010,7 +1027,7 @@
     int result = ucnv_compareNames(GET_ALIAS_STR(*(uint16_t*)alias1), GET_ALIAS_STR(*(uint16_t*)alias2));
     if (!result) {
         /* Sort the shortest first */
-        return uprv_strlen(GET_ALIAS_STR(*(uint16_t*)alias1)) - uprv_strlen(GET_ALIAS_STR(*(uint16_t*)alias2));
+        return (int)uprv_strlen(GET_ALIAS_STR(*(uint16_t*)alias1)) - (int)uprv_strlen(GET_ALIAS_STR(*(uint16_t*)alias2));
     }
     return result;
 }

Index: gencnval.vcproj
===================================================================
RCS file: /cvs/core/icu-sword/source/tools/gencnval/gencnval.vcproj,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- gencnval.vcproj	10 Sep 2003 02:42:56 -0000	1.1
+++ gencnval.vcproj	6 Apr 2004 10:10:03 -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="gencnval"
 	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"