2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: special.c /main/3 1995/11/08 09:32:32 rswiston $ */
24 /****************************************************************************/
26 /* This program generates either one or both of two include files needed */
27 /* for other programs. */
29 /* For the portion of HP Tag/Vectra that transforms characters into */
30 /* their TeX equivalents, this program produces a file with entries that */
31 /* consist of a comment field and either a 0 or a string entry. Within */
32 /* the comment field is the character's eight-bit character code plus */
33 /* the name of the character, as: */
41 /* and so on. The string entry is of the form: */
49 /* For the collating program used with indexing, this program produces a */
50 /* file with entries that consist of a comment field, a number */
51 /* representing the collating position of the character, a "handling" */
52 /* field, and the character code of the lowercase representation of */
53 /* those characters that also have uppercase representations. The */
54 /* "handling" field is one of NORMAL, SPECIAL, or UNSUPP. Here are */
55 /* examples showing the fields: */
57 /* * 63: ? * 54, SPECIAL, 63, */
58 /* * 64: @ * 55, SPECIAL, 64, */
59 /* * 65: A * 92, NORMAL, 97, */
60 /* * 161: A grave * 94, NORMAL, 200, */
61 /* * 162: A circumflex * 93, NORMAL, 192, */
62 /* * 200: a grave * 86, NORMAL, 200, */
64 /* The question mark has ROMAN8 character code 63. Its collating */
65 /* position as defined for the indexing program is 54. (That is, it */
66 /* collates just before the at-sign.) It is given SPECIAL handling by */
67 /* the collating program. Since it has no lowercase representation, the */
68 /* number in this position is the same as its ROMAN8 character code. */
69 /* The uppercase A has ROMAN8 character code 65. Its collating position */
70 /* as defined for the indexing program is 92. (That is, it collates */
71 /* just before A circumflex.) It is given NORMAL handling by the */
72 /* collating program. Its lowercase representation is 200, the same as */
73 /* lowercase a grave. */
75 /* The collating order for this program is specified in SPECIAL.H. The */
76 /* collating order to be used by the indexing program can be changed by */
77 /* modifying SPECIAL.H and recompiling and rerunning this program. For */
78 /* example, at the moment, two of the lines in SPECIAL.H are: */
80 /* 162, "A circumflex", NORMAL, "\\^A", 192, */
81 /* 161, "A grave", NORMAL, "\\`A", 200, */
83 /* Thus, A circumflex is specified to collate before A grave. If this */
84 /* changes, and it is determined that A grave should collate first, it */
85 /* would be necessary only to switch the lines, so they look like this: */
87 /* 161, "A grave", NORMAL, "\\`A", 200, */
88 /* 162, "A circumflex", NORMAL, "\\^A", 192, */
90 /* In SPECIAL.H, only those characters that have ROMAN8 representations */
91 /* are listed. The program generates the undefined positions in both */
94 /* To output only the include file for generating TeX characters, run */
95 /* this program with the "s" switch: */
97 /* SPECIAL S > output_file_name */
99 /* To output only the include file for generating the collating */
100 /* sequence, run this program with the "c" switch: */
102 /* SPECIAL C > output_file_name */
104 /* To output both, run this program with the "b" switch, or with no */
107 /* SPECIAL B > output_file_name */
108 /* SPECIAL > output_file_name */
110 /* In all cases, if you specify no redirected file name, the output goes */
111 /* to the Vectra's screen. */
113 /****************************************************************************/
125 typedef wchar_t M_WCHAR;
137 #define NOSPECIALS sizeof(specials)/sizeof(specials[0])
138 #define NO8BITCHARS 256
139 int invert[NO8BITCHARS], emptycell;
145 int i, both = FALSE, spec = FALSE, coll = FALSE, error = FALSE ;
148 { /* Either one argument or none; not more */
151 if (!stricmp(argv[1], "b")) both = TRUE;
152 else if (!stricmp(argv[1], "s")) spec = TRUE;
153 else if (!stricmp(argv[1], "c")) coll = TRUE;
161 fprintf(stderr,"Usage: SPECIAL [b | s | c]\n");
164 for (i = 0 ; i < NOSPECIALS ; i++)
165 invert[specials[i].charcode] = i + 1;
168 printf("/* Char Name TeX Expansion */\n");
170 for (i = 0 ; i < NO8BITCHARS ; i++)
174 printf("/* %3d: %-31s */ ", i, specials[invert[i] - 1].name) ;
175 if (specials[invert[i] - 1].texexpand)
176 printf("\"%s\"", specials[invert[i] - 1].texexpand) ;
179 else printf("/* %3d: undefined */ 0", i) ;
180 if (i < NO8BITCHARS - 1) putchar(',') ;
189 "/* Char Name Coll Status Lower */\n");
192 for (i = 0, emptycell = NOSPECIALS + 1; i < NO8BITCHARS ; i++)
196 printf("/* %3d: %-31s */ %3d, ",
197 specials[invert[i] - 1].charcode,
198 specials[invert[i] - 1].name, invert[i]) ;
199 switch (specials[invert[i] - 1].handling)
211 if (specials[invert[i] - 1].lower)
212 printf(" %3d", specials[invert[i] - 1].lower);
214 printf(" %3d", specials[invert[i] - 1].charcode);
218 "/* %3d: undefined */ %3d, UNSUPP, %3d",
222 if (i < NO8BITCHARS - 1) putchar(',') ;