summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2007-01-29 22:27:15 +0000
committerJames Bursa <james@netsurf-browser.org>2007-01-29 22:27:15 +0000
commita0b6661eb6980095f24d6317a31404596d70ba8c (patch)
treeb91c612d48815c03d05ec0466c543d85d72628c3 /utils
parentb76283f3d52985abd24081bcbb9196ec440e10af (diff)
downloadnetsurf-a0b6661eb6980095f24d6317a31404596d70ba8c.tar.gz
netsurf-a0b6661eb6980095f24d6317a31404596d70ba8c.tar.bz2
Make GTK build compile on FreeBSD.
svn path=/trunk/netsurf/; revision=3154
Diffstat (limited to 'utils')
-rw-r--r--utils/filename.c4
-rw-r--r--utils/talloc.h2
-rw-r--r--utils/utils.c29
-rw-r--r--utils/utils.h6
4 files changed, 37 insertions, 4 deletions
diff --git a/utils/filename.c b/utils/filename.c
index 194d11c74..84b286dfc 100644
--- a/utils/filename.c
+++ b/utils/filename.c
@@ -216,8 +216,8 @@ bool filename_flush_directory(const char *folder, int depth) {
parent = opendir(folder);
while ((entry = readdir(parent))) {
- if ((entry->d_ino == 0) || (!strcmp(entry->d_name, ".")) ||
- (!strcmp(entry->d_name, "..")))
+ if (!strcmp(entry->d_name, ".") ||
+ !strcmp(entry->d_name, ".."))
continue;
/* first 3 depths are directories only, then files only */
diff --git a/utils/talloc.h b/utils/talloc.h
index 8b448f63c..b0321384e 100644
--- a/utils/talloc.h
+++ b/utils/talloc.h
@@ -21,6 +21,8 @@
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include <unistd.h>
+
/* this is only needed for compatibility with the old talloc */
typedef void TALLOC_CTX;
diff --git a/utils/utils.c b/utils/utils.c
index 63b8e9b29..05f0059ec 100644
--- a/utils/utils.c
+++ b/utils/utils.c
@@ -2,7 +2,7 @@
* This file is part of NetSurf, http://netsurf-browser.org/
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
- * Copyright 2004 James Bursa <bursa@users.sourceforge.net>
+ * Copyright 2004-2007 James Bursa <bursa@users.sourceforge.net>
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
* Copyright 2003 John M Bell <jmb202@ecs.soton.ac.uk>
* Copyright 2004 John Tytgat <John.Tytgat@aaug.net>
@@ -235,3 +235,30 @@ char *strcasestr(const char *haystack, const char *needle)
return NULL;
}
+
+
+#ifdef __FreeBSD__
+
+/**
+ * Duplicate up to n characters of a string.
+ */
+
+char *strndup(const char *s, size_t n)
+{
+ size_t len;
+ char *s2;
+
+ for (len = 0; len != n && s[len]; len++)
+ continue;
+
+ s2 = malloc(len + 1);
+ if (!s2)
+ return 0;
+
+ memcpy(s2, s, len);
+ s2[len] = 0;
+ return s2;
+}
+
+#endif
+
diff --git a/utils/utils.h b/utils/utils.h
index 3e5ed6318..cfc7d8edc 100644
--- a/utils/utils.h
+++ b/utils/utils.h
@@ -2,7 +2,7 @@
* This file is part of NetSurf, http://netsurf-browser.org/
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
- * Copyright 2004 James Bursa <bursa@users.sourceforge.net>
+ * Copyright 2004-2007 James Bursa <bursa@users.sourceforge.net>
* Copyright 2004 John Tytgat <John.Tytgat@aaug.net>
*/
@@ -56,6 +56,10 @@ void unicode_transliterate(unsigned int c, char **r);
char *human_friendly_bytesize(unsigned long bytesize);
const char *rfc1123_date(time_t t);
char *strcasestr(const char *haystack, const char *needle);
+#ifdef __FreeBSD__
+/* FreeBSD lacks strndup */
+char *strndup(const char *s, size_t n);
+#endif
/* Platform specific functions */
void die(const char * const error);