5 * The contents of this file are subject to the terms of the
6 * Common Development and Distribution License, Version 1.0 only
7 * (the "License"). You may not use this file except in compliance
10 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 * or http://www.opensolaris.org/os/licensing.
12 * See the License for the specific language governing permissions
13 * and limitations under the License.
15 * When distributing Covered Code, include this CDDL HEADER in each
16 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 * If applicable, add the following below this CDDL HEADER, with the
18 * fields enclosed by brackets "[]" replaced with your own identifying
19 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 1991, 2001 by Sun Microsystems, Inc.
24 * All rights reserved.
26 #pragma ident "%Z%%M% %I% %E% SMI"
34 extern int stdin_only;
35 extern char curr_file[]; /* Name of file currently being read. */
36 extern int curr_linenum; /* line number in the current input file */
37 extern int warn_linenum; /* line number of current warning message */
42 extern void handle_macro_line(void);
43 extern void handle_cplus_comment_line(void);
44 extern void handle_open_comment(void);
45 extern void handle_close_comment(void);
46 extern void handle_gettext(void);
47 extern void handle_dgettext(void);
48 extern void handle_dcgettext(void);
49 extern void handle_textdomain(void);
50 extern void handle_character(void);
51 extern void handle_open_paren(void);
52 extern void handle_close_paren(void);
53 extern void handle_esc_newline(void);
54 extern void handle_comma(void);
55 extern void handle_newline(void);
56 extern void handle_quote(void);
57 extern void handle_spaces(void);
58 extern void handle_spaces(void);
59 extern void handle_character(void);
62 * The following lex rule basically wants to recognize tokens
63 * that can change the current state of scanning source code.
64 * Evertime such tokens are recognized, the specific handler will be
65 * executed. All other tokens are treated as regular characters and
66 * they are all handled the same way.
67 * The tricky part was not to miss any specification in ANSI-C code
68 * that looks like a meaningful token but not a meaningful one and
69 * should be treated as regular characters.
71 * c= '"';d='"'; printf("\"" "\(\)\\\"");
72 * c = ABgettext("Not a gettext");
73 * c = gettextXY("Not a gettext");
74 * c = ABgettextXY("Not a gettext");
81 ^#(.*\\\n)**.*\n { handle_macro_line(); }
83 \/\/ { handle_cplus_comment_line(); }
85 \/\* { handle_open_comment(); }
87 \*\/ { handle_close_comment(); }
89 dcgettext { handle_dcgettext(); }
91 dgettext { handle_dgettext(); }
93 gettext { handle_gettext(); }
95 textdomain { handle_textdomain(); }
103 \\\) { handle_character(); }
105 \( { handle_open_paren(); }
107 \) { handle_close_paren(); }
109 \\\n { handle_esc_newline(); }
111 \, { handle_comma(); }
113 \n { handle_newline(); }
115 \" { handle_quote(); }
117 " " { handle_spaces(); }
119 "\t" { handle_spaces(); }
121 . { handle_character(); }
126 * Since multiple files can be processed, yywrap() should keep feeding
127 * all input files specified.
134 if ((optind >= gargc) || (stdin_only == TRUE)) {
138 * gargv still contains not-processed input files.
140 (void) freopen(gargv[optind], "r", stdin);
141 if ((fp = freopen(gargv[optind], "r", stdin)) == NULL) {
142 (void) fprintf(stderr, "ERROR, can't open input file: %s\n",
146 (void) printf("In yywrap(), opening file %d, <%s>\n",
147 optind, gargv[optind]);
150 * Reset global file name and line number for the new file.
152 (void) strcpy(curr_file, gargv[optind]);