4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 1997 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1988 AT&T */
28 /* All Rights Reserved */
40 * Note: First of all, this used to live in libgen.h. Second, this is not
41 * reentrant. The code that was there that checked for _REENTRANT made
42 * __i_size defined as a macro to an undefined function so a reentrant
43 * version never worked anyway.
58 main(int argc
, char **argv
)
66 (void) setlocale(LC_ALL
, "");
67 #if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
68 #define TEXT_DOMAIN "SYS_TEST" /* Use this only if it weren't */
70 (void) textdomain(TEXT_DOMAIN
);
71 if (argc
> 1 && *argv
[1] == '-') {
79 if ((iobuf
= fopen(*argv
, "r")) == NULL
) {
80 message
= gettext("can not open ");
81 write(2, message
, strlen(message
));
82 write(2, *argv
, size(*argv
));
84 /* continues to next file, if any, but the */
85 /* exit status will indicate an error */
91 if (*bp
== '/') *bp
= '\0';
94 while (*bp
!= '\0' && bp
> *argv
) bp
--;
100 if (cflg
) *cp
++ = 'c';
104 if (creat(ofile
, 0644) < 0) {
105 message
= gettext("can not create .i file\n");
106 write(2, message
, strlen(message
));
114 while (((c
= getc(iobuf
)) == '\n') ||
121 while (((*name
++ = c
= getc(iobuf
)) != ' ') &&
122 (c
!= EOF
) && (c
!= '\n'))
125 while (((c
= getc(iobuf
)) == ' ') || (c
== '\n'))
129 message
= gettext("unexpected eof\n");
130 write(2, message
, strlen(message
));
133 message
= gettext("missing initial quote for ");
134 write(2, message
, strlen(message
));
135 write(2, a2
, size(a2
));
137 gettext(" : remainder of line ignored\n");
138 write(2, message
, strlen(message
));
139 while ((c
= getc(iobuf
)) != '\n')
144 while (gotflg
|| (c
= getc(iobuf
)) != EOF
) {
150 switch (c
= getc(iobuf
)) {
167 if (c
<= '7' && c
>= '0')
168 *str
++ = getnm((char)c
);
178 message
= gettext("unexpected eof\n");
179 write(2, message
, strlen(message
));
182 while (((c
= getc(iobuf
)) == '\n') || (c
== ' '))
184 if (c
== '"') goto keeponl
;
189 if (!(sv
= v
= regcmp(a1
, 0))) {
190 message
= gettext("fail: ");
191 write(2, message
, strlen(message
));
192 write(2, a2
, size(a2
));
196 printf("/* \"%s\" */\n", a1
);
197 printf("char %s[] = {\n", a2
);
198 while (__i_size
> 0) {
199 for (k
= 0; k
< 12; k
++)
201 printf("0%o, ", *v
++);
231 while (++k
< 4 && (c
= getc(iobuf
)) >= '0' && c
<= '7')