diff options
author | Andrew Bartlett <abartlet@samba.org> | 2005-09-21 12:24:41 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 13:38:38 -0500 |
commit | c44efdaa2242f50d75dd5b800e372dd5586c6deb (patch) | |
tree | 543da228fe555b91b60bcd796e723b7c9628b3f6 /source4/heimdal/lib/asn1/lex.l | |
parent | 8f334f69b5d5fcae4a7b2b70e18b7062c46c719e (diff) | |
download | samba-c44efdaa2242f50d75dd5b800e372dd5586c6deb.tar.gz samba-c44efdaa2242f50d75dd5b800e372dd5586c6deb.tar.bz2 samba-c44efdaa2242f50d75dd5b800e372dd5586c6deb.zip |
r10386: Merge current lorikeet-heimdal into Samba4.
Andrew Bartlett
(This used to be commit 4d2a9a9bc497eae269c24cbf156b43b8588e2f73)
Diffstat (limited to 'source4/heimdal/lib/asn1/lex.l')
-rw-r--r-- | source4/heimdal/lib/asn1/lex.l | 230 |
1 files changed, 114 insertions, 116 deletions
diff --git a/source4/heimdal/lib/asn1/lex.l b/source4/heimdal/lib/asn1/lex.l index cb6512f36f..4b2c5af062 100644 --- a/source4/heimdal/lib/asn1/lex.l +++ b/source4/heimdal/lib/asn1/lex.l @@ -32,7 +32,7 @@ * SUCH DAMAGE. */ -/* $Id: lex.l,v 1.26 2005/07/12 06:27:33 lha Exp $ */ +/* $Id: lex.l,v 1.27 2005/09/13 18:17:16 lha Exp $ */ #ifdef HAVE_CONFIG_H #include <config.h> @@ -54,8 +54,8 @@ static unsigned lineno = 1; #undef ECHO -static void handle_comment(int type); -static char *handle_string(void); +static void unterminated(const char *, unsigned); + %} @@ -144,9 +144,109 @@ WITH { return kw_WITH; } "[" { return *yytext; } "]" { return *yytext; } ::= { return EEQUAL; } --- { handle_comment(0); } -\/\* { handle_comment(1); } -"\"" { yylval.name = handle_string(); return STRING; } +-- { + int c, start_lineno = lineno; + int f = 0; + while((c = input()) != EOF) { + if(f && c == '-') + break; + if(c == '-') { + f = 1; + continue; + } + if(c == '\n') { + lineno++; + break; + } + f = 0; + } + if(c == EOF) + unterminated("comment", start_lineno); + } +\/\* { + int c, start_lineno = lineno; + int level = 1; + int seen_star = 0; + int seen_slash = 0; + while((c = input()) != EOF) { + if(c == '/') { + if(seen_star) { + if(--level == 0) + break; + seen_star = 0; + continue; + } + seen_slash = 1; + continue; + } + if(seen_star && c == '/') { + if(--level == 0) + break; + seen_star = 0; + continue; + } + if(c == '*') { + if(seen_slash) { + level++; + seen_star = seen_slash = 0; + continue; + } + seen_star = 1; + continue; + } + seen_star = seen_slash = 0; + if(c == '\n') { + lineno++; + continue; + } + } + if(c == EOF) + unterminated("comment", start_lineno); + } +"\"" { + int start_lineno = lineno; + int c; + char buf[1024]; + char *p = buf; + int f = 0; + int skip_ws = 0; + + while((c = input()) != EOF) { + if(isspace(c) && skip_ws) { + if(c == '\n') + lineno++; + continue; + } + skip_ws = 0; + + if(c == '"') { + if(f) { + *p++ = '"'; + f = 0; + } else + f = 1; + continue; + } + if(f == 1) { + unput(c); + break; + } + if(c == '\n') { + lineno++; + while(p > buf && isspace((unsigned char)p[-1])) + p--; + skip_ws = 1; + continue; + } + *p++ = c; + } + if(c == EOF) + unterminated("string", start_lineno); + *p++ = '\0'; + fprintf(stderr, "string -- %s\n", buf); + yylval.name = estrdup(buf); + return STRING; + } -?0x[0-9A-Fa-f]+|-?[0-9]+ { char *e, *y = yytext; yylval.constant = strtol((const char *)yytext, @@ -178,119 +278,17 @@ yywrap () void error_message (const char *format, ...) { - va_list args; + va_list args; - va_start (args, format); - fprintf (stderr, "%s:%d: ", get_filename(), lineno); - vfprintf (stderr, format, args); - va_end (args); - error_flag++; + va_start (args, format); + fprintf (stderr, "%s:%d: ", get_filename(), lineno); + vfprintf (stderr, format, args); + va_end (args); + error_flag++; } static void -handle_comment(int type) +unterminated(const char *type, unsigned start_lineno) { - int c; - int start_lineno = lineno; - if(type == 0) { - int f = 0; - while((c = input()) != EOF) { - if(f && c == '-') - return; - if(c == '-') { - f = 1; - continue; - } - if(c == '\n') { - lineno++; - return; - } - f = 0; - } - } else { - int level = 1; - int seen_star = 0; - int seen_slash = 0; - while((c = input()) != EOF) { - if(c == '/') { - if(seen_star) { - if(--level == 0) - return; - seen_star = 0; - continue; - } - seen_slash = 1; - continue; - } - if(seen_star && c == '/') { - if(--level == 0) - return; - seen_star = 0; - continue; - } - if(c == '*') { - if(seen_slash) { - level++; - seen_star = seen_slash = 0; - continue; - } - seen_star = 1; - continue; - } - seen_star = seen_slash = 0; - if(c == '\n') { - lineno++; - continue; - } - } - } - if(c == EOF) - error_message("unterminated comment, possibly started on line %d\n", start_lineno); -} - -static char * -handle_string(void) -{ - int start_lineno = lineno; - int c; - char buf[1024]; - char *p = buf; - int f = 0; - int skip_ws = 0; - - while((c = input()) != EOF) { - if(isspace(c) && skip_ws) { - if(c == '\n') - lineno++; - continue; - } - skip_ws = 0; - - if(c == '"') { - if(f) { - *p++ = '"'; - f = 0; - } else - f = 1; - continue; - } - if(f == 1) { - unput(c); - break; - } - if(c == '\n') { - lineno++; - while(p > buf && isspace((unsigned char)p[-1])) - p--; - skip_ws = 1; - continue; - } - *p++ = c; - } - if(c == EOF) - error_message("unterminated string, possibly started on line %d\n", start_lineno); - *p++ = '\0'; - fprintf(stderr, "string -- %s\n", buf); - return estrdup(buf); + error_message("unterminated %s, possibly started on line %d\n", type, start_lineno); } - |