Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

2010-02-13 Gonzalo Paniagua Javier <gonzalo@novell.com>

	* configure.in: check for strndup().
	* src/glib_compat.c: added g_strndup() from eglib.
	Fixes the compilation for systems without strndup().


svn path=/trunk/mod_mono/; revision=151690
  • Loading branch information...
commit 6dbc580ffc710f5af1141936a8e9cf9bb4afa19e 1 parent 931bdab
@gonzalop gonzalop authored
Showing with 24 additions and 2 deletions.
  1. +6 −0 ChangeLog
  2. +1 −1  configure.in
  3. +17 −1 src/glib_compat.c
View
6 ChangeLog
@@ -1,3 +1,9 @@
+2010-02-13 Gonzalo Paniagua Javier <gonzalo@novell.com>
+
+ * configure.in: check for strndup().
+ * src/glib_compat.c: added g_strndup() from eglib.
+ Fixes the compilation for systems without strndup().
+
2009-08-24 Marek Habersack <mhabersack@novell.com>
* configure.in: no longer checks for glib
View
2  configure.in
@@ -42,7 +42,7 @@ AC_HEADER_TIME
AC_FUNC_FORK
AC_HEADER_STDC
AC_FUNC_SELECT_ARGTYPES
-AC_CHECK_FUNCS([memset mkdir unsetenv putenv setenv setrlimit select strcasecmp strerror strrchr dup2])
+AC_CHECK_FUNCS([memset mkdir unsetenv putenv setenv setrlimit select strcasecmp strerror strrchr dup2 strndup])
#
# --enable-debug
View
18 src/glib_compat.c
@@ -8,6 +8,22 @@
#define ASCII_TOLOWER(_ch_) (isascii ((int)(_ch_)) && isalpha ((int)(_ch_))) ? tolower ((_ch_)) : (_ch_)
+static gchar *
+g_strndup (const char *str, int n)
+{
+#ifdef HAVE_STRNDUP
+ return strndup (str, n);
+#else
+ if (str) {
+ char *retval = malloc (n + 1);
+ if (retval)
+ strncpy (retval, str, n)[n] = 0;
+ return retval;
+ }
+ return NULL;
+#endif
+}
+
static void add_to_vector (gchar ***vector, int size, gchar *token)
{
*vector = *vector == NULL ?
@@ -60,7 +76,7 @@ gchar **g_strsplit (const gchar *string, const gchar *delimiter, int max_tokens)
if (*string) {
size_t toklen = (size_t)(string - c);
- token = strndup (c, toklen);
+ token = g_strndup (c, toklen);
if (strcmp (string, delimiter) != 0)
string += delimiter_len;
Please sign in to comment.
Something went wrong with that request. Please try again.