summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Garzik <jgarzik@src.gnome.org>1999-01-02 03:05:36 +0000
committerJeff Garzik <jgarzik@src.gnome.org>1999-01-02 03:05:36 +0000
commitbbbfe78d7051d23b0c833489b97a1a6b76e5e334 (patch)
tree09dc565cb770cafa8afbd5b30f919d6f778c7516
parent3de4d2b78162c7611d7e4823436d240e9d518cbe (diff)
downloadglib-bbbfe78d7051d23b0c833489b97a1a6b76e5e334.tar.gz
Handle NULL strings like g_strdup. s/g_strconcat_a/g_strconcat3_a/ to
* glib.h: (g_strdup_a, g_strndup_a): Handle NULL strings like g_strdup. s/g_strconcat_a/g_strconcat3_a/ to reflect fixed number of args * testglib.c: Added g_strdup, g_strconcat checks. Added str==NULL checks for alloca string macros. s/g_strconcat_a/g_strconcat3_a/
-rw-r--r--ChangeLog11
-rw-r--r--ChangeLog.pre-2-011
-rw-r--r--ChangeLog.pre-2-1011
-rw-r--r--ChangeLog.pre-2-1211
-rw-r--r--ChangeLog.pre-2-211
-rw-r--r--ChangeLog.pre-2-411
-rw-r--r--ChangeLog.pre-2-611
-rw-r--r--ChangeLog.pre-2-811
-rw-r--r--glib.h36
-rw-r--r--glib/glib.h36
-rw-r--r--testglib.c29
-rw-r--r--tests/testglib.c29
12 files changed, 186 insertions, 32 deletions
diff --git a/ChangeLog b/ChangeLog
index 9b6fc714d..92c6b0c4c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+Fri Jan 1 21:58:40 EST 1999 Jeff Garzik <jgarzik@pobox.com>
+
+ * glib.h:
+ (g_strdup_a, g_strndup_a): Handle NULL strings like g_strdup.
+ s/g_strconcat_a/g_strconcat3_a/ to reflect fixed number of args
+
+ * testglib.c:
+ Added g_strdup, g_strconcat checks.
+ Added str==NULL checks for alloca string macros.
+ s/g_strconcat_a/g_strconcat3_a/
+
Fri Jan 1 18:30:41 PST 1999 Manish Singh <yosh@gimp.org>
* testglib.c: made the alloca tests follow the testglib style
diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0
index 9b6fc714d..92c6b0c4c 100644
--- a/ChangeLog.pre-2-0
+++ b/ChangeLog.pre-2-0
@@ -1,3 +1,14 @@
+Fri Jan 1 21:58:40 EST 1999 Jeff Garzik <jgarzik@pobox.com>
+
+ * glib.h:
+ (g_strdup_a, g_strndup_a): Handle NULL strings like g_strdup.
+ s/g_strconcat_a/g_strconcat3_a/ to reflect fixed number of args
+
+ * testglib.c:
+ Added g_strdup, g_strconcat checks.
+ Added str==NULL checks for alloca string macros.
+ s/g_strconcat_a/g_strconcat3_a/
+
Fri Jan 1 18:30:41 PST 1999 Manish Singh <yosh@gimp.org>
* testglib.c: made the alloca tests follow the testglib style
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index 9b6fc714d..92c6b0c4c 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -1,3 +1,14 @@
+Fri Jan 1 21:58:40 EST 1999 Jeff Garzik <jgarzik@pobox.com>
+
+ * glib.h:
+ (g_strdup_a, g_strndup_a): Handle NULL strings like g_strdup.
+ s/g_strconcat_a/g_strconcat3_a/ to reflect fixed number of args
+
+ * testglib.c:
+ Added g_strdup, g_strconcat checks.
+ Added str==NULL checks for alloca string macros.
+ s/g_strconcat_a/g_strconcat3_a/
+
Fri Jan 1 18:30:41 PST 1999 Manish Singh <yosh@gimp.org>
* testglib.c: made the alloca tests follow the testglib style
diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12
index 9b6fc714d..92c6b0c4c 100644
--- a/ChangeLog.pre-2-12
+++ b/ChangeLog.pre-2-12
@@ -1,3 +1,14 @@
+Fri Jan 1 21:58:40 EST 1999 Jeff Garzik <jgarzik@pobox.com>
+
+ * glib.h:
+ (g_strdup_a, g_strndup_a): Handle NULL strings like g_strdup.
+ s/g_strconcat_a/g_strconcat3_a/ to reflect fixed number of args
+
+ * testglib.c:
+ Added g_strdup, g_strconcat checks.
+ Added str==NULL checks for alloca string macros.
+ s/g_strconcat_a/g_strconcat3_a/
+
Fri Jan 1 18:30:41 PST 1999 Manish Singh <yosh@gimp.org>
* testglib.c: made the alloca tests follow the testglib style
diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2
index 9b6fc714d..92c6b0c4c 100644
--- a/ChangeLog.pre-2-2
+++ b/ChangeLog.pre-2-2
@@ -1,3 +1,14 @@
+Fri Jan 1 21:58:40 EST 1999 Jeff Garzik <jgarzik@pobox.com>
+
+ * glib.h:
+ (g_strdup_a, g_strndup_a): Handle NULL strings like g_strdup.
+ s/g_strconcat_a/g_strconcat3_a/ to reflect fixed number of args
+
+ * testglib.c:
+ Added g_strdup, g_strconcat checks.
+ Added str==NULL checks for alloca string macros.
+ s/g_strconcat_a/g_strconcat3_a/
+
Fri Jan 1 18:30:41 PST 1999 Manish Singh <yosh@gimp.org>
* testglib.c: made the alloca tests follow the testglib style
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index 9b6fc714d..92c6b0c4c 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -1,3 +1,14 @@
+Fri Jan 1 21:58:40 EST 1999 Jeff Garzik <jgarzik@pobox.com>
+
+ * glib.h:
+ (g_strdup_a, g_strndup_a): Handle NULL strings like g_strdup.
+ s/g_strconcat_a/g_strconcat3_a/ to reflect fixed number of args
+
+ * testglib.c:
+ Added g_strdup, g_strconcat checks.
+ Added str==NULL checks for alloca string macros.
+ s/g_strconcat_a/g_strconcat3_a/
+
Fri Jan 1 18:30:41 PST 1999 Manish Singh <yosh@gimp.org>
* testglib.c: made the alloca tests follow the testglib style
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index 9b6fc714d..92c6b0c4c 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -1,3 +1,14 @@
+Fri Jan 1 21:58:40 EST 1999 Jeff Garzik <jgarzik@pobox.com>
+
+ * glib.h:
+ (g_strdup_a, g_strndup_a): Handle NULL strings like g_strdup.
+ s/g_strconcat_a/g_strconcat3_a/ to reflect fixed number of args
+
+ * testglib.c:
+ Added g_strdup, g_strconcat checks.
+ Added str==NULL checks for alloca string macros.
+ s/g_strconcat_a/g_strconcat3_a/
+
Fri Jan 1 18:30:41 PST 1999 Manish Singh <yosh@gimp.org>
* testglib.c: made the alloca tests follow the testglib style
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index 9b6fc714d..92c6b0c4c 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -1,3 +1,14 @@
+Fri Jan 1 21:58:40 EST 1999 Jeff Garzik <jgarzik@pobox.com>
+
+ * glib.h:
+ (g_strdup_a, g_strndup_a): Handle NULL strings like g_strdup.
+ s/g_strconcat_a/g_strconcat3_a/ to reflect fixed number of args
+
+ * testglib.c:
+ Added g_strdup, g_strconcat checks.
+ Added str==NULL checks for alloca string macros.
+ s/g_strconcat_a/g_strconcat3_a/
+
Fri Jan 1 18:30:41 PST 1999 Manish Singh <yosh@gimp.org>
* testglib.c: made the alloca tests follow the testglib style
diff --git a/glib.h b/glib.h
index a818844aa..a7160758d 100644
--- a/glib.h
+++ b/glib.h
@@ -1461,26 +1461,32 @@ gpointer g_memdup (gconstpointer mem,
#if G_HAVE_ALLOCA
# define g_strdup_a(newstr,str) G_STMT_START { \
- const char *__old = (str); \
- char *__new; \
- size_t __len = strlen (__old) + 1; \
- __new = alloca (__len); \
- memcpy (__new, __old, __len); \
- (newstr) = __new; \
+ if ((str) == NULL) (newstr) = NULL; \
+ else { \
+ const char *__old = (str); \
+ char *__new; \
+ size_t __len = strlen (__old) + 1; \
+ __new = alloca (__len); \
+ memcpy (__new, __old, __len); \
+ (newstr) = __new; \
+ } \
} G_STMT_END
# define g_strndup_a(newstr,str,n) G_STMT_START { \
- const char *__old = (str); \
- char *__new; \
- size_t __len = strlen (__old); \
- if (__len > (n)) __len = (n); \
- __new = alloca (__len + 1); \
- memcpy (__new, __old, __len); \
- __new[__len] = 0; \
- (newstr) = __new; \
+ if ((str) == NULL) (newstr) = NULL; \
+ else { \
+ const char *__old = (str); \
+ char *__new; \
+ size_t __len = strlen (__old); \
+ if (__len > (n)) __len = (n); \
+ __new = alloca (__len + 1); \
+ memcpy (__new, __old, __len); \
+ __new[__len] = 0; \
+ (newstr) = __new; \
+ } \
} G_STMT_END
-# define g_strconcat_a(newstr,str1,str2,str3) G_STMT_START { \
+# define g_strconcat3_a(newstr,str1,str2,str3) G_STMT_START { \
size_t __len1 = ((str1) == (gchar*)NULL) ? 0 : strlen((str1)); \
size_t __len2 = ((str2) == (gchar*)NULL) ? 0 : strlen((str2)); \
size_t __len3 = ((str3) == (gchar*)NULL) ? 0 : strlen((str3)); \
diff --git a/glib/glib.h b/glib/glib.h
index a818844aa..a7160758d 100644
--- a/glib/glib.h
+++ b/glib/glib.h
@@ -1461,26 +1461,32 @@ gpointer g_memdup (gconstpointer mem,
#if G_HAVE_ALLOCA
# define g_strdup_a(newstr,str) G_STMT_START { \
- const char *__old = (str); \
- char *__new; \
- size_t __len = strlen (__old) + 1; \
- __new = alloca (__len); \
- memcpy (__new, __old, __len); \
- (newstr) = __new; \
+ if ((str) == NULL) (newstr) = NULL; \
+ else { \
+ const char *__old = (str); \
+ char *__new; \
+ size_t __len = strlen (__old) + 1; \
+ __new = alloca (__len); \
+ memcpy (__new, __old, __len); \
+ (newstr) = __new; \
+ } \
} G_STMT_END
# define g_strndup_a(newstr,str,n) G_STMT_START { \
- const char *__old = (str); \
- char *__new; \
- size_t __len = strlen (__old); \
- if (__len > (n)) __len = (n); \
- __new = alloca (__len + 1); \
- memcpy (__new, __old, __len); \
- __new[__len] = 0; \
- (newstr) = __new; \
+ if ((str) == NULL) (newstr) = NULL; \
+ else { \
+ const char *__old = (str); \
+ char *__new; \
+ size_t __len = strlen (__old); \
+ if (__len > (n)) __len = (n); \
+ __new = alloca (__len + 1); \
+ memcpy (__new, __old, __len); \
+ __new[__len] = 0; \
+ (newstr) = __new; \
+ } \
} G_STMT_END
-# define g_strconcat_a(newstr,str1,str2,str3) G_STMT_START { \
+# define g_strconcat3_a(newstr,str1,str2,str3) G_STMT_START { \
size_t __len1 = ((str1) == (gchar*)NULL) ? 0 : strlen((str1)); \
size_t __len2 = ((str2) == (gchar*)NULL) ? 0 : strlen((str2)); \
size_t __len3 = ((str3) == (gchar*)NULL) ? 0 : strlen((str3)); \
diff --git a/testglib.c b/testglib.c
index 852d5582a..70e9ee85e 100644
--- a/testglib.c
+++ b/testglib.c
@@ -748,6 +748,29 @@ main (int argc,
g_print ("ok\n");
+ g_print ("checking g_strdup...");
+ g_assert(g_strdup(NULL) == NULL);
+ string = g_strdup(GLIB_TEST_STRING);
+ g_assert(string != NULL);
+ g_assert(strcmp(string, GLIB_TEST_STRING) == 0);
+ g_free(string);
+
+ g_print ("ok\n");
+
+ g_print ("checking g_strconcat...");
+ string = g_strconcat(GLIB_TEST_STRING, NULL);
+ g_assert(string != NULL);
+ g_assert(strcmp(string, GLIB_TEST_STRING) == 0);
+ g_free(string);
+ string = g_strconcat(GLIB_TEST_STRING, GLIB_TEST_STRING,
+ GLIB_TEST_STRING, NULL);
+ g_assert(string != NULL);
+ g_assert(strcmp(string, GLIB_TEST_STRING GLIB_TEST_STRING
+ GLIB_TEST_STRING) == 0);
+ g_free(string);
+
+ g_print ("ok\n");
+
/* g_debug (argv[0]); */
/* Relation tests */
@@ -879,13 +902,17 @@ main (int argc,
g_strdup_a(string, GLIB_TEST_STRING);
g_assert(string != NULL);
g_assert(strcmp(string, GLIB_TEST_STRING) == 0);
+ g_strdup_a(string, NULL);
+ g_assert(string == NULL);
g_strndup_a(string, GLIB_TEST_STRING, 5);
g_assert(string != NULL);
g_assert(strlen(string) == 5);
g_assert(strcmp(string, GLIB_TEST_STRING_5) == 0);
+ g_strndup_a(string, NULL, 20);
+ g_assert(string == NULL);
- g_strconcat_a(string, GLIB_TEST_STRING, GLIB_TEST_STRING, GLIB_TEST_STRING);
+ g_strconcat3_a(string, GLIB_TEST_STRING, GLIB_TEST_STRING, GLIB_TEST_STRING);
g_assert(string != NULL);
g_assert(strcmp(string, GLIB_TEST_STRING GLIB_TEST_STRING
GLIB_TEST_STRING) == 0);
diff --git a/tests/testglib.c b/tests/testglib.c
index 852d5582a..70e9ee85e 100644
--- a/tests/testglib.c
+++ b/tests/testglib.c
@@ -748,6 +748,29 @@ main (int argc,
g_print ("ok\n");
+ g_print ("checking g_strdup...");
+ g_assert(g_strdup(NULL) == NULL);
+ string = g_strdup(GLIB_TEST_STRING);
+ g_assert(string != NULL);
+ g_assert(strcmp(string, GLIB_TEST_STRING) == 0);
+ g_free(string);
+
+ g_print ("ok\n");
+
+ g_print ("checking g_strconcat...");
+ string = g_strconcat(GLIB_TEST_STRING, NULL);
+ g_assert(string != NULL);
+ g_assert(strcmp(string, GLIB_TEST_STRING) == 0);
+ g_free(string);
+ string = g_strconcat(GLIB_TEST_STRING, GLIB_TEST_STRING,
+ GLIB_TEST_STRING, NULL);
+ g_assert(string != NULL);
+ g_assert(strcmp(string, GLIB_TEST_STRING GLIB_TEST_STRING
+ GLIB_TEST_STRING) == 0);
+ g_free(string);
+
+ g_print ("ok\n");
+
/* g_debug (argv[0]); */
/* Relation tests */
@@ -879,13 +902,17 @@ main (int argc,
g_strdup_a(string, GLIB_TEST_STRING);
g_assert(string != NULL);
g_assert(strcmp(string, GLIB_TEST_STRING) == 0);
+ g_strdup_a(string, NULL);
+ g_assert(string == NULL);
g_strndup_a(string, GLIB_TEST_STRING, 5);
g_assert(string != NULL);
g_assert(strlen(string) == 5);
g_assert(strcmp(string, GLIB_TEST_STRING_5) == 0);
+ g_strndup_a(string, NULL, 20);
+ g_assert(string == NULL);
- g_strconcat_a(string, GLIB_TEST_STRING, GLIB_TEST_STRING, GLIB_TEST_STRING);
+ g_strconcat3_a(string, GLIB_TEST_STRING, GLIB_TEST_STRING, GLIB_TEST_STRING);
g_assert(string != NULL);
g_assert(strcmp(string, GLIB_TEST_STRING GLIB_TEST_STRING
GLIB_TEST_STRING) == 0);