Deleted Added
full compact
lang.l (153063) lang.l (169507)
1%{
2/*-
3 * Copyright (c) 1980, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 14 unchanged lines hidden (view full) ---

23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 * @(#)lang.l 8.1 (Berkeley) 6/6/93
1%{
2/*-
3 * Copyright (c) 1980, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 14 unchanged lines hidden (view full) ---

23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 * @(#)lang.l 8.1 (Berkeley) 6/6/93
31 * $FreeBSD: head/usr.sbin/config/lang.l 153063 2005-12-03 20:04:24Z ru $
31 * $FreeBSD: head/usr.sbin/config/lang.l 169507 2007-05-12 19:38:18Z wkoszek $
32 */
33
34#include <assert.h>
35#include <ctype.h>
36#include <string.h>
37#include "y.tab.h"
38#include "config.h"
39

--- 162 unchanged lines hidden (view full) ---

202hex(const char *str)
203{
204 unsigned int num;
205
206 (void) sscanf(str+2, "%x", &num);
207 return num;
208}
209
32 */
33
34#include <assert.h>
35#include <ctype.h>
36#include <string.h>
37#include "y.tab.h"
38#include "config.h"
39

--- 162 unchanged lines hidden (view full) ---

202hex(const char *str)
203{
204 unsigned int num;
205
206 (void) sscanf(str+2, "%x", &num);
207 return num;
208}
209
210void
211cfgfile_add(const char *fname)
212{
213 struct cfgfile *cf;
210
214
215 cf = calloc(1, sizeof(*cf));
216 assert(cf != NULL);
217 asprintf(&cf->cfg_path, "%s", fname);
218 STAILQ_INSERT_TAIL(&cfgfiles, cf, cfg_next);
219}
220
221void
222cfgfile_removeall(void)
223{
224 struct cfgfile *cf;
225
226 while (!STAILQ_EMPTY(&cfgfiles)) {
227 cf = STAILQ_FIRST(&cfgfiles);
228 STAILQ_REMOVE_HEAD(&cfgfiles, cfg_next);
229 if (cf->cfg_path != NULL)
230 free(cf->cfg_path);
231 free(cf);
232 }
233}
234
211/*
212 * Open the named file for inclusion at the current point. Returns 0 on
213 * success (file opened and previous state pushed), nonzero on failure
214 * (fopen failed, complaint made). The `ateof' parameter controls the
215 * token to be inserted at the end of the include file. If ateof == 0,
216 * then nothing is inserted.
217 */
218int
219include(const char *fname, int ateof)
220{
221 FILE *fp;
222 struct incl *in;
223 char *fnamebuf;
224
235/*
236 * Open the named file for inclusion at the current point. Returns 0 on
237 * success (file opened and previous state pushed), nonzero on failure
238 * (fopen failed, complaint made). The `ateof' parameter controls the
239 * token to be inserted at the end of the include file. If ateof == 0,
240 * then nothing is inserted.
241 */
242int
243include(const char *fname, int ateof)
244{
245 FILE *fp;
246 struct incl *in;
247 char *fnamebuf;
248
249 fnamebuf = NULL;
225 fp = fopen(fname, "r");
226 if (fp == NULL && fname[0] != '.' && fname[0] != '/') {
227 asprintf(&fnamebuf, "../../conf/%s", fname);
228 if (fnamebuf != NULL) {
229 fp = fopen(fnamebuf, "r");
230 free(fnamebuf);
231 }
232 }
233 if (fp == NULL) {
234 yyerror("cannot open included file");
235 return (-1);
236 }
250 fp = fopen(fname, "r");
251 if (fp == NULL && fname[0] != '.' && fname[0] != '/') {
252 asprintf(&fnamebuf, "../../conf/%s", fname);
253 if (fnamebuf != NULL) {
254 fp = fopen(fnamebuf, "r");
255 free(fnamebuf);
256 }
257 }
258 if (fp == NULL) {
259 yyerror("cannot open included file");
260 return (-1);
261 }
262 cfgfile_add(fnamebuf == NULL ? fname : fnamebuf);
237 in = malloc(sizeof(*in));
238 assert(in != NULL);
239 in->in_prev = inclp;
240 in->in_buf = YY_CURRENT_BUFFER;
241 in->in_fname = yyfile;
242 in->in_lineno = yyline;
243 in->in_ateof = ateof;
244 inclp = in;

--- 29 unchanged lines hidden ---
263 in = malloc(sizeof(*in));
264 assert(in != NULL);
265 in->in_prev = inclp;
266 in->in_buf = YY_CURRENT_BUFFER;
267 in->in_fname = yyfile;
268 in->in_lineno = yyline;
269 in->in_ateof = ateof;
270 inclp = in;

--- 29 unchanged lines hidden ---