Commit 5b6d433e authored by Roman Zippel's avatar Roman Zippel Committed by Vojtech Pavlik

[PATCH] kconfig update

- fix loading of another configuration
- accept longer strings in configuration
- move conf_filename to mconf.c (it's the only user)
- fix off by one error during string scanning
parent 55182280
......@@ -4,7 +4,6 @@
*/
#include <ctype.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -14,7 +13,6 @@
#include "lkc.h"
const char conf_def_filename[] = ".config";
char conf_filename[PATH_MAX+1];
const char conf_defname[] = "arch/$ARCH/defconfig";
......@@ -61,7 +59,7 @@ char *conf_get_default_confname(void)
int conf_read(const char *name)
{
FILE *in = NULL;
char line[128];
char line[1024];
char *p, *p2;
int lineno = 0;
struct symbol *sym;
......@@ -71,8 +69,6 @@ int conf_read(const char *name)
if (name) {
in = fopen(name, "r");
if (in)
strcpy(conf_filename, name);
} else {
const char **names = conf_confnames;
while ((name = *names++)) {
......@@ -91,21 +87,21 @@ int conf_read(const char *name)
return 1;
for_all_symbols(i, sym) {
sym->flags |= SYMBOL_NEW;
sym->flags |= SYMBOL_NEW | SYMBOL_CHANGED;
sym->flags &= ~SYMBOL_VALID;
switch (sym->type) {
case S_INT:
case S_HEX:
case S_STRING:
if (S_VAL(sym->def)) {
if (S_VAL(sym->def))
free(S_VAL(sym->def));
S_VAL(sym->def) = NULL;
}
default:
;
S_VAL(sym->def) = NULL;
S_TRI(sym->def) = no;
}
}
while (fgets(line, 128, in)) {
while (fgets(line, sizeof(line), in)) {
lineno++;
switch (line[0]) {
case '#':
......@@ -172,13 +168,19 @@ int conf_read(const char *name)
}
memmove(p2, p2 + 1, strlen(p2));
}
if (!p2) {
fprintf(stderr, "%s:%d: invalid string found\n", name, lineno);
exit(1);
}
case S_INT:
case S_HEX:
if (sym_string_valid(sym, p)) {
S_VAL(sym->def) = strdup(p);
sym->flags &= ~SYMBOL_NEW;
} else
fprintf(stderr, "%s:%d:symbol value '%s' invalid for %s\n", name, lineno, p, sym->name);
} else {
fprintf(stderr, "%s:%d: symbol value '%s' invalid for %s\n", name, lineno, p, sym->name);
exit(1);
}
break;
default:
;
......@@ -357,7 +359,6 @@ int conf_write(const char *name)
rename(name, oldname);
if (rename(".tmpconfig", name))
return 1;
strcpy(conf_filename, name);
sym_change_count = 0;
......
......@@ -2206,7 +2206,7 @@ case 48:
YY_RULE_SETUP
#line 164 "zconf.l"
{
append_string(yytext+1, yyleng);
append_string(yytext+1, yyleng - 1);
}
YY_BREAK
case 49:
......
......@@ -11,6 +11,7 @@
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stdlib.h>
......@@ -82,6 +83,7 @@ save_config_help[] =
static char buf[4096], *bufptr = buf;
static char input_buf[4096];
static char filename[PATH_MAX+1] = ".config";
static char *args[1024], **argptr = args;
static int indent = 0;
static struct termios ios_org;
......@@ -661,7 +663,7 @@ static void conf_load(void)
cprint(load_config_text);
cprint("11");
cprint("55");
cprint("%s", conf_filename);
cprint("%s", filename);
stat = exec_conf();
switch(stat) {
case 0:
......@@ -690,7 +692,7 @@ static void conf_save(void)
cprint(save_config_text);
cprint("11");
cprint("55");
cprint("%s", conf_filename);
cprint("%s", filename);
stat = exec_conf();
switch(stat) {
case 0:
......
......@@ -890,6 +890,8 @@ void ConfigView::loadConfig(void)
return;
if (conf_read(s.latin1()))
QMessageBox::information(this, "qconf", "Unable to load configuration!");
configList->updateListAll();
menuList->updateListAll();
}
void ConfigView::saveConfig(void)
......
......@@ -162,7 +162,7 @@ n [A-Za-z0-9_]
return T_STRING;
}
\\.? {
append_string(yytext+1, yyleng);
append_string(yytext+1, yyleng - 1);
}
\'|\" {
if (str == yytext[0]) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment