intl/icu/source/tools/gentest/genres32.c

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

michael@0 1 /*
michael@0 2 *******************************************************************************
michael@0 3 *
michael@0 4 * Copyright (C) 2003-2006, International Business Machines
michael@0 5 * Corporation and others. All Rights Reserved.
michael@0 6 *
michael@0 7 *******************************************************************************
michael@0 8 * file name: genres32.c
michael@0 9 * encoding: US-ASCII
michael@0 10 * tab size: 8 (not used)
michael@0 11 * indentation:4
michael@0 12 *
michael@0 13 * created on: 2003sep10
michael@0 14 * created by: Markus W. Scherer
michael@0 15 *
michael@0 16 * Write an ICU resource bundle with a table whose
michael@0 17 * number of key characters and number of items both exceed 64k.
michael@0 18 * Writing it as the root table tests also that
michael@0 19 * the new table type is recognized for the root resource by the reader code.
michael@0 20 */
michael@0 21 #include <stdio.h>
michael@0 22 #include "unicode/putil.h"
michael@0 23 #include "cstring.h"
michael@0 24 #include "gentest.h"
michael@0 25
michael@0 26 static void
michael@0 27 incKey(char *key, char *limit) {
michael@0 28 char c;
michael@0 29
michael@0 30 while(limit>key) {
michael@0 31 c=*--limit;
michael@0 32 if(c=='o') {
michael@0 33 *limit='1';
michael@0 34 break;
michael@0 35 } else {
michael@0 36 *limit='o';
michael@0 37 }
michael@0 38 }
michael@0 39 }
michael@0 40
michael@0 41 U_CFUNC int
michael@0 42 genres32(const char *prog, const char *path) {
michael@0 43 /*
michael@0 44 * key string, gets incremented binary numbers
michael@0 45 * letter 'o'=0 and digit '1'=1 so that data swapping can be tested
michael@0 46 * with reordering (ASCII: '1'<'o' EBCDIC: '1'>'o')
michael@0 47 *
michael@0 48 * need 17 digits for >64k unique items
michael@0 49 */
michael@0 50 char key[20]="ooooooooooooooooo";
michael@0 51 char *limit;
michael@0 52 int i;
michael@0 53 char file[512];
michael@0 54 FILE *out;
michael@0 55
michael@0 56 uprv_strcpy(file,path);
michael@0 57 if(file[strlen(file)-1]!=U_FILE_SEP_CHAR) {
michael@0 58 uprv_strcat(file,U_FILE_SEP_STRING);
michael@0 59 }
michael@0 60 uprv_strcat(file,"testtable32.txt");
michael@0 61 out = fopen(file, "w");
michael@0 62 /*puts(file);*/
michael@0 63 puts("Generating testtable32.txt");
michael@0 64 if(out == NULL) {
michael@0 65 fprintf(stderr, "%s: Couldn't create resource test file %s\n",
michael@0 66 prog, file);
michael@0 67 return 1;
michael@0 68 }
michael@0 69
michael@0 70 /* find the limit of the key string */
michael@0 71 for(limit=key; *limit!=0; ++limit) {
michael@0 72 }
michael@0 73
michael@0 74 /* output the beginning of the bundle */
michael@0 75 fputs(
michael@0 76 "testtable32 {", out
michael@0 77 );
michael@0 78
michael@0 79 /* output the table entries */
michael@0 80 for(i=0; i<66000; ++i) {
michael@0 81 if(i%10==0) {
michael@0 82 /*
michael@0 83 * every 10th entry contains a string with
michael@0 84 * the entry index as its code point
michael@0 85 */
michael@0 86 fprintf(out, "%s{\"\\U%08x\"}\n", key, i);
michael@0 87 } else {
michael@0 88 /* other entries contain their index as an integer */
michael@0 89 fprintf(out, "%s:int{%d}\n", key, i);
michael@0 90 }
michael@0 91
michael@0 92 incKey(key, limit);
michael@0 93 }
michael@0 94
michael@0 95 /* output the end of the bundle */
michael@0 96 fputs(
michael@0 97 "}", out
michael@0 98 );
michael@0 99
michael@0 100 fclose(out);
michael@0 101 return 0;
michael@0 102 }

mercurial