4 struct buffer
*current_buf
;
6 /*********************************************************************
8 *********************************************************************/
10 /* this buffer released in gmr parser code. */
11 void zconf_starthelp(void)
13 // do not alloc buff in command.
14 // new_string(&strbuff);
18 void zconf_endhelp(void)
20 yylval
.string
= strbuff
.text
;
26 * Try to open specified file with following names:
29 * The latter is used when srctree is separate from objtree
30 * when compiling the kernel.
31 * Return NULL if file is not found.
33 FILE *zconf_fopen(const char *name
)
35 char *env
, fullname
[PATH_MAX
+1];
39 if (!f
&& name
!= NULL
&& name
[0] != '/') {
40 env
= getenv(SRCTREE
);
42 sprintf(fullname
, "%s/%s", env
, name
);
43 f
= fopen(fullname
, "r");
49 void zconf_initscan(const char *name
)
51 yyin
= zconf_fopen(name
);
53 fprintf(stderr
, "can't find file %s\n", name
);
57 current_buf
= xmalloc(sizeof(*current_buf
));
58 memset(current_buf
, 0, sizeof(*current_buf
));
60 current_file
= file_lookup(name
);
64 void zconf_nextfile(const char *name
)
67 struct file
*file
= file_lookup(name
);
68 struct buffer
*buf
= xmalloc(sizeof(*buf
));
69 memset(buf
, 0, sizeof(*buf
));
71 current_buf
->state
= YY_CURRENT_BUFFER
;
72 yyin
= zconf_fopen(file
->name
);
74 fprintf(stderr
, "%s:%d: can't open file \"%s\"\n",
75 zconf_curname(), zconf_lineno(), file
->name
);
78 yy_switch_to_buffer(yy_create_buffer(yyin
, YY_BUF_SIZE
));
79 buf
->parent
= current_buf
;
82 current_file
->lineno
= yylineno
;
83 file
->parent
= current_file
;
85 for (iter
= current_file
; iter
; iter
= iter
->parent
) {
86 if (!strcmp(iter
->name
, file
->name
)) {
88 "Recursive inclusion detected.\n"
90 " current file : %s\n", file
->name
);
94 fprintf(stderr
, " included from: %s:%d\n",
95 iter
->name
, iter
->lineno
- 1);
96 } while (strcmp(iter
->name
, file
->name
));
105 void zconf_endfile(void)
107 struct buffer
*parent
;
109 current_file
= current_file
->parent
;
111 yylineno
= current_file
->lineno
;
113 parent
= current_buf
->parent
;
116 yy_delete_buffer(YY_CURRENT_BUFFER
);
117 yy_switch_to_buffer(parent
->state
);
120 current_buf
= parent
;
123 int zconf_lineno(void)
125 return current_pos
.lineno
;
128 const char *zconf_curname(void)
130 return current_pos
.file
? current_pos
.file
->name
: "<none>";
135 void zconf_endfile(void)