]> mj.ucw.cz Git - libucw.git/blobdiff - lib/string.c
Radix sort bit width is now controlled by the configure script.
[libucw.git] / lib / string.c
index 454910252f57c70246579e084eb50e96c016befe..602a7d730074b24ab3e4a5700994c6fe569580d4 100644 (file)
@@ -2,6 +2,7 @@
  *     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.
@@ -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;
+}