]> mj.ucw.cz Git - libucw.git/blobdiff - lib/stkstring.c
Merge with git+ssh://cvs.ucw.cz/projects/sherlock/GIT/sherlock.git
[libucw.git] / lib / stkstring.c
index c7ac9ef5b75f528eef06862510a304c94a299a91..eaeacf00f7c950aaf27de5aefa570bf58d395f6d 100644 (file)
@@ -13,7 +13,7 @@ stk_array_len(char **s, uns cnt)
 }
 
 void
-stk_array_copy(char *x, char **s, uns cnt)
+stk_array_join(char *x, char **s, uns cnt, uns sep)
 {
   while (cnt--)
     {
@@ -21,6 +21,8 @@ stk_array_copy(char *x, char **s, uns cnt)
       memcpy(x, *s, l);
       x += l;
       s++;
+      if (sep && cnt)
+       *x++ = sep;
     }
   *x = 0;
 }
@@ -72,14 +74,16 @@ stk_hexdump_internal(char *dst, byte *src, uns n)
 
 int main(void)
 {
-  char *a = stk_strdup("are");
+  char *a = stk_strndup("are!",3);
   a = stk_strcat(a, " the ");
-  a = stk_strmulticat(a, "Jabberwock, ", "my", NULL);
+  a = stk_strmulticat(a, stk_strdup("Jabberwock, "), "my", NULL);
   char *arr[] = { a, " son" };
   a = stk_strarraycat(arr, 2);
   a = stk_printf("Bew%s!", a);
   puts(a);
   puts(stk_hexdump(a, 3));
+  char *ary[] = { "The", "jaws", "that", "bite" };
+  puts(stk_strjoin(ary, 4, ' '));
   return 0;
 }