diff --git a/tools/qfcc/include/set.h b/tools/qfcc/include/set.h index 658839909..904fa4ad0 100644 --- a/tools/qfcc/include/set.h +++ b/tools/qfcc/include/set.h @@ -59,6 +59,7 @@ int set_is_intersecting (const set_t *s1, const set_t *s2); int set_is_equivalent (const set_t *s1, const set_t *s2); int set_is_subset (const set_t *set, const set_t *sub); int set_is_member (const set_t *set, unsigned x); +const char *set_as_string (const set_t *set); //@} #endif//set_h diff --git a/tools/qfcc/source/set.c b/tools/qfcc/source/set.c index 2a68422a6..9458319c0 100644 --- a/tools/qfcc/source/set.c +++ b/tools/qfcc/source/set.c @@ -40,6 +40,7 @@ #include +#include "QF/dstring.h" #include "QF/mathlib.h" #include "set.h" @@ -243,3 +244,23 @@ set_is_member (const set_t *set, unsigned x) return 0; return (set->map[x / BITS] & (1 << (x % BITS))) != 0; } + +const char * +set_as_string (const set_t *set) +{ + static dstring_t *str; + unsigned i; + + if (!str) + str = dstring_new (); + dstring_clearstr (str); + for (i = 0; i < set->size; i++) { + if (set_is_member (set, i)) { + if (str->str[0]) + dasprintf (str, " %d", i); + else + dsprintf (str, "%d", i); + } + } + return str->str; +}