1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START
3*7c478bd9Sstevel@tonic-gate *
4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only
6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance
7*7c478bd9Sstevel@tonic-gate * with the License.
8*7c478bd9Sstevel@tonic-gate *
9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
12*7c478bd9Sstevel@tonic-gate * and limitations under the License.
13*7c478bd9Sstevel@tonic-gate *
14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
19*7c478bd9Sstevel@tonic-gate *
20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END
21*7c478bd9Sstevel@tonic-gate */
22*7c478bd9Sstevel@tonic-gate /*
23*7c478bd9Sstevel@tonic-gate * Copyright (c) 1996, by Sun Microsystems, Inc.
24*7c478bd9Sstevel@tonic-gate * All rights reserved.
25*7c478bd9Sstevel@tonic-gate */
26*7c478bd9Sstevel@tonic-gate
27*7c478bd9Sstevel@tonic-gate /*
28*7c478bd9Sstevel@tonic-gate * Implementation of the mks M_INVARIANT family of mapping macros.
29*7c478bd9Sstevel@tonic-gate * Based on the IBM C/370 getsyntx() and variant.h implementation.
30*7c478bd9Sstevel@tonic-gate *
31*7c478bd9Sstevel@tonic-gate * Copyright 1993 by Mortice Kern Systems Inc. All rights reserved.
32*7c478bd9Sstevel@tonic-gate *
33*7c478bd9Sstevel@tonic-gate */
34*7c478bd9Sstevel@tonic-gate
35*7c478bd9Sstevel@tonic-gate #ifdef M_RCSID
36*7c478bd9Sstevel@tonic-gate #ifndef lint
37*7c478bd9Sstevel@tonic-gate static char const rcsID[] = "$Header: /rd/src/libc/mks/rcs/m_varian.c 1.14 1994/12/08 23:14:58 ross Exp $";
38*7c478bd9Sstevel@tonic-gate #endif /* lint */
39*7c478bd9Sstevel@tonic-gate #endif /* M_RCSID */
40*7c478bd9Sstevel@tonic-gate
41*7c478bd9Sstevel@tonic-gate #include <mks.h>
42*7c478bd9Sstevel@tonic-gate #include <m_invari.h>
43*7c478bd9Sstevel@tonic-gate
44*7c478bd9Sstevel@tonic-gate #ifdef M_VARIANTS
45*7c478bd9Sstevel@tonic-gate
46*7c478bd9Sstevel@tonic-gate #include <variant.h>
47*7c478bd9Sstevel@tonic-gate
48*7c478bd9Sstevel@tonic-gate #define SHORT_STRING_LEN 100
49*7c478bd9Sstevel@tonic-gate
50*7c478bd9Sstevel@tonic-gate void __m_setinvariant(void);
51*7c478bd9Sstevel@tonic-gate
52*7c478bd9Sstevel@tonic-gate char __m_invariant[M_CSETSIZE] = {
53*7c478bd9Sstevel@tonic-gate 0, 1, 2, 3, 4, 5, 6, 7,
54*7c478bd9Sstevel@tonic-gate 8, 9, 10, 11, 12, 13, 14, 15,
55*7c478bd9Sstevel@tonic-gate 16, 17, 18, 19, 20, 21, 22, 23,
56*7c478bd9Sstevel@tonic-gate 24, 25, 26, 27, 28, 29, 30, 31,
57*7c478bd9Sstevel@tonic-gate 32, 33, 34, 35, 36, 37, 38, 39,
58*7c478bd9Sstevel@tonic-gate 40, 41, 42, 43, 44, 45, 46, 47,
59*7c478bd9Sstevel@tonic-gate 48, 49, 50, 51, 52, 53, 54, 55,
60*7c478bd9Sstevel@tonic-gate 56, 57, 58, 59, 60, 61, 62, 63,
61*7c478bd9Sstevel@tonic-gate 64, 65, 66, 67, 68, 69, 70, 71,
62*7c478bd9Sstevel@tonic-gate 72, 73, 74, 75, 76, 77, 78, 79,
63*7c478bd9Sstevel@tonic-gate 80, 81, 82, 83, 84, 85, 86, 87,
64*7c478bd9Sstevel@tonic-gate 88, 89, 90, 91, 92, 93, 94, 95,
65*7c478bd9Sstevel@tonic-gate 96, 97, 98, 99, 100, 101, 102, 103,
66*7c478bd9Sstevel@tonic-gate 104, 105, 106, 107, 108, 109, 110, 111,
67*7c478bd9Sstevel@tonic-gate 112, 113, 114, 115, 116, 117, 118, 119,
68*7c478bd9Sstevel@tonic-gate 120, 121, 122, 123, 124, 125, 126, 127,
69*7c478bd9Sstevel@tonic-gate 128, 129, 130, 131, 132, 133, 134, 135,
70*7c478bd9Sstevel@tonic-gate 136, 137, 138, 139, 140, 141, 142, 143,
71*7c478bd9Sstevel@tonic-gate 144, 145, 146, 147, 148, 149, 150, 151,
72*7c478bd9Sstevel@tonic-gate 152, 153, 154, 155, 156, 157, 158, 159,
73*7c478bd9Sstevel@tonic-gate 160, 161, 162, 163, 164, 165, 166, 167,
74*7c478bd9Sstevel@tonic-gate 168, 169, 170, 171, 172, 173, 174, 175,
75*7c478bd9Sstevel@tonic-gate 176, 177, 178, 179, 180, 181, 182, 183,
76*7c478bd9Sstevel@tonic-gate 184, 185, 186, 187, 188, 189, 190, 191,
77*7c478bd9Sstevel@tonic-gate 192, 193, 194, 195, 196, 197, 198, 199,
78*7c478bd9Sstevel@tonic-gate 200, 201, 202, 203, 204, 205, 206, 207,
79*7c478bd9Sstevel@tonic-gate 208, 209, 210, 211, 212, 213, 214, 215,
80*7c478bd9Sstevel@tonic-gate 216, 217, 218, 219, 220, 221, 222, 223,
81*7c478bd9Sstevel@tonic-gate 224, 225, 226, 227, 228, 229, 230, 231,
82*7c478bd9Sstevel@tonic-gate 232, 233, 234, 235, 236, 237, 238, 239,
83*7c478bd9Sstevel@tonic-gate 240, 241, 242, 243, 244, 245, 246, 247,
84*7c478bd9Sstevel@tonic-gate 248, 249, 250, 251, 252, 253, 254, 255,
85*7c478bd9Sstevel@tonic-gate #if M_CSETSIZE > 256
86*7c478bd9Sstevel@tonic-gate 256, 257, 258, 259, 260, 261, 262, 263,
87*7c478bd9Sstevel@tonic-gate 264, 265, 266, 267, 268, 269, 270, 271,
88*7c478bd9Sstevel@tonic-gate 272, 273, 274, 275, 276, 277, 278, 279,
89*7c478bd9Sstevel@tonic-gate 280, 281, 282, 283, 284, 285, 286, 287,
90*7c478bd9Sstevel@tonic-gate 288, 289, 290, 291, 292, 293, 294, 295,
91*7c478bd9Sstevel@tonic-gate 296, 297, 298, 299, 300, 301, 302, 303,
92*7c478bd9Sstevel@tonic-gate 304, 305, 306, 307, 308, 309, 310, 311,
93*7c478bd9Sstevel@tonic-gate 312, 313, 314, 315, 316, 317, 318, 319,
94*7c478bd9Sstevel@tonic-gate 320, 321, 322, 323, 324, 325, 326, 327,
95*7c478bd9Sstevel@tonic-gate 328, 329, 330, 331, 332, 333, 334, 335,
96*7c478bd9Sstevel@tonic-gate 336, 337, 338, 339, 340, 341, 342, 343,
97*7c478bd9Sstevel@tonic-gate 344, 345, 346, 347, 348, 349, 350, 351,
98*7c478bd9Sstevel@tonic-gate 352, 353, 354, 355, 356, 357, 358, 359,
99*7c478bd9Sstevel@tonic-gate 360, 361, 362, 363, 364, 365, 366, 367,
100*7c478bd9Sstevel@tonic-gate 368, 369, 370, 371, 372, 373, 374, 375,
101*7c478bd9Sstevel@tonic-gate 376, 377, 378, 379, 380, 381, 382, 383,
102*7c478bd9Sstevel@tonic-gate 384, 385, 386, 387, 388, 389, 390, 391,
103*7c478bd9Sstevel@tonic-gate 392, 393, 394, 395, 396, 397, 398, 399,
104*7c478bd9Sstevel@tonic-gate 400, 401, 402, 403, 404, 405, 406, 407,
105*7c478bd9Sstevel@tonic-gate 408, 409, 410, 411, 412, 413, 414, 415,
106*7c478bd9Sstevel@tonic-gate 416, 417, 418, 419, 420, 421, 422, 423,
107*7c478bd9Sstevel@tonic-gate 424, 425, 426, 427, 428, 429, 430, 431,
108*7c478bd9Sstevel@tonic-gate 432, 433, 434, 435, 436, 437, 438, 439,
109*7c478bd9Sstevel@tonic-gate 440, 441, 442, 443, 444, 445, 446, 447,
110*7c478bd9Sstevel@tonic-gate 448, 449, 450, 451, 452, 453, 454, 455,
111*7c478bd9Sstevel@tonic-gate 456, 457, 458, 459, 460, 461, 462, 463,
112*7c478bd9Sstevel@tonic-gate 464, 465, 466, 467, 468, 469, 470, 471,
113*7c478bd9Sstevel@tonic-gate 472, 473, 474, 475, 476, 477, 478, 479,
114*7c478bd9Sstevel@tonic-gate 480, 481, 482, 483, 484, 485, 486, 487,
115*7c478bd9Sstevel@tonic-gate 488, 489, 490, 491, 492, 493, 494, 495,
116*7c478bd9Sstevel@tonic-gate 496, 497, 498, 499, 500, 501, 502, 503,
117*7c478bd9Sstevel@tonic-gate 504, 505, 506, 507, 508, 509, 510, 511
118*7c478bd9Sstevel@tonic-gate #endif
119*7c478bd9Sstevel@tonic-gate #if M_CSETSIZE > 512
120*7c478bd9Sstevel@tonic-gate #error __m_invariant table needs to be extended
121*7c478bd9Sstevel@tonic-gate #endif
122*7c478bd9Sstevel@tonic-gate };
123*7c478bd9Sstevel@tonic-gate char __m_unvariant[M_CSETSIZE] = {
124*7c478bd9Sstevel@tonic-gate 0, 1, 2, 3, 4, 5, 6, 7,
125*7c478bd9Sstevel@tonic-gate 8, 9, 10, 11, 12, 13, 14, 15,
126*7c478bd9Sstevel@tonic-gate 16, 17, 18, 19, 20, 21, 22, 23,
127*7c478bd9Sstevel@tonic-gate 24, 25, 26, 27, 28, 29, 30, 31,
128*7c478bd9Sstevel@tonic-gate 32, 33, 34, 35, 36, 37, 38, 39,
129*7c478bd9Sstevel@tonic-gate 40, 41, 42, 43, 44, 45, 46, 47,
130*7c478bd9Sstevel@tonic-gate 48, 49, 50, 51, 52, 53, 54, 55,
131*7c478bd9Sstevel@tonic-gate 56, 57, 58, 59, 60, 61, 62, 63,
132*7c478bd9Sstevel@tonic-gate 64, 65, 66, 67, 68, 69, 70, 71,
133*7c478bd9Sstevel@tonic-gate 72, 73, 74, 75, 76, 77, 78, 79,
134*7c478bd9Sstevel@tonic-gate 80, 81, 82, 83, 84, 85, 86, 87,
135*7c478bd9Sstevel@tonic-gate 88, 89, 90, 91, 92, 93, 94, 95,
136*7c478bd9Sstevel@tonic-gate 96, 97, 98, 99, 100, 101, 102, 103,
137*7c478bd9Sstevel@tonic-gate 104, 105, 106, 107, 108, 109, 110, 111,
138*7c478bd9Sstevel@tonic-gate 112, 113, 114, 115, 116, 117, 118, 119,
139*7c478bd9Sstevel@tonic-gate 120, 121, 122, 123, 124, 125, 126, 127,
140*7c478bd9Sstevel@tonic-gate 128, 129, 130, 131, 132, 133, 134, 135,
141*7c478bd9Sstevel@tonic-gate 136, 137, 138, 139, 140, 141, 142, 143,
142*7c478bd9Sstevel@tonic-gate 144, 145, 146, 147, 148, 149, 150, 151,
143*7c478bd9Sstevel@tonic-gate 152, 153, 154, 155, 156, 157, 158, 159,
144*7c478bd9Sstevel@tonic-gate 160, 161, 162, 163, 164, 165, 166, 167,
145*7c478bd9Sstevel@tonic-gate 168, 169, 170, 171, 172, 173, 174, 175,
146*7c478bd9Sstevel@tonic-gate 176, 177, 178, 179, 180, 181, 182, 183,
147*7c478bd9Sstevel@tonic-gate 184, 185, 186, 187, 188, 189, 190, 191,
148*7c478bd9Sstevel@tonic-gate 192, 193, 194, 195, 196, 197, 198, 199,
149*7c478bd9Sstevel@tonic-gate 200, 201, 202, 203, 204, 205, 206, 207,
150*7c478bd9Sstevel@tonic-gate 208, 209, 210, 211, 212, 213, 214, 215,
151*7c478bd9Sstevel@tonic-gate 216, 217, 218, 219, 220, 221, 222, 223,
152*7c478bd9Sstevel@tonic-gate 224, 225, 226, 227, 228, 229, 230, 231,
153*7c478bd9Sstevel@tonic-gate 232, 233, 234, 235, 236, 237, 238, 239,
154*7c478bd9Sstevel@tonic-gate 240, 241, 242, 243, 244, 245, 246, 247,
155*7c478bd9Sstevel@tonic-gate 248, 249, 250, 251, 252, 253, 254, 255,
156*7c478bd9Sstevel@tonic-gate #if M_CSETSIZE > 256
157*7c478bd9Sstevel@tonic-gate 256, 257, 258, 259, 260, 261, 262, 263,
158*7c478bd9Sstevel@tonic-gate 264, 265, 266, 267, 268, 269, 270, 271,
159*7c478bd9Sstevel@tonic-gate 272, 273, 274, 275, 276, 277, 278, 279,
160*7c478bd9Sstevel@tonic-gate 280, 281, 282, 283, 284, 285, 286, 287,
161*7c478bd9Sstevel@tonic-gate 288, 289, 290, 291, 292, 293, 294, 295,
162*7c478bd9Sstevel@tonic-gate 296, 297, 298, 299, 300, 301, 302, 303,
163*7c478bd9Sstevel@tonic-gate 304, 305, 306, 307, 308, 309, 310, 311,
164*7c478bd9Sstevel@tonic-gate 312, 313, 314, 315, 316, 317, 318, 319,
165*7c478bd9Sstevel@tonic-gate 320, 321, 322, 323, 324, 325, 326, 327,
166*7c478bd9Sstevel@tonic-gate 328, 329, 330, 331, 332, 333, 334, 335,
167*7c478bd9Sstevel@tonic-gate 336, 337, 338, 339, 340, 341, 342, 343,
168*7c478bd9Sstevel@tonic-gate 344, 345, 346, 347, 348, 349, 350, 351,
169*7c478bd9Sstevel@tonic-gate 352, 353, 354, 355, 356, 357, 358, 359,
170*7c478bd9Sstevel@tonic-gate 360, 361, 362, 363, 364, 365, 366, 367,
171*7c478bd9Sstevel@tonic-gate 368, 369, 370, 371, 372, 373, 374, 375,
172*7c478bd9Sstevel@tonic-gate 376, 377, 378, 379, 380, 381, 382, 383,
173*7c478bd9Sstevel@tonic-gate 384, 385, 386, 387, 388, 389, 390, 391,
174*7c478bd9Sstevel@tonic-gate 392, 393, 394, 395, 396, 397, 398, 399,
175*7c478bd9Sstevel@tonic-gate 400, 401, 402, 403, 404, 405, 406, 407,
176*7c478bd9Sstevel@tonic-gate 408, 409, 410, 411, 412, 413, 414, 415,
177*7c478bd9Sstevel@tonic-gate 416, 417, 418, 419, 420, 421, 422, 423,
178*7c478bd9Sstevel@tonic-gate 424, 425, 426, 427, 428, 429, 430, 431,
179*7c478bd9Sstevel@tonic-gate 432, 433, 434, 435, 436, 437, 438, 439,
180*7c478bd9Sstevel@tonic-gate 440, 441, 442, 443, 444, 445, 446, 447,
181*7c478bd9Sstevel@tonic-gate 448, 449, 450, 451, 452, 453, 454, 455,
182*7c478bd9Sstevel@tonic-gate 456, 457, 458, 459, 460, 461, 462, 463,
183*7c478bd9Sstevel@tonic-gate 464, 465, 466, 467, 468, 469, 470, 471,
184*7c478bd9Sstevel@tonic-gate 472, 473, 474, 475, 476, 477, 478, 479,
185*7c478bd9Sstevel@tonic-gate 480, 481, 482, 483, 484, 485, 486, 487,
186*7c478bd9Sstevel@tonic-gate 488, 489, 490, 491, 492, 493, 494, 495,
187*7c478bd9Sstevel@tonic-gate 496, 497, 498, 499, 500, 501, 502, 503,
188*7c478bd9Sstevel@tonic-gate 504, 505, 506, 507, 508, 509, 510, 511
189*7c478bd9Sstevel@tonic-gate #endif
190*7c478bd9Sstevel@tonic-gate #if M_CSETSIZE > 512
191*7c478bd9Sstevel@tonic-gate #error __m_unvariant table needs to be extended
192*7c478bd9Sstevel@tonic-gate #endif
193*7c478bd9Sstevel@tonic-gate };
194*7c478bd9Sstevel@tonic-gate
195*7c478bd9Sstevel@tonic-gate /*f
196*7c478bd9Sstevel@tonic-gate * Initialize the variant <--> invariant tables.
197*7c478bd9Sstevel@tonic-gate * May be called more than once -- successive calls ignored.
198*7c478bd9Sstevel@tonic-gate * Void return -- can't fail.
199*7c478bd9Sstevel@tonic-gate */
200*7c478bd9Sstevel@tonic-gate void
m_invariantinit(void)201*7c478bd9Sstevel@tonic-gate m_invariantinit(void)
202*7c478bd9Sstevel@tonic-gate {
203*7c478bd9Sstevel@tonic-gate static int first = 1;
204*7c478bd9Sstevel@tonic-gate
205*7c478bd9Sstevel@tonic-gate if (!first)
206*7c478bd9Sstevel@tonic-gate return;
207*7c478bd9Sstevel@tonic-gate first = 0;
208*7c478bd9Sstevel@tonic-gate __m_setinvariant();
209*7c478bd9Sstevel@tonic-gate return;
210*7c478bd9Sstevel@tonic-gate }
211*7c478bd9Sstevel@tonic-gate
212*7c478bd9Sstevel@tonic-gate /*f
213*7c478bd9Sstevel@tonic-gate * Initialize the variant -> invariant tables.
214*7c478bd9Sstevel@tonic-gate * Void return -- can't fail.
215*7c478bd9Sstevel@tonic-gate */
216*7c478bd9Sstevel@tonic-gate void
__m_setinvariant(void)217*7c478bd9Sstevel@tonic-gate __m_setinvariant(void)
218*7c478bd9Sstevel@tonic-gate {
219*7c478bd9Sstevel@tonic-gate int i;
220*7c478bd9Sstevel@tonic-gate struct variant *v;
221*7c478bd9Sstevel@tonic-gate
222*7c478bd9Sstevel@tonic-gate /* Initialize to identity mappings */
223*7c478bd9Sstevel@tonic-gate for (i = 0; i < M_CSETSIZE; i++) {
224*7c478bd9Sstevel@tonic-gate __m_invariant[i] = i;
225*7c478bd9Sstevel@tonic-gate __m_unvariant[i] = i;
226*7c478bd9Sstevel@tonic-gate }
227*7c478bd9Sstevel@tonic-gate
228*7c478bd9Sstevel@tonic-gate /*
229*7c478bd9Sstevel@tonic-gate * Find the set of variant characters
230*7c478bd9Sstevel@tonic-gate * On error, return success -- i.e. assume it wasn't specified, and
231*7c478bd9Sstevel@tonic-gate * hence it is the identity.
232*7c478bd9Sstevel@tonic-gate */
233*7c478bd9Sstevel@tonic-gate if ((v = getsyntx()) == NULL)
234*7c478bd9Sstevel@tonic-gate return;
235*7c478bd9Sstevel@tonic-gate
236*7c478bd9Sstevel@tonic-gate /*
237*7c478bd9Sstevel@tonic-gate * Build the invariant mapping tables: map from current codeset's
238*7c478bd9Sstevel@tonic-gate * variant locations, to the location that we were compiled in.
239*7c478bd9Sstevel@tonic-gate */
240*7c478bd9Sstevel@tonic-gate __m_invariant[v->backslash] = '\\';
241*7c478bd9Sstevel@tonic-gate __m_invariant[v->right_bracket] = ']';
242*7c478bd9Sstevel@tonic-gate __m_invariant[v->left_bracket] = '[';
243*7c478bd9Sstevel@tonic-gate __m_invariant[v->right_brace] = '}';
244*7c478bd9Sstevel@tonic-gate __m_invariant[v->left_brace] = '{';
245*7c478bd9Sstevel@tonic-gate __m_invariant[v->circumflex] = '^';
246*7c478bd9Sstevel@tonic-gate __m_invariant[v->tilde] = '~';
247*7c478bd9Sstevel@tonic-gate __m_invariant[v->exclamation_mark] = '!';
248*7c478bd9Sstevel@tonic-gate __m_invariant[v->number_sign] = '#';
249*7c478bd9Sstevel@tonic-gate __m_invariant[v->vertical_line] = '|';
250*7c478bd9Sstevel@tonic-gate __m_invariant[v->dollar_sign] = '$';
251*7c478bd9Sstevel@tonic-gate __m_invariant[v->commercial_at] = '@';
252*7c478bd9Sstevel@tonic-gate __m_invariant[v->grave_accent] = '`';
253*7c478bd9Sstevel@tonic-gate
254*7c478bd9Sstevel@tonic-gate /*
255*7c478bd9Sstevel@tonic-gate * Build the unvariant mapping tables: map from compiled codeset
256*7c478bd9Sstevel@tonic-gate * to that of the current codeset.
257*7c478bd9Sstevel@tonic-gate */
258*7c478bd9Sstevel@tonic-gate __m_unvariant['\\'] = v->backslash;
259*7c478bd9Sstevel@tonic-gate __m_unvariant[']'] = v->right_bracket;
260*7c478bd9Sstevel@tonic-gate __m_unvariant['['] = v->left_bracket;
261*7c478bd9Sstevel@tonic-gate __m_unvariant['}'] = v->right_brace;
262*7c478bd9Sstevel@tonic-gate __m_unvariant['{'] = v->left_brace;
263*7c478bd9Sstevel@tonic-gate __m_unvariant['^'] = v->circumflex;
264*7c478bd9Sstevel@tonic-gate __m_unvariant['~'] = v->tilde;
265*7c478bd9Sstevel@tonic-gate __m_unvariant['!'] = v->exclamation_mark;
266*7c478bd9Sstevel@tonic-gate __m_unvariant['#'] = v->number_sign;
267*7c478bd9Sstevel@tonic-gate __m_unvariant['|'] = v->vertical_line;
268*7c478bd9Sstevel@tonic-gate __m_unvariant['$'] = v->dollar_sign;
269*7c478bd9Sstevel@tonic-gate __m_unvariant['@'] = v->commercial_at;
270*7c478bd9Sstevel@tonic-gate __m_unvariant['`'] = v->grave_accent;
271*7c478bd9Sstevel@tonic-gate
272*7c478bd9Sstevel@tonic-gate return;
273*7c478bd9Sstevel@tonic-gate }
274*7c478bd9Sstevel@tonic-gate
275*7c478bd9Sstevel@tonic-gate /*f
276*7c478bd9Sstevel@tonic-gate * Convert a compiled in string to the external form. Assumes a fixed
277*7c478bd9Sstevel@tonic-gate * length short string which is available until another call to m_unvariantstr.
278*7c478bd9Sstevel@tonic-gate * Uses 10 alternating strings to allow multiple calls on a printf.
279*7c478bd9Sstevel@tonic-gate * The extra buffers are probably only required by yacc.
280*7c478bd9Sstevel@tonic-gate */
281*7c478bd9Sstevel@tonic-gate char *
m_unvariantstr(char const * s)282*7c478bd9Sstevel@tonic-gate m_unvariantstr(char const *s)
283*7c478bd9Sstevel@tonic-gate {
284*7c478bd9Sstevel@tonic-gate static char str[10][SHORT_STRING_LEN];
285*7c478bd9Sstevel@tonic-gate static int buf = 0;
286*7c478bd9Sstevel@tonic-gate char *ret;
287*7c478bd9Sstevel@tonic-gate char c;
288*7c478bd9Sstevel@tonic-gate int i = 0;
289*7c478bd9Sstevel@tonic-gate
290*7c478bd9Sstevel@tonic-gate ret = str[buf++];
291*7c478bd9Sstevel@tonic-gate if (buf >= 10)
292*7c478bd9Sstevel@tonic-gate buf = 0;
293*7c478bd9Sstevel@tonic-gate
294*7c478bd9Sstevel@tonic-gate while((ret[i++] = M_UNVARIANT(*s)) != '\0') {
295*7c478bd9Sstevel@tonic-gate s++;
296*7c478bd9Sstevel@tonic-gate if (i >= SHORT_STRING_LEN) {
297*7c478bd9Sstevel@tonic-gate fprintf(stderr, "m_unvariantstr: internal error.\n"),
298*7c478bd9Sstevel@tonic-gate abort();
299*7c478bd9Sstevel@tonic-gate }
300*7c478bd9Sstevel@tonic-gate }
301*7c478bd9Sstevel@tonic-gate ret[i] = '\0';
302*7c478bd9Sstevel@tonic-gate return ret;
303*7c478bd9Sstevel@tonic-gate }
304*7c478bd9Sstevel@tonic-gate
305*7c478bd9Sstevel@tonic-gate /*f
306*7c478bd9Sstevel@tonic-gate * Ditto, for wchar's
307*7c478bd9Sstevel@tonic-gate */
308*7c478bd9Sstevel@tonic-gate wchar_t *
m_wunvariantstr(wchar_t const * s)309*7c478bd9Sstevel@tonic-gate m_wunvariantstr(wchar_t const *s)
310*7c478bd9Sstevel@tonic-gate {
311*7c478bd9Sstevel@tonic-gate static wchar_t str[SHORT_STRING_LEN];
312*7c478bd9Sstevel@tonic-gate static wchar_t * const strend = str + sizeof(str);
313*7c478bd9Sstevel@tonic-gate wchar_t *s1;
314*7c478bd9Sstevel@tonic-gate int i = 0;
315*7c478bd9Sstevel@tonic-gate
316*7c478bd9Sstevel@tonic-gate for (s1 = str ; *s != '\0'; s++) {
317*7c478bd9Sstevel@tonic-gate *s1++ = M_UNVARIANT(*s);
318*7c478bd9Sstevel@tonic-gate if (str == strend) {
319*7c478bd9Sstevel@tonic-gate fprintf(stderr, "m_wunvariantstr: internal error.\n"),
320*7c478bd9Sstevel@tonic-gate abort();
321*7c478bd9Sstevel@tonic-gate }
322*7c478bd9Sstevel@tonic-gate }
323*7c478bd9Sstevel@tonic-gate *s1 = '\0';
324*7c478bd9Sstevel@tonic-gate
325*7c478bd9Sstevel@tonic-gate return str;
326*7c478bd9Sstevel@tonic-gate }
327*7c478bd9Sstevel@tonic-gate #endif /* M_VARIANTS */
328