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 libraries 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:03:16 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 */
41 LOGICAL getname(int first)
47 if ((curcon != DEFAULT && curcon != DEFVAL &&
48 curcon != DEFAULT2 && curcon != DEF2VAL) ||
49 newpar->type != CDATA)
55 if (m_cttype(*p) == M_NONNAME) break;
56 if (p >= name + M_NAMELEN)
58 *(name + M_NAMELEN) = M_EOS;
59 m_error("Name too long");
62 if ((curcon != DEFAULT && curcon != DEFVAL &&
63 curcon != DEFAULT2 && curcon != DEF2VAL) ||
64 newpar->type != CDATA)
72 /* Returns the next token to the main procedure */
77 M_WCHAR wsp, wnl, wtb;
80 ret = mbtowc(&wsp, " ", 1);
81 ret = mbtowc(&wnl, "\n", 1);
82 ret = mbtowc(&wtb, "\t", 1);
86 if (! m_newcon(curcon - 1, TEXT - 1))
88 while ((n = gettoken(&c, COMCON)) == COMMENT)
89 while ((n = gettoken(&c, COMCON)) != COMMENT)
92 m_error("EOF occurred within comment");
97 n = gettoken(&c, curcon);
100 if (n != LIT && n != LITA) return(n);
107 mb_literal = MakeMByteString(literal);
108 printf("literal '%s'\n", mb_literal);
109 m_free(mb_literal, "multibyte string");
113 /* Litproc returns FALSE in case of error, when returned have
114 scanned to the end of erroneous rule */
117 if (c == wsp || c == wnl || c == wtb)
119 if (m_newcon(curcon - 1, TEXT - 1))
121 scanval = (M_WCHAR) c;
126 if (m_newcon(curcon - 1, NAME - 1))
127 if (m_cttype(c) == M_NMSTART ||
128 (m_cttype(c) != M_NONNAME &&
129 (curcon == DEFAULT || curcon == DEFVAL || curcon == NTNAME ||
130 curcon == DEFAULT2 || curcon == DEF2VAL || curcon == NT2NAME
140 mb_name = MakeMByteString(name);
141 printf("name '%s'\n", mb_name);
142 m_free(mb_name, "multibyte string");
148 if (c == EOF) return(ENDFILE);
149 if (m_newcon(curcon - 1, TEXT - 1))
151 scanval = (M_WCHAR) c;
156 char mbyte[32]; /* bigger than the biggest multibyte char */
158 ret = wctomb(mbyte, c);
161 fprintf(stderr, "\n'%s' (%d)", mbyte, c);
162 fprintf(m_errfile, "\n'%s' (%d)", mbyte, c);
163 m_error("Unexpected character");
168 #include "scanutil.c"