lex.l (127807) | lex.l (178846) |
---|---|
1%{ 2/* 3 * Copyright (c) 1998 - 2000 Kungliga Tekniska H�gskolan 4 * (Royal Institute of Technology, Stockholm, Sweden). 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 17 unchanged lines hidden (view full) --- 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 */ | 1%{ 2/* 3 * Copyright (c) 1998 - 2000 Kungliga Tekniska H�gskolan 4 * (Royal Institute of Technology, Stockholm, Sweden). 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 17 unchanged lines hidden (view full) --- 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 */ |
34/* $FreeBSD: head/contrib/com_err/lex.l 127807 2004-04-03 21:17:01Z nectar $ */ | 34/* $FreeBSD: head/contrib/com_err/lex.l 178846 2008-05-08 11:01:46Z dfr $ */ |
35 36/* 37 * This is to handle the definition of this symbol in some AIX 38 * headers, which will conflict with the definition that lex will 39 * generate for it. It's only a problem for AIX lex. 40 */ 41 42#undef ECHO 43 44#include "compile_et.h" 45#include "parse.h" 46#include "lex.h" 47 48#if 0 | 35 36/* 37 * This is to handle the definition of this symbol in some AIX 38 * headers, which will conflict with the definition that lex will 39 * generate for it. It's only a problem for AIX lex. 40 */ 41 42#undef ECHO 43 44#include "compile_et.h" 45#include "parse.h" 46#include "lex.h" 47 48#if 0 |
49RCSID("$Id: lex.l,v 1.6 2000/06/22 00:42:52 assar Exp $"); | 49RCSID("$Id: lex.l 15143 2005-05-16 08:52:54Z lha $"); |
50#endif 51 52static unsigned lineno = 1; 53static int getstring(void); 54 55#define YY_NO_UNPUT 56 57#undef ECHO --- 29 unchanged lines hidden (view full) --- 87 88static int 89getstring(void) 90{ 91 char x[128]; 92 int i = 0; 93 int c; 94 int quote = 0; | 50#endif 51 52static unsigned lineno = 1; 53static int getstring(void); 54 55#define YY_NO_UNPUT 56 57#undef ECHO --- 29 unchanged lines hidden (view full) --- 87 88static int 89getstring(void) 90{ 91 char x[128]; 92 int i = 0; 93 int c; 94 int quote = 0; |
95 while((c = input()) != EOF){ | 95 while(i < sizeof(x) - 1 && (c = input()) != EOF){ |
96 if(quote) { 97 x[i++] = c; 98 quote = 0; 99 continue; 100 } 101 if(c == '\n'){ 102 error_message("unterminated string"); 103 lineno++; --- 4 unchanged lines hidden (view full) --- 108 continue; 109 } 110 if(c == '\"') 111 break; 112 x[i++] = c; 113 } 114 x[i] = '\0'; 115 yylval.string = strdup(x); | 96 if(quote) { 97 x[i++] = c; 98 quote = 0; 99 continue; 100 } 101 if(c == '\n'){ 102 error_message("unterminated string"); 103 lineno++; --- 4 unchanged lines hidden (view full) --- 108 continue; 109 } 110 if(c == '\"') 111 break; 112 x[i++] = c; 113 } 114 x[i] = '\0'; 115 yylval.string = strdup(x); |
116 if (yylval.string == NULL) 117 err(1, "malloc"); |
|
116 return STRING; 117} 118 119void 120error_message (const char *format, ...) 121{ 122 va_list args; 123 124 va_start (args, format); 125 fprintf (stderr, "%s:%d:", filename, lineno); 126 vfprintf (stderr, format, args); 127 va_end (args); 128 numerror++; 129} | 118 return STRING; 119} 120 121void 122error_message (const char *format, ...) 123{ 124 va_list args; 125 126 va_start (args, format); 127 fprintf (stderr, "%s:%d:", filename, lineno); 128 vfprintf (stderr, format, args); 129 va_end (args); 130 numerror++; 131} |