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: scan.c /main/3 1995/11/08 09:26:36 rswiston $ */
25 Copyright 1986 Tandem Computers Incorporated.
26 This product and information is proprietary of Tandem Computers Incorporated.
27 Copyright (c) 1986, 1987, 1988, 1989 Hewlett-Packard Co.
30 /* Scan.c contains scanner procedures for program BUILD */
44 LOGICAL getname(first)
51 if ((curcon != DEFAULT && curcon != DEFVAL &&
52 curcon != DEFAULT2 && curcon != DEF2VAL) ||
53 newpar->type != CDATA)
59 if (m_cttype(*p) == M_NONNAME) break;
60 if (p >= name + M_NAMELEN)
62 *(name + M_NAMELEN) = M_EOS;
63 m_error("Name too long");
66 if ((curcon != DEFAULT && curcon != DEFVAL &&
67 curcon != DEFAULT2 && curcon != DEF2VAL) ||
68 newpar->type != CDATA)
76 /* Returns the next token to the main procedure */
81 M_WCHAR wsp, wnl, wtb;
84 mbtowc(&wnl, "\n", 1);
85 mbtowc(&wtb, "\t", 1);
89 if (! m_newcon(curcon - 1, TEXT - 1))
91 while ((n = gettoken(&c, COMCON)) == COMMENT)
92 while ((n = gettoken(&c, COMCON)) != COMMENT)
95 m_error("EOF occurred within comment");
100 n = gettoken(&c, curcon);
103 if (n != LIT && n != LITA) return(n);
110 mb_literal = MakeMByteString(literal);
111 printf("literal '%s'\n", mb_literal);
112 m_free(mb_literal, "multibyte string");
116 /* Litproc returns FALSE in case of error, when returned have
117 scanned to the end of erroneous rule */
120 if (c == wsp || c == wnl || c == wtb)
122 if (m_newcon(curcon - 1, TEXT - 1))
124 scanval = (M_WCHAR) c;
129 if (m_newcon(curcon - 1, NAME - 1))
130 if (m_cttype(c) == M_NMSTART ||
131 (m_cttype(c) != M_NONNAME &&
132 (curcon == DEFAULT || curcon == DEFVAL || curcon == NTNAME ||
133 curcon == DEFAULT2 || curcon == DEF2VAL || curcon == NT2NAME
143 mb_name = MakeMByteString(name);
144 printf("name '%s'\n", mb_name);
145 m_free(mb_name, "multibyte string");
151 if (c == EOF) return(ENDFILE);
152 if (m_newcon(curcon - 1, TEXT - 1))
154 scanval = (M_WCHAR) c;
159 char mbyte[32]; /* bigger than the biggest multibyte char */
163 fprintf(stderr, "\n'%s' (%d)", mbyte, c);
164 fprintf(m_errfile, "\n'%s' (%d)", mbyte, c);
165 m_error("Unexpected character");
170 #include "scanutil.c"