]>
diplodocus.org Git - nmh/blob - sbr/concat.c
d603d4258cfaedfd39d5f5fa4d75393b56e06ff8
2 * concat.c -- concatenate a variable number (minimum of 1)
3 * of strings in managed memory
5 * This code is Copyright (c) 2002, by the authors of nmh. See the
6 * COPYRIGHT file in the root directory of the nmh distribution for
7 * complete copyright information.
14 /* concat returns a non-NULL malloc'd pointer to the catenation of the
15 * argument strings less their NUL terminators other than the last. The
16 * arguments are terminated by a NULL.
18 * Example: concat("abc", "def", "", "g", NULL) returns "abcdefg". */
20 concat (const char *s1
, ...)
26 len
= strlen (s1
) + 1;
28 while ((cp
= va_arg(list
, char *)))
32 dp
= sp
= mh_xmalloc(len
);
37 while ((cp
= va_arg (list
, char *)))