From ee1fe73e110f7009719b6befefd9fabe94672931 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 4 Mar 2008 23:10:38 +0000 Subject: From Craig Silverstein: rework option handling to make it easier to add a new option. --- gold/debug.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'gold/debug.h') diff --git a/gold/debug.h b/gold/debug.h index e37e2f157a3..143c7dfbf1d 100644 --- a/gold/debug.h +++ b/gold/debug.h @@ -36,6 +36,25 @@ const int DEBUG_SCRIPT = 2; const int DEBUG_ALL = DEBUG_TASK | DEBUG_SCRIPT; +// Convert a debug string to the appropriate enum. +inline int +debug_string_to_enum(const char* arg) +{ + static const struct { const char* name; int value; } + debug_options[] = + { + { "task", DEBUG_TASK }, + { "script", DEBUG_SCRIPT }, + { "all", DEBUG_ALL } + }; + + int retval = 0; + for (size_t i = 0; i < sizeof(debug_options) / sizeof(*debug_options); ++i) + if (strstr(arg, debug_options[i].name)) + retval |= debug_options[i].value; + return retval; +} + // Print a debug message if TYPE is enabled. This is a macro so that // we only evaluate the arguments if necessary. -- cgit v1.2.1