i've been pondering this idea for a while and, recently, simon
arlott posted a patch on LKML, which i simplified slightly and it's
shown below, but it's obviously broken somehow:

$ make menuconfig
...
bison -l -b scripts/kconfig/zconf -p zconf scripts/kconfig/zconf.y
scripts/kconfig/zconf.y: conflicts: 28 shift/reduce
scripts/kconfig/zconf.y: expected 26 shift/reduce conflicts
make[1]: *** [scripts/kconfig/zconf.tab.c] Error 1
make: *** [menuconfig] Error 2

  all i'm trying to do is support this new directive in a Kconfig
entry:

        maturity DEPRECATED     (or ...)
        maturity OBSOLETE

and that's it for now -- two levels of maturity (which, some day, will
be extended to include EXPERIMENTAL but that can be avoided for now.)

  i'm not trying to *use* this new directive yet, just trying to
define so that it can be added to an entry and will display when you
run "make config" or "make menuconfig", that's all.  i'm not a
yacc/lex expert so if someone who is can take a look at this and
figure out what i've screwed up, i'd appreciate it.

p.s.  most of this is fairly clear, but i'm still not sure what that
extra code in "symbol.c" is doing with "sym_lookup".  again, any
advice would be appreciated.

---

 scripts/kconfig/Makefile    |    2 +-
 scripts/kconfig/conf.c      |   13 +++++++++++++
 scripts/kconfig/expr.h      |    7 ++++++-
 scripts/kconfig/lkc.h       |    1 +
 scripts/kconfig/mconf.c     |   15 +++++++++++++++
 scripts/kconfig/menu.c      |    9 +++++++++
 scripts/kconfig/symbol.c    |   11 +++++++++++
 scripts/kconfig/zconf.gperf |    1 +
 scripts/kconfig/zconf.y     |   24 ++++++++++++++++++++++--
 9 files changed, 79 insertions(+), 4 deletions(-)

diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 8986a48..0426636 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -257,7 +257,7 @@ $(obj)/lkc_defs.h: $(src)/lkc_proto.h
 # The following requires flex/bison/gperf
 # By default we use the _shipped versions, uncomment the following line if
 # you are modifying the flex/bison src.
-# LKC_GENPARSER := 1
+LKC_GENPARSER := 1

 ifdef LKC_GENPARSER

diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 1199baf..373483a 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -211,8 +211,21 @@ static int conf_sym(struct menu *menu)

        while (1) {
                printf("%*s%s ", indent - 1, "", menu->prompt->text);
+
                if (sym->name)
                        printf("(%s) ", sym->name);
+
+               switch (sym->maturity) {
+                       case M_DEPRECATED:
+                               printf("(DEPRECATED) ");
+                               break;
+                       case M_OBSOLETE:
+                               printf("(OBSOLETE) ");
+                               break;
+                       default:
+                               break;
+               }
+
                type = sym_get_type(sym);
                putchar('[');
                oldval = sym_get_tristate_value(sym);
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index 6084525..3dd7957 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -60,7 +60,11 @@ struct symbol_value {
 };

 enum symbol_type {
-       S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER
+       S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_MATURITY, 
S_OTHER
+};
+
+enum maturity_level {
+       M_NONE, M_DEPRECATED, M_OBSOLETE
 };

 enum {
@@ -72,6 +76,7 @@ struct symbol {
        struct symbol *next;
        char *name;
        char *help;
+       enum maturity_level maturity;
        enum symbol_type type;
        struct symbol_value curr;
        struct symbol_value def[4];
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index 8a07ee4..9add1cd 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -79,6 +79,7 @@ void menu_end_menu(void);
 void menu_add_entry(struct symbol *sym);
 void menu_end_entry(void);
 void menu_add_dep(struct expr *dep);
+void menu_set_maturity(struct symbol *sym);
 struct property *menu_add_prop(enum prop_type type, char *prompt, struct expr 
*expr, struct expr *dep);
 struct property *menu_add_prompt(enum prop_type type, char *prompt, struct 
expr *dep);
 void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep);
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index d2c2a42..88768ed 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -359,6 +359,21 @@ static void get_symbol_str(struct gstr *r, struct symbol 
*sym)

        str_printf(r, "Symbol: %s [=%s]\n", sym->name,
                                       sym_get_string_value(sym));
+
+       if (sym->maturity != M_NONE) {
+               str_append(r, "Maturity: ");
+               switch (sym->maturity) {
+                       case M_DEPRECATED:
+                               str_append(r, "DEPRECATED\n");
+                               break;
+                       case M_OBSOLETE:
+                               str_append(r, "OBSOLETE\n");
+                               break;
+                       default:
+                               break;
+               }
+       }
+
        for_all_prompts(sym, prop)
                get_prompt_str(r, prop);
        hit = false;
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index f14aeac..3e37e5b 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -104,6 +104,15 @@ void menu_add_dep(struct expr *dep)
        current_entry->dep = expr_alloc_and(current_entry->dep, 
menu_check_dep(dep));
 }

+void menu_set_maturity(struct symbol *sym)
+{
+       if (sym->type != S_MATURITY) {
+               zconf_error("'%s' is an invalid maturity level", sym->name);
+       } else {
+               current_entry->sym->maturity = sym->maturity;
+       }
+}
+
 void menu_set_type(int type)
 {
        struct symbol *sym = current_entry->sym;
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index c35dcc5..8a3cc02 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -72,6 +72,14 @@ void sym_init(void)
        sym->type = S_STRING;
        sym->flags |= SYMBOL_AUTO;
        sym_add_default(sym, uts.release);
+
+       sym = sym_lookup("_DEPRECATED", 0);
+       sym->type = S_MATURITY;
+       sym->maturity = M_DEPRECATED;
+
+       sym = sym_lookup("_OBSOLETE", 0);
+       sym->type = S_MATURITY;
+       sym->maturity = M_OBSOLETE;
 }

 enum symbol_type sym_get_type(struct symbol *sym)
@@ -100,6 +108,8 @@ const char *sym_type_name(enum symbol_type type)
                return "hex";
        case S_STRING:
                return "string";
+       case S_MATURITY:
+               return "maturity";
        case S_UNKNOWN:
                return "unknown";
        case S_OTHER:
@@ -679,6 +689,7 @@ struct symbol *sym_lookup(const char *name, int isconst)
        memset(symbol, 0, sizeof(*symbol));
        symbol->name = new_name;
        symbol->type = S_UNKNOWN;
+       symbol->maturity = M_NONE;
        if (isconst)
                symbol->flags |= SYMBOL_CONST;

diff --git a/scripts/kconfig/zconf.gperf b/scripts/kconfig/zconf.gperf
index 9b44c80..756d559 100644
--- a/scripts/kconfig/zconf.gperf
+++ b/scripts/kconfig/zconf.gperf
@@ -25,6 +25,7 @@ endif,                T_ENDIF,        TF_COMMAND
 depends,       T_DEPENDS,      TF_COMMAND
 requires,      T_REQUIRES,     TF_COMMAND
 optional,      T_OPTIONAL,     TF_COMMAND
+maturity,      T_MATURITY,     TF_COMMAND
 default,       T_DEFAULT,      TF_COMMAND, S_UNKNOWN
 prompt,                T_PROMPT,       TF_COMMAND
 tristate,      T_TYPE,         TF_COMMAND, S_TRISTATE
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
index 92eb02b..1b47966 100644
--- a/scripts/kconfig/zconf.y
+++ b/scripts/kconfig/zconf.y
@@ -66,6 +66,7 @@ static struct menu *current_menu, *current_entry;
 %token <id>T_DEPENDS
 %token <id>T_REQUIRES
 %token <id>T_OPTIONAL
+%token <id>T_MATURITY
 %token <id>T_PROMPT
 %token <id>T_TYPE
 %token <id>T_DEFAULT
@@ -120,7 +121,7 @@ stmt_list:
 ;

 option_name:
-       T_DEPENDS | T_PROMPT | T_TYPE | T_SELECT | T_OPTIONAL | T_RANGE | 
T_DEFAULT
+       T_DEPENDS | T_MATURITY | T_PROMPT | T_TYPE | T_SELECT | T_OPTIONAL | 
T_RANGE | T_DEFAULT
 ;

 common_stmt:
@@ -177,6 +178,7 @@ config_option_list:
        | config_option_list config_option
        | config_option_list symbol_option
        | config_option_list depends
+       | config_option_list maturity
        | config_option_list help
        | config_option_list option_error
        | config_option_list T_EOL
@@ -269,6 +271,7 @@ choice_option_list:
          /* empty */
        | choice_option_list choice_option
        | choice_option_list depends
+       | choice_option_list maturity
        | choice_option_list help
        | choice_option_list T_EOL
        | choice_option_list option_error
@@ -349,7 +352,7 @@ menu: T_MENU prompt T_EOL
        printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno());
 };

-menu_entry: menu depends_list
+menu_entry: menu maturity_set_opt depends_list
 {
        $$ = menu_add_menu();
 };
@@ -430,6 +433,19 @@ depends: T_DEPENDS T_ON expr T_EOL
        printd(DEBUG_PARSE, "%s:%d:requires\n", zconf_curname(), 
zconf_lineno());
 };

+/* maturity setting */
+
+maturity_set_opt:
+         /* empty */
+       | maturity
+;
+
+maturity: T_MATURITY symbol T_EOL
+{
+       menu_set_maturity($2);
+       printd(DEBUG_PARSE, "%s:%d:maturity\n", zconf_curname(), 
zconf_lineno());
+};
+
 /* prompt statement */

 prompt_stmt_opt:
@@ -519,6 +535,7 @@ const char *zconf_tokenname(int token)
        case T_IF:              return "if";
        case T_ENDIF:           return "endif";
        case T_DEPENDS:         return "depends";
+       case T_MATURITY:        return "maturity";
        }
        return "<token>";
 }
@@ -615,6 +632,9 @@ void print_symbol(FILE *out, struct menu *menu)
        case S_HEX:
                fputs("  hex\n", out);
                break;
+       case S_MATURITY:
+               fputs("  maturity\n", out);
+               break;
        default:
                fputs("  ???\n", out);
                break;
-- 
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://fsdev.net/wiki/index.php?title=Main_Page
========================================================================

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [EMAIL PROTECTED]
Please read the FAQ at http://kernelnewbies.org/FAQ

Reply via email to