]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] kconfig update
authorRoman Zippel <zippel@linux-m68k.org>
Sat, 9 Nov 2002 04:26:20 +0000 (20:26 -0800)
committerVojtech Pavlik <vojtech@suse.cz>
Sat, 9 Nov 2002 04:26:20 +0000 (20:26 -0800)
- 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

scripts/kconfig/confdata.c
scripts/kconfig/lex.zconf.c_shipped
scripts/kconfig/mconf.c
scripts/kconfig/qconf.cc
scripts/kconfig/zconf.l

index da174a396489e140c1d4520374a7e4a1cb70c37d..5add21f155b0d0ef9bb75566c8a4596b25d527e4 100644 (file)
@@ -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;
 
index 18eea3015bd22d8e68f41e5b5794bc518b560a64..414b8d359bb30167b6fa631ce07f8a199fb611a6 100644 (file)
@@ -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:
index 1ac145e6866b8eb9fb539d541cb3504c590f0589..30148873184cecef5d31eb4cc4b9d12eb9e4677f 100644 (file)
@@ -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:
index c304757597b2cf4969caae95ea07adf98cdf6857..c47344dd18ce40ec3289c3ad99ec23f23ef07e01 100644 (file)
@@ -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)
index a412bf411240a31f62107c5f1c54724b12199a84..0c3268e077372a25ca684f9c0d86960e0c238c67 100644 (file)
@@ -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]) {