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/.
40 #include <ctype.h> /* For tolower() */
41 #if !defined (HAVE_STRSIGNAL) || !defined(NO_SYS_SIGLIST_DECL)
50 /* do not include <unistd.h> in this place since it
51 * inteferes with g_strsignal() on some OSes
55 g_strdup (const gchar
*str
)
61 new_str
= g_new (char, strlen (str
) + 1);
62 strcpy (new_str
, str
);
71 g_memdup (gconstpointer mem
,
78 new_mem
= g_malloc (byte_size
);
79 memcpy (new_mem
, mem
, byte_size
);
88 g_strndup (const gchar
*str
,
95 new_str
= g_new (gchar
, n
+ 1);
96 strncpy (new_str
, str
, n
);
106 g_strnfill (guint length
,
109 register gchar
*str
, *s
, *end
;
111 str
= g_new (gchar
, length
+ 1);
122 g_strdup_vprintf (const gchar
*format
,
128 G_VA_COPY (args2
, args1
);
130 buffer
= g_new (gchar
, g_printf_string_upper_bound (format
, args1
));
132 vsprintf (buffer
, format
, args2
);
139 g_strdup_printf (const gchar
*format
,
145 va_start (args
, format
);
146 buffer
= g_strdup_vprintf (format
, args
);
153 g_strconcat (const gchar
*string1
, ...)
160 g_return_val_if_fail (string1
!= NULL
, NULL
);
162 l
= 1 + strlen (string1
);
163 va_start (args
, string1
);
164 s
= va_arg (args
, gchar
*);
168 s
= va_arg (args
, gchar
*);
172 concat
= g_new (gchar
, l
);
175 strcat (concat
, string1
);
176 va_start (args
, string1
);
177 s
= va_arg (args
, gchar
*);
181 s
= va_arg (args
, gchar
*);
189 g_strtod (const gchar
*nptr
,
197 g_return_val_if_fail (nptr
!= NULL
, 0);
202 val_1
= strtod (nptr
, &fail_pos_1
);
204 if (fail_pos_1
&& fail_pos_1
[0] != 0)
208 old_locale
= g_strdup (setlocale (LC_NUMERIC
, NULL
));
209 setlocale (LC_NUMERIC
, "C");
210 val_2
= strtod (nptr
, &fail_pos_2
);
211 setlocale (LC_NUMERIC
, old_locale
);
215 if (!fail_pos_1
|| fail_pos_1
[0] == 0 || fail_pos_1
>= fail_pos_2
)
218 *endptr
= fail_pos_1
;
224 *endptr
= fail_pos_2
;
230 g_strerror (gint errnum
)
232 static GStaticPrivate msg_private
= G_STATIC_PRIVATE_INIT
;
236 return strerror (errnum
);
241 case E2BIG
: return "argument list too long";
244 case EACCES
: return "permission denied";
247 case EADDRINUSE
: return "address already in use";
250 case EADDRNOTAVAIL
: return "can't assign requested address";
253 case EADV
: return "advertise error";
256 case EAFNOSUPPORT
: return "address family not supported by protocol family";
259 case EAGAIN
: return "try again";
262 case EALIGN
: return "EALIGN";
265 case EALREADY
: return "operation already in progress";
268 case EBADE
: return "bad exchange descriptor";
271 case EBADF
: return "bad file number";
274 case EBADFD
: return "file descriptor in bad state";
277 case EBADMSG
: return "not a data message";
280 case EBADR
: return "bad request descriptor";
283 case EBADRPC
: return "RPC structure is bad";
286 case EBADRQC
: return "bad request code";
289 case EBADSLT
: return "invalid slot";
292 case EBFONT
: return "bad font file format";
295 case EBUSY
: return "mount device busy";
298 case ECHILD
: return "no children";
301 case ECHRNG
: return "channel number out of range";
304 case ECOMM
: return "communication error on send";
307 case ECONNABORTED
: return "software caused connection abort";
310 case ECONNREFUSED
: return "connection refused";
313 case ECONNRESET
: return "connection reset by peer";
315 #if defined(EDEADLK) && (!defined(EWOULDBLOCK) || (EDEADLK != EWOULDBLOCK))
316 case EDEADLK
: return "resource deadlock avoided";
319 case EDEADLOCK
: return "resource deadlock avoided";
322 case EDESTADDRREQ
: return "destination address required";
325 case EDIRTY
: return "mounting a dirty fs w/o force";
328 case EDOM
: return "math argument out of range";
331 case EDOTDOT
: return "cross mount point";
334 case EDQUOT
: return "disk quota exceeded";
337 case EDUPPKG
: return "duplicate package name";
340 case EEXIST
: return "file already exists";
343 case EFAULT
: return "bad address in system call argument";
346 case EFBIG
: return "file too large";
349 case EHOSTDOWN
: return "host is down";
352 case EHOSTUNREACH
: return "host is unreachable";
355 case EIDRM
: return "identifier removed";
358 case EINIT
: return "initialization error";
361 case EINPROGRESS
: return "operation now in progress";
364 case EINTR
: return "interrupted system call";
367 case EINVAL
: return "invalid argument";
370 case EIO
: return "I/O error";
373 case EISCONN
: return "socket is already connected";
376 case EISDIR
: return "illegal operation on a directory";
379 case EISNAM
: return "is a name file";
382 case ELBIN
: return "ELBIN";
385 case EL2HLT
: return "level 2 halted";
388 case EL2NSYNC
: return "level 2 not synchronized";
391 case EL3HLT
: return "level 3 halted";
394 case EL3RST
: return "level 3 reset";
397 case ELIBACC
: return "can not access a needed shared library";
400 case ELIBBAD
: return "accessing a corrupted shared library";
403 case ELIBEXEC
: return "can not exec a shared library directly";
406 case ELIBMAX
: return "attempting to link in more shared libraries than system limit";
409 case ELIBSCN
: return ".lib section in a.out corrupted";
412 case ELNRNG
: return "link number out of range";
415 case ELOOP
: return "too many levels of symbolic links";
418 case EMFILE
: return "too many open files";
421 case EMLINK
: return "too many links";
424 case EMSGSIZE
: return "message too long";
427 case EMULTIHOP
: return "multihop attempted";
430 case ENAMETOOLONG
: return "file name too long";
433 case ENAVAIL
: return "not available";
436 case ENET
: return "ENET";
439 case ENETDOWN
: return "network is down";
442 case ENETRESET
: return "network dropped connection on reset";
445 case ENETUNREACH
: return "network is unreachable";
448 case ENFILE
: return "file table overflow";
451 case ENOANO
: return "anode table overflow";
453 #if defined(ENOBUFS) && (!defined(ENOSR) || (ENOBUFS != ENOSR))
454 case ENOBUFS
: return "no buffer space available";
457 case ENOCSI
: return "no CSI structure available";
460 case ENODATA
: return "no data available";
463 case ENODEV
: return "no such device";
466 case ENOENT
: return "no such file or directory";
469 case ENOEXEC
: return "exec format error";
472 case ENOLCK
: return "no locks available";
475 case ENOLINK
: return "link has be severed";
478 case ENOMEM
: return "not enough memory";
481 case ENOMSG
: return "no message of desired type";
484 case ENONET
: return "machine is not on the network";
487 case ENOPKG
: return "package not installed";
490 case ENOPROTOOPT
: return "bad proocol option";
493 case ENOSPC
: return "no space left on device";
496 case ENOSR
: return "out of stream resources";
499 case ENOSTR
: return "not a stream device";
502 case ENOSYM
: return "unresolved symbol name";
505 case ENOSYS
: return "function not implemented";
508 case ENOTBLK
: return "block device required";
511 case ENOTCONN
: return "socket is not connected";
514 case ENOTDIR
: return "not a directory";
517 case ENOTEMPTY
: return "directory not empty";
520 case ENOTNAM
: return "not a name file";
523 case ENOTSOCK
: return "socket operation on non-socket";
526 case ENOTTY
: return "inappropriate device for ioctl";
529 case ENOTUNIQ
: return "name not unique on network";
532 case ENXIO
: return "no such device or address";
535 case EOPNOTSUPP
: return "operation not supported on socket";
538 case EPERM
: return "not owner";
541 case EPFNOSUPPORT
: return "protocol family not supported";
544 case EPIPE
: return "broken pipe";
547 case EPROCLIM
: return "too many processes";
550 case EPROCUNAVAIL
: return "bad procedure for program";
553 case EPROGMISMATCH
: return "program version wrong";
556 case EPROGUNAVAIL
: return "RPC program not available";
559 case EPROTO
: return "protocol error";
561 #ifdef EPROTONOSUPPORT
562 case EPROTONOSUPPORT
: return "protocol not suppored";
565 case EPROTOTYPE
: return "protocol wrong type for socket";
568 case ERANGE
: return "math result unrepresentable";
570 #if defined(EREFUSED) && (!defined(ECONNREFUSED) || (EREFUSED != ECONNREFUSED))
571 case EREFUSED
: return "EREFUSED";
574 case EREMCHG
: return "remote address changed";
577 case EREMDEV
: return "remote device";
580 case EREMOTE
: return "pathname hit remote file system";
583 case EREMOTEIO
: return "remote i/o error";
585 #ifdef EREMOTERELEASE
586 case EREMOTERELEASE
: return "EREMOTERELEASE";
589 case EROFS
: return "read-only file system";
592 case ERPCMISMATCH
: return "RPC version is wrong";
595 case ERREMOTE
: return "object is remote";
598 case ESHUTDOWN
: return "can't send afer socket shutdown";
600 #ifdef ESOCKTNOSUPPORT
601 case ESOCKTNOSUPPORT
: return "socket type not supported";
604 case ESPIPE
: return "invalid seek";
607 case ESRCH
: return "no such process";
610 case ESRMNT
: return "srmount error";
613 case ESTALE
: return "stale remote file handle";
616 case ESUCCESS
: return "Error 0";
619 case ETIME
: return "timer expired";
622 case ETIMEDOUT
: return "connection timed out";
625 case ETOOMANYREFS
: return "too many references: can't splice";
628 case ETXTBSY
: return "text file or pseudo-device busy";
631 case EUCLEAN
: return "structure needs cleaning";
634 case EUNATCH
: return "protocol driver not attached";
637 case EUSERS
: return "too many users";
640 case EVERSION
: return "version mismatch";
642 #if defined(EWOULDBLOCK) && (!defined(EAGAIN) || (EWOULDBLOCK != EAGAIN))
643 case EWOULDBLOCK
: return "operation would block";
646 case EXDEV
: return "cross-domain link";
649 case EXFULL
: return "message tables full";
652 #else /* NO_SYS_ERRLIST */
654 extern char *sys_errlist
[];
656 if ((errnum
> 0) && (errnum
<= sys_nerr
))
657 return sys_errlist
[errnum
];
658 #endif /* NO_SYS_ERRLIST */
660 msg
= g_static_private_get (&msg_private
);
663 msg
= g_new (gchar
, 64);
664 g_static_private_set (&msg_private
, msg
, g_free
);
667 sprintf (msg
, "unknown error (%d)", errnum
);
673 g_strsignal (gint signum
)
675 static GStaticPrivate msg_private
= G_STATIC_PRIVATE_INIT
;
678 #ifdef HAVE_STRSIGNAL
679 #if defined(G_OS_BEOS) || defined(G_WITH_CYGWIN)
680 extern const char * strsignal(int);
681 #else /* !G_OS_BEOS */
682 /* this is declared differently (const) in string.h on BeOS */
683 extern char *strsignal (int sig
);
684 #endif /* !G_OS_BEOS */
685 return strsignal (signum
);
690 case SIGHUP
: return "Hangup";
693 case SIGINT
: return "Interrupt";
696 case SIGQUIT
: return "Quit";
699 case SIGILL
: return "Illegal instruction";
702 case SIGTRAP
: return "Trace/breakpoint trap";
705 case SIGABRT
: return "IOT trap/Abort";
708 case SIGBUS
: return "Bus error";
711 case SIGFPE
: return "Floating point exception";
714 case SIGKILL
: return "Killed";
717 case SIGUSR1
: return "User defined signal 1";
720 case SIGSEGV
: return "Segmentation fault";
723 case SIGUSR2
: return "User defined signal 2";
726 case SIGPIPE
: return "Broken pipe";
729 case SIGALRM
: return "Alarm clock";
732 case SIGTERM
: return "Terminated";
735 case SIGSTKFLT
: return "Stack fault";
738 case SIGCHLD
: return "Child exited";
741 case SIGCONT
: return "Continued";
744 case SIGSTOP
: return "Stopped (signal)";
747 case SIGTSTP
: return "Stopped";
750 case SIGTTIN
: return "Stopped (tty input)";
753 case SIGTTOU
: return "Stopped (tty output)";
756 case SIGURG
: return "Urgent condition";
759 case SIGXCPU
: return "CPU time limit exceeded";
762 case SIGXFSZ
: return "File size limit exceeded";
765 case SIGVTALRM
: return "Virtual time alarm";
768 case SIGPROF
: return "Profile signal";
771 case SIGWINCH
: return "Window size changed";
774 case SIGIO
: return "Possible I/O";
777 case SIGPWR
: return "Power failure";
780 case SIGUNUSED
: return "Unused signal";
783 #else /* NO_SYS_SIGLIST */
785 #ifdef NO_SYS_SIGLIST_DECL
786 extern char *sys_siglist
[]; /*(see Tue Jan 19 00:44:24 1999 in changelog)*/
789 return (char*) /* this function should return const --josh */ sys_siglist
[signum
];
790 #endif /* NO_SYS_SIGLIST */
792 msg
= g_static_private_get (&msg_private
);
795 msg
= g_new (gchar
, 64);
796 g_static_private_set (&msg_private
, msg
, g_free
);
799 sprintf (msg
, "unknown signal (%d)", signum
);
804 /* Functions g_strlcpy and g_strlcat were originally developed by
805 * Todd C. Miller <Todd.Miller@courtesan.com> to simplify writing secure code.
806 * See ftp://ftp.openbsd.org/pub/OpenBSD/src/lib/libc/string/strlcpy.3
807 * for more information.
811 /* Use the native ones, if available; they might be implemented in assembly */
813 g_strlcpy (gchar
*dest
,
817 g_return_val_if_fail (dest
!= NULL
, 0);
818 g_return_val_if_fail (src
!= NULL
, 0);
820 return strlcpy (dest
, src
, dest_size
);
824 g_strlcat (gchar
*dest
,
828 g_return_val_if_fail (dest
!= NULL
, 0);
829 g_return_val_if_fail (src
!= NULL
, 0);
831 return strlcat (dest
, src
, dest_size
);
834 #else /* ! HAVE_STRLCPY */
837 * Copy string src to buffer dest (of buffer size dest_size). At most
838 * dest_size-1 characters will be copied. Always NUL terminates
839 * (unless dest_size == 0). This function does NOT allocate memory.
840 * Unlike strncpy, this function doesn't pad dest (so it's often faster).
841 * Returns size of attempted result, strlen(src),
842 * so if retval >= dest_size, truncation occurred.
845 g_strlcpy (gchar
*dest
,
849 register gchar
*d
= dest
;
850 register const gchar
*s
= src
;
851 register gsize n
= dest_size
;
853 g_return_val_if_fail (dest
!= NULL
, 0);
854 g_return_val_if_fail (src
!= NULL
, 0);
856 /* Copy as many bytes as will fit */
857 if (n
!= 0 && --n
!= 0)
860 register gchar c
= *s
++;
868 /* If not enough room in dest, add NUL and traverse rest of src */
877 return s
- src
- 1; /* count does not include NUL */
882 * Appends string src to buffer dest (of buffer size dest_size).
883 * At most dest_size-1 characters will be copied.
884 * Unlike strncat, dest_size is the full size of dest, not the space left over.
885 * This function does NOT allocate memory.
886 * This always NUL terminates (unless siz == 0 or there were no NUL characters
887 * in the dest_size characters of dest to start with).
888 * Returns size of attempted result, which is
889 * MIN (dest_size, strlen (original dest)) + strlen (src),
890 * so if retval >= dest_size, truncation occurred.
893 g_strlcat (gchar
*dest
,
897 register gchar
*d
= dest
;
898 register const gchar
*s
= src
;
899 register gsize bytes_left
= dest_size
;
900 gsize dlength
; /* Logically, MIN (strlen (d), dest_size) */
902 g_return_val_if_fail (dest
!= NULL
, 0);
903 g_return_val_if_fail (src
!= NULL
, 0);
905 /* Find the end of dst and adjust bytes left but don't go past end */
906 while (*d
!= 0 && bytes_left
-- != 0)
909 bytes_left
= dest_size
- dlength
;
912 return dlength
+ strlen (s
);
925 return dlength
+ (s
- src
); /* count does not include NUL */
927 #endif /* ! HAVE_STRLCPY */
930 g_strdown (gchar
*string
)
934 g_return_val_if_fail (string
!= NULL
, NULL
);
936 s
= (guchar
*) string
;
944 return (gchar
*) string
;
948 g_strup (gchar
*string
)
952 g_return_val_if_fail (string
!= NULL
, NULL
);
954 s
= (guchar
*) string
;
962 return (gchar
*) string
;
966 g_strreverse (gchar
*string
)
968 g_return_val_if_fail (string
!= NULL
, NULL
);
972 register gchar
*h
, *t
;
975 t
= string
+ strlen (string
) - 1;
993 g_strcasecmp (const gchar
*s1
,
996 #ifdef HAVE_STRCASECMP
997 g_return_val_if_fail (s1
!= NULL
, 0);
998 g_return_val_if_fail (s2
!= NULL
, 0);
1000 return strcasecmp (s1
, s2
);
1004 g_return_val_if_fail (s1
!= NULL
, 0);
1005 g_return_val_if_fail (s2
!= NULL
, 0);
1009 /* According to A. Cox, some platforms have islower's that
1010 * don't work right on non-uppercase
1012 c1
= isupper ((guchar
)*s1
) ? tolower ((guchar
)*s1
) : *s1
;
1013 c2
= isupper ((guchar
)*s2
) ? tolower ((guchar
)*s2
) : *s2
;
1019 return (((gint
)(guchar
) *s1
) - ((gint
)(guchar
) *s2
));
1024 g_strncasecmp (const gchar
*s1
,
1028 #ifdef HAVE_STRNCASECMP
1029 return strncasecmp (s1
, s2
, n
);
1033 g_return_val_if_fail (s1
!= NULL
, 0);
1034 g_return_val_if_fail (s2
!= NULL
, 0);
1036 while (n
&& *s1
&& *s2
)
1039 /* According to A. Cox, some platforms have islower's that
1040 * don't work right on non-uppercase
1042 c1
= isupper ((guchar
)*s1
) ? tolower ((guchar
)*s1
) : *s1
;
1043 c2
= isupper ((guchar
)*s2
) ? tolower ((guchar
)*s2
) : *s2
;
1050 return (((gint
) (guchar
) *s1
) - ((gint
) (guchar
) *s2
));
1057 g_strdelimit (gchar
*string
,
1058 const gchar
*delimiters
,
1063 g_return_val_if_fail (string
!= NULL
, NULL
);
1066 delimiters
= G_STR_DELIMITERS
;
1068 for (c
= string
; *c
; c
++)
1070 if (strchr (delimiters
, *c
))
1078 g_strcanon (gchar
*string
,
1079 const gchar
*valid_chars
,
1084 g_return_val_if_fail (string
!= NULL
, NULL
);
1085 g_return_val_if_fail (valid_chars
!= NULL
, NULL
);
1087 for (c
= string
; *c
; c
++)
1089 if (!strchr (valid_chars
, *c
))
1097 g_strcompress (const gchar
*source
)
1099 const gchar
*p
= source
, *octal
;
1100 gchar
*dest
= g_malloc (strlen (source
) + 1);
1110 case '0': case '1': case '2': case '3': case '4':
1111 case '5': case '6': case '7':
1114 while ((p
< octal
+ 3) && (*p
>= '0') && (*p
<= '7'))
1116 *q
= (*q
* 8) + (*p
- '0');
1137 default: /* Also handles \" and \\ */
1152 g_strescape (const gchar
*source
,
1153 const gchar
*exceptions
)
1160 g_return_val_if_fail (source
!= NULL
, NULL
);
1162 p
= (guchar
*) source
;
1163 /* Each source byte needs maximally four destination chars (\777) */
1164 q
= dest
= g_malloc (strlen (source
) * 4 + 1);
1166 memset (excmap
, 0, 256);
1169 guchar
*e
= (guchar
*) exceptions
;
1215 if ((*p
< ' ') || (*p
>= 0177))
1218 *q
++ = '0' + (((*p
) >> 6) & 07);
1219 *q
++ = '0' + (((*p
) >> 3) & 07);
1220 *q
++ = '0' + ((*p
) & 07);
1234 g_strchug (gchar
*string
)
1238 g_return_val_if_fail (string
!= NULL
, NULL
);
1240 for (start
= (guchar
*) string
; *start
&& isspace (*start
); start
++)
1243 g_memmove (string
, start
, strlen ((gchar
*) start
) + 1);
1249 g_strchomp (gchar
*string
)
1253 g_return_val_if_fail (string
!= NULL
, NULL
);
1258 for (s
= string
+ strlen (string
) - 1; s
>= string
&& isspace ((guchar
)*s
);
1266 g_strsplit (const gchar
*string
,
1267 const gchar
*delimiter
,
1270 GSList
*string_list
= NULL
, *slist
;
1271 gchar
**str_array
, *s
;
1274 g_return_val_if_fail (string
!= NULL
, NULL
);
1275 g_return_val_if_fail (delimiter
!= NULL
, NULL
);
1278 max_tokens
= G_MAXINT
;
1280 s
= strstr (string
, delimiter
);
1283 guint delimiter_len
= strlen (delimiter
);
1291 new_string
= g_new (gchar
, len
+ 1);
1292 strncpy (new_string
, string
, len
);
1293 new_string
[len
] = 0;
1294 string_list
= g_slist_prepend (string_list
, new_string
);
1296 string
= s
+ delimiter_len
;
1297 s
= strstr (string
, delimiter
);
1299 while (--max_tokens
&& s
);
1301 string_list
= g_slist_prepend (string_list
, g_strdup (string
));
1303 str_array
= g_new (gchar
*, n
+ 1);
1305 str_array
[n
--] = NULL
;
1306 for (slist
= string_list
; slist
; slist
= slist
->next
)
1307 str_array
[n
--] = slist
->data
;
1309 g_slist_free (string_list
);
1315 g_strfreev (gchar
**str_array
)
1321 for(i
= 0; str_array
[i
] != NULL
; i
++)
1322 g_free(str_array
[i
]);
1330 * @str_array: %NULL-terminated array of strings
1332 * Copies %NULL-terminated array of strings. The copy is a deep copy;
1333 * the new array should be freed by first freeing each string, then
1334 * the array itself. g_strfreev() does this for you. If called
1335 * on a %NULL value, g_strdupv() simply returns %NULL.
1337 * Return value: a new %NULL-terminated array of strings
1340 g_strdupv (gchar
**str_array
)
1348 while (str_array
[i
])
1351 retval
= g_new (gchar
*, i
+ 1);
1354 while (str_array
[i
])
1356 retval
[i
] = g_strdup (str_array
[i
]);
1368 g_strjoinv (const gchar
*separator
,
1373 g_return_val_if_fail (str_array
!= NULL
, NULL
);
1375 if (separator
== NULL
)
1381 guint separator_len
;
1383 separator_len
= strlen (separator
);
1384 len
= 1 + strlen (str_array
[0]);
1385 for(i
= 1; str_array
[i
] != NULL
; i
++)
1386 len
+= separator_len
+ strlen(str_array
[i
]);
1388 string
= g_new (gchar
, len
);
1390 strcat (string
, *str_array
);
1391 for (i
= 1; str_array
[i
] != NULL
; i
++)
1393 strcat (string
, separator
);
1394 strcat (string
, str_array
[i
]);
1398 string
= g_strdup ("");
1404 g_strjoin (const gchar
*separator
,
1410 guint separator_len
;
1412 if (separator
== NULL
)
1415 separator_len
= strlen (separator
);
1417 va_start (args
, separator
);
1419 s
= va_arg (args
, gchar
*);
1425 s
= va_arg (args
, gchar
*);
1428 len
+= separator_len
+ strlen (s
);
1429 s
= va_arg (args
, gchar
*);
1433 string
= g_new (gchar
, len
+ 1);
1436 va_start (args
, separator
);
1438 s
= va_arg (args
, gchar
*);
1441 s
= va_arg (args
, gchar
*);
1444 strcat (string
, separator
);
1446 s
= va_arg (args
, gchar
*);
1450 string
= g_strdup ("");