summaryrefslogtreecommitdiffstats
path: root/sbin/devd/token.l
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2002-12-07 08:04:36 +0000
committerimp <imp@FreeBSD.org>2002-12-07 08:04:36 +0000
commita536ab821b9ea241e31d101e54da3e7d33e9211b (patch)
tree9e4f2dc42ade56bf73aaf3d7752d018a5c1abda8 /sbin/devd/token.l
parent4af7578bb83cb753b88567e1d0866203e4583db5 (diff)
downloadFreeBSD-src-a536ab821b9ea241e31d101e54da3e7d33e9211b.zip
FreeBSD-src-a536ab821b9ea241e31d101e54da3e7d33e9211b.tar.gz
MFp4 (imp_freebsd branch): snapshot of devd work:
o improve parsing and lexing o create data structures based on the parsed file now. o Still need to rewrite main loop and add regex (still uses hard coded devd-generic) o minor man page updates. # There should be one more commit before rc2 Approved by: re (blanket)
Diffstat (limited to 'sbin/devd/token.l')
-rw-r--r--sbin/devd/token.l35
1 files changed, 26 insertions, 9 deletions
diff --git a/sbin/devd/token.l b/sbin/devd/token.l
index 233abec..c2b89b9 100644
--- a/sbin/devd/token.l
+++ b/sbin/devd/token.l
@@ -29,6 +29,7 @@
* $FreeBSD$
*/
+#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
@@ -38,6 +39,14 @@
int lineno = 1;
#define YY_NO_UNPUT
+static void
+update_lineno(const char *cp)
+{
+ while (*cp)
+ if (*cp++ == '\n')
+ lineno++;
+}
+
%}
%%
@@ -45,17 +54,30 @@ int lineno = 1;
[ \t]+ ;
\n lineno++;
; { return SEMICOLON; }
+#.*$ ;
\/\/.*$ ;
-\/\*(.|\n)*\*\/ ;
+\/\*(.|\n)*\*\/ { update_lineno(yytext); }
\{ { return BEGINBLOCK; }
\} { return ENDBLOCK; }
[0-9]+ { yylval.i = atoi(yytext); return NUMBER; }
\"[^"]+\" {
+ update_lineno(yytext);
int len = strlen(yytext) - 2;
+ char *walker;
+ int i;
if ((yylval.str = (char *) malloc(len + 1)) == NULL)
goto out;
- memcpy(yylval.str, yytext + 1, len);
- yylval.str[len] = '\0';
+ walker = yylval.str;
+ for (i = 1; i <= len; i++) {
+ if (yytext[i] == '\\' &&
+ yytext[i + 1] == '\n') {
+ i += 2;
+ while(isspace(yytext[i]))
+ i++;
+ }
+ *walker++ = yytext[i];
+ }
+ *walker++ = '\0';
out:;
return STRING;
}
@@ -72,12 +94,7 @@ action { return ACTION; }
match { return MATCH; }
nomatch { return NOMATCH; }
[A-Za-z][A-Za-z0-9-]* {
- int len = strlen(yytext);
- if ((yylval.str = (char *) malloc(len + 1)) == NULL)
- goto out2;
- memcpy(yylval.str, yytext + 1, len);
- yylval.str[len] = '\0';
- out2:;
+ yylval.str = strdup(yytext);
return ID;
}
%%
OpenPOWER on IntegriCloud