Deleted Added
sdiff udiff text old ( 87052 ) new ( 87243 )
full compact
1%x string name charmap defn nchar subs subs2
2%{
3/*-
4 * Copyright (c) 1995 Alex Tatmanjants <alex@elvisti.kiev.ua>
5 * at Electronni Visti IA, Kiev, Ukraine.
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 11 unchanged lines hidden (view full) ---

20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * $FreeBSD: head/usr.bin/colldef/scan.l 87052 2001-11-28 09:50:24Z ache $
30 */
31
32#include <ctype.h>
33#include <err.h>
34#include <unistd.h>
35#include <string.h>
36#include <sysexits.h>
37#include "collate.h"
38#include "common.h"
39#include "y.tab.h"
40
41int line_no = 1, save_no, fromsubs;
42u_char buf[BUFSIZE], *ptr;
43FILE *map_fp;
44YY_BUFFER_STATE main_buf, map_buf;
45#ifdef FLEX_DEBUG
46YYSTYPE yylval;
47#endif /* FLEX_DEBUG */
48%}
49%%
50<INITIAL,charmap,nchar,subs,subs2>[ \t]+ ;
51<subs2>\" { ptr = buf; BEGIN(string); }
52<subs>\< { ptr = buf; fromsubs = 1; BEGIN(name); }
53<INITIAL>\< { ptr = buf; fromsubs = 0; BEGIN(name); }
54^#.*\n line_no++;
55^\n line_no++;

--- 105 unchanged lines hidden (view full) ---

161}
162<string>\" {
163 *ptr = '\0';
164 strcpy(yylval.str, buf);
165 BEGIN(subs2);
166 return STRING;
167}
168<name,defn>. {
169 char *s = (map_fp != NULL) ? map_name : "input";
170
171 if (!isascii(*yytext) || !isprint(*yytext))
172 errx(EX_UNAVAILABLE, "non-ASCII or non-printable character 0x%02x not allowed in the map/name near line %u of %s",
173 *yytext, line_no, s);
174 if(ptr >= buf + sizeof(buf) - 1)
175 errx(EX_UNAVAILABLE, "map/name buffer overflow near line %u of %s, character '%c'",
176 line_no, s, *yytext);
177 *ptr++ = *yytext;

--- 36 unchanged lines hidden (view full) ---

214}
215<string>\\a {
216 if(ptr >= buf + sizeof(buf) - 1)
217 errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '\\a'",
218 line_no);
219 *ptr++ = '\a';
220}
221<name,string,defn>\n {
222 char *s = (map_fp != NULL) ? map_name : "input";
223
224 errx(EX_UNAVAILABLE, "unterminated map/name/string near line %u of %s", line_no, s);
225}
226<name,string,nchar><<EOF>> {
227 char *s = (map_fp != NULL) ? map_name : "input";
228
229 errx(EX_UNAVAILABLE, "premature EOF in the name/string/char near line %u of %s", line_no, s);
230}
231<string>\\x[0-9a-f]{2} {
232 u_int v;
233
234 sscanf(&yytext[2], "%x", &v);
235 *ptr++ = (u_char)v;

--- 63 unchanged lines hidden ---