diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2001-04-16 21:07:33 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2001-04-16 21:07:33 +0000 |
commit | 62c24f315bd8fba0c72e4af4076cfb6985d57c1b (patch) | |
tree | 382d5c499c34a92070a2bb4e046175f1cf7ab583 | |
parent | a2ade36eb1905bf8ead7143fa1ec8170579552f5 (diff) |
return hex string for unknown tokens in _mesa_lookup_enum_by_nr()
-rw-r--r-- | src/mesa/main/enums.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/mesa/main/enums.c b/src/mesa/main/enums.c index 1801a4e499..7b6dd53f02 100644 --- a/src/mesa/main/enums.c +++ b/src/mesa/main/enums.c @@ -1,4 +1,4 @@ -/* $Id: enums.c,v 1.16 2001/03/26 19:42:40 brianp Exp $ */ +/* $Id: enums.c,v 1.17 2001/04/16 21:07:33 brianp Exp $ */ /* * Mesa 3-D graphics library @@ -902,6 +902,8 @@ int _mesa_lookup_enum_by_name( const char *symbol ) } +static char token_tmp[20]; + const char *_mesa_lookup_enum_by_nr( int nr ) { enum_elt tmp, *e, **f; @@ -915,5 +917,12 @@ const char *_mesa_lookup_enum_by_nr( int nr ) f = (enum_elt **)bsearch( &e, index1, Elements(all_enums), sizeof(*index1), (cfunc) compar_nr ); - return f ? (*f)->c : "(unknown)"; + if (f) { + return (*f)->c; + } + else { + /* this isn't re-entrant safe, no big deal here */ + sprintf(token_tmp, "0x%x\n", nr); + return token_tmp; + } } |