[sword-cvs] icu-sword/source/tools/gentest genres32.c,NONE,1.1 gentest.h,NONE,1.1 Makefile.in,1.4,1.5 gentest.c,1.3,1.4 gentest.dsp,1.3,1.4 gentest.vcproj,1.1,1.2
sword@www.crosswire.org
sword@www.crosswire.org
Tue, 6 Apr 2004 03:10:50 -0700
Update of /cvs/core/icu-sword/source/tools/gentest
In directory www:/tmp/cvs-serv8911/source/tools/gentest
Modified Files:
Makefile.in gentest.c gentest.dsp gentest.vcproj
Added Files:
genres32.c gentest.h
Log Message:
ICU 2.8 sync
--- NEW FILE: genres32.c ---
/*
*******************************************************************************
*
* Copyright (C) 2003-2003, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* file name: genres32.c
* encoding: US-ASCII
* tab size: 8 (not used)
* indentation:4
*
* created on: 2003sep10
* created by: Markus W. Scherer
*
* Write an ICU resource bundle with a table whose
* number of key characters and number of items both exceed 64k.
* Writing it as the root table tests also that
* the new table type is recognized for the root resource by the reader code.
*/
#include <stdio.h>
#include "unicode/putil.h"
#include "cstring.h"
#include "gentest.h"
static void
incKey(char *key, char *limit) {
char c;
while(limit>key) {
c=*--limit;
if(c=='o') {
*limit='1';
break;
} else {
*limit='o';
}
}
}
U_CAPI int
genres32(const char *prog, const char *path) {
/*
* key string, gets incremented binary numbers
* letter 'o'=0 and digit '1'=1 so that data swapping can be tested
* with reordering (ASCII: '1'<'o' EBCDIC: '1'>'o')
*
* need 17 digits for >64k unique items
*/
char key[20]="ooooooooooooooooo";
char *limit;
int i;
char file[512];
FILE *out;
uprv_strcpy(file,path);
if(file[strlen(file)-1]!=U_FILE_SEP_CHAR) {
uprv_strcat(file,U_FILE_SEP_STRING);
}
uprv_strcat(file,"testtable32.txt");
out = fopen(file, "w");
puts(file);
if(out == NULL) {
fprintf(stderr, "%s: Couldn't create resource test file %s\n",
prog, file);
return 1;
}
/* find the limit of the key string */
for(limit=key; *limit!=0; ++limit) {
}
/* output the beginning of the bundle */
fputs(
"testtable32 {", out
);
/* output the table entries */
for(i=0; i<66000; ++i) {
if(i%10==0) {
/*
* every 10th entry contains a string with
* the entry index as its code point
*/
fprintf(out, "%s{\"\\U%08x\"}\n", key, i);
} else {
/* other entries contain their index as an integer */
fprintf(out, "%s:int{%d}\n", key, i);
}
incKey(key, limit);
}
/* output the end of the bundle */
fputs(
"}", out
);
fclose(out);
return 0;
}
--- NEW FILE: gentest.h ---
/*
*******************************************************************************
*
* Copyright (C) 2003-2003, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
*/
#include "unicode/utypes.h"
U_CAPI int genres32(const char *prog, const char *path);
Index: Makefile.in
===================================================================
RCS file: /cvs/core/icu-sword/source/tools/gentest/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:59 -0000 1.4
+++ Makefile.in 6 Apr 2004 10:10:16 -0000 1.5
@@ -28,7 +28,7 @@
CPPFLAGS += -I$(top_builddir)/common -I$(top_srcdir)/common -I$(srcdir)/../toolutil
LIBS = $(LIBICUTOOLUTIL) $(LIBICUUC) $(DEFAULT_LIBS) $(LIB_M)
-OBJECTS = gentest.o
+OBJECTS = gentest.o genres32.o
DEPS = $(OBJECTS:.o=.d)
Index: gentest.c
===================================================================
RCS file: /cvs/core/icu-sword/source/tools/gentest/gentest.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- gentest.c 10 Sep 2003 02:42:59 -0000 1.3
+++ gentest.c 6 Apr 2004 10:10:17 -0000 1.4
@@ -1,7 +1,7 @@
/*
*******************************************************************************
*
-* Copyright (C) 1999-2001, International Business Machines
+* Copyright (C) 1999-2003, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
@@ -20,11 +20,13 @@
#include <stdlib.h>
#include "unicode/utypes.h"
#include "unicode/putil.h"
+#include "unicode/uclean.h"
#include "unicode/udata.h"
#include "unewdata.h"
#include "cmemory.h"
#include "cstring.h"
#include "uoptions.h"
+#include "gentest.h"
#define DATA_PKG "testdata"
#define DATA_NAME "test"
@@ -45,16 +47,19 @@
{1, 0, 0, 0} /* dataVersion */
};
-static void createData(const char*);
+static void createData(const char*, UErrorCode *);
static UOption options[]={
- UOPTION_HELP_H,
- UOPTION_HELP_QUESTION_MARK,
- UOPTION_DESTDIR
+ /*0*/ UOPTION_HELP_H,
+ /*1*/ UOPTION_HELP_QUESTION_MARK,
+ /*2*/ UOPTION_DESTDIR,
+ /*3*/ UOPTION_DEF("genres", 'r', UOPT_NO_ARG)
};
extern int
main(int argc, char* argv[]) {
+ UErrorCode errorCode = U_ZERO_ERROR;
+
/* preset then read command line options */
options[2].value=u_getDataDirectory();
argc=u_parseArgs(argc, argv, sizeof(options)/sizeof(options[0]), options);
@@ -68,24 +73,28 @@
if(argc<0 || options[0].doesOccur || options[1].doesOccur) {
fprintf(stderr,
"usage: %s [-options]\n"
- "\tcreate the test file " DATA_PKG "_" DATA_NAME "." DATA_TYPE "\n"
+ "\tcreate the test file " DATA_PKG "_" DATA_NAME "." DATA_TYPE " unless the -r option is given.\n"
"\toptions:\n"
"\t\t-h or -? or --help this usage text\n"
- "\t\t-d or --destdir destination directory, followed by the path\n",
+ "\t\t-d or --destdir destination directory, followed by the path\n"
+ "\t\t-r or --genres generate resource file testtable32.txt instead of UData test \n",
argv[0]);
return argc<0 ? U_ILLEGAL_ARGUMENT_ERROR : U_ZERO_ERROR;
}
- /* printf("Generating the test memory mapped file\n"); */
- createData(options[2].value);
- return 0;
+ if ( options[3].doesOccur ) {
+ return genres32( argv[0], options[2].value );
+ } else {
+ /* printf("Generating the test memory mapped file\n"); */
+ createData(options[2].value, &errorCode);
+ }
+ return U_FAILURE(errorCode);
}
/* Create data file ----------------------------------------------------- */
static void
-createData(const char* outputDirectory) {
+createData(const char* outputDirectory, UErrorCode *errorCode) {
UNewDataMemory *pData;
- UErrorCode errorCode=U_ZERO_ERROR;
char stringValue[]={'Y', 'E', 'A', 'R', '\0'};
uint16_t intValue=2000;
@@ -93,10 +102,10 @@
uint32_t size;
pData=udata_create(outputDirectory, DATA_TYPE, DATA_PKG "_" DATA_NAME, &dataInfo,
- U_COPYRIGHT_STRING, &errorCode);
- if(U_FAILURE(errorCode)) {
- fprintf(stderr, "gentest: unable to create data memory, error %d\n", errorCode);
- exit(errorCode);
+ U_COPYRIGHT_STRING, errorCode);
+ if(U_FAILURE(*errorCode)) {
+ fprintf(stderr, "gentest: unable to create data memory, error %d\n", *errorCode);
+ exit(*errorCode);
}
/* write the data to the file */
@@ -105,10 +114,10 @@
udata_writeString(pData, stringValue, sizeof(stringValue));
/* finish up */
- dataLength=udata_finish(pData, &errorCode);
- if(U_FAILURE(errorCode)) {
- fprintf(stderr, "gentest: error %d writing the output file\n", errorCode);
- exit(errorCode);
+ dataLength=udata_finish(pData, errorCode);
+ if(U_FAILURE(*errorCode)) {
+ fprintf(stderr, "gentest: error %d writing the output file\n", *errorCode);
+ exit(*errorCode);
}
size=sizeof(stringValue) + sizeof(intValue);
Index: gentest.dsp
===================================================================
RCS file: /cvs/core/icu-sword/source/tools/gentest/gentest.dsp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- gentest.dsp 10 Sep 2003 02:42:59 -0000 1.3
+++ gentest.dsp 6 Apr 2004 10:10:17 -0000 1.4
@@ -185,6 +185,10 @@
SOURCE=.\gentest.c
# End Source File
+# Begin Source File
+
+SOURCE=.\genres32.c
+# End Source File
# End Group
# Begin Group "Header Files"
Index: gentest.vcproj
===================================================================
RCS file: /cvs/core/icu-sword/source/tools/gentest/gentest.vcproj,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- gentest.vcproj 10 Sep 2003 02:42:59 -0000 1.1
+++ gentest.vcproj 6 Apr 2004 10:10:17 -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="gentest"
SccProjectName=""
SccLocalPath="">
@@ -37,9 +37,9 @@
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"
- CommandLine="copy $(TargetPath) ..\..\..\bin
+ CommandLine="copy "$(TargetPath)" ..\..\..\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 "$(TargetPath)" ..\..\..\bin
"
- Outputs="..\..\..\bin\$(InputName).exe"/>
+ Outputs="..\..\..\bin\$(TargetFileName)"/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="/MACHINE:I386"
@@ -127,20 +133,34 @@
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
+ <References>
+ </References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
<File
+ RelativePath=".\genres32.c">
+ </File>
+ <File
RelativePath=".\gentest.c">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl">
+ <File
+ RelativePath=".\gentest.h">
+ </File>
</Filter>
<Filter
Name="Resource Files"