*** empty log message ***
authorOwen Taylor <otaylor@src.gnome.org>
Mon, 26 Mar 2001 18:35:34 +0000 (18:35 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Mon, 26 Mar 2001 18:35:34 +0000 (18:35 +0000)
19 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
config.h.win32.in
configure.in
docs/reference/glib/glib-sections.txt
docs/reference/glib/tmpl/macros_misc.sgml
docs/reference/glib/tmpl/string_utils.sgml
glib.def
glib/glib.def
glib/gstrfuncs.c
glib/gstrfuncs.h
gstrfuncs.c
gstrfuncs.h

index 995f57a..12e494f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+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
index 995f57a..12e494f 100644 (file)
@@ -1,3 +1,14 @@
+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
index 995f57a..12e494f 100644 (file)
@@ -1,3 +1,14 @@
+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
index 995f57a..12e494f 100644 (file)
@@ -1,3 +1,14 @@
+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
index 995f57a..12e494f 100644 (file)
@@ -1,3 +1,14 @@
+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
index 995f57a..12e494f 100644 (file)
@@ -1,3 +1,14 @@
+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
index 995f57a..12e494f 100644 (file)
@@ -1,3 +1,14 @@
+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
index 995f57a..12e494f 100644 (file)
@@ -1,3 +1,14 @@
+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
index d263cf2..6e8f1a8 100644 (file)
 /* 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 */
 
index 9f6a21b..5cd4e33 100644 (file)
@@ -412,7 +412,7 @@ GLIB_SIZEOF([$size_includes], ptrdiff_t, ptrdiff_t)
 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.
index c2bbb37..ebc9f37 100644 (file)
@@ -804,6 +804,7 @@ g_strdup
 g_strndup
 g_strdupv
 g_strnfill
+g_stpcpy
 
 <SUBSECTION>
 g_strlcpy
index 994ffb7..a7768c7 100644 (file)
@@ -66,7 +66,6 @@ only one statement is expected by the compiler.
 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>.
 
index 7ee4906..2bcd04a 100644 (file)
@@ -59,6 +59,16 @@ The returned string should be freed when no longer needed.
 @Returns: a newly-allocated string filled the @fill_char.
 
 
+<!-- ##### FUNCTION g_stpcpy ##### -->
+<para>
+
+</para>
+
+@dest: 
+@src: 
+@Returns: 
+
+
 <!-- ##### FUNCTION g_strlcpy ##### -->
 <para>
 
index 62012cd..3042c52 100644 (file)
--- a/glib.def
+++ b/glib.def
@@ -475,6 +475,7 @@ EXPORTS
        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
index 62012cd..3042c52 100644 (file)
@@ -475,6 +475,7 @@ EXPORTS
        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
index 0efc262..add39aa 100644 (file)
@@ -118,6 +118,40 @@ g_strnfill (guint length,
   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)
@@ -156,6 +190,7 @@ g_strconcat (const gchar *string1, ...)
   va_list args;
   gchar          *s;
   gchar          *concat;
+  gchar   *ptr;
 
   g_return_val_if_fail (string1 != NULL, NULL);
 
@@ -170,9 +205,9 @@ g_strconcat (const gchar *string1, ...)
   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)
@@ -1369,6 +1404,7 @@ g_strjoinv (const gchar  *separator,
            gchar       **str_array)
 {
   gchar *string;
+  gchar *ptr;
 
   g_return_val_if_fail (str_array != NULL, NULL);
 
@@ -1381,17 +1417,19 @@ g_strjoinv (const gchar  *separator,
       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
@@ -1408,6 +1446,7 @@ g_strjoin (const gchar  *separator,
   va_list args;
   guint len;
   guint separator_len;
+  gchar *ptr;
 
   if (separator == NULL)
     separator = "";
@@ -1420,7 +1459,8 @@ g_strjoin (const gchar  *separator,
 
   if (s)
     {
-      len = strlen (s);
+      /* First part, getting length */
+      len = 1 + strlen (s);
 
       s = va_arg (args, gchar*);
       while (s)
@@ -1430,19 +1470,19 @@ g_strjoin (const gchar  *separator,
        }
       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*);
        }
     }
index 11064c3..183fecf 100644 (file)
@@ -119,6 +119,9 @@ gchar*                g_strjoinv       (const gchar  *separator,
 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__ */
index 0efc262..add39aa 100644 (file)
@@ -118,6 +118,40 @@ g_strnfill (guint length,
   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)
@@ -156,6 +190,7 @@ g_strconcat (const gchar *string1, ...)
   va_list args;
   gchar          *s;
   gchar          *concat;
+  gchar   *ptr;
 
   g_return_val_if_fail (string1 != NULL, NULL);
 
@@ -170,9 +205,9 @@ g_strconcat (const gchar *string1, ...)
   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)
@@ -1369,6 +1404,7 @@ g_strjoinv (const gchar  *separator,
            gchar       **str_array)
 {
   gchar *string;
+  gchar *ptr;
 
   g_return_val_if_fail (str_array != NULL, NULL);
 
@@ -1381,17 +1417,19 @@ g_strjoinv (const gchar  *separator,
       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
@@ -1408,6 +1446,7 @@ g_strjoin (const gchar  *separator,
   va_list args;
   guint len;
   guint separator_len;
+  gchar *ptr;
 
   if (separator == NULL)
     separator = "";
@@ -1420,7 +1459,8 @@ g_strjoin (const gchar  *separator,
 
   if (s)
     {
-      len = strlen (s);
+      /* First part, getting length */
+      len = 1 + strlen (s);
 
       s = va_arg (args, gchar*);
       while (s)
@@ -1430,19 +1470,19 @@ g_strjoin (const gchar  *separator,
        }
       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*);
        }
     }
index 11064c3..183fecf 100644 (file)
@@ -119,6 +119,9 @@ gchar*                g_strjoinv       (const gchar  *separator,
 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__ */