From 0f9583b69bc46ef52c4660cd3b4f6eb39af20aae Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sun, 14 Apr 2013 10:12:36 +0200 Subject: [PATCH] muscle: factor the handling of used variables * src/muscle-tab.c (muscle_percent_define_use): New, corresponding to b4_percent_define_use. Use it where appropriate. --- src/muscle-tab.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/muscle-tab.c b/src/muscle-tab.c index d666824b..bd75a7de 100644 --- a/src/muscle-tab.c +++ b/src/muscle-tab.c @@ -550,16 +550,21 @@ muscle_percent_define_ensure (char const *variable, location loc, MUSCLE_PERCENT_DEFINE_GRAMMAR_FILE); } +/* Mark %define VARIABLE as used. */ +static void +muscle_percent_define_use (char const *variable) +{ + muscle_insert (muscle_name (variable, "bison_variables"), ""); +} + char * muscle_percent_define_get (char const *variable) { uniqstr name = muscle_name (variable, NULL); - uniqstr usage_name = muscle_name (variable, "bison_variables"); char *value = string_decode (name); if (!value) value = xstrdup (""); - - muscle_insert (usage_name, ""); + muscle_percent_define_use (variable); return value; } @@ -587,15 +592,13 @@ muscle_percent_define_get_syncline (char const *variable) bool muscle_percent_define_ifdef (char const *variable) { - char const *value = muscle_find_const (muscle_name (variable, NULL)); - if (value) + if (muscle_find_const (muscle_name (variable, NULL))) { - uniqstr usage_name = muscle_name (variable, "bison_variables"); - muscle_insert (usage_name, ""); + muscle_percent_define_use (variable); return true; } - - return false; + else + return false; } bool -- 2.45.2