End my resistance to jmg's multiple hints files and bring in support
for having multiple hints files generate a correct hints.c (eg, with all the specified ones catenated together).
This commit is contained in:
parent
55659bb594
commit
86418d0cef
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=163638
@ -127,9 +127,15 @@ struct opt_list {
|
||||
|
||||
SLIST_HEAD(, opt_list) otab;
|
||||
|
||||
struct hint {
|
||||
char *hint_name;
|
||||
STAILQ_ENTRY(hint) hint_next;
|
||||
};
|
||||
|
||||
STAILQ_HEAD(hint_head, hint) hints;
|
||||
|
||||
extern char *ident;
|
||||
extern char *env;
|
||||
extern char *hints;
|
||||
extern int do_trace;
|
||||
extern int envmode;
|
||||
extern int hintmode;
|
||||
|
@ -81,7 +81,6 @@ struct device_head dtab;
|
||||
char *ident;
|
||||
char *env;
|
||||
int envmode;
|
||||
char *hints;
|
||||
int hintmode;
|
||||
int yyline;
|
||||
const char *yyfile;
|
||||
@ -191,10 +190,11 @@ Config_spec:
|
||||
} |
|
||||
HINTS ID
|
||||
= {
|
||||
if (hints != NULL)
|
||||
errx(1, "More than one 'hints' line at %s:%d", yyfile,
|
||||
yyline);
|
||||
hints = $2;
|
||||
struct hint *hint;
|
||||
|
||||
hint = (struct hint *)calloc(1, sizeof (struct hint));
|
||||
hint->hint_name = $2;
|
||||
STAILQ_INSERT_TAIL(&hints, hint, hint_next);
|
||||
hintmode = 1;
|
||||
}
|
||||
|
||||
|
@ -160,6 +160,7 @@ main(int argc, char **argv)
|
||||
STAILQ_INIT(&fntab);
|
||||
SLIST_INIT(&cputype);
|
||||
STAILQ_INIT(&ftab);
|
||||
STAILQ_INIT(&hints);
|
||||
if (yyparse())
|
||||
exit(3);
|
||||
|
||||
|
@ -182,17 +182,11 @@ makefile(void)
|
||||
void
|
||||
makehints(void)
|
||||
{
|
||||
FILE *ifp, *ofp;
|
||||
FILE *ifp = NULL, *ofp;
|
||||
char line[BUFSIZ];
|
||||
char *s;
|
||||
struct hint *hint;
|
||||
|
||||
if (hints) {
|
||||
ifp = fopen(hints, "r");
|
||||
if (ifp == NULL)
|
||||
err(1, "%s", hints);
|
||||
} else {
|
||||
ifp = NULL;
|
||||
}
|
||||
ofp = fopen(path("hints.c.new"), "w");
|
||||
if (ofp == NULL)
|
||||
err(1, "%s", path("hints.c.new"));
|
||||
@ -201,7 +195,10 @@ makehints(void)
|
||||
fprintf(ofp, "\n");
|
||||
fprintf(ofp, "int hintmode = %d;\n", hintmode);
|
||||
fprintf(ofp, "char static_hints[] = {\n");
|
||||
if (ifp) {
|
||||
STAILQ_FOREACH(hint, &hints, hint_next) {
|
||||
ifp = fopen(hint->hint_name, "r");
|
||||
if (ifp == NULL)
|
||||
err(1, "%s", hint->hint_name);
|
||||
while (fgets(line, BUFSIZ, ifp) != 0) {
|
||||
/* zap trailing CR and/or LF */
|
||||
while ((s = rindex(line, '\n')) != NULL)
|
||||
|
Loading…
Reference in New Issue
Block a user