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