scan.l (23012) | scan.l (43940) |
---|---|
1%x string name charmap defn nchar subs 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 --- 12 unchanged lines hidden (view full) --- 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 * | 1%x string name charmap defn nchar subs 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 --- 12 unchanged lines hidden (view full) --- 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 * $Id$ | 29 * $Id: scan.l,v 1.7 1997/02/22 19:54:32 peter Exp $ |
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" --- 58 unchanged lines hidden (view full) --- 96 return CHAR; 97} 98<INITIAL>[^;,{}() \t\n"<]+ { 99 if(yyleng == 1) { 100 yylval.ch = *yytext; 101 return CHAR; 102 } 103 if(yyleng > STR_LEN - 1) | 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" --- 58 unchanged lines hidden (view full) --- 96 return CHAR; 97} 98<INITIAL>[^;,{}() \t\n"<]+ { 99 if(yyleng == 1) { 100 yylval.ch = *yytext; 101 return CHAR; 102 } 103 if(yyleng > STR_LEN - 1) |
104 errx(EX_UNAVAILABLE, "chain buffer overflaw near line %u", | 104 errx(EX_UNAVAILABLE, "chain buffer overflow near line %u", |
105 line_no); 106 strcpy(yylval.str, yytext); 107 return CHAIN; 108} 109<nchar>. { 110 yylval.ch = *yytext; 111 return CHAR; 112} 113<defn>[ \t]+ { 114 if (ptr == buf) 115 errx(EX_UNAVAILABLE, "map expected near line %u of %s", 116 line_no, map_name); 117 *ptr = '\0'; 118 strcpy(yylval.str, buf); 119 BEGIN(nchar); 120 return DEFN; 121} 122<name>\/\/ { 123 if(ptr >= buf + sizeof(buf) - 1) | 105 line_no); 106 strcpy(yylval.str, yytext); 107 return CHAIN; 108} 109<nchar>. { 110 yylval.ch = *yytext; 111 return CHAR; 112} 113<defn>[ \t]+ { 114 if (ptr == buf) 115 errx(EX_UNAVAILABLE, "map expected near line %u of %s", 116 line_no, map_name); 117 *ptr = '\0'; 118 strcpy(yylval.str, buf); 119 BEGIN(nchar); 120 return DEFN; 121} 122<name>\/\/ { 123 if(ptr >= buf + sizeof(buf) - 1) |
124 errx(EX_UNAVAILABLE, "name buffer overflaw near line %u, character '/'", | 124 errx(EX_UNAVAILABLE, "name buffer overflow near line %u, character '/'", |
125 line_no); 126 *ptr++ = '/'; 127} 128<name>\/\> { 129 if(ptr >= buf + sizeof(buf) - 1) | 125 line_no); 126 *ptr++ = '/'; 127} 128<name>\/\> { 129 if(ptr >= buf + sizeof(buf) - 1) |
130 errx(EX_UNAVAILABLE, "name buffer overflaw near line %u, character '>'", | 130 errx(EX_UNAVAILABLE, "name buffer overflow near line %u, character '>'", |
131 line_no); 132 *ptr++ = '>'; 133} 134<string>\\\" { 135 if(ptr >= buf + sizeof(buf) - 1) | 131 line_no); 132 *ptr++ = '>'; 133} 134<string>\\\" { 135 if(ptr >= buf + sizeof(buf) - 1) |
136 errx(EX_UNAVAILABLE, "string buffer overflaw near line %u, character '\"'", | 136 errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '\"'", |
137 line_no); 138 *ptr++ = '"'; 139} 140<name>\> { 141 u_int i; 142 143 if (ptr == buf) 144 errx(EX_UNAVAILABLE, "non-empty name expected near line %u", --- 17 unchanged lines hidden (view full) --- 162} 163<name,defn>. { 164 char *s = (map_fp != NULL) ? map_name : "input"; 165 166 if (!isascii(*yytext) || !isprint(*yytext)) 167 errx(EX_UNAVAILABLE, "non-ASCII or non-printable character 0x%02x not allowed in the map/name near line %u of %s", 168 *yytext, line_no, s); 169 if(ptr >= buf + sizeof(buf) - 1) | 137 line_no); 138 *ptr++ = '"'; 139} 140<name>\> { 141 u_int i; 142 143 if (ptr == buf) 144 errx(EX_UNAVAILABLE, "non-empty name expected near line %u", --- 17 unchanged lines hidden (view full) --- 162} 163<name,defn>. { 164 char *s = (map_fp != NULL) ? map_name : "input"; 165 166 if (!isascii(*yytext) || !isprint(*yytext)) 167 errx(EX_UNAVAILABLE, "non-ASCII or non-printable character 0x%02x not allowed in the map/name near line %u of %s", 168 *yytext, line_no, s); 169 if(ptr >= buf + sizeof(buf) - 1) |
170 errx(EX_UNAVAILABLE, "map/name buffer overflaw near line %u of %s, character '%c'", | 170 errx(EX_UNAVAILABLE, "map/name buffer overflow near line %u of %s, character '%c'", |
171 line_no, s, *yytext); 172 *ptr++ = *yytext; 173} 174<string>\\t { 175 if(ptr >= buf + sizeof(buf) - 1) | 171 line_no, s, *yytext); 172 *ptr++ = *yytext; 173} 174<string>\\t { 175 if(ptr >= buf + sizeof(buf) - 1) |
176 errx(EX_UNAVAILABLE, "string buffer overflaw near line %u, character '\\t'", | 176 errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '\\t'", |
177 line_no); 178 *ptr++ = '\t'; 179} 180<string>\\b { 181 if(ptr >= buf + sizeof(buf) - 1) | 177 line_no); 178 *ptr++ = '\t'; 179} 180<string>\\b { 181 if(ptr >= buf + sizeof(buf) - 1) |
182 errx(EX_UNAVAILABLE, "string buffer overflaw near line %u, character '\\b'", | 182 errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '\\b'", |
183 line_no); 184 *ptr++ = '\b'; 185} 186<string>\\f { 187 if(ptr >= buf + sizeof(buf) - 1) | 183 line_no); 184 *ptr++ = '\b'; 185} 186<string>\\f { 187 if(ptr >= buf + sizeof(buf) - 1) |
188 errx(EX_UNAVAILABLE, "string buffer overflaw near line %u, character '\\f'", | 188 errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '\\f'", |
189 line_no); 190 *ptr++ = '\f'; 191} 192<string>\\v { 193 if(ptr >= buf + sizeof(buf) - 1) | 189 line_no); 190 *ptr++ = '\f'; 191} 192<string>\\v { 193 if(ptr >= buf + sizeof(buf) - 1) |
194 errx(EX_UNAVAILABLE, "string buffer overflaw near line %u, character '\\v'", | 194 errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '\\v'", |
195 line_no); 196 *ptr++ = '\v'; 197} 198<string>\\n { 199 if(ptr >= buf + sizeof(buf) - 1) | 195 line_no); 196 *ptr++ = '\v'; 197} 198<string>\\n { 199 if(ptr >= buf + sizeof(buf) - 1) |
200 errx(EX_UNAVAILABLE, "string buffer overflaw near line %u, character '\\n'", | 200 errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '\\n'", |
201 line_no); 202 *ptr++ = '\n'; 203} 204<string>\\r { 205 if(ptr >= buf + sizeof(buf) - 1) | 201 line_no); 202 *ptr++ = '\n'; 203} 204<string>\\r { 205 if(ptr >= buf + sizeof(buf) - 1) |
206 errx(EX_UNAVAILABLE, "string buffer overflaw near line %u, character '\\r'", | 206 errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '\\r'", |
207 line_no); 208 *ptr++ = '\r'; 209} 210<string>\\a { 211 if(ptr >= buf + sizeof(buf) - 1) | 207 line_no); 208 *ptr++ = '\r'; 209} 210<string>\\a { 211 if(ptr >= buf + sizeof(buf) - 1) |
212 errx(EX_UNAVAILABLE, "string buffer overflaw near line %u, character '\\a'", | 212 errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '\\a'", |
213 line_no); 214 *ptr++ = '\a'; 215} 216<name,string,defn>\n { 217 char *s = (map_fp != NULL) ? map_name : "input"; 218 219 errx(EX_UNAVAILABLE, "unterminated map/name/string near line %u of %s", line_no, s); 220} --- 11 unchanged lines hidden (view full) --- 232<string>\\[0-7]{3} { 233 u_int v; 234 235 sscanf(&yytext[1], "%o", &v); 236 *ptr++ = (u_char)v; 237} 238<string>\\. { 239 if(ptr >= buf + sizeof(buf) - 1) | 213 line_no); 214 *ptr++ = '\a'; 215} 216<name,string,defn>\n { 217 char *s = (map_fp != NULL) ? map_name : "input"; 218 219 errx(EX_UNAVAILABLE, "unterminated map/name/string near line %u of %s", line_no, s); 220} --- 11 unchanged lines hidden (view full) --- 232<string>\\[0-7]{3} { 233 u_int v; 234 235 sscanf(&yytext[1], "%o", &v); 236 *ptr++ = (u_char)v; 237} 238<string>\\. { 239 if(ptr >= buf + sizeof(buf) - 1) |
240 errx(EX_UNAVAILABLE, "string buffer overflaw near line %u, character '%c'", | 240 errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '%c'", |
241 line_no, yytext[1]); 242 *ptr++ = yytext[1]; 243} 244<string>. { 245 if(ptr >= buf + sizeof(buf) - 1) | 241 line_no, yytext[1]); 242 *ptr++ = yytext[1]; 243} 244<string>. { 245 if(ptr >= buf + sizeof(buf) - 1) |
246 errx(EX_UNAVAILABLE, "string buffer overflaw near line %u, character '%c'", | 246 errx(EX_UNAVAILABLE, "string buffer overflow near line %u, character '%c'", |
247 line_no, *yytext); 248 *ptr++ = *yytext; 249} 250<charmap>[^ \t\n]+ { 251 strcat(map_name, "/"); 252 strcat(map_name, yytext); 253 if((map_fp = fopen(map_name, "r")) == NULL) 254 err(EX_UNAVAILABLE, "can't open 'charmap' file %s", --- 39 unchanged lines hidden --- | 247 line_no, *yytext); 248 *ptr++ = *yytext; 249} 250<charmap>[^ \t\n]+ { 251 strcat(map_name, "/"); 252 strcat(map_name, yytext); 253 if((map_fp = fopen(map_name, "r")) == NULL) 254 err(EX_UNAVAILABLE, "can't open 'charmap' file %s", --- 39 unchanged lines hidden --- |