debug: add noprefix version of debug_dump_enum
authorKeith Whitwell <keith@tungstengraphics.com>
Sat, 17 Jan 2009 18:45:20 +0000 (18:45 +0000)
committerKeith Whitwell <keith@tungstengraphics.com>
Sat, 17 Jan 2009 18:45:20 +0000 (18:45 +0000)
src/gallium/auxiliary/util/p_debug.c
src/gallium/include/pipe/p_debug.h

index acdfa21..f373f94 100644 (file)
@@ -406,6 +406,32 @@ debug_dump_enum(const struct debug_named_value *names,
 
 
 const char *
+debug_dump_enum_noprefix(const struct debug_named_value *names, 
+                         const char *prefix,
+                         unsigned long value)
+{
+   static char rest[64];
+   
+   while(names->name) {
+      if(names->value == value) {
+         const char *name = names->name;
+         while (*name == *prefix) {
+            name++;
+            prefix++;
+         }
+         return name;
+      }
+      ++names;
+   }
+
+   
+
+   util_snprintf(rest, sizeof(rest), "0x%08lx", value);
+   return rest;
+}
+
+
+const char *
 debug_dump_flags(const struct debug_named_value *names, 
                  unsigned long value)
 {
index 3b00fb9..e9c9598 100644 (file)
@@ -261,6 +261,11 @@ const char *
 debug_dump_enum(const struct debug_named_value *names, 
                 unsigned long value);
 
+const char *
+debug_dump_enum_noprefix(const struct debug_named_value *names, 
+                         const char *prefix,
+                         unsigned long value);
+
 
 /**
  * Convert binary flags value to a string.