w32tex
About: TeX Live provides a comprehensive TeX system including all the major TeX-related programs, macro packages, and fonts that are free software. Windows sources.
  Fossies Dox: w32tex-src.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

makeutype.c
Go to the documentation of this file.
1 /* Copyright (C) 2000-2012 by George Williams */
2 /*
3  * Redistribution and use in source and binary forms, with or without
4  * modification, are permitted provided that the following conditions are met:
5 
6  * Redistributions of source code must retain the above copyright notice, this
7  * list of conditions and the following disclaimer.
8 
9  * Redistributions in binary form must reproduce the above copyright notice,
10  * this list of conditions and the following disclaimer in the documentation
11  * and/or other materials provided with the distribution.
12 
13  * The name of the author may not be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15 
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19  * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 /*
29  * This program generates 4 different files based on the latest UnicodeData.txt
30  * obtained from http://unicode.org which is then used to build FontForge
31  *
32  * To generate the latest files, you will first need to go and get these 4 files
33  * and put them in the Unicode subdirectory:
34  * http://unicode.org/Public/UNIDATA/LineBreak.txt
35  * http://unicode.org/Public/UNIDATA/NamesList.txt
36  * http://unicode.org/Public/UNIDATA/PropList.txt
37  * http://unicode.org/Public/UNIDATA/UnicodeData.txt
38  *
39  * Next, you will need to build ./makeutype before you can use it:
40  * Run "make makeutype"
41  * or
42  * Run "gcc -s -I../inc -o makeutype makeutype.c"
43  *
44  * Then run the executable binary "/makeutype".
45  * This will create 4 files in the same directory:
46  * ArabicForms.c, unialt.c, utype.c, utype.h
47  * (please move utype.h into Fontforge's "../inc" subdirectory)
48  *
49  * When done building the updated files, you can clean-up by removing
50  * LineBreak.txt, NamesList.txt, PropList.txt,UnicodeData.txt, and the
51  * binary executable file makeutype as they are no longer needed now.
52  */
53 
54 
55 /* Build a ctype array out of the UnicodeData.txt and PropList.txt files */
56 #include <stdio.h>
57 #include <stdlib.h>
58 #include <string.h>
59 #include <unibasics.h>
60 #define true 1
61 #define false 0
62 
63 /*#define MAXC 0x600 /* Last upper/lower case dicodomy is Armenian 0x580, er, nope. 1fff (greek and latin extended) then full-width 0xff00 */
64 #define MAXC 65536
65 #define MAXA 18
66 
67 /* These values get stored within flags[unicodechar={0..MAXC}] */
68 #define _LOWER 1
69 #define _UPPER 2
70 #define _TITLE 4
71 #define _DIGIT 8
72 #define _SPACE 0x10
73 #define _PUNCT 0x20
74 #define _HEX 0x40
75 #define _ZEROWIDTH 0x80
76 
77 #define _LEFT_2_RIGHT 0x100
78 #define _RIGHT_2_LEFT 0x200
79 #define _ENUMERIC 0x400
80 #define _ANUMERIC 0x800
81 #define _ENS 0x1000
82 #define _CS 0x2000
83 #define _ENT 0x4000
84 #define _COMBINING 0x8000
85 
86 #define _BREAKBEFOREOK 0x10000
87 #define _BREAKAFTEROK 0x20000
88 #define _NONSTART 0x40000 /* small kana, close punct, can't start a line */
89 #define _NONEND 0x80000 /* open punct, can't end a line */
90 /*#define _MUSTBREAK 0x100000 /* newlines, paragraphs, etc. */
91 #define _URLBREAKAFTER 0x100000 /* break after slash not followed by digits (ie. in URLs not fractions or dates) */
92 
93 #define _ALPHABETIC 0x200000
94 #define _IDEOGRAPHIC 0x400000
95 
96 #define _INITIAL 0x800000
97 #define _MEDIAL 0x1000000
98 #define _FINAL 0x2000000
99 #define _ISOLATED 0x4000000
100 
101 #define _NOBREAK 0x8000000
102 #define _DecompositionNormative 0x10000000
103 
104 #define _CombiningClass 0xff
105 #define _Above 0x100
106 #define _Below 0x200
107 #define _Overstrike 0x400
108 #define _Left 0x800
109 #define _Right 0x1000
110 #define _Joins2 0x2000
111 #define _CenterLeft 0x4000
112 #define _CenterRight 0x8000
113 #define _CenteredOutside 0x10000
114 #define _Outside 0x20000
115 #define _RightEdge 0x40000
116 #define _LeftEdge 0x80000
117 #define _Touching 0x100000
118 
119 #include "combiners.h"
120 
121 char *names[MAXC];
122 unsigned short mytolower[MAXC];
123 unsigned short mytoupper[MAXC];
124 unsigned short mytotitle[MAXC];
125 unsigned char mynumericvalue[MAXC];
126 unsigned short mymirror[MAXC];
127 unsigned long flags[MAXC]; /* 32 binary flags for each unicode.org character */
128 unsigned long flags2[MAXC];
130 unsigned long assignedcodepoints[0x120000/32]; /* 32 characters represented per each long value */
131 
132 const char GeneratedFileMessage[] = "\n/* This file was generated using the program 'makeutype' */\n\n";
133 const char CantReadFile[] = "Can't find or read file %s\n"; /* exit(1) */
134 const char CantSaveFile[] = "Can't open or write to output file %s\n"; /* exit(2) */
135 const char NoMoreMemory[] = "Can't access more memory.\n"; /* exit(3) */
136 const char LineLengthBg[] = "Error with %s. Found line too long: %s\n"; /* exit(4) */
137 
138 static void FreeNamesMemorySpace() {
139  long index;
140  for ( index=0; index<MAXC ; ++index ) {
141  if ( names[index]!=NULL ) free( names[index] );
142  }
143 }
144 
145 static void FigureAlternates(long index, char *apt, int normative) {
146  int alt, i;
147  char *end;
148  int isisolated=0, iscircled=0;
149 
150  for ( i=0; ; ++i ) {
151  while ( *apt=='<' ) {
152  isisolated = strncmp(apt,"<isolated>",strlen("<isolated>"))==0;
153  iscircled = strncmp(apt,"<circle>",strlen("<circle>"))==0;
154  while ( *apt && *apt!='>' ) ++apt;
155  if ( *apt=='>' ) ++apt;
156  while ( *apt==' ' ) ++apt;
157  }
158  alt = strtol(apt,&end,16);
159  if ( end==apt )
160  break;
161  apt = end;
162  if ( i<MAXA ) {
163  alts[index][i] = alt;
164  alts[index][i+1] = 0;
165  }
166  }
167  if ( iscircled && i<MAXA ) {
168  alts[index][i] = 0x20dd;
169  alts[index][++i] = 0;
170  }
171  if ( i>MAXA )
172  fprintf( stderr, "%d is too many alternates for U+%04X\n", i, index );
173  if ( i>0 && normative)
175 
176  /* arabic isolated forms are alternates for the standard forms */
177  if ( isisolated && alts[index][0]>=0x600 && alts[index][0]<0x6ff && alts[index][1]==0 &&
178  alts[alts[index][0]][0]==0 )
179  alts[alts[index][0]][0] = index;
180 }
181 
182 static void processAssignment(long index,char *pt) {
183  static long first=-1;
184  long i;
185 
186  if ( index>0x11ffff )
187 return;
188  ++pt; /* move past semicolon */
189  if ( *pt!='<' ) {
190  assignedcodepoints[index/32] |= (1<<(index%32)); /* This Unicode char is visible */
191  } else if ( strstr(pt,", First")!=NULL ) { /* start of an extended charset */
192  first = index;
193  } else if ( strstr(pt,", Last")!=NULL ) { /* end of an extended charset */
194  if ( first==-1 || first > index )
195  fprintf( stderr,"Something went wrong, first isn't defined at last. %x\n", index );
196  else if ( first>=0xd800 && first<=0xdfff )
197  /* surrogate pairs. Not assigned really */;
198  else {
199  /* mark all characters visible in the range of {First...Last} */
200  for ( i=first; i<=index; ++i )
201  assignedcodepoints[i/32] |= (1<<(i%32));
202  }
203  first = -1;
204  }
205 }
206 
207 static void readin(void) {
208  char buffer[512+1], buf2[300+1], oldname[301], *pt, *end, *pt1;
209  long index, lc, uc, tc, flg, val, indexend, wasfirst;
210  int cc;
211  FILE *fp;
212  int i,j;
213 
214  buffer[512]='\0'; buf2[0] = buf2[300]='\0'; oldname[0]='\0';
215  if ((fp = fopen("UnicodeData.txt","r"))==NULL ) {
216  fprintf( stderr, CantReadFile,"UnicodeData.txt" );
217  exit(1);
218  }
219  while ( fgets(buffer,sizeof(buffer)-1,fp)!=NULL ) {
220  if (strlen(buffer)>=299) { /* previous version was linelength of 300 chars, jul2012 */
221  fprintf( stderr, LineLengthBg,"UnicodeData.txt",buffer );
222  fprintf( stderr, "\n%s\n",buffer );
223 
224  fclose(fp);
226  exit(4);
227  }
228  if ( *buffer=='#' )
229  continue;
230  flg = 0;
231  /* Unicode character value */
232  index = strtol(buffer,&end,16);
234  if ( index>=MAXC ) /* For now can only deal with BMP !!!! */
235  continue;
236  pt = end;
237  if ( *pt==';' ) {
238  ++pt;
239  /* buf2 = character name */
240  for ( pt1=pt; *pt1!=';' && *pt1!='\0'; ++pt1 );
241  strncpy(buf2,pt,pt1-pt); buf2[pt1-pt] = '\0'; pt = pt1;
242  if ( *pt==';' ) ++pt;
243  /* general category */
244  for ( pt1=pt; *pt1!=';' && *pt1!='\0'; ++pt1 );
245  if ( strncmp(pt,"Lu",pt1-pt)==0 )
246  flg |= _UPPER|_ALPHABETIC;
247  else if ( strncmp(pt,"Ll",pt1-pt)==0 )
248  flg |= _LOWER|_ALPHABETIC;
249  else if ( strncmp(pt,"Lt",pt1-pt)==0 )
250  flg |= _TITLE|_ALPHABETIC;
251  else if ( strncmp(pt,"Lo",pt1-pt)==0 )
252  flg |= _ALPHABETIC;
253  else if ( strncmp(pt,"Nd",pt1-pt)==0 )
254  flg |= _DIGIT;
255  pt = pt1;
256  if ( *pt==';' ) ++pt;
257  /* Unicode combining classes, I do my own version later */
258  cc = strtol(pt,&end,16);
259  pt = end;
260  if ( *pt==';' ) ++pt;
261  /* Bidirectional Category */
262  for ( pt1=pt; *pt1!=';' && *pt1!='\0'; ++pt1 );
263  if ( strncmp(pt,"L",pt1-pt)==0 || strncmp(pt,"LRE",pt1-pt)==0 || strncmp(pt,"LRO",pt1-pt)==0 )
264  flg |= _LEFT_2_RIGHT;
265  if ( strncmp(pt,"R",pt1-pt)==0 || strncmp(pt,"AL",pt1-pt)==0 || strncmp(pt,"RLE",pt1-pt)==0 || strncmp(pt,"RLO",pt1-pt)==0 )
266  flg |= _RIGHT_2_LEFT;
267  else if ( strncmp(pt,"EN",pt1-pt)==0 )
268  flg |= _ENUMERIC;
269  else if ( strncmp(pt,"ES",pt1-pt)==0 )
270  flg |= _ENS;
271  else if ( strncmp(pt,"ET",pt1-pt)==0 )
272  flg |= _ENT;
273  else if ( strncmp(pt,"AN",pt1-pt)==0 )
274  flg |= _ANUMERIC;
275  else if ( strncmp(pt,"CS",pt1-pt)==0 )
276  flg |= _CS;
277  pt = pt1;
278  if ( *pt==';' ) ++pt;
279  /* character decomposition */
280  if ( strncmp(pt,"<initial>",strlen("<initial>"))==0 )
281  flg |= _INITIAL;
282  else if ( strncmp(pt,"<final>",strlen("<final>"))==0 )
283  flg |= _FINAL;
284  else if ( strncmp(pt,"<medial>",strlen("<medial>"))==0 )
285  flg |= _MEDIAL;
286  else if ( strncmp(pt,"<isolated>",strlen("<isolated>"))==0 )
287  flg |= _ISOLATED;
288  FigureAlternates(index,pt, true);
289  while ( *pt!=';' && *pt!='\0' ) ++pt;
290  if ( *pt==';' ) ++pt;
291  /* Don't care about decimal digit value */
292  while ( *pt!=';' && *pt!='\0' ) ++pt;
293  if ( *pt==';' ) ++pt;
294  /* Don't care about digit value */
295  while ( *pt!=';' && *pt!='\0' ) ++pt;
296  if ( *pt==';' ) ++pt;
297  /* numeric value */
298  val = strtol(pt,&end,10);
299  if ( pt==end ) val = -1;
300  pt = end;
301  if ( *pt==';' ) ++pt;
302  /* Don't care about mirrored value */
303  while ( *pt!=';' && *pt!='\0' ) ++pt;
304  if ( *pt==';' ) ++pt;
305  /* Only care about old name (unicode 1.0) for control characters */
306  for ( pt1=pt; *pt1!=';' && *pt1!='\0'; ++pt1 );
307  strncpy(oldname,pt,pt1-pt); oldname[pt1-pt] = '\0';
308  if ( pt1-pt>100 ) oldname[100] = '\0'; pt = pt1;
309  if ( *pt==';' ) ++pt;
310  /* Don't care about 10646 comment field */
311  while ( *pt!=';' && *pt!='\0' ) ++pt;
312  if ( *pt==';' ) ++pt;
313  /* upper-case value */
314  uc = strtol(pt,&end,16);
315  if ( end==pt )
316  uc = index;
317  pt = end;
318  if ( *pt==';' ) ++pt;
319  /* lower-case value */
320  lc = strtol(pt,&end,16);
321  if ( end==pt )
322  lc = index;
323  pt = end;
324  if ( *pt==';' ) ++pt;
325  /* title-case value */
326  tc = strtol(pt,&end,16);
327  if ( end==pt )
328  tc = index;
329  pt = end;
330  if ( *pt==';' ) ++pt;
331  if ( index>=MAXC )
332  break;
333  mytolower[index]= lc;
334  mytoupper[index]= uc;
335  mytotitle[index]= tc;
337  flags[index] |= flg;
338  flags2[index] = cc&0xff;
339  if ( strstr(buf2," First>")!=NULL )
340  wasfirst = index;
341  else if ( strstr(buf2," Last>")!=NULL ) {
342  for ( ; wasfirst<index; ++wasfirst ) {
343  mytolower[wasfirst]= wasfirst;
344  mytoupper[wasfirst]= wasfirst;
345  mytotitle[wasfirst]= wasfirst;
346  mynumericvalue[wasfirst]= -1;
347  flags[wasfirst] = flg;
348  flags2[wasfirst] = cc&0xff;
349  }
350  } else {
351  if ( strcmp(buf2,"<control>")==0 ) {
352  strcat(buf2, " ");
353  strcat(buf2, oldname);
354  }
355  names[index]= strdup(buf2);
356  }
357  }
358  }
359  fclose(fp);
360 
361  if ((fp = fopen("LineBreak.txt","r"))==NULL ) {
362  fprintf( stderr, CantReadFile, "LineBreak.txt" );
364  exit(1);
365  }
366  while ( fgets(buffer,sizeof(buffer)-1,fp)!=NULL ) {
367  if (strlen(buffer)>=299) { /* previous version was linelength of 300 chars, jul2012 */
368  fprintf( stderr, LineLengthBg,"LineBreak.txt",buffer );
369  fclose(fp);
371  exit(4);
372  }
373  if ( *buffer=='#' )
374  continue;
375  flg = 0;
376  /* Unicode character value */
377  indexend = index = strtol(buffer,&end,16);
378  if ( index>0xffff ) /* Only BMP now !!!!!! */
379  continue;
380  pt = end;
381  if ( *pt=='.' && pt[1]=='.' ) {
382  indexend = strtol(pt+2,&end,16);
383  if ( indexend>0xffff ) indexend = 0xffff; /* Only BMP now !!!!! */
384  pt = end;
385  }
386  if ( *pt==';' ) {
387  ++pt;
388  for ( pt1=pt; *pt1!=';' && *pt1!=' ' && *pt1!='\0'; ++pt1 );
389  if ( strncmp(pt,"BK",pt1-pt)==0 || strncmp(pt,"CR",pt1-pt)==0 || strncmp(pt,"LF",pt1-pt)==0 )
390  /*flg |= _MUSTBREAK*/;
391  else if ( strncmp(pt,"NS",pt1-pt)==0 || strncmp(pt,"CL",pt1-pt)==0 )
392  flg |= _NONSTART;
393  else if ( strncmp(pt,"OP",pt1-pt)==0 || strncmp(pt,"CM",pt1-pt)==0 )
394  flg |= _NONEND;
395  else if ( strncmp(pt,"GL",pt1-pt)==0 )
396  flg |= _NONEND|_NONSTART;
397  else if ( strncmp(pt,"SP",pt1-pt)==0 || strncmp(pt,"HY",pt1-pt)==0 ||
398  strncmp(pt,"BA",pt1-pt)==0 ||
399  strncmp(pt,"ZW",pt1-pt)==0 )
400  flg |= _BREAKAFTEROK;
401  else if ( strncmp(pt,"BB",pt1-pt)==0 )
402  flg |= _BREAKBEFOREOK;
403  else if ( strncmp(pt,"B2",pt1-pt)==0 )
405  else if ( strncmp(pt,"ID",pt1-pt)==0 )
407  else if ( strncmp(pt,"SY",pt1-pt)==0 )
408  flg |= _URLBREAKAFTER;
409  pt = pt1;
410  for ( ; index<=indexend; ++index )
411  flags[index] |= flg;
412 #if 0
413  if ( strstr(pt," First>")!=NULL )
414  wasfirst = index;
415  else if ( strstr(pt," Last>")!=NULL ) {
416  for ( ; wasfirst<index; ++wasfirst ) {
417  flags[wasfirst] = flg;
418  }
419  }
420 #endif
421  }
422  }
423  fclose(fp);
424 
425  if ((fp = fopen("PropList.txt","r"))==NULL ) {
426  fprintf( stderr, CantReadFile, "PropList.txt" );
428  exit(1);
429  }
430  while ( fgets(buffer,sizeof(buffer)-1,fp)!=NULL ) {
431  flg = 0;
432  if (strlen(buffer)>=299) { /* previous version was linelength of 300 chars, jul2012 */
433  fprintf( stderr, LineLengthBg,"PropList.txt",buffer );
434  fclose(fp);
436  exit(4);
437  }
438  if ( true || strncmp(buffer,"Property dump for:", strlen("Property dump for:"))==0 ) {
439  if ( strstr(buffer, "(Zero-width)")!=NULL || strstr(buffer, "ZERO WIDTH")!=NULL )
440  flg = _ZEROWIDTH;
441  else if ( strstr(buffer, "(White space)")!=NULL || strstr(buffer, "White_Space")!=NULL )
442  flg = _SPACE;
443  else if ( strstr(buffer, "(Punctuation)")!=NULL || strstr(buffer, "Punctuation")!=NULL )
444  flg = _PUNCT;
445  else if ( strstr(buffer, "(Alphabetic)")!=NULL || strstr(buffer, "Alphabetic")!=NULL )
446  flg = _ALPHABETIC;
447  else if ( strstr(buffer, "(Ideographic)")!=NULL || strstr(buffer, "Ideographic")!=NULL )
448  flg = _IDEOGRAPHIC;
449  else if ( strstr(buffer, "(Hex Digit)")!=NULL || strstr(buffer, "Hex_Digit")!=NULL )
450  flg = _HEX;
451  else if ( strstr(buffer, "(Combining)")!=NULL || strstr(buffer, "COMBINING")!=NULL )
452  flg = _COMBINING;
453  else if ( strstr(buffer, "(Non-break)")!=NULL )
454  flg = _NOBREAK;
455  if ( flg!=0 ) {
456  if (( buffer[0]>='0' && buffer[0]<='9') || (buffer[0]>='A' && buffer[0]<='F')) {
457  index = wasfirst = strtol(buffer,NULL,16);
458  if ( buffer[4]=='.' && buffer[5]=='.' )
459  index = strtol(buffer+6,NULL,16);
460  for ( ; wasfirst<=index && wasfirst<=0xffff; ++wasfirst ) /* BMP !!!!! */
461  flags[wasfirst] |= flg;
462  }
463  }
464  }
465  }
466  fclose(fp);
467  /* There used to be a zero width property, but no longer */
468  flags[0x200B] |= _ZEROWIDTH;
469  flags[0x200C] |= _ZEROWIDTH;
470  flags[0x200D] |= _ZEROWIDTH;
471  flags[0x2060] |= _ZEROWIDTH;
472  flags[0xFEFF] |= _ZEROWIDTH;
473  /* There used to be a No Break property, but no longer */
474  flags[0x00A0] |= _NOBREAK;
475  flags[0x2011] |= _NOBREAK;
476  flags[0x202F] |= _NOBREAK;
477  flags[0xFEFF] |= _NOBREAK;
478 
479  if ((fp = fopen("NamesList.txt","r"))==NULL ) {
480  fprintf( stderr, CantReadFile, "NamesList.txt" );
482  exit(1);
483  }
484  while ( fgets(buffer,sizeof(buffer)-1,fp)!=NULL ) {
485  flg = 0;
486  if (strlen(buffer)>=511) {
487  fprintf( stderr, LineLengthBg,"NamesList.txt",buffer );
488  fclose(fp);
490  exit(4);
491  }
492  if ( (index = strtol(buffer,NULL,16))!=0 ) {
493  if ( strstr(buffer, "COMBINING")!=NULL )
494  flg = _COMBINING;
495  else if ( strstr(buffer, "N0-BREAK")!=NULL )
496  flg = _NOBREAK;
497  else if ( strstr(buffer, "ZERO WIDTH")!=NULL )
498  flg = _ZEROWIDTH;
499 
500  if ( index<0xffff ) /* !!!!! BMP */
501  flags[wasfirst] |= flg;
502  }
503  }
504  fclose(fp);
505 
506  for ( i=0; combiners[i].low!=0; ++i ) {
507  for ( j=combiners[i].low; j<=combiners[i].high; ++j )
508  flags2[j] |= combiners[i].pos[j-combiners[i].low];
509  }
510 }
511 
512 static void readcorpfile(char *prefix, char *corp) {
513  char buffer[300+1], buf2[300+1], *pt, *end, *pt1;
514  long index;
515  FILE *fp;
516 
517  buffer[300]='\0'; buf2[0] = buf2[300]='\0';
518  if ((fp = fopen(corp,"r"))==NULL ) {
519  fprintf( stderr, CantReadFile, corp ); /* Not essential */
520 return;
521  }
522  while ( fgets(buffer,sizeof(buffer)-1,fp)!=NULL ) {
523  if (strlen(buffer)>=299) {
524  fprintf( stderr, LineLengthBg,corp,buffer );
525  fclose(fp);
527  exit(4);
528  }
529  if ( *buffer=='#' )
530  continue;
531  /* code */
532  index = strtol(buffer,&end,16);
533  pt = end;
534  if ( *pt==';' ) {
535  ++pt;
536  while ( *pt!=';' && *pt!='\0' ) ++pt;
537  if ( *pt==';' ) ++pt;
538  /* character name */
539  for ( pt1=pt; *pt1!=';' && *pt1!='\0' && *pt1!='\n' && *pt1!='\r'; ++pt1 );
540  strncpy(buf2,pt,pt1-pt); buf2[pt1-pt] = '\0'; pt = pt1;
541  if ( *pt==';' ) ++pt;
542  /* character decomposition */
543  FigureAlternates(index,pt, false);
544  if ( index>=MAXC )
545  break;
546  if ((names[index]= malloc(strlen(buf2)+strlen(prefix)+4)) == NULL) {
547  fprintf( stderr, NoMoreMemory );
548  fclose(fp);
550  exit(3);
551  }
552  strcpy(names[index],prefix); strcat(names[index],buf2);
553  }
554  }
555  fclose(fp);
556 }
557 
558 static int find(char *base, char *suffix) {
559  char name[300+1];
560  int i;
561 
562  name[300]='\0';
563  strcpy(name,base);
564  strcat(name,suffix);
565 
566  for ( i=0; i<MAXC; ++i )
567  if ( names[i]!=NULL && strcmp(names[i],name)==0 )
568 return( i );
569 
570 return( -1 );
571 }
572 
573 static void dumparabicdata(FILE *header) {
574  FILE *data;
575  struct arabicforms {
576  unsigned short initial, medial, final, isolated;
577  unsigned int isletter: 1;
578  unsigned int joindual: 1;
579  unsigned int required_lig_with_alef: 1;
580  } forms[256];
581  int i, j, index;
582 
583  memset(forms,'\0',sizeof(forms));
584  for ( i=0x600; i<0x700; ++i ) {
585  j = i-0x600;
586  if ( names[i]==NULL )
587  /* No op (not defined) */;
588  else if ( strncmp(names[i],"ARABIC LETTER ",strlen("ARABIC LETTER "))!=0 )
589  /* No op (not a letter, no fancy forms) */
590  forms[j].initial = forms[j].medial = forms[j].final = forms[j].isolated = i;
591  else {
592  forms[j].isletter = 1;
593  forms[j].initial = forms[j].medial = forms[j].final = forms[j].isolated = i;
594  if ( (index = find(names[i]," ISOLATED FORM"))!= -1 )
595  forms[j].isolated = index;
596  if ( (index = find(names[i]," FINAL FORM"))!= -1 )
597  forms[j].final = index;
598  if ( (index = find(names[i]," INITIAL FORM"))!= -1 )
599  forms[j].initial = index;
600  if ( (index = find(names[i]," MEDIAL FORM"))!= -1 )
601  forms[j].medial = index;
602  if ( forms[j].initial!=i && forms[j].medial!=i )
603  forms[j].joindual = 1;
604  }
605  }
606  forms[0x44/* 0x644 == LAM */].required_lig_with_alef = 1;
607 
608  fprintf(header,"\nextern struct arabicforms {\n" );
609  fprintf(header," unsigned short initial, medial, final, isolated;\n" );
610  fprintf(header," unsigned int isletter: 1;\n" );
611  fprintf(header," unsigned int joindual: 1;\n" );
612  fprintf(header," unsigned int required_lig_with_alef: 1;\n" );
613  fprintf(header,"} ArabicForms[256];\t/* for chars 0x600-0x6ff, subtract 0x600 to use array */\n" );
614 
615  data = fopen( "ArabicForms.c","w");
616  if ( data==NULL || data==NULL ) {
617  fprintf( stderr, CantSaveFile, "ArabicForms.c" );
619  exit(2);
620  }
621 
622  fprintf( data, "#include <utype.h>\n" );
623 
625 
626  fprintf( data, "struct arabicforms ArabicForms[] = {\n" );
627  fprintf( data, "\t/* initial, medial, final, isolated, isletter, joindual, required_lig_with_alef */\n");
628  for ( i=0; i<256; ++i ) {
629  fprintf( data, "\t{ 0x%04x, 0x%04x, 0x%04x, 0x%04x, %d, %d, %d }",
630  forms[i].initial, forms[i].medial, forms[i].final, forms[i].isolated,
631  forms[i].isletter, forms[i].joindual, forms[i].required_lig_with_alef);
632  if ( i==255 )
633  fprintf( data, "\n");
634  else
635  if ( (i & 31)==0 )
636  fprintf( data, ",\t/* 0x%04x */\n",0x600+i);
637  else
638  fprintf( data, ",\n");
639  }
640  fprintf( data, "};\n" );
641  fclose( data );
642 }
643 
644 static void dump() {
645  FILE *header, *data;
646  int i,j;
647 
648  header=fopen("utype.h","w");
649  data = fopen("utype.c","w");
650 
651  if ( header==NULL || data==NULL ) {
652  fprintf( stderr, CantSaveFile, "(utype.[ch])" );
653  if ( header ) fclose( header );
654  if ( data ) fclose( data );
656  exit(2);
657  }
658 
659  fprintf( header, "#ifndef _UTYPE_H\n" );
660  fprintf( header, "#define _UTYPE_H\n" );
661 
663 
664  fprintf( header, "#include <ctype.h>\t\t/* Include here so we can control it. If a system header includes it later bad things happen */\n" );
665  fprintf( header, "#include <unibasics.h>\t\t/* Include here so we can use pre-defined int types to correctly size constant data arrays. */\n" );
666  fprintf( header, "#ifdef tolower\n" );
667  fprintf( header, "# undef tolower\n" );
668  fprintf( header, "#endif\n" );
669  fprintf( header, "#ifdef toupper\n" );
670  fprintf( header, "# undef toupper\n" );
671  fprintf( header, "#endif\n" );
672  fprintf( header, "#ifdef islower\n" );
673  fprintf( header, "# undef islower\n" );
674  fprintf( header, "#endif\n" );
675  fprintf( header, "#ifdef isupper\n" );
676  fprintf( header, "# undef isupper\n" );
677  fprintf( header, "#endif\n" );
678  fprintf( header, "#ifdef isalpha\n" );
679  fprintf( header, "# undef isalpha\n" );
680  fprintf( header, "#endif\n" );
681  fprintf( header, "#ifdef isdigit\n" );
682  fprintf( header, "# undef isdigit\n" );
683  fprintf( header, "#endif\n" );
684  fprintf( header, "#ifdef isalnum\n" );
685  fprintf( header, "# undef isalnum\n" );
686  fprintf( header, "#endif\n" );
687  fprintf( header, "#ifdef isspace\n" );
688  fprintf( header, "# undef isspace\n" );
689  fprintf( header, "#endif\n" );
690  fprintf( header, "#ifdef ispunct\n" );
691  fprintf( header, "# undef ispunct\n" );
692  fprintf( header, "#endif\n" );
693  fprintf( header, "#ifdef ishexdigit\n" );
694  fprintf( header, "# undef ishexdigit\n" );
695  fprintf( header, "#endif\n\n" );
696 
697  fprintf( header, "#define ____L 0x%0x\n", _LOWER );
698  fprintf( header, "#define ____U 0x%0x\n", _UPPER );
699  fprintf( header, "#define ____TITLE 0x%0x\n", _TITLE );
700  fprintf( header, "#define ____D 0x%0x\n", _DIGIT );
701  fprintf( header, "#define ____S 0x%0x\n", _SPACE );
702  fprintf( header, "#define ____P 0x%0x\n", _PUNCT );
703  fprintf( header, "#define ____X 0x%0x\n", _HEX );
704  fprintf( header, "#define ____ZW 0x%0x\n", _ZEROWIDTH );
705  fprintf( header, "#define ____L2R 0x%0x\n", _LEFT_2_RIGHT );
706  fprintf( header, "#define ____R2L 0x%0x\n", _RIGHT_2_LEFT );
707  fprintf( header, "#define ____ENUM 0x%0x\n", _ENUMERIC );
708  fprintf( header, "#define ____ANUM 0x%0x\n", _ANUMERIC );
709  fprintf( header, "#define ____ENS 0x%0x\n", _ENS );
710  fprintf( header, "#define ____CS 0x%0x\n", _CS );
711  fprintf( header, "#define ____ENT 0x%0x\n", _ENT );
712  fprintf( header, "#define ____COMBINE 0x%0x\n", _COMBINING );
713  fprintf( header, "#define ____BB 0x%0x\n", _BREAKBEFOREOK );
714  fprintf( header, "#define ____BA 0x%0x\n", _BREAKAFTEROK );
715  fprintf( header, "#define ____NS 0x%0x\n", _NONSTART );
716  fprintf( header, "#define ____NE 0x%0x\n", _NONEND );
717  fprintf( header, "#define ____UB 0x%0x\n", _URLBREAKAFTER );
718  fprintf( header, "#define ____NB 0x%0x\n", _NOBREAK );
719  fprintf( header, "#define ____AL 0x%0x\n", _ALPHABETIC );
720  fprintf( header, "#define ____ID 0x%0x\n", _IDEOGRAPHIC );
721  fprintf( header, "#define ____INITIAL 0x%0x\n", _INITIAL );
722  fprintf( header, "#define ____MEDIAL 0x%0x\n", _MEDIAL );
723  fprintf( header, "#define ____FINAL 0x%0x\n", _FINAL );
724  fprintf( header, "#define ____ISOLATED 0x%0x\n", _ISOLATED );
725  fprintf( header, "#define ____DECOMPNORM 0x%0x\n", _DecompositionNormative );
726  fprintf( header, "\n" );
727 
728  fprintf( header, "extern const unsigned short ____tolower[];\n" );
729  fprintf( header, "extern const unsigned short ____toupper[];\n" );
730  fprintf( header, "extern const unsigned short ____totitle[];\n" );
731  fprintf( header, "extern const unsigned short ____tomirror[];\n" );
732  fprintf( header, "extern const unsigned char ____digitval[];\n" );
733  fprintf( header, "extern const uint32 ____utype[];\n\n" );
734 
735  fprintf( header, "#define ____COMBININGCLASS\t0x%0x\n", _CombiningClass );
736  fprintf( header, "#define ____ABOVE\t\t0x%0x\n", _Above );
737  fprintf( header, "#define ____BELOW\t\t0x%0x\n", _Below );
738  fprintf( header, "#define ____OVERSTRIKE\t\t0x%0x\n", _Overstrike );
739  fprintf( header, "#define ____LEFT\t\t0x%0x\n", _Left );
740  fprintf( header, "#define ____RIGHT\t\t0x%0x\n", _Right );
741  fprintf( header, "#define ____JOINS2\t\t0x%0x\n", _Joins2 );
742  fprintf( header, "#define ____CENTERLEFT\t\t0x%0x\n", _CenterLeft );
743  fprintf( header, "#define ____CENTERRIGHT\t\t0x%0x\n", _CenterRight );
744  fprintf( header, "#define ____CENTEREDOUTSIDE\t0x%0x\n", _CenteredOutside );
745  fprintf( header, "#define ____OUTSIDE\t\t0x%0x\n", _Outside );
746  fprintf( header, "#define ____LEFTEDGE\t\t0x%0x\n", _LeftEdge );
747  fprintf( header, "#define ____RIGHTEDGE\t\t0x%0x\n", _RightEdge );
748  fprintf( header, "#define ____TOUCHING\t\t0x%0x\n", _Touching );
749  fprintf( header, "#define ____COMBININGPOSMASK\t0x%0x\n",
752  _Touching );
753  fprintf( header, "#define ____NOPOSDATAGIVEN\t(uint32)(-1)\t/* -1 == no position data given */\n\n" );
754 
755  fprintf( header, "#define combiningclass(ch)\t(____utype2[(ch)+1]&____COMBININGCLASS)\n" );
756  fprintf( header, "#define combiningposmask(ch)\t(____utype2[(ch)+1]&____COMBININGPOSMASK)\n\n" );
757 
758  fprintf( header, "extern const uint32\t____utype2[];\t\t\t/* hold position boolean flags for each Unicode.org defined character */\n\n" );
759 
760  fprintf( header, "#define isunicodepointassigned(ch) (____codepointassigned[(ch)/32]&(1<<((ch)%%32)))\n\n" );
761 
762  fprintf( header, "extern const uint32\t____codepointassigned[];\t/* 1bit_boolean_flag x 32 = exists in Unicode.org character chart list. */\n\n" );
763 
764  fprintf( header, "#define tolower(ch) (____tolower[(ch)+1])\n" );
765  fprintf( header, "#define toupper(ch) (____toupper[(ch)+1])\n" );
766  fprintf( header, "#define totitle(ch) (____totitle[(ch)+1])\n" );
767  fprintf( header, "#define tomirror(ch) (____tomirror[(ch)+1])\n" );
768  fprintf( header, "#define tovalue(ch) (____digitval[(ch)+1])\n" );
769  fprintf( header, "#define islower(ch) (____utype[(ch)+1]&____L)\n" );
770  fprintf( header, "#define isupper(ch) (____utype[(ch)+1]&____U)\n" );
771  fprintf( header, "#define istitle(ch) (____utype[(ch)+1]&____TITLE)\n" );
772  fprintf( header, "#define isalpha(ch) (____utype[(ch)+1]&(____L|____U|____TITLE|____AL))\n" );
773  fprintf( header, "#define isdigit(ch) (____utype[(ch)+1]&____D)\n" );
774  fprintf( header, "#define isalnum(ch) (____utype[(ch)+1]&(____L|____U|____TITLE|____AL|____D))\n" );
775  fprintf( header, "#define isideographic(ch) (____utype[(ch)+1]&____ID)\n" );
776  fprintf( header, "#define isideoalpha(ch) (____utype[(ch)+1]&(____ID|____L|____U|____TITLE|____AL))\n" );
777  fprintf( header, "#define isspace(ch) (____utype[(ch)+1]&____S)\n" );
778  fprintf( header, "#define ispunct(ch) (____utype[(ch)+1]&____P)\n" );
779  fprintf( header, "#define ishexdigit(ch) (____utype[(ch)+1]&____X)\n" );
780  fprintf( header, "#define iszerowidth(ch) (____utype[(ch)+1]&____ZW)\n" );
781  fprintf( header, "#define islefttoright(ch) (____utype[(ch)+1]&____L2R)\n" );
782  fprintf( header, "#define isrighttoleft(ch) (____utype[(ch)+1]&____R2L)\n" );
783  fprintf( header, "#define iseuronumeric(ch) (____utype[(ch)+1]&____ENUM)\n" );
784  fprintf( header, "#define isarabnumeric(ch) (____utype[(ch)+1]&____ANUM)\n" );
785  fprintf( header, "#define iseuronumsep(ch) (____utype[(ch)+1]&____ENS)\n" );
786  fprintf( header, "#define iscommonsep(ch) (____utype[(ch)+1]&____CS)\n" );
787  fprintf( header, "#define iseuronumterm(ch) (____utype[(ch)+1]&____ENT)\n" );
788  fprintf( header, "#define iscombining(ch) (____utype[(ch)+1]&____COMBINE)\n" );
789  fprintf( header, "#define isbreakbetweenok(ch1,ch2) (((____utype[(ch1)+1]&____BA) && !(____utype[(ch2)+1]&____NS)) || ((____utype[(ch2)+1]&____BB) && !(____utype[(ch1)+1]&____NE)) || (!(____utype[(ch2)+1]&____D) && ch1=='/'))\n" );
790  fprintf( header, "#define isnobreak(ch) (____utype[(ch)+1]&____NB)\n" );
791  fprintf( header, "#define isarabinitial(ch) (____utype[(ch)+1]&____INITIAL)\n" );
792  fprintf( header, "#define isarabmedial(ch) (____utype[(ch)+1]&____MEDIAL)\n" );
793  fprintf( header, "#define isarabfinal(ch) (____utype[(ch)+1]&____FINAL)\n" );
794  fprintf( header, "#define isarabisolated(ch) (____utype[(ch)+1]&____ISOLATED)\n\n" );
795  fprintf( header, "#define isdecompositionnormative(ch) (____utype[(ch)+1]&____DECOMPNORM)\n\n" );
796 
797  fprintf( header, "\n" );
798 
799  fprintf( data, "#include \"utype.h\"\n" );
801  fprintf( data, "const unsigned short ____tolower[]= { 0,\n" );
802  for ( i=0; i<MAXC; i+=j ) {
803  fprintf( data, " " );
804  for ( j=0; j<8 && i+j<MAXC-1; ++j )
805  fprintf(data, " 0x%04x,", mytolower[i+j]);
806  if ( i+j==MAXC-1 ) {
807  fprintf(data, " 0x%04x\n};\n\n", mytolower[i+j]);
808  break;
809  } else
810  if ( (i & 63)==0 )
811  fprintf( data, "\t/* 0x%04x */\n",i);
812  else
813  fprintf( data, "\n");
814  }
815  fprintf( data, "const unsigned short ____toupper[] = { 0,\n" );
816  for ( i=0; i<MAXC; i+=j ) {
817  fprintf( data, " " );
818  for ( j=0; j<8 && i+j<MAXC-1; ++j )
819  fprintf(data, " 0x%04x,", mytoupper[i+j]);
820  if ( i+j==MAXC-1 ) {
821  fprintf(data, " 0x%04x\n};\n\n", mytoupper[i+j]);
822  break;
823  } else
824  if ( (i & 63)==0 )
825  fprintf( data, "\t/* 0x%04x */\n",i);
826  else
827  fprintf( data, "\n");
828  }
829  fprintf( data, "const unsigned short ____totitle[] = { 0,\n" );
830  for ( i=0; i<MAXC; i+=j ) {
831  fprintf( data, " " );
832  for ( j=0; j<8 && i+j<MAXC-1; ++j )
833  fprintf(data, " 0x%04x,", mytotitle[i+j]);
834  if ( i+j==MAXC-1 ) {
835  fprintf(data, " 0x%04x\n};\n\n", mytotitle[i+j]);
836  break;
837  } else
838  if ( (i & 63)==0 )
839  fprintf( data, "\t/* 0x%04x */\n",i);
840  else
841  fprintf( data, "\n");
842  }
843  fprintf( data, "const unsigned short ____tomirror[] = { 0,\n" );
844  for ( i=0; i<MAXC; i+=j ) {
845  fprintf( data, " " );
846  for ( j=0; j<8 && i+j<MAXC-1; ++j )
847  fprintf(data, " 0x%04x,", mymirror[i+j]);
848  if ( i+j==MAXC-1 ) {
849  fprintf(data, " 0x%04x\n};\n\n", mymirror[i+j]);
850  break;
851  } else
852  if ( (i & 63)==0 )
853  fprintf( data, "\t/* 0x%04x */\n",i);
854  else
855  fprintf( data, "\n");
856  }
857  fprintf( data, "const unsigned char ____digitval[] = { 0,\n" );
858  for ( i=0; i<MAXC; i+=j ) {
859  fprintf( data, " " );
860  for ( j=0; j<8 && i+j<MAXC-1; ++j )
861  fprintf(data, " 0x%02x,", mynumericvalue[i+j]);
862  if ( i+j==MAXC-1 ) {
863  fprintf(data, " 0x%02x\n};\n\n", mynumericvalue[i+j]);
864  break;
865  } else
866  if ( (i & 63)==0 )
867  fprintf( data, "\t/* 0x%04x */\n",i);
868  else
869  fprintf( data, "\n");
870  }
871  fprintf( data, "const uint32 ____utype[] = { 0,\n" );
872  for ( i=0; i<MAXC; i+=j ) {
873  fprintf( data, " " );
874  for ( j=0; j<8 && i+j<MAXC-1; ++j )
875  fprintf(data, " 0x%08x,", flags[i+j]);
876  if ( i+j==MAXC-1 ) {
877  fprintf(data, " 0x%08x\n};\n\n", flags[i+j]);
878  break;
879  } else
880  if ( (i & 63)==0 )
881  fprintf( data, "\t/* 0x%04x */\n",i);
882  else
883  fprintf( data, "\n");
884  }
885  fprintf( data, "const uint32 ____utype2[] = { 0,\n" );
886  fprintf( data, " /* binary flags used for physical layout of each unicode.org character */\n" );
887  for ( i=0; i<MAXC; i+=j ) {
888  fprintf( data, " " );
889  for ( j=0; j<8 && i+j<MAXC-1; ++j )
890  fprintf(data, " 0x%08x,", flags2[i+j]);
891  if ( i+j==MAXC-1 ) {
892  fprintf(data, " 0x%08x\n};\n\n", flags2[i+j]);
893  break;
894  } else
895  if ( (i & 63)==0 )
896  fprintf( data, "\t/* 0x%04x */\n",i);
897  else
898  fprintf( data, "\n");
899  }
900 
901  fprintf( data, "const uint32 ____codepointassigned[] = {\n" );
902  fprintf( data, " /* 32 unicode.org characters represented for each data value in array */\n" );
903  for ( i=0; i<0x120000/32; i+=j ) {
904  fprintf( data, " " );
905  for ( j=0; j<8 && i+j<0x120000/32-1; ++j )
906  fprintf(data, " 0x%08x,", assignedcodepoints[i+j]);
907  if ( i+j==0x120000/32-1 ) {
908  fprintf(data, " 0x%08x\n};\n\n", assignedcodepoints[i+j]);
909  break;
910  } else
911  if ( (i & 63)==0 )
912  fprintf( data, "\t/* 0x%04x */\n",i);
913  else
914  fprintf( data, "\n");
915  }
916 
917  fclose( data );
918 
919 #if 0
920  data = fopen( "uninames.c", "w");
921  if ( data==NULL ) {
922  fprintf( stderr, CantSaveFile, "uninames.c" );
924  exit( 1 );
925  }
926 
927  fprintf( data, "#include <stdio.h>\n" );
928  fprintf( data, "#include <utype.h>\n" );
930  for ( i=0; i<MAXC; ++i ) if ( names[i]!=NULL && *names[i]!='<' ) {
931  fprintf( data, "static const unsigned short _%04x[] = { ", i );
932  for ( j=0; names[i][j]!='\0'; ++j )
933  fprintf( data, "'%c', ", names[i][j]);
934  fprintf( data, "0 };\n" );
935  }
936  for ( i=0; i<MAXC; i+=256 ) { int any=0;
937  for ( j=0; j<256 && !any; ++j )
938  if ( names[i+j]!=NULL && *names[i+j]!='<' ) any = 1;
939  if ( any ) {
940  fprintf( data, "static const unsigned short * const __%04x[] = {\n", i );
941  for ( j=0; j<256; ++j )
942  if ( names[i+j]!=NULL && *names[i+j]!='<' )
943  fprintf( data, "\t_%04x%s\n", i+j, j==255?"":"," );
944  else
945  fprintf( data, "\tNULL%s\n", j==255?"":"," );
946  fprintf(data, "};\n" );
947  }
948  }
949  fprintf( data, "static const unsigned short *const __NULLALL[] = {\n" );
950  for ( j=0; j<255; ++j ) fprintf( data, "\tNULL,\n" );
951  fprintf( data, "\tNULL\n};\n" );
952  fprintf( data, "\nunsigned const short *const*const UnicodeCharacterNames[] = {\n" );
953  for ( i=0; i<MAXC; i+=256 ) { int any=0;
954  for ( j=0; j<256 && !any; ++j )
955  if ( names[i+j]!=NULL && *names[i+j]!='<' ) any = 1;
956  if ( any )
957  fprintf( data, "\t__%04x%s\n", i, i==0xff00?"":"," );
958  else
959  fprintf( data, "\t__NULLALL%s\n", i==0xff00?"":"," );
960  }
961  fprintf( data, "};\n" );
962  fclose( data );
963 
964  fprintf( header, "\nextern const unsigned short *const *const UnicodeCharacterNames[];\n" );
965  fprintf( header, "\t/* An array of 256 arrays of 256 strings of 2byte unicode chars */\n" );
966  fprintf( header, "\t/* containing the names of all non-algorithmically named unicode chars */\n" );
967 #endif
968 
970  fprintf( header, "\n#define _SOFT_HYPHEN\t0xad\n" );
971  fprintf( header, "\n#define _DOUBLE_S\t0xdf\n" );
972  fprintf( header, "\n#endif\n" );
973  fclose( header );
974 }
975 
976 static int AnyAlts(int i ) {
977  int j;
978 
979  for ( j=(i<<8); j< (i<<8)+0x100; ++j )
980  if ( alts[j][0]!=0 )
981 return( 1 );
982 
983 return( 0 );
984 }
985 
986 static void dump_alttable() {
987  int i,j;
988  FILE *file;
989 
990  if (( file = fopen("unialt.c","w" ))==NULL ) {
991  fprintf(stderr, CantSaveFile, "unialt.c" );
992 return;
993  }
994 
995  fprintf(file, "#include <chardata.h>\n" );
996 
998 
999  for ( i=32; i<MAXC; ++i ) {
1000  if ( alts[i][0]!=0 ) {
1001  fprintf( file, "static const unichar_t str_%x[] = { 0x%04x, ", i, alts[i][0] );
1002  for ( j=1; j<MAXA && alts[i][j]!=0; ++j )
1003  fprintf( file, "0x%04x, ", alts[i][j] );
1004  fprintf( file, "0 };\n" );
1005  }
1006  }
1007  fprintf( file, "\n" );
1008 
1009  fprintf( file, "static const unichar_t *const up_allzeros[256] = { NULL };\n\n" );
1010 
1011  for ( i=32; i<0xffff; ++i ) {
1012  if ( alts[i][0]!=0 ) {
1013  fprintf( file, "static const unichar_t * const tab_%x[] = {\n", i>>8 );
1014  for ( j=(i&0xff00); j<=(i&0xff00)+0xff; ++j ) {
1015  if ( alts[j][0]==0 )
1016  fprintf( file, "0, " );
1017  else
1018  fprintf( file, "str_%x,\n", j );
1019  }
1020  fprintf(file, "0};\n\n" );
1021  i = j;
1022  }
1023  }
1024 
1025  fprintf( file, "const unichar_t *const * const unicode_alternates[] = {\n" );
1026  for ( i=0; i<=0xff; ++i ) {
1027  if ( AnyAlts(i) )
1028  fprintf(file, "tab_%x,\n", i );
1029  else
1030  fprintf(file, "up_allzeros, " );
1031  }
1032  fprintf(file, "0};\n" );
1033  fclose(file);
1034 
1035 #if 0 /* moved to dump.c to make build process easier */
1036  /* Now only one thing touches chardata. Even though it's our entry */
1037  /* best if done elsewhere */
1038  file = fopen("chardata.h","a");
1040  fprintf( file,"\nextern const unichar_t *const * const unicode_alternates[];\n" );
1041  fclose(file);
1042 #endif
1043 }
1044 
1045 static void visualalts(void) {
1046 
1047  /* These non-normative decompositions allow display algorithems to */
1048  /* pick something that looks right, even if the character doesn't mean */
1049  /* what it should. For example Alpha LOOKS LIKE A so if we don't have */
1050  /* an Alpha character available we can draw it with an A. But this decomp */
1051  /* is not normative and should not be used for ordering purposes */
1052 
1053  /* ligatures */
1054  alts[0x152][0] = 'O'; alts[0x152][1] = 'E';
1055  alts[0x153][0] = 'o'; alts[0x153][1] = 'e';
1056  /* I don't bother with AE, ae because they are in latin1 and so common */
1057 
1058  /* Things which look alike to my eyes */
1059  alts[0x110][0] = 0xD0; alts[0x110][1] = '\0';
1060  alts[0x138][0] = 0x3ba;
1061  alts[0x182][0] = 0x402;
1062  alts[0x189][0] = 0xD0;
1063  alts[0x19e][0] = 0x3b7;
1064  alts[0x19f][0] = 0x398;
1065  alts[0x1a9][0] = 0x3a3;
1066  alts[0x1c0][0] = '|';
1067  alts[0x1c1][0] = '|'; alts[0x1c1][1] = '|';
1068 
1069  alts[0x269][0] = 0x3b9;
1070 
1071  alts[0x278][0] = 0x3a6; /* IPA */
1072  alts[0x299][0] = 0x432;
1073  alts[0x292][0] = 0x1b7;
1074  alts[0x29c][0] = 0x43d;
1075 
1076  alts[0x2b9][0] = '\'';
1077  alts[0x2ba][0] = '"';
1078  alts[0x2bc][0] = '\'';
1079  alts[0x2c4][0] = '^';
1080  alts[0x2c6][0] = '^';
1081  alts[0x2c8][0] = '\'';
1082  alts[0x2dc][0] = '~';
1083  alts[0x2e0][0] = 0x263;
1084  alts[0x2e1][0] = 'l';
1085  alts[0x2e2][0] = 's';
1086  alts[0x2e3][0] = 'x';
1087  alts[0x2e4][0] = 0x2e4;
1088 
1089  alts[0x301][0] = 0xb4;
1090  alts[0x302][0] = '^';
1091  alts[0x303][0] = '~';
1092  alts[0x308][0] = 0xa8;
1093  alts[0x30a][0] = 0xb0;
1094  alts[0x30b][0] = '"';
1095  alts[0x30e][0] = '"';
1096  alts[0x327][0] = 0xb8;
1097 
1098  alts[0x374][0] = '\''; /* Greek */
1099  alts[0x375][0] = 0x2cf;
1100  alts[0x37a][0] = 0x345;
1101  alts[0x37e][0] = ';';
1102  alts[0x391][0] = 'A';
1103  alts[0x392][0] = 'B';
1104  alts[0x393][0] = 0x413;
1105  alts[0x395][0] = 'E';
1106  alts[0x396][0] = 'Z';
1107  alts[0x397][0] = 'H';
1108  alts[0x399][0] = 'I';
1109  alts[0x39a][0] = 'K';
1110  alts[0x39c][0] = 'M';
1111  alts[0x39d][0] = 'N';
1112  alts[0x39f][0] = 'O';
1113  alts[0x3A1][0] = 'P';
1114  alts[0x3A4][0] = 'T';
1115  alts[0x3A5][0] = 'Y';
1116  alts[0x3A7][0] = 'X';
1117  alts[0x3ba][0] = 0x138;
1118  alts[0x3bf][0] = 'o';
1119  alts[0x3c1][0] = 'p';
1120  alts[0x3c7][0] = 'x';
1121 
1122  alts[0x405][0] = 'S'; /* Cyrillic */
1123  alts[0x406][0] = 'I';
1124  alts[0x408][0] = 'J';
1125  alts[0x410][0] = 'A';
1126  alts[0x412][0] = 'B';
1127  alts[0x413][0] = 0x393;
1128  alts[0x415][0] = 'E';
1129  alts[0x41a][0] = 'K';
1130  alts[0x41c][0] = 'M';
1131  alts[0x41d][0] = 'H';
1132  alts[0x41e][0] = 'O';
1133  alts[0x41f][0] = 0x3a0;
1134  alts[0x420][0] = 'P';
1135  alts[0x421][0] = 'C';
1136  alts[0x422][0] = 'T';
1137  alts[0x424][0] = 0x3a6;
1138  alts[0x425][0] = 'X';
1139  alts[0x430][0] = 'a';
1140  alts[0x435][0] = 'e';
1141  alts[0x43a][0] = 0x3ba;
1142  alts[0x43e][0] = 'o';
1143  alts[0x43f][0] = 0x3c0; /* Not quite right, but close */
1144  alts[0x440][0] = 'p';
1145  alts[0x441][0] = 'c';
1146  alts[0x443][0] = 'y';
1147  alts[0x445][0] = 'x';
1148  alts[0x455][0] = 's';
1149  alts[0x456][0] = 'i';
1150  alts[0x458][0] = 'j';
1151 
1152  alts[0x470][0] = 0x3a8; /* extended Cyrillic */
1153  alts[0x471][0] = 0x3c8;
1154  alts[0x4ae][0] = 'Y';
1155  alts[0x4c0][0] = 'I';
1156  alts[0x4d4][0] = 0xc6;
1157  alts[0x4d5][0] = 0xe6;
1158  alts[0x4e0][0] = 0x1b7;
1159  alts[0x4e1][0] = 0x292;
1160  alts[0x4e8][0] = 0x398;
1161  alts[0x4e9][0] = 0x3b8;
1162 
1163  alts[0x54f][0] = 'S'; /* Armenian */
1164  alts[0x555][0] = 'O';
1165  alts[0x570][0] = 0x26f;
1166  alts[0x570][0] = 'h';
1167  alts[0x578][0] = 'n';
1168  alts[0x57a][0] = 0x270;
1169  alts[0x57d][0] = 'u';
1170  alts[0x581][0] = 0x261;
1171  alts[0x582][0] = 0x269;
1172  alts[0x584][0] = 'f';
1173  alts[0x585][0] = 'o';
1174  alts[0x589][0] = ':';
1175 
1176  alts[0x5f0][0] = 0x5d5; alts[0x5f0][1] = 0x5d5; /* Yiddish ligs */
1177  alts[0x5f1][0] = 0x5d5; alts[0x5f1][1] = 0x5d9; /* 0x5d9 should be drawn first (r to l) */
1178  alts[0x5f2][0] = 0x5d9; alts[0x5f2][1] = 0x5d9;
1179 
1180  alts[0x60c][0] = 0x2018; /* Arabic */
1181  alts[0x66a][0] = '%';
1182  alts[0x66c][0] = ',';
1183  alts[0x66d][0] = 0x22c6;
1184  alts[0x6d4][0] = 0xb7;
1185 
1186  /* Many of the Korean Jamo are ligatures of other Jamo */
1187  /* 0x110b often, but not always, rides underneath (0x1135 it's left) */
1188  /* Chosung */
1189  alts[0x1101][0] = 0x1100; alts[0x1101][1] = 0x1100;
1190  alts[0x1104][0] = 0x1103; alts[0x1104][1] = 0x1103;
1191  alts[0x1108][0] = 0x1107; alts[0x1108][1] = 0x1107;
1192  alts[0x110a][0] = 0x1109; alts[0x110a][1] = 0x1109;
1193  alts[0x110d][0] = 0x110c; alts[0x110d][1] = 0x110c;
1194  alts[0x1113][0] = 0x1102; alts[0x1113][1] = 0x1100;
1195  alts[0x1114][0] = 0x1102; alts[0x1114][1] = 0x1102;
1196  alts[0x1115][0] = 0x1102; alts[0x1115][1] = 0x1103;
1197  alts[0x1116][0] = 0x1102; alts[0x1116][1] = 0x1107;
1198  alts[0x1117][0] = 0x1103; alts[0x1117][1] = 0x1100;
1199  alts[0x1118][0] = 0x1105; alts[0x1118][1] = 0x1102;
1200  alts[0x1119][0] = 0x1105; alts[0x1119][1] = 0x1105;
1201  alts[0x111a][0] = 0x1105; alts[0x111a][1] = 0x1112;
1202  alts[0x111b][0] = 0x1105; alts[0x111b][1] = 0x110b;
1203  alts[0x111c][0] = 0x1106; alts[0x111c][1] = 0x1107;
1204  alts[0x111d][0] = 0x1106; alts[0x111d][1] = 0x110b;
1205  alts[0x111e][0] = 0x1107; alts[0x111e][1] = 0x1100;
1206  alts[0x111f][0] = 0x1107; alts[0x111f][1] = 0x1102;
1207  alts[0x1120][0] = 0x1107; alts[0x1120][1] = 0x1103;
1208  alts[0x1121][0] = 0x1107; alts[0x1121][1] = 0x1109;
1209  alts[0x1122][0] = 0x1107; alts[0x1122][1] = 0x1109; alts[0x1122][2] = 0x1100;
1210  alts[0x1123][0] = 0x1107; alts[0x1123][1] = 0x1109; alts[0x1123][2] = 0x1103;
1211  alts[0x1124][0] = 0x1107; alts[0x1124][1] = 0x1109; alts[0x1124][2] = 0x1107;
1212  alts[0x1125][0] = 0x1107; alts[0x1125][1] = 0x1109; alts[0x1125][2] = 0x1109;
1213  alts[0x1126][0] = 0x1107; alts[0x1126][1] = 0x1109; alts[0x1126][2] = 0x110c;
1214  alts[0x1127][0] = 0x1107; alts[0x1127][1] = 0x110c;
1215  alts[0x1128][0] = 0x1107; alts[0x1128][1] = 0x110e;
1216  alts[0x1129][0] = 0x1107; alts[0x1129][1] = 0x1110;
1217  alts[0x112a][0] = 0x1107; alts[0x112a][1] = 0x1111;
1218  alts[0x112b][0] = 0x1107; alts[0x112b][1] = 0x110b;
1219  alts[0x112c][0] = 0x1107; alts[0x112c][1] = 0x1107; alts[0x112c][2] = 0x110b;
1220  alts[0x112d][0] = 0x1109; alts[0x112d][1] = 0x1100;
1221  alts[0x112e][0] = 0x1109; alts[0x112e][1] = 0x1102;
1222  alts[0x112f][0] = 0x1109; alts[0x112f][1] = 0x1103;
1223  alts[0x1130][0] = 0x1109; alts[0x1130][1] = 0x1105;
1224  alts[0x1131][0] = 0x1109; alts[0x1131][1] = 0x1106;
1225  alts[0x1132][0] = 0x1109; alts[0x1132][1] = 0x1107;
1226  alts[0x1133][0] = 0x1109; alts[0x1133][1] = 0x1107; alts[0x1133][2] = 0x1100;
1227  alts[0x1134][0] = 0x1109; alts[0x1134][1] = 0x1109; alts[0x1134][2] = 0x1109;
1228  alts[0x1135][0] = 0x1109; alts[0x1135][1] = 0x110b;
1229  alts[0x1136][0] = 0x1109; alts[0x1136][1] = 0x110c;
1230  alts[0x1137][0] = 0x1109; alts[0x1137][1] = 0x110e;
1231  alts[0x1138][0] = 0x1109; alts[0x1138][1] = 0x110f;
1232  alts[0x1139][0] = 0x1109; alts[0x1139][1] = 0x1110;
1233  alts[0x113a][0] = 0x1109; alts[0x113a][1] = 0x1111;
1234  alts[0x113b][0] = 0x1109; alts[0x113b][1] = 0x1112;
1235  alts[0x113d][0] = 0x113c; alts[0x113d][1] = 0x113c;
1236  alts[0x113f][0] = 0x113e; alts[0x113f][1] = 0x113e;
1237  alts[0x1141][0] = 0x110b; alts[0x1141][1] = 0x1100;
1238  alts[0x1142][0] = 0x110b; alts[0x1142][1] = 0x1103;
1239  alts[0x1143][0] = 0x110b; alts[0x1143][1] = 0x1106;
1240  alts[0x1144][0] = 0x110b; alts[0x1144][1] = 0x1107;
1241  alts[0x1145][0] = 0x110b; alts[0x1145][1] = 0x1109;
1242  alts[0x1146][0] = 0x110b; alts[0x1146][1] = 0x1140;
1243  alts[0x1147][0] = 0x110b; alts[0x1147][1] = 0x110b;
1244  alts[0x1148][0] = 0x110b; alts[0x1148][1] = 0x110c;
1245  alts[0x1149][0] = 0x110b; alts[0x1149][1] = 0x110e;
1246  alts[0x114a][0] = 0x110b; alts[0x114a][1] = 0x1110;
1247  alts[0x114b][0] = 0x110b; alts[0x114b][1] = 0x1111;
1248  alts[0x114d][0] = 0x110c; alts[0x114d][1] = 0x110b;
1249  alts[0x114f][0] = 0x114e; alts[0x114f][1] = 0x114e;
1250  alts[0x1151][0] = 0x1150; alts[0x1151][1] = 0x1150;
1251  alts[0x1152][0] = 0x110e; alts[0x1152][1] = 0x110f;
1252  alts[0x1153][0] = 0x110e; alts[0x1153][1] = 0x1112;
1253  alts[0x1156][0] = 0x1111; alts[0x1156][1] = 0x1107;
1254  alts[0x1157][0] = 0x1111; alts[0x1157][1] = 0x110b;
1255  alts[0x1158][0] = 0x1112; alts[0x1158][1] = 0x1112;
1256  /* Jungsung */
1257  alts[0x1162][0] = 0x1161; alts[0x1162][1] = 0x1175;
1258  alts[0x1164][0] = 0x1163; alts[0x1164][1] = 0x1175;
1259  alts[0x1166][0] = 0x1165; alts[0x1166][1] = 0x1175;
1260  alts[0x1168][0] = 0x1167; alts[0x1168][1] = 0x1175;
1261  alts[0x116a][0] = 0x1169; alts[0x116a][1] = 0x1161;
1262  alts[0x116b][0] = 0x1169; alts[0x116b][1] = 0x1162;
1263  alts[0x116c][0] = 0x1169; alts[0x116c][1] = 0x1175;
1264  alts[0x116f][0] = 0x116e; alts[0x116f][1] = 0x1165;
1265  alts[0x1170][0] = 0x116e; alts[0x1170][1] = 0x1166;
1266  alts[0x1171][0] = 0x116e; alts[0x1171][1] = 0x1175;
1267  alts[0x1174][0] = 0x1173; alts[0x1174][1] = 0x1175;
1268  alts[0x1176][0] = 0x1161; alts[0x1176][1] = 0x1169;
1269  alts[0x1177][0] = 0x1161; alts[0x1177][1] = 0x116e;
1270  alts[0x1178][0] = 0x1163; alts[0x1178][1] = 0x1169;
1271  alts[0x1179][0] = 0x1163; alts[0x1179][1] = 0x116d;
1272  alts[0x117a][0] = 0x1165; alts[0x117a][1] = 0x1169;
1273  alts[0x117b][0] = 0x1165; alts[0x117b][1] = 0x116e;
1274  alts[0x117c][0] = 0x1165; alts[0x117c][1] = 0x1173;
1275  alts[0x117d][0] = 0x1167; alts[0x117d][1] = 0x1169;
1276  alts[0x117e][0] = 0x1167; alts[0x117e][1] = 0x116e;
1277  alts[0x117f][0] = 0x1169; alts[0x117f][1] = 0x1165;
1278  alts[0x1180][0] = 0x1169; alts[0x1180][1] = 0x1166;
1279  alts[0x1181][0] = 0x1169; alts[0x1181][1] = 0x1168;
1280  alts[0x1182][0] = 0x1169; alts[0x1182][1] = 0x1169;
1281  alts[0x1183][0] = 0x1169; alts[0x1183][1] = 0x116e;
1282  alts[0x1184][0] = 0x116d; alts[0x1184][1] = 0x1163;
1283  alts[0x1185][0] = 0x116d; alts[0x1185][1] = 0x1164;
1284  alts[0x1186][0] = 0x116d; alts[0x1186][1] = 0x1167;
1285  alts[0x1187][0] = 0x116d; alts[0x1187][1] = 0x1169;
1286  alts[0x1188][0] = 0x116d; alts[0x1188][1] = 0x1175;
1287  alts[0x1189][0] = 0x116e; alts[0x1189][1] = 0x1161;
1288  alts[0x118a][0] = 0x116e; alts[0x118a][1] = 0x1162;
1289  alts[0x118b][0] = 0x116e; alts[0x118b][1] = 0x1165; alts[0x118b][2] = 0x1173;
1290  alts[0x118c][0] = 0x116e; alts[0x118c][1] = 0x1168;
1291  alts[0x118d][0] = 0x116e; alts[0x118d][1] = 0x116e;
1292  alts[0x118e][0] = 0x1172; alts[0x118e][1] = 0x1161;
1293  alts[0x118f][0] = 0x1172; alts[0x118f][1] = 0x1165;
1294  alts[0x1190][0] = 0x1172; alts[0x1190][1] = 0x1166;
1295  alts[0x1191][0] = 0x1172; alts[0x1191][1] = 0x1167;
1296  alts[0x1192][0] = 0x1172; alts[0x1192][1] = 0x1168;
1297  alts[0x1193][0] = 0x1172; alts[0x1193][1] = 0x116e;
1298  alts[0x1194][0] = 0x1172; alts[0x1194][1] = 0x1175;
1299  alts[0x1195][0] = 0x1173; alts[0x1195][1] = 0x116e;
1300  alts[0x1196][0] = 0x1173; alts[0x1196][1] = 0x1173;
1301  alts[0x1197][0] = 0x1174; alts[0x1197][1] = 0x116e;
1302  alts[0x1198][0] = 0x1175; alts[0x1198][1] = 0x1161;
1303  alts[0x1199][0] = 0x1175; alts[0x1199][1] = 0x1163;
1304  alts[0x119a][0] = 0x1175; alts[0x119a][1] = 0x1169;
1305  alts[0x119b][0] = 0x1175; alts[0x119b][1] = 0x116e;
1306  alts[0x119c][0] = 0x1175; alts[0x119c][1] = 0x1173;
1307  alts[0x119d][0] = 0x1175; alts[0x119d][1] = 0x119e;
1308  alts[0x119f][0] = 0x119e; alts[0x119f][1] = 0x1165;
1309  alts[0x11a0][0] = 0x119e; alts[0x11a0][1] = 0x116e;
1310  alts[0x11a1][0] = 0x119e; alts[0x11a1][1] = 0x1175;
1311  alts[0x11a2][0] = 0x119e; alts[0x11a2][1] = 0x119e;
1312  /* Jongsung */
1313  alts[0x11a8][0] = 0x1100;
1314  alts[0x11a9][0] = 0x11a8; alts[0x11a9][1] = 0x11a8;
1315  alts[0x11aa][0] = 0x11a8; alts[0x11aa][1] = 0x11ba;
1316  alts[0x11ab][0] = 0x1102;
1317  alts[0x11ac][0] = 0x11ab; alts[0x11ac][1] = 0x11bd;
1318  alts[0x11ad][0] = 0x11ab; alts[0x11ad][1] = 0x11c2;
1319  alts[0x11ae][0] = 0x1103;
1320  alts[0x11af][0] = 0x1105;
1321  alts[0x11b0][0] = 0x11af; alts[0x11b0][1] = 0x11a8;
1322  alts[0x11b1][0] = 0x11af; alts[0x11b1][1] = 0x11b7;
1323  alts[0x11b2][0] = 0x11af; alts[0x11b2][1] = 0x11b8;
1324  alts[0x11b3][0] = 0x11af; alts[0x11b3][1] = 0x11ba;
1325  alts[0x11b4][0] = 0x11af; alts[0x11b4][1] = 0x11c0;
1326  alts[0x11b5][0] = 0x11af; alts[0x11b5][1] = 0x11c1;
1327  alts[0x11b6][0] = 0x11af; alts[0x11b6][1] = 0x11c2;
1328  alts[0x11b7][0] = 0x1106;
1329  alts[0x11b8][0] = 0x1107;
1330  alts[0x11b9][0] = 0x11b8; alts[0x11b9][1] = 0x11ba;
1331  alts[0x11ba][0] = 0x1109;
1332  alts[0x11bb][0] = 0x11ba; alts[0x11bb][1] = 0x11ba;
1333  alts[0x11bc][0] = 0x110b;
1334  alts[0x11bd][0] = 0x110c;
1335  alts[0x11be][0] = 0x110e;
1336  alts[0x11bf][0] = 0x110f;
1337  alts[0x11c0][0] = 0x1110;
1338  alts[0x11c1][0] = 0x1111;
1339  alts[0x11c2][0] = 0x1112;
1340  alts[0x11c3][0] = 0x11a8; alts[0x11c3][1] = 0x11af;
1341  alts[0x11c4][0] = 0x11a8; alts[0x11c4][1] = 0x11ba; alts[0x11c4][2] = 0x11a8;
1342  alts[0x11c5][0] = 0x11ab; alts[0x11c5][1] = 0x11a8;
1343  alts[0x11c6][0] = 0x11ab; alts[0x11c6][1] = 0x11ae;
1344  alts[0x11c7][0] = 0x11ab; alts[0x11c7][1] = 0x11ba;
1345  alts[0x11c8][0] = 0x11ab; alts[0x11c8][1] = 0x11eb;
1346  alts[0x11c9][0] = 0x11ab; alts[0x11c9][1] = 0x11c0;
1347  alts[0x11ca][0] = 0x11ae; alts[0x11ca][1] = 0x11a8;
1348  alts[0x11cb][0] = 0x11ae; alts[0x11cb][1] = 0x11af;
1349  alts[0x11cc][0] = 0x11af; alts[0x11cc][1] = 0x11a8; alts[0x11cc][2] = 0x11ba;
1350  alts[0x11cd][0] = 0x11af; alts[0x11cd][1] = 0x11ab;
1351  alts[0x11ce][0] = 0x11af; alts[0x11ce][1] = 0x11ae;
1352  alts[0x11cf][0] = 0x11af; alts[0x11cf][1] = 0x11ae; alts[0x11cf][2] = 0x11c2;
1353  alts[0x11d0][0] = 0x11af; alts[0x11d0][1] = 0x11af;
1354  alts[0x11d1][0] = 0x11af; alts[0x11d1][1] = 0x11b7; alts[0x11d1][2] = 0x11a8;
1355  alts[0x11d2][0] = 0x11af; alts[0x11d2][1] = 0x11b7; alts[0x11d2][2] = 0x11ba;
1356  alts[0x11d3][0] = 0x11af; alts[0x11d3][1] = 0x11b8; alts[0x11d3][2] = 0x11ba;
1357  alts[0x11d4][0] = 0x11af; alts[0x11d4][1] = 0x11b8; alts[0x11d4][2] = 0x11c2;
1358  /*alts[0x11d5][0] = 0x11af; alts[0x11d5][1] = 0x11b8; alts[0x11d5][2] = 0x11bc;*/
1359  alts[0x11d5][0] = 0x11af; alts[0x11d5][1] = 0x11e6;
1360  alts[0x11d6][0] = 0x11af; alts[0x11d6][1] = 0x11ba; alts[0x11d6][2] = 0x11ba;
1361  alts[0x11d7][0] = 0x11af; alts[0x11d7][1] = 0x11eb;
1362  alts[0x11d8][0] = 0x11af; alts[0x11d8][1] = 0x11bf;
1363  alts[0x11d9][0] = 0x11af; alts[0x11d9][1] = 0x11f9;
1364  alts[0x11da][0] = 0x11b7; alts[0x11da][1] = 0x11a8;
1365  alts[0x11db][0] = 0x11b7; alts[0x11db][1] = 0x11af;
1366  alts[0x11dc][0] = 0x11b7; alts[0x11dc][1] = 0x11b8;
1367  alts[0x11dd][0] = 0x11b7; alts[0x11dd][1] = 0x11ba;
1368  alts[0x11de][0] = 0x11b7; alts[0x11de][1] = 0x11ba; alts[0x11de][2] = 0x11ba;
1369  alts[0x11df][0] = 0x11b7; alts[0x11df][1] = 0x11eb;
1370  alts[0x11e0][0] = 0x11b7; alts[0x11e0][1] = 0x11be;
1371  alts[0x11e1][0] = 0x11b7; alts[0x11e1][1] = 0x11c2;
1372  alts[0x11e2][0] = 0x11b7; alts[0x11e2][1] = 0x11bc;
1373  alts[0x11e3][0] = 0x11b8; alts[0x11e3][1] = 0x11af;
1374  alts[0x11e4][0] = 0x11b8; alts[0x11e4][1] = 0x11c1;
1375  alts[0x11e5][0] = 0x11b8; alts[0x11e5][1] = 0x11c2;
1376  alts[0x11e6][0] = 0x11b8; alts[0x11e6][1] = 0x11bc;
1377  alts[0x11e7][0] = 0x11ba; alts[0x11e7][1] = 0x11a8;
1378  alts[0x11e8][0] = 0x11ba; alts[0x11e8][1] = 0x11ae;
1379  alts[0x11e9][0] = 0x11ba; alts[0x11e9][1] = 0x11af;
1380  alts[0x11ea][0] = 0x11ba; alts[0x11ea][1] = 0x11b8;
1381  alts[0x11eb][0] = 0x1140;
1382  alts[0x11ec][0] = 0x11bc; alts[0x11ec][1] = 0x11a8;
1383  alts[0x11ed][0] = 0x11bc; alts[0x11ed][1] = 0x11a8; alts[0x11ed][2] = 0x11a8;
1384  alts[0x11ee][0] = 0x11bc; alts[0x11ee][1] = 0x11bc;
1385  alts[0x11ef][0] = 0x11bc; alts[0x11ef][1] = 0x11bf;
1386  alts[0x11f0][0] = 0x114c;
1387  alts[0x11f1][0] = 0x11f0; alts[0x11f1][1] = 0x11ba;
1388  alts[0x11f2][0] = 0x11f0; alts[0x11f2][1] = 0x11eb;
1389  alts[0x11f3][0] = 0x11c1; alts[0x11f3][1] = 0x11b8;
1390  alts[0x11f4][0] = 0x11c1; alts[0x11f4][1] = 0x11bc;
1391  alts[0x11f5][0] = 0x11c2; alts[0x11f5][1] = 0x11ab;
1392  alts[0x11f6][0] = 0x11c2; alts[0x11f6][1] = 0x11af;
1393  alts[0x11f7][0] = 0x11c2; alts[0x11f7][1] = 0x11b7;
1394  alts[0x11f8][0] = 0x11c2; alts[0x11f8][1] = 0x11b8;
1395  alts[0x11f9][0] = 0x1159;
1396 
1397  alts[0x13a0][0] = 'D'; /* Cherokee */
1398  alts[0x13a1][0] = 'R';
1399  alts[0x13a2][0] = 'T';
1400  alts[0x13a2][0] = 'T';
1401  alts[0x13a9][0] = 0x423;
1402  alts[0x13aa][0] = 'A';
1403  alts[0x13ab][0] = 'J';
1404  alts[0x13ac][0] = 'E';
1405  alts[0x13b1][0] = 0x393;
1406  alts[0x13b3][0] = 'W';
1407  alts[0x13b7][0] = 'M';
1408  alts[0x13bb][0] = 'H';
1409  alts[0x13be][0] = 0x398;
1410  alts[0x13c0][0] = 'G';
1411  alts[0x13c2][0] = 'h';
1412  alts[0x13c3][0] = 'Z';
1413  alts[0x13cf][0] = 0x42c;
1414  alts[0x13d9][0] = 'V';
1415  alts[0x13da][0] = 'S';
1416  alts[0x13de][0] = 'L';
1417  alts[0x13df][0] = 'C';
1418  alts[0x13e2][0] = 'P';
1419  alts[0x13e6][0] = 'K';
1420  alts[0x13f4][0] = 'B';
1421 
1422  alts[0x2000][0] = ' '; /* punctuation */
1423  alts[0x2001][0] = ' ';
1424  alts[0x2010][0] = '-';
1425  alts[0x2011][0] = '-';
1426  alts[0x2012][0] = '-';
1427  alts[0x2013][0] = '-';
1428  alts[0x2014][0] = '-';
1429  alts[0x2015][0] = '-';
1430  alts[0x2016][0] = '|'; alts[0x2016][1] = '|';
1431  alts[0x2018][0] = '`';
1432  alts[0x2019][0] = '\'';
1433  alts[0x201c][0] = '"';
1434  alts[0x201d][0] = '"';
1435  alts[0x2024][0] = '.';
1436  alts[0x2025][0] = '.'; alts[0x2025][1] = '.';
1437  alts[0x2026][0] = '.'; alts[0x2026][1] = '.'; alts[0x2026][2] = '.';
1438  alts[0x2032][0] = '\'';
1439  alts[0x2033][0] = '"';
1440  alts[0x2035][0] = '`';
1441  alts[0x2036][0] = '"';
1442  alts[0x2039][0] = '<';
1443  alts[0x203a][0] = '>';
1444  alts[0x203c][0] = '!'; alts[0x203c][1] = '!';
1445  alts[0x2048][0] = '?'; alts[0x2048][1] = '!';
1446  alts[0x2049][0] = '!'; alts[0x2049][1] = '?';
1447 
1448  alts[0x2126][0] = 0x3a9;
1449 
1450  alts[0x2205][0] = 0xd8; /* Mathematical operators */
1451  alts[0x2206][0] = 0x394;
1452  alts[0x220f][0] = 0x3a0;
1453  alts[0x2211][0] = 0x3a3;
1454  alts[0x2212][0] = '-';
1455  alts[0x2215][0] = '/';
1456  alts[0x2216][0] = '\\';
1457  alts[0x2217][0] = '*';
1458  alts[0x2218][0] = 0xb0;
1459  alts[0x2219][0] = 0xb7;
1460  alts[0x2223][0] = '|';
1461  alts[0x2225][0] = '|'; alts[0x2225][1] = '|';
1462  alts[0x2236][0] = ':';
1463  alts[0x223c][0] = '~';
1464  alts[0x226a][0] = 0xab;
1465  alts[0x226b][0] = 0xbb;
1466  alts[0x2299][0] = 0x298;
1467  alts[0x22c4][0] = 0x25ca;
1468  alts[0x22c5][0] = 0xb7;
1469  alts[0x22ef][0] = 0xb7; alts[0x22ef][1] = 0xb7; alts[0x22ef][2] = 0xb7;
1470 
1471  alts[0x2303][0] = '^'; /* Misc Technical */
1472 
1473  alts[0x2373][0] = 0x3b9; /* APL greek */
1474  alts[0x2374][0] = 0x3c1;
1475  alts[0x2375][0] = 0x3c9;
1476  alts[0x237a][0] = 0x3b1;
1477 
1478  /* names of control chars */
1479  alts[0x2400][0] = 'N'; alts[0x2400][1] = 'U'; alts[0x2400][2] = 'L';
1480  alts[0x2401][0] = 'S'; alts[0x2401][1] = 'O'; alts[0x2401][2] = 'H';
1481  alts[0x2402][0] = 'S'; alts[0x2402][1] = 'T'; alts[0x2402][2] = 'X';
1482  alts[0x2403][0] = 'E'; alts[0x2403][1] = 'T'; alts[0x2403][2] = 'X';
1483  alts[0x2404][0] = 'E'; alts[0x2404][1] = 'O'; alts[0x2404][2] = 'T';
1484  alts[0x2405][0] = 'E'; alts[0x2405][1] = 'N'; alts[0x2405][2] = 'A';
1485  alts[0x2406][0] = 'A'; alts[0x2406][1] = 'C'; alts[0x2406][2] = 'K';
1486  alts[0x2407][0] = 'B'; alts[0x2407][1] = 'E'; alts[0x2407][2] = 'L';
1487  alts[0x2408][0] = 'B'; alts[0x2408][1] = 'S';
1488  alts[0x2409][0] = 'H'; alts[0x2409][1] = 'T';
1489  alts[0x240A][0] = 'L'; alts[0x240a][1] = 'F';
1490  alts[0x240b][0] = 'V'; alts[0x240b][1] = 'T';
1491  alts[0x240C][0] = 'F'; alts[0x240c][1] = 'F';
1492  alts[0x240d][0] = 'C'; alts[0x240d][1] = 'R';
1493  alts[0x240e][0] = 'S'; alts[0x240e][1] = 'O';
1494  alts[0x240f][0] = 'S'; alts[0x240f][1] = 'I';
1495  alts[0x2410][0] = 'D'; alts[0x2410][1] = 'L'; alts[0x2410][2] = 'E';
1496  alts[0x2411][0] = 'D'; alts[0x2411][1] = 'C'; alts[0x2411][2] = '1';
1497  alts[0x2412][0] = 'D'; alts[0x2412][1] = 'C'; alts[0x2412][2] = '2';
1498  alts[0x2413][0] = 'D'; alts[0x2413][1] = 'C'; alts[0x2413][2] = '3';
1499  alts[0x2414][0] = 'D'; alts[0x2414][1] = 'C'; alts[0x2414][2] = '4';
1500  alts[0x2415][0] = 'N'; alts[0x2415][1] = 'A'; alts[0x2415][2] = 'K';
1501  alts[0x2416][0] = 'S'; alts[0x2416][1] = 'Y'; alts[0x2416][2] = 'N';
1502  alts[0x2417][0] = 'E'; alts[0x2417][1] = 'T'; alts[0x2417][2] = 'B';
1503  alts[0x2418][0] = 'C'; alts[0x2418][1] = 'A'; alts[0x2418][2] = 'N';
1504  alts[0x2419][0] = 'E'; alts[0x2419][1] = 'M';
1505  alts[0x241a][0] = 'S'; alts[0x241a][1] = 'U'; alts[0x241a][2] = 'B';
1506  alts[0x241b][0] = 'E'; alts[0x241b][1] = 'S'; alts[0x241b][2] = 'C';
1507  alts[0x241c][0] = 'F'; alts[0x241c][1] = 'S';
1508  alts[0x241d][0] = 'G'; alts[0x241d][1] = 'S';
1509  alts[0x241e][0] = 'R'; alts[0x241e][1] = 'S';
1510  alts[0x241f][0] = 'U'; alts[0x241f][1] = 'S';
1511  alts[0x2420][0] = 'S'; alts[0x2420][1] = 'P';
1512  alts[0x2421][0] = 'D'; alts[0x2421][1] = 'E'; alts[0x2421][2] = 'L';
1513  alts[0x2422][0] = 0x180;
1514 
1515  alts[0x2500][0] = 0x2014;
1516  alts[0x2502][0] = '|';
1517  alts[0x25b3][0] = 0x2206;
1518  alts[0x25b8][0] = 0x2023;
1519  alts[0x25bd][0] = 0x2207;
1520  alts[0x25c7][0] = 0x25ca;
1521  alts[0x25e6][0] = 0xb0;
1522 
1523  alts[0x2662][0] = 0x25ca;
1524 
1525  alts[0x2731][0] = '*';
1526  alts[0x2758][0] = '|';
1527  alts[0x2762][0] = '!';
1528 
1529  alts[0x3001][0] = ','; /* Idiographic symbols */
1530  alts[0x3008][0] = '<';
1531  alts[0x3009][0] = '>';
1532  alts[0x300a][0] = 0xab;
1533  alts[0x300b][0] = 0xbb;
1534 
1535  /* The Hangul Compatibility Jamo are just copies of the real Jamo */
1536  /* (different spacing semantics though) */
1537  alts[0x3131][0] = 0x1100;
1538  alts[0x3132][0] = 0x1101;
1539  alts[0x3133][0] = 0x11aa;
1540  alts[0x3134][0] = 0x1102;
1541  alts[0x3135][0] = 0x11ac;
1542  alts[0x3136][0] = 0x11ad;
1543  alts[0x3137][0] = 0x1103;
1544  alts[0x3138][0] = 0x1104;
1545  alts[0x3139][0] = 0x1105;
1546  alts[0x313a][0] = 0x11b0;
1547  alts[0x313b][0] = 0x11b1;
1548  alts[0x313c][0] = 0x11b2;
1549  alts[0x313d][0] = 0x11b3;
1550  alts[0x313e][0] = 0x11b4;
1551  alts[0x313f][0] = 0x11b5;
1552  alts[0x3140][0] = 0x111a;
1553  alts[0x3141][0] = 0x1106;
1554  alts[0x3142][0] = 0x1107;
1555  alts[0x3143][0] = 0x1108;
1556  alts[0x3144][0] = 0x1121;
1557  alts[0x3145][0] = 0x1109;
1558  alts[0x3146][0] = 0x110a;
1559  alts[0x3147][0] = 0x110b;
1560  alts[0x3148][0] = 0x110c;
1561  alts[0x3149][0] = 0x110d;
1562  alts[0x314a][0] = 0x110e;
1563  alts[0x314b][0] = 0x110f;
1564  alts[0x314c][0] = 0x1110;
1565  alts[0x314d][0] = 0x1111;
1566  alts[0x314e][0] = 0x1112;
1567  alts[0x314f][0] = 0x1161;
1568  alts[0x3150][0] = 0x1162;
1569  alts[0x3151][0] = 0x1163;
1570  alts[0x3152][0] = 0x1164;
1571  alts[0x3153][0] = 0x1165;
1572  alts[0x3154][0] = 0x1166;
1573  alts[0x3155][0] = 0x1167;
1574  alts[0x3156][0] = 0x1168;
1575  alts[0x3157][0] = 0x1169;
1576  alts[0x3158][0] = 0x116a;
1577  alts[0x3159][0] = 0x116b;
1578  alts[0x315a][0] = 0x116c;
1579  alts[0x315b][0] = 0x116d;
1580  alts[0x315c][0] = 0x116e;
1581  alts[0x315d][0] = 0x116f;
1582  alts[0x315e][0] = 0x1170;
1583  alts[0x315f][0] = 0x1171;
1584  alts[0x3160][0] = 0x1172;
1585  alts[0x3161][0] = 0x1173;
1586  alts[0x3162][0] = 0x1174;
1587  alts[0x3163][0] = 0x1175;
1588  alts[0x3164][0] = 0x1160;
1589  alts[0x3165][0] = 0x1114;
1590  alts[0x3166][0] = 0x1115;
1591  alts[0x3167][0] = 0x11c7;
1592  alts[0x3168][0] = 0x11c8;
1593  alts[0x3169][0] = 0x11cc;
1594  alts[0x316a][0] = 0x11ce;
1595  alts[0x316b][0] = 0x11d3;
1596  alts[0x316c][0] = 0x11d7;
1597  alts[0x316d][0] = 0x11d9;
1598  alts[0x316e][0] = 0x111c;
1599  alts[0x316f][0] = 0x11dd;
1600  alts[0x3170][0] = 0x11df;
1601  alts[0x3171][0] = 0x111d;
1602  alts[0x3172][0] = 0x111e;
1603  alts[0x3173][0] = 0x1120;
1604  alts[0x3174][0] = 0x1122;
1605  alts[0x3175][0] = 0x1123;
1606  alts[0x3176][0] = 0x1127;
1607  alts[0x3177][0] = 0x1129;
1608  alts[0x3178][0] = 0x112b;
1609  alts[0x3179][0] = 0x112c;
1610  alts[0x317a][0] = 0x112d;
1611  alts[0x317b][0] = 0x112e;
1612  alts[0x317c][0] = 0x112f;
1613  alts[0x317d][0] = 0x1132;
1614  alts[0x317e][0] = 0x1136;
1615  alts[0x317f][0] = 0x1140;
1616  alts[0x3180][0] = 0x1147;
1617  alts[0x3181][0] = 0x114c;
1618  alts[0x3182][0] = 0x11f1;
1619  alts[0x3183][0] = 0x11f2;
1620  alts[0x3184][0] = 0x1157;
1621  alts[0x3185][0] = 0x1158;
1622  alts[0x3186][0] = 0x1159;
1623  alts[0x3187][0] = 0x1184;
1624  alts[0x3188][0] = 0x1185;
1625  alts[0x3189][0] = 0x1188;
1626  alts[0x318a][0] = 0x1191;
1627  alts[0x318b][0] = 0x1192;
1628  alts[0x318c][0] = 0x1194;
1629  alts[0x318d][0] = 0x119e;
1630  alts[0x318e][0] = 0x11a1;
1631 
1632  alts[0xff5f][0] = 0x2e28; alts[0x2e28][0] = 0xff5f; /* similar double brackets*/
1633  alts[0xff60][0] = 0x2e29; alts[0x2e29][0] = 0xff60;
1634 }
1635 
1636 
1637 static void cheat(void) {
1638 #if 0
1639  /* Adobe's private use symbols (some) */
1640  alts[0xf6de][0] = '-'; /* 3/4 em dash */
1641 
1642  alts[0xf66d][0] = 0xf761; alts[0xf66d][1] = 0x306; /* A breve */
1643  alts[0xf66e][0] = 0xf761; alts[0xf66e][1] = 0x304; /* A macron */
1644  alts[0xf66f][0] = 0xf761; alts[0xf66f][1] = 0x328; /* A ogonek */
1645  alts[0xf670][0] = 0xf7e6; alts[0xf670][1] = 0x301; /* AE acute */
1646  alts[0xf671][0] = 0xf763; alts[0xf671][1] = 0x301;
1647  alts[0xf672][0] = 0xf763; alts[0xf672][1] = 0x30c; /* C caron */
1648  alts[0xf673][0] = 0xf763; alts[0xf673][1] = 0x302; /* C circumflex */
1649  alts[0xf674][0] = 0xf763; alts[0xf674][1] = 0x307; /* C dot above */
1650  alts[0xf675][0] = 0xf764; alts[0xf675][1] = 0x30c; /* D caron */
1651  alts[0xf677][0] = 0xf765; alts[0xf677][1] = 0x306; /* E breve */
1652  alts[0xf678][0] = 0xf765; alts[0xf678][1] = 0x30c;
1653  alts[0xf679][0] = 0xf765; alts[0xf679][1] = 0x307;
1654  alts[0xf67a][0] = 0xf765; alts[0xf67a][1] = 0x304;
1655  alts[0xf67c][0] = 0xf765; alts[0xf67c][1] = 0x328;
1656  alts[0xf67d][0] = 0xf767; alts[0xf67d][1] = 0x306; /* G breve */
1657  alts[0xf67e][0] = 0xf767; alts[0xf67e][1] = 0x302;
1658  alts[0xf67f][0] = 0xf767; alts[0xf67f][1] = 0x326; /* G comma below */
1659  alts[0xf680][0] = 0xf767; alts[0xf680][1] = 0x307;
1660  alts[0xf682][0] = 0xf768; alts[0xf682][1] = 0x302; /* H circum */
1661  alts[0xf683][0] = 0xf769; alts[0xf683][1] = 0x306; /* I breve */
1662  alts[0xf684][0] = 0xf769; alts[0xf684][1] = 0xf76a; /* I J */
1663  alts[0xf685][0] = 0xf769; alts[0xf685][1] = 0x304;
1664  alts[0xf686][0] = 0xf769; alts[0xf686][1] = 0x328;
1665  alts[0xf687][0] = 0xf769; alts[0xf687][1] = 0x303; /* I tilde */
1666  alts[0xf688][0] = 0xf76a; alts[0xf688][1] = 0x302; /* J circum */
1667  alts[0xf689][0] = 0xf76b; alts[0xf689][1] = 0x326; /* K comma below */
1668  alts[0xf68a][0] = 0xf76c; alts[0xf68a][1] = 0x301; /* L accute */
1669  alts[0xf68b][0] = 0xf76c; alts[0xf68b][1] = 0x30c;
1670  alts[0xf68c][0] = 0xf76c; alts[0xf68c][1] = 0x326;
1671  alts[0xf68d][0] = 0xf76c; alts[0xf68d][1] = 0xB7; /* L middle dot */
1672  alts[0xf68e][0] = 0xf76e; alts[0xf68e][1] = 0x301; /* N accute */
1673  alts[0xf68f][0] = 0xf76e; alts[0xf68f][1] = 0x30c;
1674  alts[0xf690][0] = 0xf76e; alts[0xf690][1] = 0x326;
1675  alts[0xf691][0] = 0xf76f; alts[0xf691][1] = 0x306; /* O breve */
1676  alts[0xf692][0] = 0xf76f; alts[0xf692][1] = 0x30b; /* O double accute */
1677  alts[0xf693][0] = 0xf76f; alts[0xf693][1] = 0x304;
1678  alts[0xf694][0] = 0xf7f8; alts[0xf694][1] = 0x301;
1679  alts[0xf695][0] = 0xf772; alts[0xf695][1] = 0x301; /* R acute */
1680  alts[0xf696][0] = 0xf772; alts[0xf696][1] = 0x30c;
1681  alts[0xf697][0] = 0xf772; alts[0xf697][1] = 0x326;
1682  alts[0xf698][0] = 0xf773; alts[0xf698][1] = 0x301; /* S acute */
1683  alts[0xf699][0] = 0xf773; alts[0xf699][1] = 0x327; /* S cedilla */
1684  alts[0xf69a][0] = 0xf773; alts[0xf69a][1] = 0x302;
1685  alts[0xf69b][0] = 0xf773; alts[0xf69b][1] = 0x326;
1686  alts[0xf69d][0] = 0xf774; alts[0xf69d][1] = 0x30c; /* T caron */
1687  alts[0xf69e][0] = 0xf774; alts[0xf69e][1] = 0x326;
1688  alts[0xf69f][0] = 0xf775; alts[0xf69f][1] = 0x306; /* U breve */
1689  alts[0xf6a0][0] = 0xf775; alts[0xf6a0][1] = 0x30b;
1690  alts[0xf6a1][0] = 0xf775; alts[0xf6a1][1] = 0x304;
1691  alts[0xf6a2][0] = 0xf775; alts[0xf6a2][1] = 0x328;
1692  alts[0xf6a3][0] = 0xf775; alts[0xf6a3][1] = 0x30a; /* U ring */
1693  alts[0xf6a4][0] = 0xf775; alts[0xf6a4][1] = 0x303;
1694  alts[0xf6a5][0] = 0xf777; alts[0xf6a5][1] = 0x301; /* W accute */
1695  alts[0xf6a6][0] = 0xf777; alts[0xf6a6][1] = 0x302;
1696  alts[0xf6a7][0] = 0xf777; alts[0xf6a7][1] = 0x308;
1697  alts[0xf6a8][0] = 0xf777; alts[0xf6a8][1] = 0x300;
1698  alts[0xf6a9][0] = 0xf779; alts[0xf6a9][1] = 0x302;
1699  alts[0xf6aa][0] = 0xf779; alts[0xf6aa][1] = 0x300;
1700  alts[0xf6ab][0] = 0xf77a; alts[0xf6ab][1] = 0x301;
1701  alts[0xf6ac][0] = 0xf77a; alts[0xf6ac][1] = 0x307;
1702  alts[0xf6ad][0] = 0xf769; alts[0xf6ad][1] = 0x307;
1703 
1704  alts[0xf6be][0] = 'j';
1705  alts[0xf6bf][0] = 'L'; alts[0xf6bf][1] = 'L';
1706  alts[0xf6c0][0] = 'l'; alts[0xf6c0][1] = 'l';
1707  alts[0xf6c3][0] = 0x313;
1708  alts[0xf6c9][0] = 0x2ca;
1709  alts[0xf6ca][0] = 0x2c7;
1710  alts[0xf6cb][0] = 0xa8;
1711  alts[0xf6cc][0] = 0xa8; alts[0xf6cc][1] = 0x2ca;
1712  alts[0xf6cd][0] = 0xa8; alts[0xf6cd][1] = 0x2cb;
1713  alts[0xf6ce][0] = 0x2cb;
1714  alts[0xf6cf][0] = 0x2dd;
1715  alts[0xf6d0][0] = 0x2c9;
1716  alts[0xf6d1][0] = 0x2d8;
1717  alts[0xf6d3][0] = 0x30f;
1718  alts[0xf6d4][0] = 0x2d8;
1719  alts[0xf6d6][0] = 0x30f;
1720  alts[0xf6d7][0] = 0xa8; alts[0xf6d7][1] = 0x2ca;
1721  alts[0xf6d8][0] = 0xa8; alts[0xf6d8][1] = 0x2cb;
1722  alts[0xf6d9][0] = 0xa9;
1723  alts[0xf6da][0] = 0xae;
1724  alts[0xf6db][0] = 0x2122;
1725  alts[0xf6de][0] = '-';
1726 
1727  alts[0xf6f4][0] = 0x2d8;
1728  alts[0xf6f5][0] = 0x2c7;
1729  alts[0xf6f6][0] = 0x2c6;
1730  alts[0xf6f7][0] = 0x2d9;
1731  alts[0xf6f8][0] = 0x2dd;
1732  alts[0xf6fa][0] = 0xf76f; alts[0xf6fa][1] = 0xf765;
1733  alts[0xf6fb][0] = 0xf76f; alts[0xf6fb][1] = 0x328;
1734  alts[0xf6fc][0] = 0xf772; alts[0xf6fc][1] = 0x30a;
1735  alts[0xf6fd][0] = 0xf773; alts[0xf6fd][1] = 0x30c;
1736  alts[0xf6fe][0] = 0xf774; alts[0xf6fe][1] = 0x303;
1737  alts[0xf6ff][0] = 0xf77a; alts[0xf6ff][1] = 0x30c;
1738  alts[0xf760][0] = '`';
1739  alts[0xf7a8][0] = 0xa8;
1740  alts[0xf7af][0] = 0xaf;
1741  alts[0xf7b4][0] = 0xb4;
1742  alts[0xf7b8][0] = 0xb8;
1743  alts[0xf7e0][0] = 0xf761; alts[0xf7e0][1] = 0x300;
1744  alts[0xf7e1][0] = 0xf761; alts[0xf7e1][1] = 0x301;
1745  alts[0xf7e2][0] = 0xf761; alts[0xf7e2][1] = 0x302;
1746  alts[0xf7e3][0] = 0xf761; alts[0xf7e3][1] = 0x303;
1747  alts[0xf7e4][0] = 0xf761; alts[0xf7e4][1] = 0x308;
1748  alts[0xf7e5][0] = 0xf761; alts[0xf7e5][1] = 0x30a;
1749  alts[0xf7e6][0] = 0xf761; alts[0xf7e6][1] = 0xf765;
1750  alts[0xf7e7][0] = 0xf763; alts[0xf7e7][1] = 0x327;
1751  alts[0xf7e8][0] = 0xf765; alts[0xf7e8][1] = 0x300;
1752  alts[0xf7e9][0] = 0xf765; alts[0xf7e9][1] = 0x301;
1753  alts[0xf7ea][0] = 0xf765; alts[0xf7ea][1] = 0x302;
1754  alts[0xf7eb][0] = 0xf765; alts[0xf7eb][1] = 0x308;
1755  alts[0xf7ec][0] = 0xf769; alts[0xf7ec][1] = 0x300;
1756  alts[0xf7ed][0] = 0xf769; alts[0xf7ed][1] = 0x301;
1757  alts[0xf7ee][0] = 0xf769; alts[0xf7ee][1] = 0x302;
1758  alts[0xf7ef][0] = 0xf769; alts[0xf7ef][1] = 0x308;
1759  alts[0xf7f1][0] = 0xf76e; alts[0xf7f1][1] = 0x303;
1760  alts[0xf7f2][0] = 0xf76f; alts[0xf7f2][1] = 0x300;
1761  alts[0xf7f3][0] = 0xf76f; alts[0xf7f3][1] = 0x301;
1762  alts[0xf7f4][0] = 0xf76f; alts[0xf7f4][1] = 0x302;
1763  alts[0xf7f5][0] = 0xf76f; alts[0xf7f5][1] = 0x303;
1764  alts[0xf7f6][0] = 0xf76f; alts[0xf7f6][1] = 0x308;
1765  alts[0xf7f9][0] = 0xf775; alts[0xf7f9][1] = 0x300;
1766  alts[0xf7fa][0] = 0xf775; alts[0xf7fa][1] = 0x301;
1767  alts[0xf7fb][0] = 0xf775; alts[0xf7fb][1] = 0x302;
1768  alts[0xf7fc][0] = 0xf775; alts[0xf7fc][1] = 0x308;
1769 
1770  alts[0xf7fd][0] = 0xf779; alts[0xf7fd][1] = 0x301;
1771  alts[0xf7ff][0] = 0xf779; alts[0xf7ff][1] = 0x308;
1772 
1773  mytoupper[0xf6be] = 'J'; /* Adobe's dotlessj character */
1774  mytotitle[0xf6be] = 'J';
1775  mytolower[0xf6bf] = 0xf6c0; /* Adobe's LL character */
1776  mytoupper[0xf6c0] = 0xf6bf; /* Adobe's ll character */
1777  mytotitle[0xf6c0] = 0xf6bf;
1778 #endif
1779 
1780  mymirror['('] = ')';
1781  mymirror[')'] = '(';
1782  mymirror['>'] = '<';
1783  mymirror['<'] = '>';
1784  mymirror['['] = ']';
1785  mymirror[']'] = '[';
1786  mymirror['{'] = '}';
1787  mymirror['}'] = '{';
1788  mymirror[0xab] = 0xbb; /* double Guillemet */
1789  mymirror[0xbb] = 0xab;
1790  mymirror[0x2039] = 0x203A; /* single Guillemet */
1791  mymirror[0x203A] = 0x2039;
1792  mymirror[0x2045] = 0x2046; /* square bracket with quill */
1793  mymirror[0x2046] = 0x2045;
1794  mymirror[0x207D] = 0x207E; /* superscript paren */
1795  mymirror[0x207E] = 0x207D;
1796  mymirror[0x208D] = 0x208E; /* subscript paren */
1797  mymirror[0x208E] = 0x208D;
1798  /* mathematical symbols not mirrorred!!!! some tech symbols missing too */
1799  /* no code points */
1800  mymirror[0x2308] = 0x2309; /* ceiling */
1801  mymirror[0x2309] = 0x2308;
1802  mymirror[0x230a] = 0x230b; /* floor */
1803  mymirror[0x230b] = 0x230a;
1804  mymirror[0x2329] = 0x232a; /* bra/ket */
1805  mymirror[0x232a] = 0x2329;
1806  mymirror[0x3008] = 0x3009; /* CJK symbols */
1807  mymirror[0x3009] = 0x3008;
1808  mymirror[0x300a] = 0x300b;
1809  mymirror[0x300b] = 0x300a;
1810  mymirror[0x300c] = 0x300d;
1811  mymirror[0x300d] = 0x300c;
1812  mymirror[0x300e] = 0x300f;
1813  mymirror[0x300f] = 0x300e;
1814  mymirror[0x3010] = 0x3011;
1815  mymirror[0x3011] = 0x3010;
1816  mymirror[0x3014] = 0x3015;
1817  mymirror[0x3015] = 0x3014;
1818  mymirror[0x3016] = 0x3017;
1819  mymirror[0x3017] = 0x3016;
1820  mymirror[0x3018] = 0x3019;
1821  mymirror[0x3019] = 0x3018;
1822  mymirror[0x301a] = 0x301b;
1823  mymirror[0x301b] = 0x301a;
1824 }
1825 
1826 int main() {
1827  visualalts(); /* pre-populate matrix with visual alternative fonts */
1828  readin(); /* load the "official" Unicode data from unicode.org */
1829  /* Apple's file contains no interesting information that I can see */
1830  /* Adobe's file is interesting, but should only be used conditionally */
1831  /* so apply at a different level */
1832  /* readcorpfile("ADOBE ", "AdobeCorporateuse.txt"); */
1833  cheat(); /* over-ride with these mods after reading input files */
1834  dump(); /* create utype.h, utype.c and ArabicForms.c */
1835  dump_alttable(); /* create unialt.c */
1836  FreeNamesMemorySpace(); /* cleanup alloc of memory */
1837 return( 0 );
1838 }
long __cdecl strtol(char const *_String, char **_EndPtr, int _Radix)
#define strdup
Definition: Utility.h:167
#define name
#define free(a)
Definition: decNumber.cpp:310
#define fopen
Definition: xxstdio.h:21
#define fgets
Definition: xxstdio.h:29
char * strncpy()
int strcmp()
Definition: coll.cpp:143
char * strcpy()
struct rect data
Definition: dvipdfm.c:64
int base
Definition: gsftopk.c:1502
#define NULL
Definition: ftobjs.h:61
small capitals from c petite p scientific i
Definition: afcover.h:80
void exit()
char * strstr()
#define fclose
Definition: debug.h:100
#define fprintf
Definition: mendex.h:64
union hdr header
Definition: pbmtomacp.c:291
#define malloc
Definition: alloca.c:91
int strncmp()
int low
Definition: combiners.h:904
const int * pos
Definition: combiners.h:905
static const struct @2148 combiners[]
static void readin(void)
Definition: makeutype.c:207
#define _LeftEdge
Definition: makeutype.c:116
#define _PUNCT
Definition: makeutype.c:73
const char CantSaveFile[]
Definition: makeutype.c:134
#define _CombiningClass
Definition: makeutype.c:104
unichar_t alts[65536][18+1]
Definition: makeutype.c:129
#define _CenteredOutside
Definition: makeutype.c:113
static void dumparabicdata(FILE *header)
Definition: makeutype.c:573
const char NoMoreMemory[]
Definition: makeutype.c:135
static void dump_alttable()
Definition: makeutype.c:986
static void dump()
Definition: makeutype.c:644
#define _LOWER
Definition: makeutype.c:68
#define MAXA
Definition: makeutype.c:65
static int find(char *base, char *suffix)
Definition: makeutype.c:558
const char GeneratedFileMessage[]
Definition: makeutype.c:132
#define _CenterRight
Definition: makeutype.c:112
unsigned long assignedcodepoints[0x120000/32]
Definition: makeutype.c:130
const char CantReadFile[]
Definition: makeutype.c:133
#define _SPACE
Definition: makeutype.c:72
#define _IDEOGRAPHIC
Definition: makeutype.c:94
#define _TITLE
Definition: makeutype.c:70
char * names[65536]
Definition: makeutype.c:121
static void cheat(void)
Definition: makeutype.c:1637
#define _Overstrike
Definition: makeutype.c:107
#define _ENS
Definition: makeutype.c:81
#define _INITIAL
Definition: makeutype.c:96
#define _ENT
Definition: makeutype.c:83
unsigned long flags[65536]
Definition: makeutype.c:127
#define _MEDIAL
Definition: makeutype.c:97
#define _Right
Definition: makeutype.c:109
unsigned short mytoupper[65536]
Definition: makeutype.c:123
#define _Below
Definition: makeutype.c:106
#define _Outside
Definition: makeutype.c:114
#define _UPPER
Definition: makeutype.c:69
unsigned short mytotitle[65536]
Definition: makeutype.c:124
#define _DecompositionNormative
Definition: makeutype.c:102
#define _Left
Definition: makeutype.c:108
unsigned long flags2[65536]
Definition: makeutype.c:128
#define _RIGHT_2_LEFT
Definition: makeutype.c:78
unsigned short mymirror[65536]
Definition: makeutype.c:126
static void FigureAlternates(long index, char *apt, int normative)
Definition: makeutype.c:145
#define _LEFT_2_RIGHT
Definition: makeutype.c:77
#define MAXC
Definition: makeutype.c:64
#define _HEX
Definition: makeutype.c:74
#define _BREAKAFTEROK
Definition: makeutype.c:87
static void FreeNamesMemorySpace()
Definition: makeutype.c:138
unsigned short mytolower[65536]
Definition: makeutype.c:122
#define _ISOLATED
Definition: makeutype.c:99
#define _ZEROWIDTH
Definition: makeutype.c:75
#define _Above
Definition: makeutype.c:105
#define _DIGIT
Definition: makeutype.c:71
#define _CS
Definition: makeutype.c:82
#define _NONSTART
Definition: makeutype.c:88
#define _URLBREAKAFTER
Definition: makeutype.c:91
static void visualalts(void)
Definition: makeutype.c:1045
const char LineLengthBg[]
Definition: makeutype.c:136
static void readcorpfile(char *prefix, char *corp)
Definition: makeutype.c:512
#define _COMBINING
Definition: makeutype.c:84
#define _NOBREAK
Definition: makeutype.c:101
#define _RightEdge
Definition: makeutype.c:115
unsigned char mynumericvalue[65536]
Definition: makeutype.c:125
#define _ENUMERIC
Definition: makeutype.c:79
#define _Joins2
Definition: makeutype.c:110
#define _Touching
Definition: makeutype.c:117
static int AnyAlts(int i)
Definition: makeutype.c:976
#define _FINAL
Definition: makeutype.c:98
static void processAssignment(long index, char *pt)
Definition: makeutype.c:182
int main()
Definition: makeutype.c:1826
#define _ALPHABETIC
Definition: makeutype.c:93
#define _ANUMERIC
Definition: makeutype.c:80
#define _BREAKBEFOREOK
Definition: makeutype.c:86
#define _CenterLeft
Definition: makeutype.c:111
#define _NONEND
Definition: makeutype.c:89
#define fp
const char * suffix
Definition: pkg_icu.cpp:27
#define index(s, c)
Definition: plain2.h:351
static int32_t first
Definition: ppagelist.c:29
bstring c int memset(void *s, int c, int length)
uint32 unichar_t
Definition: basics.h:51
static unsigned long int lc(mp_ptr rp, gmp_randstate_t rstate)
Definition: randlc2x.c:72
unsigned int joindual
Definition: utype.h:147
unsigned int required_lig_with_alef
Definition: utype.h:148
unsigned int isletter
Definition: utype.h:146
unsigned short isolated
Definition: utype.h:145
unsigned short initial
Definition: utype.h:145
unsigned short medial
Definition: utype.h:145
Definition: utils.c:300
Definition: filedef.h:30
Definition: mendex.h:20
Definition: strexpr.c:21
#define FILE
Definition: t1stdio.h:34
int j
Definition: t4ht.c:1589
*job_name strlen((char *) job_name) - 4)
char * file
Definition: t4ht.c:931
val
Definition: tex4ht.c:3227
PATTERN * pt
Definition: vlna.c:74
#define end(cp)
Definition: zic.c:71