1 /* GLIB - Library of useful routines for C programming
2 * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GLib Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GLib Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GLib at ftp://ftp.gtk.org/pub/gtk/.
35 #define _GNU_SOURCE /* For stpcpy */
42 #include <ctype.h> /* For tolower() */
43 #if !defined (HAVE_STRSIGNAL) || !defined(NO_SYS_SIGLIST_DECL)
52 /* do not include <unistd.h> in this place since it
53 * inteferes with g_strsignal() on some OSes
57 g_strdup (const gchar *str)
63 new_str = g_new (char, strlen (str) + 1);
64 strcpy (new_str, str);
73 g_memdup (gconstpointer mem,
80 new_mem = g_malloc (byte_size);
81 memcpy (new_mem, mem, byte_size);
90 g_strndup (const gchar *str,
97 new_str = g_new (gchar, n + 1);
98 strncpy (new_str, str, n);
108 g_strnfill (guint length,
111 register gchar *str, *s, *end;
113 str = g_new (gchar, length + 1);
125 * @dest: destination buffer
126 * @src: source string
128 * Copies a nul-terminated string into the dest buffer, include the
129 * trailing nul, and return a pointer to the trailing nul byte.
130 * This is useful for concatenating multiple strings together
131 * without having to repeatedly scan for the end.
133 * Return value: a pointer to trailing nul byte.
136 g_stpcpy (gchar *dest,
140 g_return_val_if_fail (dest != NULL, NULL);
141 g_return_val_if_fail (src != NULL, NULL);
142 return stpcpy (dest, src);
144 register gchar *d = dest;
145 register const gchar *s = src;
147 g_return_val_if_fail (dest != NULL, NULL);
148 g_return_val_if_fail (src != NULL, NULL);
151 while (*s++ != '\0');
158 g_strdup_vprintf (const gchar *format,
164 G_VA_COPY (args2, args1);
166 buffer = g_new (gchar, g_printf_string_upper_bound (format, args1));
168 vsprintf (buffer, format, args2);
175 g_strdup_printf (const gchar *format,
181 va_start (args, format);
182 buffer = g_strdup_vprintf (format, args);
189 g_strconcat (const gchar *string1, ...)
197 g_return_val_if_fail (string1 != NULL, NULL);
199 l = 1 + strlen (string1);
200 va_start (args, string1);
201 s = va_arg (args, gchar*);
205 s = va_arg (args, gchar*);
209 concat = g_new (gchar, l);
212 ptr = g_stpcpy (ptr, string1);
213 va_start (args, string1);
214 s = va_arg (args, gchar*);
218 s = va_arg (args, gchar*);
226 g_strtod (const gchar *nptr,
234 g_return_val_if_fail (nptr != NULL, 0);
239 val_1 = strtod (nptr, &fail_pos_1);
241 if (fail_pos_1 && fail_pos_1[0] != 0)
245 old_locale = g_strdup (setlocale (LC_NUMERIC, NULL));
246 setlocale (LC_NUMERIC, "C");
247 val_2 = strtod (nptr, &fail_pos_2);
248 setlocale (LC_NUMERIC, old_locale);
252 if (!fail_pos_1 || fail_pos_1[0] == 0 || fail_pos_1 >= fail_pos_2)
255 *endptr = fail_pos_1;
261 *endptr = fail_pos_2;
266 G_CONST_RETURN gchar*
267 g_strerror (gint errnum)
269 static GStaticPrivate msg_private = G_STATIC_PRIVATE_INIT;
273 return strerror (errnum);
278 case E2BIG: return "argument list too long";
281 case EACCES: return "permission denied";
284 case EADDRINUSE: return "address already in use";
287 case EADDRNOTAVAIL: return "can't assign requested address";
290 case EADV: return "advertise error";
293 case EAFNOSUPPORT: return "address family not supported by protocol family";
296 case EAGAIN: return "try again";
299 case EALIGN: return "EALIGN";
302 case EALREADY: return "operation already in progress";
305 case EBADE: return "bad exchange descriptor";
308 case EBADF: return "bad file number";
311 case EBADFD: return "file descriptor in bad state";
314 case EBADMSG: return "not a data message";
317 case EBADR: return "bad request descriptor";
320 case EBADRPC: return "RPC structure is bad";
323 case EBADRQC: return "bad request code";
326 case EBADSLT: return "invalid slot";
329 case EBFONT: return "bad font file format";
332 case EBUSY: return "mount device busy";
335 case ECHILD: return "no children";
338 case ECHRNG: return "channel number out of range";
341 case ECOMM: return "communication error on send";
344 case ECONNABORTED: return "software caused connection abort";
347 case ECONNREFUSED: return "connection refused";
350 case ECONNRESET: return "connection reset by peer";
352 #if defined(EDEADLK) && (!defined(EWOULDBLOCK) || (EDEADLK != EWOULDBLOCK))
353 case EDEADLK: return "resource deadlock avoided";
356 case EDEADLOCK: return "resource deadlock avoided";
359 case EDESTADDRREQ: return "destination address required";
362 case EDIRTY: return "mounting a dirty fs w/o force";
365 case EDOM: return "math argument out of range";
368 case EDOTDOT: return "cross mount point";
371 case EDQUOT: return "disk quota exceeded";
374 case EDUPPKG: return "duplicate package name";
377 case EEXIST: return "file already exists";
380 case EFAULT: return "bad address in system call argument";
383 case EFBIG: return "file too large";
386 case EHOSTDOWN: return "host is down";
389 case EHOSTUNREACH: return "host is unreachable";
392 case EIDRM: return "identifier removed";
395 case EINIT: return "initialization error";
398 case EINPROGRESS: return "operation now in progress";
401 case EINTR: return "interrupted system call";
404 case EINVAL: return "invalid argument";
407 case EIO: return "I/O error";
410 case EISCONN: return "socket is already connected";
413 case EISDIR: return "illegal operation on a directory";
416 case EISNAM: return "is a name file";
419 case ELBIN: return "ELBIN";
422 case EL2HLT: return "level 2 halted";
425 case EL2NSYNC: return "level 2 not synchronized";
428 case EL3HLT: return "level 3 halted";
431 case EL3RST: return "level 3 reset";
434 case ELIBACC: return "can not access a needed shared library";
437 case ELIBBAD: return "accessing a corrupted shared library";
440 case ELIBEXEC: return "can not exec a shared library directly";
443 case ELIBMAX: return "attempting to link in more shared libraries than system limit";
446 case ELIBSCN: return ".lib section in a.out corrupted";
449 case ELNRNG: return "link number out of range";
452 case ELOOP: return "too many levels of symbolic links";
455 case EMFILE: return "too many open files";
458 case EMLINK: return "too many links";
461 case EMSGSIZE: return "message too long";
464 case EMULTIHOP: return "multihop attempted";
467 case ENAMETOOLONG: return "file name too long";
470 case ENAVAIL: return "not available";
473 case ENET: return "ENET";
476 case ENETDOWN: return "network is down";
479 case ENETRESET: return "network dropped connection on reset";
482 case ENETUNREACH: return "network is unreachable";
485 case ENFILE: return "file table overflow";
488 case ENOANO: return "anode table overflow";
490 #if defined(ENOBUFS) && (!defined(ENOSR) || (ENOBUFS != ENOSR))
491 case ENOBUFS: return "no buffer space available";
494 case ENOCSI: return "no CSI structure available";
497 case ENODATA: return "no data available";
500 case ENODEV: return "no such device";
503 case ENOENT: return "no such file or directory";
506 case ENOEXEC: return "exec format error";
509 case ENOLCK: return "no locks available";
512 case ENOLINK: return "link has be severed";
515 case ENOMEM: return "not enough memory";
518 case ENOMSG: return "no message of desired type";
521 case ENONET: return "machine is not on the network";
524 case ENOPKG: return "package not installed";
527 case ENOPROTOOPT: return "bad proocol option";
530 case ENOSPC: return "no space left on device";
533 case ENOSR: return "out of stream resources";
536 case ENOSTR: return "not a stream device";
539 case ENOSYM: return "unresolved symbol name";
542 case ENOSYS: return "function not implemented";
545 case ENOTBLK: return "block device required";
548 case ENOTCONN: return "socket is not connected";
551 case ENOTDIR: return "not a directory";
554 case ENOTEMPTY: return "directory not empty";
557 case ENOTNAM: return "not a name file";
560 case ENOTSOCK: return "socket operation on non-socket";
563 case ENOTTY: return "inappropriate device for ioctl";
566 case ENOTUNIQ: return "name not unique on network";
569 case ENXIO: return "no such device or address";
572 case EOPNOTSUPP: return "operation not supported on socket";
575 case EPERM: return "not owner";
578 case EPFNOSUPPORT: return "protocol family not supported";
581 case EPIPE: return "broken pipe";
584 case EPROCLIM: return "too many processes";
587 case EPROCUNAVAIL: return "bad procedure for program";
590 case EPROGMISMATCH: return "program version wrong";
593 case EPROGUNAVAIL: return "RPC program not available";
596 case EPROTO: return "protocol error";
598 #ifdef EPROTONOSUPPORT
599 case EPROTONOSUPPORT: return "protocol not suppored";
602 case EPROTOTYPE: return "protocol wrong type for socket";
605 case ERANGE: return "math result unrepresentable";
607 #if defined(EREFUSED) && (!defined(ECONNREFUSED) || (EREFUSED != ECONNREFUSED))
608 case EREFUSED: return "EREFUSED";
611 case EREMCHG: return "remote address changed";
614 case EREMDEV: return "remote device";
617 case EREMOTE: return "pathname hit remote file system";
620 case EREMOTEIO: return "remote i/o error";
622 #ifdef EREMOTERELEASE
623 case EREMOTERELEASE: return "EREMOTERELEASE";
626 case EROFS: return "read-only file system";
629 case ERPCMISMATCH: return "RPC version is wrong";
632 case ERREMOTE: return "object is remote";
635 case ESHUTDOWN: return "can't send afer socket shutdown";
637 #ifdef ESOCKTNOSUPPORT
638 case ESOCKTNOSUPPORT: return "socket type not supported";
641 case ESPIPE: return "invalid seek";
644 case ESRCH: return "no such process";
647 case ESRMNT: return "srmount error";
650 case ESTALE: return "stale remote file handle";
653 case ESUCCESS: return "Error 0";
656 case ETIME: return "timer expired";
659 case ETIMEDOUT: return "connection timed out";
662 case ETOOMANYREFS: return "too many references: can't splice";
665 case ETXTBSY: return "text file or pseudo-device busy";
668 case EUCLEAN: return "structure needs cleaning";
671 case EUNATCH: return "protocol driver not attached";
674 case EUSERS: return "too many users";
677 case EVERSION: return "version mismatch";
679 #if defined(EWOULDBLOCK) && (!defined(EAGAIN) || (EWOULDBLOCK != EAGAIN))
680 case EWOULDBLOCK: return "operation would block";
683 case EXDEV: return "cross-domain link";
686 case EXFULL: return "message tables full";
689 #else /* NO_SYS_ERRLIST */
691 extern char *sys_errlist[];
693 if ((errnum > 0) && (errnum <= sys_nerr))
694 return sys_errlist [errnum];
695 #endif /* NO_SYS_ERRLIST */
697 msg = g_static_private_get (&msg_private);
700 msg = g_new (gchar, 64);
701 g_static_private_set (&msg_private, msg, g_free);
704 sprintf (msg, "unknown error (%d)", errnum);
709 G_CONST_RETURN gchar*
710 g_strsignal (gint signum)
712 static GStaticPrivate msg_private = G_STATIC_PRIVATE_INIT;
715 #ifdef HAVE_STRSIGNAL
716 #if defined(G_OS_BEOS) || defined(G_WITH_CYGWIN)
717 extern const char *strsignal(int);
719 /* this is declared differently (const) in string.h on BeOS */
720 extern char *strsignal (int sig);
721 #endif /* !G_OS_BEOS && !G_WITH_CYGWIN */
722 return strsignal (signum);
727 case SIGHUP: return "Hangup";
730 case SIGINT: return "Interrupt";
733 case SIGQUIT: return "Quit";
736 case SIGILL: return "Illegal instruction";
739 case SIGTRAP: return "Trace/breakpoint trap";
742 case SIGABRT: return "IOT trap/Abort";
745 case SIGBUS: return "Bus error";
748 case SIGFPE: return "Floating point exception";
751 case SIGKILL: return "Killed";
754 case SIGUSR1: return "User defined signal 1";
757 case SIGSEGV: return "Segmentation fault";
760 case SIGUSR2: return "User defined signal 2";
763 case SIGPIPE: return "Broken pipe";
766 case SIGALRM: return "Alarm clock";
769 case SIGTERM: return "Terminated";
772 case SIGSTKFLT: return "Stack fault";
775 case SIGCHLD: return "Child exited";
778 case SIGCONT: return "Continued";
781 case SIGSTOP: return "Stopped (signal)";
784 case SIGTSTP: return "Stopped";
787 case SIGTTIN: return "Stopped (tty input)";
790 case SIGTTOU: return "Stopped (tty output)";
793 case SIGURG: return "Urgent condition";
796 case SIGXCPU: return "CPU time limit exceeded";
799 case SIGXFSZ: return "File size limit exceeded";
802 case SIGVTALRM: return "Virtual time alarm";
805 case SIGPROF: return "Profile signal";
808 case SIGWINCH: return "Window size changed";
811 case SIGIO: return "Possible I/O";
814 case SIGPWR: return "Power failure";
817 case SIGUNUSED: return "Unused signal";
820 #else /* NO_SYS_SIGLIST */
822 #ifdef NO_SYS_SIGLIST_DECL
823 extern char *sys_siglist[]; /*(see Tue Jan 19 00:44:24 1999 in changelog)*/
826 return (char*) /* this function should return const --josh */ sys_siglist [signum];
827 #endif /* NO_SYS_SIGLIST */
829 msg = g_static_private_get (&msg_private);
832 msg = g_new (gchar, 64);
833 g_static_private_set (&msg_private, msg, g_free);
836 sprintf (msg, "unknown signal (%d)", signum);
841 /* Functions g_strlcpy and g_strlcat were originally developed by
842 * Todd C. Miller <Todd.Miller@courtesan.com> to simplify writing secure code.
843 * See ftp://ftp.openbsd.org/pub/OpenBSD/src/lib/libc/string/strlcpy.3
844 * for more information.
848 /* Use the native ones, if available; they might be implemented in assembly */
850 g_strlcpy (gchar *dest,
854 g_return_val_if_fail (dest != NULL, 0);
855 g_return_val_if_fail (src != NULL, 0);
857 return strlcpy (dest, src, dest_size);
861 g_strlcat (gchar *dest,
865 g_return_val_if_fail (dest != NULL, 0);
866 g_return_val_if_fail (src != NULL, 0);
868 return strlcat (dest, src, dest_size);
871 #else /* ! HAVE_STRLCPY */
874 * Copy string src to buffer dest (of buffer size dest_size). At most
875 * dest_size-1 characters will be copied. Always NUL terminates
876 * (unless dest_size == 0). This function does NOT allocate memory.
877 * Unlike strncpy, this function doesn't pad dest (so it's often faster).
878 * Returns size of attempted result, strlen(src),
879 * so if retval >= dest_size, truncation occurred.
882 g_strlcpy (gchar *dest,
886 register gchar *d = dest;
887 register const gchar *s = src;
888 register gsize n = dest_size;
890 g_return_val_if_fail (dest != NULL, 0);
891 g_return_val_if_fail (src != NULL, 0);
893 /* Copy as many bytes as will fit */
894 if (n != 0 && --n != 0)
897 register gchar c = *s++;
905 /* If not enough room in dest, add NUL and traverse rest of src */
914 return s - src - 1; /* count does not include NUL */
919 * Appends string src to buffer dest (of buffer size dest_size).
920 * At most dest_size-1 characters will be copied.
921 * Unlike strncat, dest_size is the full size of dest, not the space left over.
922 * This function does NOT allocate memory.
923 * This always NUL terminates (unless siz == 0 or there were no NUL characters
924 * in the dest_size characters of dest to start with).
925 * Returns size of attempted result, which is
926 * MIN (dest_size, strlen (original dest)) + strlen (src),
927 * so if retval >= dest_size, truncation occurred.
930 g_strlcat (gchar *dest,
934 register gchar *d = dest;
935 register const gchar *s = src;
936 register gsize bytes_left = dest_size;
937 gsize dlength; /* Logically, MIN (strlen (d), dest_size) */
939 g_return_val_if_fail (dest != NULL, 0);
940 g_return_val_if_fail (src != NULL, 0);
942 /* Find the end of dst and adjust bytes left but don't go past end */
943 while (*d != 0 && bytes_left-- != 0)
946 bytes_left = dest_size - dlength;
949 return dlength + strlen (s);
962 return dlength + (s - src); /* count does not include NUL */
964 #endif /* ! HAVE_STRLCPY */
967 g_strdown (gchar *string)
971 g_return_val_if_fail (string != NULL, NULL);
973 s = (guchar *) string;
981 return (gchar *) string;
985 g_strup (gchar *string)
989 g_return_val_if_fail (string != NULL, NULL);
991 s = (guchar *) string;
999 return (gchar *) string;
1003 g_strreverse (gchar *string)
1005 g_return_val_if_fail (string != NULL, NULL);
1009 register gchar *h, *t;
1012 t = string + strlen (string) - 1;
1030 g_strcasecmp (const gchar *s1,
1033 #ifdef HAVE_STRCASECMP
1034 g_return_val_if_fail (s1 != NULL, 0);
1035 g_return_val_if_fail (s2 != NULL, 0);
1037 return strcasecmp (s1, s2);
1041 g_return_val_if_fail (s1 != NULL, 0);
1042 g_return_val_if_fail (s2 != NULL, 0);
1046 /* According to A. Cox, some platforms have islower's that
1047 * don't work right on non-uppercase
1049 c1 = isupper ((guchar)*s1) ? tolower ((guchar)*s1) : *s1;
1050 c2 = isupper ((guchar)*s2) ? tolower ((guchar)*s2) : *s2;
1056 return (((gint)(guchar) *s1) - ((gint)(guchar) *s2));
1061 g_strncasecmp (const gchar *s1,
1065 #ifdef HAVE_STRNCASECMP
1066 return strncasecmp (s1, s2, n);
1070 g_return_val_if_fail (s1 != NULL, 0);
1071 g_return_val_if_fail (s2 != NULL, 0);
1073 while (n && *s1 && *s2)
1076 /* According to A. Cox, some platforms have islower's that
1077 * don't work right on non-uppercase
1079 c1 = isupper ((guchar)*s1) ? tolower ((guchar)*s1) : *s1;
1080 c2 = isupper ((guchar)*s2) ? tolower ((guchar)*s2) : *s2;
1087 return (((gint) (guchar) *s1) - ((gint) (guchar) *s2));
1094 g_strdelimit (gchar *string,
1095 const gchar *delimiters,
1100 g_return_val_if_fail (string != NULL, NULL);
1103 delimiters = G_STR_DELIMITERS;
1105 for (c = string; *c; c++)
1107 if (strchr (delimiters, *c))
1115 g_strcanon (gchar *string,
1116 const gchar *valid_chars,
1121 g_return_val_if_fail (string != NULL, NULL);
1122 g_return_val_if_fail (valid_chars != NULL, NULL);
1124 for (c = string; *c; c++)
1126 if (!strchr (valid_chars, *c))
1134 g_strcompress (const gchar *source)
1136 const gchar *p = source, *octal;
1137 gchar *dest = g_malloc (strlen (source) + 1);
1147 case '0': case '1': case '2': case '3': case '4':
1148 case '5': case '6': case '7':
1151 while ((p < octal + 3) && (*p >= '0') && (*p <= '7'))
1153 *q = (*q * 8) + (*p - '0');
1174 default: /* Also handles \" and \\ */
1189 g_strescape (const gchar *source,
1190 const gchar *exceptions)
1197 g_return_val_if_fail (source != NULL, NULL);
1199 p = (guchar *) source;
1200 /* Each source byte needs maximally four destination chars (\777) */
1201 q = dest = g_malloc (strlen (source) * 4 + 1);
1203 memset (excmap, 0, 256);
1206 guchar *e = (guchar *) exceptions;
1252 if ((*p < ' ') || (*p >= 0177))
1255 *q++ = '0' + (((*p) >> 6) & 07);
1256 *q++ = '0' + (((*p) >> 3) & 07);
1257 *q++ = '0' + ((*p) & 07);
1271 g_strchug (gchar *string)
1275 g_return_val_if_fail (string != NULL, NULL);
1277 for (start = (guchar*) string; *start && isspace (*start); start++)
1280 g_memmove (string, start, strlen ((gchar *) start) + 1);
1286 g_strchomp (gchar *string)
1290 g_return_val_if_fail (string != NULL, NULL);
1295 for (s = string + strlen (string) - 1; s >= string && isspace ((guchar)*s);
1303 g_strsplit (const gchar *string,
1304 const gchar *delimiter,
1307 GSList *string_list = NULL, *slist;
1308 gchar **str_array, *s;
1311 g_return_val_if_fail (string != NULL, NULL);
1312 g_return_val_if_fail (delimiter != NULL, NULL);
1315 max_tokens = G_MAXINT;
1317 s = strstr (string, delimiter);
1320 guint delimiter_len = strlen (delimiter);
1328 new_string = g_new (gchar, len + 1);
1329 strncpy (new_string, string, len);
1330 new_string[len] = 0;
1331 string_list = g_slist_prepend (string_list, new_string);
1333 string = s + delimiter_len;
1334 s = strstr (string, delimiter);
1336 while (--max_tokens && s);
1338 string_list = g_slist_prepend (string_list, g_strdup (string));
1340 str_array = g_new (gchar*, n + 1);
1342 str_array[n--] = NULL;
1343 for (slist = string_list; slist; slist = slist->next)
1344 str_array[n--] = slist->data;
1346 g_slist_free (string_list);
1352 g_strfreev (gchar **str_array)
1358 for(i = 0; str_array[i] != NULL; i++)
1359 g_free(str_array[i]);
1367 * @str_array: %NULL-terminated array of strings
1369 * Copies %NULL-terminated array of strings. The copy is a deep copy;
1370 * the new array should be freed by first freeing each string, then
1371 * the array itself. g_strfreev() does this for you. If called
1372 * on a %NULL value, g_strdupv() simply returns %NULL.
1374 * Return value: a new %NULL-terminated array of strings
1377 g_strdupv (gchar **str_array)
1385 while (str_array[i])
1388 retval = g_new (gchar*, i + 1);
1391 while (str_array[i])
1393 retval[i] = g_strdup (str_array[i]);
1405 g_strjoinv (const gchar *separator,
1411 g_return_val_if_fail (str_array != NULL, NULL);
1413 if (separator == NULL)
1419 guint separator_len;
1421 separator_len = strlen (separator);
1422 /* First part, getting length */
1423 len = 1 + strlen (str_array[0]);
1424 for (i = 1; str_array[i] != NULL; i++)
1425 len += strlen (str_array[i]);
1426 len += separator_len * (i - 1);
1428 /* Second part, building string */
1429 string = g_new (gchar, len);
1430 ptr = g_stpcpy (string, *str_array);
1431 for (i = 1; str_array[i] != NULL; i++)
1433 ptr = g_stpcpy (ptr, separator);
1434 ptr = g_stpcpy (ptr, str_array[i]);
1438 string = g_strdup ("");
1444 g_strjoin (const gchar *separator,
1450 guint separator_len;
1453 if (separator == NULL)
1456 separator_len = strlen (separator);
1458 va_start (args, separator);
1460 s = va_arg (args, gchar*);
1464 /* First part, getting length */
1465 len = 1 + strlen (s);
1467 s = va_arg (args, gchar*);
1470 len += separator_len + strlen (s);
1471 s = va_arg (args, gchar*);
1475 /* Second part, building string */
1476 string = g_new (gchar, len);
1478 va_start (args, separator);
1480 s = va_arg (args, gchar*);
1481 ptr = g_stpcpy (string, s);
1483 s = va_arg (args, gchar*);
1486 ptr = g_stpcpy (ptr, separator);
1487 ptr = g_stpcpy (ptr, s);
1488 s = va_arg (args, gchar*);
1492 string = g_strdup ("");