From: handa Date: Wed, 15 Aug 2007 11:35:21 +0000 (+0000) Subject: (mdebug__flag): Delete this variable. X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=bfa61586fa44339378e5dd044a5bf311a046e86a;p=m17n%2Fm17n-lib.git (mdebug__flag): Delete this variable. (mdebug__flags): New variable. (SET_DEBUG_FLAG): Make it a function. (m17n_init_core): Set mdebug_flag instead of mdebug_mask. (m17n_fini_core): Likewise. --- diff --git a/src/m17n-core.c b/src/m17n-core.c index 6257ad9..f3744da 100644 --- a/src/m17n-core.c +++ b/src/m17n-core.c @@ -420,7 +420,7 @@ void *(*mdatabase__finder) (MSymbol tag1, MSymbol tag2, MSymbol tag3, MSymbol tag4); void *(*mdatabase__loader) (void *); -int mdebug__flag; +int mdebug__flags[MDEBUG_MAX]; FILE *mdebug__output; void @@ -451,19 +451,25 @@ mdebug__print_time () time_stack[time_stack_index - 1] = tv; } -#define SET_DEBUG_FLAG(env_name, mask) \ - do { \ - char *env_value = getenv (env_name); \ - \ - if (env_value) \ - { \ - if (env_value[0] == '1') \ - mdebug__flag |= (mask); \ - else if (env_value[0] == '0') \ - mdebug__flag &= ~(mask); \ - } \ - } while (0) +static void +SET_DEBUG_FLAG (char *env_name, enum MDebugFlag flag) +{ + char *env_value = getenv (env_name); + if (env_value) + { + int int_value = atoi (env_value); + + if (flag == MDEBUG_ALL) + { + int i; + for (i = 0; i < MDEBUG_MAX; i++) + mdebug__flags[i] = int_value; + } + else + mdebug__flags[flag] = int_value; + } +} void mdebug__add_object_array (M17NObjectArray *array, char *name) @@ -515,7 +521,7 @@ mdebug__unregister_object (M17NObjectArray *array, void *object) void m17n_init_core (void) { - int mdebug_mask = MDEBUG_INIT; + int mdebug_flag = MDEBUG_INIT; merror_code = MERROR_NONE; if (m17n__core_initialized++) @@ -523,7 +529,6 @@ m17n_init_core (void) m17n_memory_full_handler = default_error_handler; - mdebug__flag = 0; SET_DEBUG_FLAG ("MDEBUG_ALL", MDEBUG_ALL); SET_DEBUG_FLAG ("MDEBUG_INIT", MDEBUG_INIT); SET_DEBUG_FLAG ("MDEBUG_FINI", MDEBUG_FINI); @@ -587,7 +592,7 @@ m17n_init_core (void) void m17n_fini_core (void) { - int mdebug_mask = MDEBUG_FINI; + int mdebug_flag = MDEBUG_FINI; if (m17n__core_initialized == 0 || --m17n__core_initialized > 0) @@ -610,7 +615,7 @@ m17n_fini_core (void) MDEBUG_POP_TIME (); MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize the core modules.")); MDEBUG_POP_TIME (); - if (mdebug__flag & MDEBUG_FINI) + if (mdebug__flags[MDEBUG_FINI]) report_object_array (); msymbol__free_table (); if (mdebug__output != stderr)