X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fstring.c;h=602a7d730074b24ab3e4a5700994c6fe569580d4;hb=3bb641c18d60f38d6e646211aa5c6a4b63ba9180;hp=6a1f1d2da432b7a05855c860c7f605cb8d9aca5f;hpb=44209a159f54dece08a023928f1d87adfe0d9e6a;p=libucw.git diff --git a/lib/string.c b/lib/string.c index 6a1f1d2d..602a7d73 100644 --- a/lib/string.c +++ b/lib/string.c @@ -2,6 +2,7 @@ * UCW Library -- String Routines * * (c) 2006 Pavel Charvat + * (c) 2007 Martin Mares * * This software may be freely distributed and used according to the terms * of the GNU Lesser General Public License. @@ -15,8 +16,8 @@ /* 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) { @@ -48,7 +49,7 @@ str_unesc(byte *d, byte *s) *d++ = v; else DBG("hex escape sequence out of range"); - s = (byte *)p; + s = (char *)p; } break; default: @@ -73,3 +74,17 @@ str_unesc(byte *d, byte *s) 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; +}