X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fstring.c;h=602a7d730074b24ab3e4a5700994c6fe569580d4;hb=3291ba387ddc1e079a63d628b0c1f7f84db6cd1f;hp=454910252f57c70246579e084eb50e96c016befe;hpb=47a0795e8a28e8ad6ff55cda89e300267d9e590c;p=libucw.git diff --git a/lib/string.c b/lib/string.c index 45491025..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: @@ -72,3 +73,18 @@ str_unesc(byte *d, byte *s) *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; +}