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 |
30#include <sys/cdefs.h> 31 32__FBSDID("$FreeBSD: head/usr.bin/colldef/scan.l 87243 2001-12-02 23:40:46Z markm $"); 33 |
34#include <ctype.h> 35#include <err.h> 36#include <unistd.h> 37#include <string.h> 38#include <sysexits.h> 39#include "collate.h" 40#include "common.h" 41#include "y.tab.h" 42 43int line_no = 1, save_no, fromsubs; 44u_char buf[BUFSIZE], *ptr; 45FILE *map_fp; 46YY_BUFFER_STATE main_buf, map_buf; 47#ifdef FLEX_DEBUG 48YYSTYPE yylval; 49#endif /* FLEX_DEBUG */ |
50int yylex(void); |
51%} 52%% 53<INITIAL,charmap,nchar,subs,subs2>[ \t]+ ; 54<subs2>\" { ptr = buf; BEGIN(string); } 55<subs>\< { ptr = buf; fromsubs = 1; BEGIN(name); } 56<INITIAL>\< { ptr = buf; fromsubs = 0; BEGIN(name); } 57^#.*\n line_no++; 58^\n line_no++; --- 105 unchanged lines hidden (view full) --- 164} 165<string>\" { 166 *ptr = '\0'; 167 strcpy(yylval.str, buf); 168 BEGIN(subs2); 169 return STRING; 170} 171<name,defn>. { |
172 const char *s = (map_fp != NULL) ? map_name : "input"; |
173 174 if (!isascii(*yytext) || !isprint(*yytext)) 175 errx(EX_UNAVAILABLE, "non-ASCII or non-printable character 0x%02x not allowed in the map/name near line %u of %s", 176 *yytext, line_no, s); 177 if(ptr >= buf + sizeof(buf) - 1) 178 errx(EX_UNAVAILABLE, "map/name buffer overflow near line %u of %s, character '%c'", 179 line_no, s, *yytext); 180 *ptr++ = *yytext; --- 36 unchanged lines hidden (view full) --- 217} 218<string>\\a { 219 if(ptr >= buf + sizeof(buf) - 1) 220 errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '\\a'", 221 line_no); 222 *ptr++ = '\a'; 223} 224<name,string,defn>\n { |
225 const char *s = (map_fp != NULL) ? map_name : "input"; |
226 227 errx(EX_UNAVAILABLE, "unterminated map/name/string near line %u of %s", line_no, s); 228} 229<name,string,nchar><<EOF>> { |
230 const char *s = (map_fp != NULL) ? map_name : "input"; |
231 232 errx(EX_UNAVAILABLE, "premature EOF in the name/string/char near line %u of %s", line_no, s); 233} 234<string>\\x[0-9a-f]{2} { 235 u_int v; 236 237 sscanf(&yytext[2], "%x", &v); 238 *ptr++ = (u_char)v; --- 63 unchanged lines hidden --- |