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