From 9b736ef9e62df55e151501d1c3cfd515c7980b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Sun, 24 Oct 2004 09:38:41 +0000 Subject: [PATCH] If the file specified in an "include" line does not exist in the current directory, and its name does not begin with a period or a forward slash, go look for it in ../../conf. Wished for by: scottl MFC after: 2 weeks --- usr.sbin/config/lang.l | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/usr.sbin/config/lang.l b/usr.sbin/config/lang.l index 801d5082a859..f43322068d3a 100644 --- a/usr.sbin/config/lang.l +++ b/usr.sbin/config/lang.l @@ -215,10 +215,18 @@ include(const char *fname, int ateof) { FILE *fp; struct incl *in; + char *fnamebuf; fp = fopen(fname, "r"); + if (fp == NULL && fname[0] != '.' && fname[0] != '/') { + asprintf(&fnamebuf, "../../conf/%s", fname); + if (fnamebuf != NULL) { + fp = fopen(fnamebuf, "r"); + free(fnamebuf); + } + } if (fp == NULL) { - yyerror("cannot open file"); + yyerror("cannot open included file"); return (-1); } in = malloc(sizeof(*in));