* 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.
/* Expands C99-like escape sequences.
* It is safe to use the same buffer for both input and output. */
-byte *
-str_unesc(byte *d, byte *s)
+char *
+str_unesc(char *d, const char *s)
{
while (*s)
{
*d++ = v;
else
DBG("hex escape sequence out of range");
- s = (byte *)p;
+ s = (char *)p;
}
break;
default:
*d = 0;
return d;
}
+
+char *
+str_format_flags(char *dest, const char *fmt, uns flags)
+{
+ char *start = dest;
+ for (uns i=0; fmt[i]; i++)
+ {
+ if (flags & (1 << i))
+ *dest++ = fmt[i];
+ else
+ *dest++ = '-';
+ }
+ *dest = 0;
+ return start;
+}