+Mon Mar 26 13:34:50 2001 Owen Taylor <otaylor@redhat.com>
+
+ [ Patch from DindinX <David.Odin@bigfoot.com>, added docs ]
+
+ * gstrfuncs.c, gstrfuncs.h: Add g_stpcpy () for platform that don't
+ have stpcpy ().
+ * gstrfuncs.c (g_strjoin, g_strjoinv and g_strconcat): use
+ g_stpcpy () so these functions run much faster.
+ * config.h.win32.in, glib.def: add reference to g_stpcpy ()
+ * configure.in: Add a test for the stpcpy () function.
+
2001-03-20 Havoc Pennington <hp@redhat.com>
* gutf8.c (g_utf8_strlen): rewrite, based on bug #52328 from
+Mon Mar 26 13:34:50 2001 Owen Taylor <otaylor@redhat.com>
+
+ [ Patch from DindinX <David.Odin@bigfoot.com>, added docs ]
+
+ * gstrfuncs.c, gstrfuncs.h: Add g_stpcpy () for platform that don't
+ have stpcpy ().
+ * gstrfuncs.c (g_strjoin, g_strjoinv and g_strconcat): use
+ g_stpcpy () so these functions run much faster.
+ * config.h.win32.in, glib.def: add reference to g_stpcpy ()
+ * configure.in: Add a test for the stpcpy () function.
+
2001-03-20 Havoc Pennington <hp@redhat.com>
* gutf8.c (g_utf8_strlen): rewrite, based on bug #52328 from
+Mon Mar 26 13:34:50 2001 Owen Taylor <otaylor@redhat.com>
+
+ [ Patch from DindinX <David.Odin@bigfoot.com>, added docs ]
+
+ * gstrfuncs.c, gstrfuncs.h: Add g_stpcpy () for platform that don't
+ have stpcpy ().
+ * gstrfuncs.c (g_strjoin, g_strjoinv and g_strconcat): use
+ g_stpcpy () so these functions run much faster.
+ * config.h.win32.in, glib.def: add reference to g_stpcpy ()
+ * configure.in: Add a test for the stpcpy () function.
+
2001-03-20 Havoc Pennington <hp@redhat.com>
* gutf8.c (g_utf8_strlen): rewrite, based on bug #52328 from
+Mon Mar 26 13:34:50 2001 Owen Taylor <otaylor@redhat.com>
+
+ [ Patch from DindinX <David.Odin@bigfoot.com>, added docs ]
+
+ * gstrfuncs.c, gstrfuncs.h: Add g_stpcpy () for platform that don't
+ have stpcpy ().
+ * gstrfuncs.c (g_strjoin, g_strjoinv and g_strconcat): use
+ g_stpcpy () so these functions run much faster.
+ * config.h.win32.in, glib.def: add reference to g_stpcpy ()
+ * configure.in: Add a test for the stpcpy () function.
+
2001-03-20 Havoc Pennington <hp@redhat.com>
* gutf8.c (g_utf8_strlen): rewrite, based on bug #52328 from
+Mon Mar 26 13:34:50 2001 Owen Taylor <otaylor@redhat.com>
+
+ [ Patch from DindinX <David.Odin@bigfoot.com>, added docs ]
+
+ * gstrfuncs.c, gstrfuncs.h: Add g_stpcpy () for platform that don't
+ have stpcpy ().
+ * gstrfuncs.c (g_strjoin, g_strjoinv and g_strconcat): use
+ g_stpcpy () so these functions run much faster.
+ * config.h.win32.in, glib.def: add reference to g_stpcpy ()
+ * configure.in: Add a test for the stpcpy () function.
+
2001-03-20 Havoc Pennington <hp@redhat.com>
* gutf8.c (g_utf8_strlen): rewrite, based on bug #52328 from
+Mon Mar 26 13:34:50 2001 Owen Taylor <otaylor@redhat.com>
+
+ [ Patch from DindinX <David.Odin@bigfoot.com>, added docs ]
+
+ * gstrfuncs.c, gstrfuncs.h: Add g_stpcpy () for platform that don't
+ have stpcpy ().
+ * gstrfuncs.c (g_strjoin, g_strjoinv and g_strconcat): use
+ g_stpcpy () so these functions run much faster.
+ * config.h.win32.in, glib.def: add reference to g_stpcpy ()
+ * configure.in: Add a test for the stpcpy () function.
+
2001-03-20 Havoc Pennington <hp@redhat.com>
* gutf8.c (g_utf8_strlen): rewrite, based on bug #52328 from
+Mon Mar 26 13:34:50 2001 Owen Taylor <otaylor@redhat.com>
+
+ [ Patch from DindinX <David.Odin@bigfoot.com>, added docs ]
+
+ * gstrfuncs.c, gstrfuncs.h: Add g_stpcpy () for platform that don't
+ have stpcpy ().
+ * gstrfuncs.c (g_strjoin, g_strjoinv and g_strconcat): use
+ g_stpcpy () so these functions run much faster.
+ * config.h.win32.in, glib.def: add reference to g_stpcpy ()
+ * configure.in: Add a test for the stpcpy () function.
+
2001-03-20 Havoc Pennington <hp@redhat.com>
* gutf8.c (g_utf8_strlen): rewrite, based on bug #52328 from
+Mon Mar 26 13:34:50 2001 Owen Taylor <otaylor@redhat.com>
+
+ [ Patch from DindinX <David.Odin@bigfoot.com>, added docs ]
+
+ * gstrfuncs.c, gstrfuncs.h: Add g_stpcpy () for platform that don't
+ have stpcpy ().
+ * gstrfuncs.c (g_strjoin, g_strjoinv and g_strconcat): use
+ g_stpcpy () so these functions run much faster.
+ * config.h.win32.in, glib.def: add reference to g_stpcpy ()
+ * configure.in: Add a test for the stpcpy () function.
+
2001-03-20 Havoc Pennington <hp@redhat.com>
* gutf8.c (g_utf8_strlen): rewrite, based on bug #52328 from
/* Define if you have the on_exit function. */
/* #undef HAVE_ON_EXIT */
+/* Define if you have the stpcpy function. */
+/* #undef HAVE_STPCPY */
+
/* Define if you have the strcasecmp function. */
/* #undef HAVE_STRCASECMP */
GLIB_SIZEOF([$size_includes], intmax_t, intmax_t)
# Check for some functions
-AC_CHECK_FUNCS(lstat strerror strsignal memmove mkstemp vsnprintf strcasecmp strncasecmp poll getcwd)
+AC_CHECK_FUNCS(lstat strerror strsignal memmove mkstemp vsnprintf stpcpy strcasecmp strncasecmp poll getcwd)
# Check if bcopy can be used for overlapping copies, if memmove isn't found.
# The check is borrowed from the PERL Configure script.
g_strndup
g_strdupv
g_strnfill
+g_stpcpy
<SUBSECTION>
g_strlcpy
Portable way to copy <type>va_list</type> variables.
</para>
-<!-- # Unused Parameters # -->
@ap1: the <type>va_list</type> variable to place a copy of @ap2 in.
@ap2: a <type>va_list</type>.
@Returns: a newly-allocated string filled the @fill_char.
+<!-- ##### FUNCTION g_stpcpy ##### -->
+<para>
+
+</para>
+
+@dest:
+@src:
+@Returns:
+
+
<!-- ##### FUNCTION g_strlcpy ##### -->
<para>
g_static_rw_lock_writer_lock
g_static_rw_lock_writer_trylock
g_static_rw_lock_writer_unlock
+ g_strcpy
g_str_equal
g_str_hash
g_strcanon
g_static_rw_lock_writer_lock
g_static_rw_lock_writer_trylock
g_static_rw_lock_writer_unlock
+ g_strcpy
g_str_equal
g_str_hash
g_strcanon
return str;
}
+/**
+ * g_stpcpy:
+ * @dest: destination buffer
+ * @src: source string
+ *
+ * Copies a nul-terminated string into the dest buffer, include the
+ * trailing nul, and return a pointer to the trailing nul byte.
+ * This is useful for concatenating multiple strings together
+ * without having to repeatedly scan for the end.
+ *
+ * Return value: a pointer to trailing nul byte.
+ **/
+gchar *
+g_stpcpy (gchar *dest,
+ const gchar *src)
+{
+#ifdef HAVE_STPCPY
+ g_return_val_if_fail (dest != NULL, NULL);
+ g_return_val_if_fail (src != NULL, NULL);
+ return stpcpy (dest, src);
+#else
+ register gchar *d = dest;
+ register const gchar *s = src;
+
+ g_return_val_if_fail (dest != NULL, NULL);
+ g_return_val_if_fail (src != NULL, NULL);
+ do
+ *d++ = *s;
+ while (*s++ != '\0');
+
+ return d - 1;
+#endif
+}
+
gchar*
g_strdup_vprintf (const gchar *format,
va_list args1)
va_list args;
gchar *s;
gchar *concat;
+ gchar *ptr;
g_return_val_if_fail (string1 != NULL, NULL);
va_end (args);
concat = g_new (gchar, l);
- concat[0] = 0;
+ ptr = concat;
- strcat (concat, string1);
+ ptr = g_stpcpy (ptr, string1);
va_start (args, string1);
s = va_arg (args, gchar*);
while (s)
gchar **str_array)
{
gchar *string;
+ gchar *ptr;
g_return_val_if_fail (str_array != NULL, NULL);
guint separator_len;
separator_len = strlen (separator);
+ /* First part, getting length */
len = 1 + strlen (str_array[0]);
- for(i = 1; str_array[i] != NULL; i++)
- len += separator_len + strlen(str_array[i]);
+ for (i = 1; str_array[i] != NULL; i++)
+ len += strlen (str_array[i]);
+ len += separator_len * (i - 1);
+ /* Second part, building string */
string = g_new (gchar, len);
- *string = 0;
- strcat (string, *str_array);
+ ptr = g_stpcpy (string, *str_array);
for (i = 1; str_array[i] != NULL; i++)
{
- strcat (string, separator);
- strcat (string, str_array[i]);
+ ptr = g_stpcpy (ptr, separator);
+ ptr = g_stpcpy (ptr, str_array[i]);
}
}
else
va_list args;
guint len;
guint separator_len;
+ gchar *ptr;
if (separator == NULL)
separator = "";
if (s)
{
- len = strlen (s);
+ /* First part, getting length */
+ len = 1 + strlen (s);
s = va_arg (args, gchar*);
while (s)
}
va_end (args);
- string = g_new (gchar, len + 1);
- *string = 0;
+ /* Second part, building string */
+ string = g_new (gchar, len);
va_start (args, separator);
s = va_arg (args, gchar*);
- strcat (string, s);
+ ptr = g_stpcpy (string, s);
s = va_arg (args, gchar*);
while (s)
{
- strcat (string, separator);
- strcat (string, s);
+ ptr = g_stpcpy (ptr, separator);
+ ptr = g_stpcpy (ptr, s);
s = va_arg (args, gchar*);
}
}
void g_strfreev (gchar **str_array);
gchar** g_strdupv (gchar **str_array);
+gchar* g_stpcpy (gchar *dest,
+ const char *src);
+
G_END_DECLS
#endif /* __G_STRFUNCS_H__ */
return str;
}
+/**
+ * g_stpcpy:
+ * @dest: destination buffer
+ * @src: source string
+ *
+ * Copies a nul-terminated string into the dest buffer, include the
+ * trailing nul, and return a pointer to the trailing nul byte.
+ * This is useful for concatenating multiple strings together
+ * without having to repeatedly scan for the end.
+ *
+ * Return value: a pointer to trailing nul byte.
+ **/
+gchar *
+g_stpcpy (gchar *dest,
+ const gchar *src)
+{
+#ifdef HAVE_STPCPY
+ g_return_val_if_fail (dest != NULL, NULL);
+ g_return_val_if_fail (src != NULL, NULL);
+ return stpcpy (dest, src);
+#else
+ register gchar *d = dest;
+ register const gchar *s = src;
+
+ g_return_val_if_fail (dest != NULL, NULL);
+ g_return_val_if_fail (src != NULL, NULL);
+ do
+ *d++ = *s;
+ while (*s++ != '\0');
+
+ return d - 1;
+#endif
+}
+
gchar*
g_strdup_vprintf (const gchar *format,
va_list args1)
va_list args;
gchar *s;
gchar *concat;
+ gchar *ptr;
g_return_val_if_fail (string1 != NULL, NULL);
va_end (args);
concat = g_new (gchar, l);
- concat[0] = 0;
+ ptr = concat;
- strcat (concat, string1);
+ ptr = g_stpcpy (ptr, string1);
va_start (args, string1);
s = va_arg (args, gchar*);
while (s)
gchar **str_array)
{
gchar *string;
+ gchar *ptr;
g_return_val_if_fail (str_array != NULL, NULL);
guint separator_len;
separator_len = strlen (separator);
+ /* First part, getting length */
len = 1 + strlen (str_array[0]);
- for(i = 1; str_array[i] != NULL; i++)
- len += separator_len + strlen(str_array[i]);
+ for (i = 1; str_array[i] != NULL; i++)
+ len += strlen (str_array[i]);
+ len += separator_len * (i - 1);
+ /* Second part, building string */
string = g_new (gchar, len);
- *string = 0;
- strcat (string, *str_array);
+ ptr = g_stpcpy (string, *str_array);
for (i = 1; str_array[i] != NULL; i++)
{
- strcat (string, separator);
- strcat (string, str_array[i]);
+ ptr = g_stpcpy (ptr, separator);
+ ptr = g_stpcpy (ptr, str_array[i]);
}
}
else
va_list args;
guint len;
guint separator_len;
+ gchar *ptr;
if (separator == NULL)
separator = "";
if (s)
{
- len = strlen (s);
+ /* First part, getting length */
+ len = 1 + strlen (s);
s = va_arg (args, gchar*);
while (s)
}
va_end (args);
- string = g_new (gchar, len + 1);
- *string = 0;
+ /* Second part, building string */
+ string = g_new (gchar, len);
va_start (args, separator);
s = va_arg (args, gchar*);
- strcat (string, s);
+ ptr = g_stpcpy (string, s);
s = va_arg (args, gchar*);
while (s)
{
- strcat (string, separator);
- strcat (string, s);
+ ptr = g_stpcpy (ptr, separator);
+ ptr = g_stpcpy (ptr, s);
s = va_arg (args, gchar*);
}
}
void g_strfreev (gchar **str_array);
gchar** g_strdupv (gchar **str_array);
+gchar* g_stpcpy (gchar *dest,
+ const char *src);
+
G_END_DECLS
#endif /* __G_STRFUNCS_H__ */