From 6075feb4875ed2035de460fcdc7858f314ad0bef Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sat, 21 Jan 2017 14:20:55 +0000 Subject: create netsurf inttypes header to have portable integer formatting macros --- content/content.c | 3 +- content/fetchers/data.c | 1 + content/fetchers/file.c | 1 + content/fetchers/resource.c | 1 + content/fs_backing_store.c | 2 +- content/handlers/image/image_cache.c | 2 +- content/handlers/image/png.c | 1 + content/handlers/javascript/duktape/dukky.c | 7 ++-- content/llcache.c | 4 +- desktop/netsurf.c | 2 +- frontends/amiga/iff_dr2d.c | 2 +- frontends/atari/bitmap.c | 2 +- frontends/atari/cookies.c | 2 +- frontends/atari/deskmenu.c | 1 + frontends/atari/font.c | 2 +- frontends/atari/treeview.c | 2 +- frontends/framebuffer/font_freetype.c | 2 +- frontends/gtk/window.c | 2 +- frontends/riscos/url_complete.h | 3 +- frontends/riscos/window.c | 3 +- frontends/windows/font.c | 2 +- include/netsurf/inttypes.h | 59 +++++++++++++++++++++++++++++ render/html_css_fetcher.c | 9 +++-- utils/http/primitives.c | 2 +- utils/idna.c | 2 + utils/utils.h | 25 ++---------- 26 files changed, 95 insertions(+), 49 deletions(-) create mode 100644 include/netsurf/inttypes.h diff --git a/content/content.c b/content/content.c index 51c40d73f..2eb035cdf 100644 --- a/content/content.c +++ b/content/content.c @@ -21,10 +21,11 @@ * Content handling implementation. */ -#include +#include #include #include +#include "netsurf/inttypes.h" #include "utils/log.h" #include "utils/messages.h" #include "netsurf/browser_window.h" diff --git a/content/fetchers/data.c b/content/fetchers/data.c index 139d09aea..cb99e6ff2 100644 --- a/content/fetchers/data.c +++ b/content/fetchers/data.c @@ -27,6 +27,7 @@ #include #include +#include "netsurf/inttypes.h" #include "utils/url.h" #include "utils/nsurl.h" #include "utils/corestrings.h" diff --git a/content/fetchers/file.c b/content/fetchers/file.c index 6ffa63810..4fa1a2138 100644 --- a/content/fetchers/file.c +++ b/content/fetchers/file.c @@ -44,6 +44,7 @@ #endif #include +#include "netsurf/inttypes.h" #include "utils/nsurl.h" #include "utils/dirent.h" #include "utils/corestrings.h" diff --git a/content/fetchers/resource.c b/content/fetchers/resource.c index 21ad8c746..b8b4b191f 100644 --- a/content/fetchers/resource.c +++ b/content/fetchers/resource.c @@ -29,6 +29,7 @@ #include #include +#include "netsurf/inttypes.h" #include "utils/nsurl.h" #include "utils/corestrings.h" #include "utils/log.h" diff --git a/content/fs_backing_store.c b/content/fs_backing_store.c index 635f917ba..8670c3117 100644 --- a/content/fs_backing_store.c +++ b/content/fs_backing_store.c @@ -43,11 +43,11 @@ #include #include +#include "netsurf/inttypes.h" #include "utils/filepath.h" #include "utils/file.h" #include "utils/nsurl.h" #include "utils/log.h" -#include "utils/utils.h" #include "utils/messages.h" #include "desktop/gui_internal.h" #include "netsurf/misc.h" diff --git a/content/handlers/image/image_cache.c b/content/handlers/image/image_cache.c index 9c7ce2200..02107f75f 100644 --- a/content/handlers/image/image_cache.c +++ b/content/handlers/image/image_cache.c @@ -22,12 +22,12 @@ */ #include -#include #include #include #include #include +#include "netsurf/inttypes.h" #include "utils/utils.h" #include "utils/log.h" #include "netsurf/misc.h" diff --git a/content/handlers/image/png.c b/content/handlers/image/png.c index 93185c12f..0baf411bf 100644 --- a/content/handlers/image/png.c +++ b/content/handlers/image/png.c @@ -22,6 +22,7 @@ #include #include +#include "netsurf/inttypes.h" #include "utils/utils.h" #include "utils/log.h" #include "utils/messages.h" diff --git a/content/handlers/javascript/duktape/dukky.c b/content/handlers/javascript/duktape/dukky.c index 7dd3bd71e..1282ad9fe 100644 --- a/content/handlers/javascript/duktape/dukky.c +++ b/content/handlers/javascript/duktape/dukky.c @@ -23,16 +23,15 @@ * Duktapeish implementation of javascript engine functions. */ -#include - +#include #include -#include "content/content.h" - +#include "netsurf/inttypes.h" #include "utils/utils.h" #include "utils/nsoption.h" #include "utils/log.h" #include "utils/corestrings.h" +#include "content/content.h" #include "javascript/js.h" #include "javascript/content.h" diff --git a/content/llcache.c b/content/llcache.c index 4bd6eb3e4..eb300534d 100644 --- a/content/llcache.c +++ b/content/llcache.c @@ -35,12 +35,10 @@ #include #include #include -#include - #include +#include "netsurf/inttypes.h" #include "utils/config.h" - #include "utils/corestrings.h" #include "utils/log.h" #include "utils/messages.h" diff --git a/desktop/netsurf.c b/desktop/netsurf.c index 4a1473753..0f597aa9d 100644 --- a/desktop/netsurf.c +++ b/desktop/netsurf.c @@ -25,12 +25,12 @@ #include #include +#include "netsurf/inttypes.h" #include "utils/config.h" #include "utils/nsoption.h" #include "utils/corestrings.h" #include "utils/log.h" #include "utils/utf8.h" -#include "utils/utils.h" #include "utils/messages.h" #include "content/content_factory.h" #include "content/fetchers.h" diff --git a/frontends/amiga/iff_dr2d.c b/frontends/amiga/iff_dr2d.c index 91973f43b..a4c5855a1 100644 --- a/frontends/amiga/iff_dr2d.c +++ b/frontends/amiga/iff_dr2d.c @@ -20,12 +20,12 @@ #include #include -#include #include #include #include #include +#include "netsurf/inttypes.h" #ifndef AMIGA_DR2D_STANDALONE #include "utils/nsurl.h" #include "netsurf/content.h" diff --git a/frontends/atari/bitmap.c b/frontends/atari/bitmap.c index d0de37881..cbb719586 100644 --- a/frontends/atari/bitmap.c +++ b/frontends/atari/bitmap.c @@ -16,12 +16,12 @@ * along with this program. If not, see . */ -#include #include #include #include #include +#include "netsurf/inttypes.h" #include "utils/nsoption.h" #include "utils/log.h" #include "netsurf/bitmap.h" diff --git a/frontends/atari/cookies.c b/frontends/atari/cookies.c index a49aec794..9045009fc 100644 --- a/frontends/atari/cookies.c +++ b/frontends/atari/cookies.c @@ -17,8 +17,8 @@ */ #include -#include +#include "netsurf/inttypes.h" #include "utils/log.h" #include "utils/messages.h" #include "netsurf/mouse.h" diff --git a/frontends/atari/deskmenu.c b/frontends/atari/deskmenu.c index 77df4e568..addba2764 100644 --- a/frontends/atari/deskmenu.c +++ b/frontends/atari/deskmenu.c @@ -23,6 +23,7 @@ #include "utils/nsurl.h" #include "utils/messages.h" #include "utils/nsoption.h" +#include "utils/utils.h" #include "netsurf/browser_window.h" #include "netsurf/keypress.h" #include "desktop/save_complete.h" diff --git a/frontends/atari/font.c b/frontends/atari/font.c index 5402e7870..79716551f 100644 --- a/frontends/atari/font.c +++ b/frontends/atari/font.c @@ -16,11 +16,11 @@ * along with this program. If not, see . */ -#include #include #include #include +#include "netsurf/inttypes.h" #include "utils/utf8.h" #include "utils/log.h" #include "utils/nsoption.h" diff --git a/frontends/atari/treeview.c b/frontends/atari/treeview.c index 731c032e3..78da2b097 100644 --- a/frontends/atari/treeview.c +++ b/frontends/atari/treeview.c @@ -16,13 +16,13 @@ * along with this program. If not, see . */ -#include #include #include #include "assert.h" #include "cflib.h" +#include "netsurf/inttypes.h" #include "utils/nsoption.h" #include "utils/log.h" #include "utils/messages.h" diff --git a/frontends/framebuffer/font_freetype.c b/frontends/framebuffer/font_freetype.c index ccc60ea47..e7c07f5ff 100644 --- a/frontends/framebuffer/font_freetype.c +++ b/frontends/framebuffer/font_freetype.c @@ -17,12 +17,12 @@ * along with this program. If not, see . */ -#include #include #include #include FT_CACHE_H +#include "netsurf/inttypes.h" #include "utils/filepath.h" #include "utils/utf8.h" #include "utils/log.h" diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c index abfda9305..326e57395 100644 --- a/frontends/gtk/window.c +++ b/frontends/gtk/window.c @@ -23,7 +23,6 @@ */ #include -#include #include #include #include @@ -32,6 +31,7 @@ #include #include +#include "netsurf/inttypes.h" #include "utils/log.h" #include "utils/utf8.h" #include "utils/nsoption.h" diff --git a/frontends/riscos/url_complete.h b/frontends/riscos/url_complete.h index 6a4660e4a..92436129e 100644 --- a/frontends/riscos/url_complete.h +++ b/frontends/riscos/url_complete.h @@ -23,9 +23,8 @@ #ifndef _NETSURF_RISCOS_URLCOMPLETE_H_ #define _NETSURF_RISCOS_URLCOMPLETE_H_ -#include #include -#include "oslib/wimp.h" +#include struct gui_window; diff --git a/frontends/riscos/window.c b/frontends/riscos/window.c index 45d5b1461..b1ea58ae1 100644 --- a/frontends/riscos/window.c +++ b/frontends/riscos/window.c @@ -29,10 +29,10 @@ #include #include -#include #include #include #include +#include #include #include #include @@ -43,6 +43,7 @@ #include #include +#include "netsurf/inttypes.h" #include "utils/nsoption.h" #include "utils/log.h" #include "utils/talloc.h" diff --git a/frontends/windows/font.c b/frontends/windows/font.c index 791b8cd5c..f50ba6e9e 100644 --- a/frontends/windows/font.c +++ b/frontends/windows/font.c @@ -23,10 +23,10 @@ */ #include "utils/config.h" -#include #include #include +#include "netsurf/inttypes.h" #include "utils/log.h" #include "utils/nsoption.h" #include "utils/utf8.h" diff --git a/include/netsurf/inttypes.h b/include/netsurf/inttypes.h new file mode 100644 index 000000000..874d83f3d --- /dev/null +++ b/include/netsurf/inttypes.h @@ -0,0 +1,59 @@ +/* + * Copyright 2017 Vincent Sanders + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file + * Netsurf additional integer type formatting macros. + */ + +#ifndef NETSURF_INTTYPES_H +#define NETSURF_INTTYPES_H + +#include + +#ifndef PRIxPTR +#define PRIxPTR "x" +#endif + +#ifndef PRId64 +#define PRId64 "lld" +#endif + +/* Windows does not have sizet formating codes */ +#if defined(_WIN32) + +/** windows printf formatting for size_t type */ +#define PRIsizet "Iu" + +/** windows printf formatting for ssize_t type */ +#define PRIssizet "Id" + +#else + +/** c99 standard printf formatting for size_t type */ +#define PRIsizet "zu" + +/** c99 standard printf formatting for ssize_t type */ +#define PRIssizet "zd" + +#endif + + + +#endif + diff --git a/render/html_css_fetcher.c b/render/html_css_fetcher.c index b9d79a792..9eda6aeb7 100644 --- a/render/html_css_fetcher.c +++ b/render/html_css_fetcher.c @@ -21,18 +21,19 @@ #include #include #include - #include #include +#include "netsurf/inttypes.h" #include "utils/config.h" -#include "content/fetch.h" -#include "content/fetchers.h" -#include "render/html_internal.h" #include "utils/log.h" #include "utils/ring.h" #include "utils/nsurl.h" #include "utils/utils.h" +#include "content/fetch.h" +#include "content/fetchers.h" + +#include "render/html_internal.h" typedef struct html_css_fetcher_item { uint32_t key; diff --git a/utils/http/primitives.c b/utils/http/primitives.c index f4c4e056e..1e24d2a0d 100644 --- a/utils/http/primitives.c +++ b/utils/http/primitives.c @@ -16,11 +16,11 @@ * along with this program. If not, see . */ -#include #include #include #include +#include "netsurf/inttypes.h" #include "utils/http/primitives.h" /** diff --git a/utils/idna.c b/utils/idna.c index d75f957ed..34cc40f83 100644 --- a/utils/idna.c +++ b/utils/idna.c @@ -28,6 +28,8 @@ #include #include +#include "netsurf/inttypes.h" + #include "utils/errors.h" #include "utils/idna.h" #include "utils/idna_props.h" diff --git a/utils/utils.h b/utils/utils.h index 6f2ee4599..3995071cd 100644 --- a/utils/utils.h +++ b/utils/utils.h @@ -23,10 +23,9 @@ * \todo Many of these functions and macros should have their own headers. */ -#ifndef _NETSURF_UTILS_UTILS_H_ -#define _NETSURF_UTILS_UTILS_H_ +#ifndef NETSURF_UTILS_UTILS_H +#define NETSURF_UTILS_UTILS_H -#include #include #ifndef NOF_ELEMENTS @@ -52,29 +51,11 @@ #endif #endif -#ifndef PRIxPTR -#define PRIxPTR "x" -#endif - -#ifndef PRId64 -#define PRId64 "lld" -#endif - -/* Windows does not have sizet formating codes or POSIX mkdir so work - * around that - */ +/* Windows does not have POSIX mkdir so work around that */ #if defined(_WIN32) -/** windows printf formatting for size_t type */ -#define PRIsizet "Iu" -/** windows printf formatting for ssize_t type */ -#define PRIssizet "Id" /** windows mkdir function */ #define nsmkdir(dir, mode) mkdir((dir)) #else -/** c99 standard printf formatting for size_t type */ -#define PRIsizet "zu" -/** c99 standard printf formatting for ssize_t type */ -#define PRIssizet "zd" /** POSIX mkdir function */ #define nsmkdir(dir, mode) mkdir((dir), (mode)) #endif -- cgit v1.2.3