I've moved format_flags() from idxdump to libucw and used it where possible.
I've also unified the direction in which flag bits are printed, so the order
of the state flags has changed [but I don't think anything relies on it].
/* string.c */
byte *str_unesc(byte *dest, byte *src);
+byte *str_format_flags(byte *dest, const byte *fmt, uns flags);
/* bigalloc.c */
* UCW Library -- String Routines
*
* (c) 2006 Pavel Charvat <pchar@ucw.cz>
+ * (c) 2007 Martin Mares <mj@ucw.cz>
*
* This software may be freely distributed and used according to the terms
* of the GNU Lesser General Public License.
*d = 0;
return d;
}
+
+byte *
+str_format_flags(byte *dest, const byte *fmt, uns flags)
+{
+ byte *start = dest;
+ for (uns i=0; fmt[i]; i++)
+ {
+ if (flags & (1 << i))
+ *dest++ = fmt[i];
+ else
+ *dest++ = '-';
+ }
+ *dest = 0;
+ return start;
+}