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 10:43:54 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 ret = mbtowc(&wsp, " ", 1);
85 ret = mbtowc(&wnl, "\n", 1);
86 ret = mbtowc(&wtb, "\t", 1);
90 if (! m_newcon(curcon - 1, TEXT - 1))
92 while ((n = gettoken(&c, COMCON)) == COMMENT)
93 while ((n = gettoken(&c, COMCON)) != COMMENT)
96 m_error("EOF occurred within comment");
101 n = gettoken(&c, curcon);
104 if (n != LIT && n != LITA) return(n);
111 mb_literal = MakeMByteString(literal);
112 printf("literal '%s'\n", mb_literal);
113 m_free(mb_literal, "multibyte string");
117 /* Litproc returns FALSE in case of error, when returned have
118 scanned to the end of erroneous rule */
121 if (c == wsp || c == wnl || c == wtb)
123 if (m_newcon(curcon - 1, TEXT - 1))
125 scanval = (M_WCHAR) c;
130 if (m_newcon(curcon - 1, NAME - 1))
131 if (m_cttype(c) == M_NMSTART ||
132 (m_cttype(c) != M_NONNAME &&
133 (curcon == DEFAULT || curcon == DEFVAL || curcon == NTNAME ||
134 curcon == DEFAULT2 || curcon == DEF2VAL || curcon == NT2NAME
144 mb_name = MakeMByteString(name);
145 printf("name '%s'\n", mb_name);
146 m_free(mb_name, "multibyte string");
152 if (c == EOF) return(ENDFILE);
153 if (m_newcon(curcon - 1, TEXT - 1))
155 scanval = (M_WCHAR) c;
160 char mbyte[32]; /* bigger than the biggest multibyte char */
162 ret = wctomb(mbyte, c);
165 fprintf(stderr, "\n'%s' (%d)", mbyte, c);
166 fprintf(m_errfile, "\n'%s' (%d)", mbyte, c);
167 m_error("Unexpected character");
172 #include "scanutil.c"