summaryrefslogtreecommitdiffstats
path: root/usr.sbin/config/config.y
diff options
context:
space:
mode:
authordd <dd@FreeBSD.org>2001-07-12 02:08:51 +0000
committerdd <dd@FreeBSD.org>2001-07-12 02:08:51 +0000
commitb5164c6585fabc3c848ff92ada3f6ffb64a9e8f2 (patch)
tree6e5c6a1c595fde5e5c90b1af74b8c2880c887a37 /usr.sbin/config/config.y
parent93faa5d597dce09f52a652cb24242bd11e6b6682 (diff)
downloadFreeBSD-src-b5164c6585fabc3c848ff92ada3f6ffb64a9e8f2.zip
FreeBSD-src-b5164c6585fabc3c848ff92ada3f6ffb64a9e8f2.tar.gz
Introduce an "include" directive. It takes one argument, a filename
to be included into this one. This works the same way as #include does in C; as far as the user is concerned, the included file is inlined into the current one. Since config(8) is no longer limited to working on one user-supplied file, printing just a line number in an error message is not sufficient. The new global variable yyfile represents the file currently being parsed, and must be printed as well. Reviewed by: imp Obtained from: OpenBSD
Diffstat (limited to 'usr.sbin/config/config.y')
-rw-r--r--usr.sbin/config/config.y23
1 files changed, 15 insertions, 8 deletions
diff --git a/usr.sbin/config/config.y b/usr.sbin/config/config.y
index 96e57d9..5f15774 100644
--- a/usr.sbin/config/config.y
+++ b/usr.sbin/config/config.y
@@ -17,6 +17,7 @@
%token OPTIONS
%token MAKEOPTIONS
%token SEMICOLON
+%token INCLUDE
%token <str> ID
%token <val> NUMBER
@@ -77,13 +78,14 @@ char *ident;
char *hints;
int hintmode;
int yyline;
+const char *yyfile;
struct file_list *ftab;
char errbuf[80];
int maxusers;
#define ns(s) strdup(s)
-
-static void yyerror(const char *s);
+int include(const char *, int);
+void yyerror(const char *s);
static char *
devopt(char *dev)
@@ -147,11 +149,14 @@ Config_spec:
= {
hints = $2;
hintmode = 1;
- };
+ } |
+ INCLUDE ID
+ = { include($2, 0); };
System_spec:
CONFIG System_id System_parameter_list
- = { errx(1, "line %d: root/dump/swap specifications obsolete", yyline);}
+ = { errx(1, "%s:%d: root/dump/swap specifications obsolete",
+ yyfile, yyline);}
|
CONFIG System_id
;
@@ -178,7 +183,8 @@ Option:
newopt(&opt, $1, NULL);
if ((s = strchr($1, '=')))
- errx(1, "line %d: The `=' in options should not be quoted", yyline);
+ errx(1, "%s:%d: The `=' in options should not be "
+ "quoted", yyfile, yyline);
} |
Save_id EQUALS Opt_value
= {
@@ -229,16 +235,17 @@ Device_spec:
/* and the device part */
newdev($2, $3);
if ($3 == 0)
- errx(1, "line %d: devices with zero units are not likely to be correct", yyline);
+ errx(1, "%s:%d: devices with zero units are not "
+ "likely to be correct", yyfile, yyline);
} ;
%%
-static void
+void
yyerror(const char *s)
{
- errx(1, "line %d: %s", yyline + 1, s);
+ errx(1, "%s:%d: %s", yyfile, yyline + 1, s);
}
/*
OpenPOWER on IntegriCloud