From a0b6661eb6980095f24d6317a31404596d70ba8c Mon Sep 17 00:00:00 2001 From: James Bursa Date: Mon, 29 Jan 2007 22:27:15 +0000 Subject: Make GTK build compile on FreeBSD. svn path=/trunk/netsurf/; revision=3154 --- content/content.c | 1 + content/fetch.c | 5 +++-- content/fetch.h | 3 ++- content/fetchcache.c | 1 + content/urldb.c | 2 ++ css/makeenum | 2 +- css/parser.y | 2 +- css/ruleset.c | 1 + desktop/browser.c | 1 + gtk/gtk_gui.c | 1 + makefile | 4 ++-- posix.mk | 4 ++-- render/box_construct.c | 1 + render/directory.c | 4 ++-- utils/filename.c | 4 ++-- utils/talloc.h | 2 ++ utils/utils.c | 29 ++++++++++++++++++++++++++++- utils/utils.h | 6 +++++- 18 files changed, 58 insertions(+), 15 deletions(-) diff --git a/content/content.c b/content/content.c index 8af888699..f87084bce 100644 --- a/content/content.c +++ b/content/content.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include "netsurf/utils/config.h" #include "netsurf/content/content.h" diff --git a/content/fetch.c b/content/fetch.c index ed1431741..337e4a5ed 100644 --- a/content/fetch.c +++ b/content/fetch.c @@ -24,14 +24,15 @@ #include #include #include +#include #include #ifdef riscos #include #endif -#include "curl/curl.h" +#include #include "netsurf/utils/config.h" #ifdef WITH_SSL -#include "openssl/ssl.h" +#include #endif #include "netsurf/content/fetch.h" #include "netsurf/content/urldb.h" diff --git a/content/fetch.h b/content/fetch.h index 847d16abf..c8a454816 100644 --- a/content/fetch.h +++ b/content/fetch.h @@ -13,7 +13,8 @@ #define _NETSURF_DESKTOP_FETCH_H_ #include -#include "curl/curl.h" +#include +#include #include "netsurf/utils/config.h" typedef enum { diff --git a/content/fetchcache.c b/content/fetchcache.c index 0a7e34c2d..c6c6e3507 100644 --- a/content/fetchcache.c +++ b/content/fetchcache.c @@ -16,6 +16,7 @@ #define _GNU_SOURCE /* for strndup */ #include #include +#include #include #include #include diff --git a/content/urldb.c b/content/urldb.c index 9c3214823..457dc7a90 100644 --- a/content/urldb.c +++ b/content/urldb.c @@ -76,8 +76,10 @@ #include #include #include +#include #include +#include #include #include "netsurf/image/bitmap.h" diff --git a/css/makeenum b/css/makeenum index 0bf4a8f36..54c513d06 100755 --- a/css/makeenum +++ b/css/makeenum @@ -11,7 +11,7 @@ $out = shift or die "usage: makeenum leafname"; open H, ">$out.h" or die "open 'enum.h' failed"; open C, ">$out.c" or die "open 'enum.c' failed"; -print C "#include \n"; +print C "#include \n"; print C "#include \"$out.h\"\n\n"; while (<>) { diff --git a/css/parser.y b/css/parser.y index d131926c8..49bf932fc 100644 --- a/css/parser.y +++ b/css/parser.y @@ -398,7 +398,7 @@ any(A) ::= ASTERISK(B). %extra_argument { struct css_parser_params *param } %include { -#include +#include #define CSS_INTERNALS #include "netsurf/css/css.h" #include "netsurf/utils/utils.h" } diff --git a/css/ruleset.c b/css/ruleset.c index bcfe302f7..1a065cbc1 100644 --- a/css/ruleset.c +++ b/css/ruleset.c @@ -23,6 +23,7 @@ #include #include #include +#include #define CSS_INTERNALS #define NDEBUG #include "netsurf/css/css.h" diff --git a/desktop/browser.c b/desktop/browser.c index f2ac0cde3..1a54232b8 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "curl/curl.h" #include "netsurf/utils/config.h" #include "netsurf/content/fetch.h" diff --git a/gtk/gtk_gui.c b/gtk/gtk_gui.c index d38a0fa17..25cf0edb0 100644 --- a/gtk/gtk_gui.c +++ b/gtk/gtk_gui.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/makefile b/makefile index 09bbc58a2..fbf1a871e 100644 --- a/makefile +++ b/makefile @@ -94,7 +94,7 @@ OBJS_DEBUG=$(OBJECTS_DEBUG:%.o=$(OBJDIR_DEBUG)/%.o) OBJS_DEBUGRO=$(OBJECTS_DEBUGRO:%.o=$(OBJDIR_RISCOS)/%.o) -OBJDIR_GTK = $(shell $(SYSTEM_CC) -dumpmachine)-gtk +OBJDIR_GTK = objects-gtk SOURCES_GTK=$(OBJECTS_GTK:.o=.c) OBJS_GTK=$(OBJECTS_GTK:%.o=$(OBJDIR_GTK)/%.o) @@ -129,7 +129,7 @@ CFLAGS_RISCOS_SMALL = $(CFLAGS_RISCOS) -Dsmall CFLAGS_NCOS = $(CFLAGS_RISCOS) -Dncos CFLAGS_DEBUG = -std=c9x -D_BSD_SOURCE -DDEBUG_BUILD $(WARNFLAGS) -I.. \ $(PLATFORM_CFLAGS_DEBUG) -g -CFLAGS_GTK = -Dnsgtk -std=c9x -D_BSD_SOURCE -D_POSIX_C_SOURCE -Dgtk \ +CFLAGS_GTK = -Dnsgtk -std=c9x -D_BSD_SOURCE -Dgtk \ $(WARNFLAGS) -I.. -g -O0 -Wformat=2 -DNDEBUG \ `pkg-config --cflags libglade-2.0 gtk+-2.0` `xml2-config --cflags` diff --git a/posix.mk b/posix.mk index 11c3c3b13..938f9487b 100644 --- a/posix.mk +++ b/posix.mk @@ -10,14 +10,14 @@ PLATFORM_CFLAGS_RISCOS = -I$(GCCSDK_INSTALL_ENV)/include \ -I$(GCCSDK_INSTALL_ENV)/include/libmng \ #-finstrument-functions PLATFORM_CFLAGS_DEBUG = -I/usr/include/libxml2 -I/riscos/src/OSLib \ - -I/riscos/include/libjpeg -D_POSIX_C_SOURCE + -I/riscos/include/libjpeg -D_POSIX_C_SOURCE=200112 PLATFORM_AFLAGS_RISCOS = -I$(GCCSDK_INSTALL_ENV)/include LDFLAGS_RISCOS = -L$(GCCSDK_INSTALL_ENV)/lib -lxml2 -lz -lcurl -lssl -lcrypto \ -lcares -lmng -lOSLib32 -ljpeg -lrufl -lpencil #-lprof LDFLAGS_SMALL = -L$(GCCSDK_INSTALL_ENV)/lib -lxml2 -lz -lucurl \ -lcares -lmng -lOSLib32 -ljpeg -lrufl -lpencil -LDFLAGS_DEBUG = -L/usr/lib -lxml2 -lz -lm -lcurl -lssl -lcrypto -ldl -lmng \ +LDFLAGS_DEBUG = -L/usr/lib -lxml2 -lz -lm -lcurl -lssl -lcrypto -lmng \ -ljpeg -llcms # Hackery for Cygwin - it has no libdl, so remove it from LDFLAGS diff --git a/render/box_construct.c b/render/box_construct.c index 4244f1337..c7c91fee3 100644 --- a/render/box_construct.c +++ b/render/box_construct.c @@ -19,6 +19,7 @@ #include #include #include +#include #include "libxml/HTMLparser.h" #include "libxml/parserInternals.h" #include "netsurf/utils/config.h" diff --git a/render/directory.c b/render/directory.c index 1449b46f0..c64d05a77 100644 --- a/render/directory.c +++ b/render/directory.c @@ -101,8 +101,8 @@ bool directory_convert(struct content *c, int width, int height) { return false; } while ((entry = readdir(parent)) != NULL) { - if ((entry->d_ino == 0) || (!strcmp(entry->d_name, ".")) || - (!strcmp(entry->d_name, ".."))) + if (!strcmp(entry->d_name, ".") || + !strcmp(entry->d_name, "..")) continue; snprintf(buffer, sizeof(buffer), "%s\n", 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 + /* 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 + * Copyright 2004-2007 James Bursa * Copyright 2003 Phil Mellor * Copyright 2003 John M Bell * Copyright 2004 John Tytgat @@ -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 + * Copyright 2004-2007 James Bursa * Copyright 2004 John Tytgat */ @@ -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); -- cgit v1.2.3