From 4d51150ca0aae979718ac10030df85421b763cd1 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Sun, 28 Jul 2024 16:35:51 +0200 Subject: Make Dillo C99 standard compliant Reviewed-by: dogma --- src/IO/dpi.c | 10 +++---- src/IO/http.c | 6 ++-- src/IO/mime.c | 2 +- src/IO/tls.c | 2 +- src/IO/tls.h | 4 +-- src/IO/tls_mbedtls.h | 4 +-- src/IO/tls_openssl.c | 6 ++-- src/IO/tls_openssl.h | 4 +-- src/auth.c | 16 +++++------ src/bw.c | 4 +-- src/bw.h | 4 +-- src/cache.c | 3 +- src/cookies.c | 4 +-- src/decode.c | 2 +- src/dialog.cc | 2 +- src/dillo.cc | 3 +- src/dns.c | 12 +------- src/history.c | 4 +-- src/hsts.c | 2 +- src/jpeg.c | 11 +++----- src/md5.c | 3 +- src/menu.cc | 4 +-- src/misc.c | 4 +-- src/misc.h | 1 + src/nanosvg.h | 80 ++++++++++++++++++++++++++-------------------------- src/nanosvgrast.h | 4 +-- src/nav.c | 2 +- src/timeout.hh | 2 +- src/uicmd.hh | 2 +- src/url.c | 3 +- 30 files changed, 101 insertions(+), 109 deletions(-) (limited to 'src') diff --git a/src/IO/dpi.c b/src/IO/dpi.c index d7dd7d0b..c1786de6 100644 --- a/src/IO/dpi.c +++ b/src/IO/dpi.c @@ -419,7 +419,7 @@ static int Dpi_read_comm_keys(int *port) /** * Return a socket file descriptor */ -static int Dpi_make_socket_fd() +static int Dpi_make_socket_fd(void) { int fd, one = 1, ret = -1; @@ -435,7 +435,7 @@ static int Dpi_make_socket_fd() * Make a connection test for a IDS. * Return: 1 OK, -1 Not working. */ -static int Dpi_check_dpid_ids() +static int Dpi_check_dpid_ids(void) { struct sockaddr_in sin; const socklen_t sin_sz = sizeof(sin); @@ -504,12 +504,12 @@ static int Dpi_check_dpid(int num_tries) static int Dpi_blocking_start_dpid(void) { int cst, try = 0, - n_tries = 12; /* 3 seconds */ + n_tries = 3; /* 3 seconds */ /* test the dpid, and wait a bit for it to start if necessary */ while ((cst = Dpi_check_dpid(n_tries)) == 1) { MSG("Dpi_blocking_start_dpid: try %d\n", ++try); - usleep(250000); /* 1/4 sec */ + sleep(1); } return cst; } @@ -757,7 +757,7 @@ void a_Dpi_ccc(int Op, int Branch, int Dir, ChainLink *Info, * Note: currently disabled. It may serve to let the cookies dpi know * when to expire session cookies. */ -void a_Dpi_dillo_exit() +void a_Dpi_dillo_exit(void) { } diff --git a/src/IO/http.c b/src/IO/http.c index 4c4618c5..c7915fc5 100644 --- a/src/IO/http.c +++ b/src/IO/http.c @@ -234,7 +234,7 @@ void a_Http_connect_done(int fd, bool_t success) dFree(info); } } else { - MSG("**** but no luck with fme %p or sd\n", fme); + MSG("**** but no luck with fme %p or sd\n", (void *) fme); } } @@ -1091,7 +1091,7 @@ static void Http_server_remove(Server_t *srv) dFree(srv); } -static void Http_servers_remove_all() +static void Http_servers_remove_all(void) { Server_t *srv; SocketData_t *sd; @@ -1107,7 +1107,7 @@ static void Http_servers_remove_all() dList_free(servers); } -static void Http_fd_map_remove_all() +static void Http_fd_map_remove_all(void) { FdMapEntry_t *fme; int i, n = dList_length(fd_map); diff --git a/src/IO/mime.c b/src/IO/mime.c index bc70a85f..1f6a3d47 100644 --- a/src/IO/mime.c +++ b/src/IO/mime.c @@ -94,7 +94,7 @@ static Viewer_t Mime_major_type_fetch(const char *Key, uint_t Size) /** * Initializes Mime module and, sets the supported Mime types. */ -void a_Mime_init() +void a_Mime_init(void) { #ifdef ENABLE_GIF Mime_add_minor_type("image/gif", a_Dicache_gif_image); diff --git a/src/IO/tls.c b/src/IO/tls.c index 05ae2514..4c0cfe7e 100644 --- a/src/IO/tls.c +++ b/src/IO/tls.c @@ -28,7 +28,7 @@ /** * Initialize TLS library. */ -void a_Tls_init() +void a_Tls_init(void) { #if ! defined(ENABLE_TLS) MSG("TLS: Disabled at compilation time.\n"); diff --git a/src/IO/tls.h b/src/IO/tls.h index 25da6ea6..500b2421 100644 --- a/src/IO/tls.h +++ b/src/IO/tls.h @@ -31,13 +31,13 @@ extern "C" { #define TLS_CONNECT_NOT_YET 0 #define TLS_CONNECT_READY 1 -void a_Tls_init(); +void a_Tls_init(void); int a_Tls_certificate_is_clean(const DilloUrl *url); int a_Tls_connect_ready(const DilloUrl *url); void a_Tls_reset_server_state(const DilloUrl *url); void a_Tls_connect(int fd, const DilloUrl *url); void *a_Tls_connection(int fd); -void a_Tls_freeall(); +void a_Tls_freeall(void); void a_Tls_close_by_fd(int fd); int a_Tls_read(void *conn, void *buf, size_t len); int a_Tls_write(void *conn, void *buf, size_t len); diff --git a/src/IO/tls_mbedtls.h b/src/IO/tls_mbedtls.h index 4a679698..8ce16318 100644 --- a/src/IO/tls_mbedtls.h +++ b/src/IO/tls_mbedtls.h @@ -21,13 +21,13 @@ extern "C" { #include "../url.h" -void a_Tls_mbedtls_init(); +void a_Tls_mbedtls_init(void); int a_Tls_mbedtls_certificate_is_clean(const DilloUrl *url); int a_Tls_mbedtls_connect_ready(const DilloUrl *url); void a_Tls_mbedtls_reset_server_state(const DilloUrl *url); void a_Tls_mbedtls_connect(int fd, const DilloUrl *url); void *a_Tls_mbedtls_connection(int fd); -void a_Tls_mbedtls_freeall(); +void a_Tls_mbedtls_freeall(void); void a_Tls_mbedtls_close_by_fd(int fd); int a_Tls_mbedtls_read(void *conn, void *buf, size_t len); int a_Tls_mbedtls_write(void *conn, void *buf, size_t len); diff --git a/src/IO/tls_openssl.c b/src/IO/tls_openssl.c index 10a68dbd..3e68e928 100644 --- a/src/IO/tls_openssl.c +++ b/src/IO/tls_openssl.c @@ -199,7 +199,7 @@ static void Tls_info_cb(const SSL *ssl, int where, int ret) * abysmal openssl documentation, this was worked out from reading discussion * on the web and then reading openssl source to see what it normally does. */ -static void Tls_load_certificates() +static void Tls_load_certificates(void) { /* curl-7.37.1 says that the following bundle locations are used on "Debian * systems", "Redhat and Mandriva", "old(er) Redhat", "FreeBSD", and @@ -1338,7 +1338,7 @@ void a_Tls_openssl_close_by_fd(int fd) } } -static void Tls_servers_freeall() +static void Tls_servers_freeall(void) { if (servers) { Server_t *s; @@ -1353,7 +1353,7 @@ static void Tls_servers_freeall() } } -static void Tls_fd_map_remove_all() +static void Tls_fd_map_remove_all(void) { if (fd_map) { FdMapEntry_t *fme; diff --git a/src/IO/tls_openssl.h b/src/IO/tls_openssl.h index 5cfd5dfd..edde93ef 100644 --- a/src/IO/tls_openssl.h +++ b/src/IO/tls_openssl.h @@ -31,13 +31,13 @@ extern "C" { #include "../url.h" -void a_Tls_openssl_init(); +void a_Tls_openssl_init(void); int a_Tls_openssl_certificate_is_clean(const DilloUrl *url); int a_Tls_openssl_connect_ready(const DilloUrl *url); void a_Tls_openssl_reset_server_state(const DilloUrl *url); void a_Tls_openssl_connect(int fd, const DilloUrl *url); void *a_Tls_openssl_connection(int fd); -void a_Tls_openssl_freeall(); +void a_Tls_openssl_freeall(void); void a_Tls_openssl_close_by_fd(int fd); int a_Tls_openssl_read(void *conn, void *buf, size_t len); int a_Tls_openssl_write(void *conn, void *buf, size_t len); diff --git a/src/auth.c b/src/auth.c index 816bc9d3..cb00f475 100644 --- a/src/auth.c +++ b/src/auth.c @@ -17,7 +17,7 @@ */ -#include /* iscntrl */ +#include /* iscntrl, isascii */ #include "auth.h" #include "msg.h" #include "misc.h" @@ -61,7 +61,7 @@ void a_Auth_init(void) auth_hosts = dList_new(1); } -static AuthParse_t *Auth_parse_new() +static AuthParse_t *Auth_parse_new(void) { AuthParse_t *auth_parse = dNew(AuthParse_t, 1); auth_parse->ok = 0; @@ -105,7 +105,7 @@ static int Auth_path_is_inside(const char *path1, const char *path2, int len) static int Auth_is_token_char(char c) { const char *invalid = "\"()<>@,;:\\[]?=/{} \t"; - return (!isascii(c) || strchr(invalid, c) || iscntrl((uchar_t)c)) ? 0 : 1; + return (!d_isascii(c) || strchr(invalid, c) || iscntrl((uchar_t)c)) ? 0 : 1; } /** @@ -231,7 +231,7 @@ static int Auth_parse_basic_challenge_cb(AuthParse_t *auth_parse, char *token, { if (dStrAsciiCasecmp("realm", token) == 0) { if (!auth_parse->realm) - auth_parse->realm = strdup(value); + auth_parse->realm = dStrdup(value); return 0; /* end parsing */ } else MSG("Auth_parse_basic_challenge_cb: Ignoring unknown parameter: %s = " @@ -245,13 +245,13 @@ static int Auth_parse_digest_challenge_cb(AuthParse_t *auth_parse, char *token, const char *const fn = "Auth_parse_digest_challenge_cb"; if (!dStrAsciiCasecmp("realm", token) && !auth_parse->realm) - auth_parse->realm = strdup(value); + auth_parse->realm = dStrdup(value); else if (!strcmp("domain", token) && !auth_parse->domain) - auth_parse->domain = strdup(value); + auth_parse->domain = dStrdup(value); else if (!strcmp("nonce", token) && !auth_parse->nonce) - auth_parse->nonce = strdup(value); + auth_parse->nonce = dStrdup(value); else if (!strcmp("opaque", token) && !auth_parse->opaque) - auth_parse->opaque = strdup(value); + auth_parse->opaque = dStrdup(value); else if (strcmp("stale", token) == 0) { if (dStrAsciiCasecmp("true", value) == 0) auth_parse->stale = 1; diff --git a/src/bw.c b/src/bw.c index ae399028..dbc61fa6 100644 --- a/src/bw.c +++ b/src/bw.c @@ -44,7 +44,7 @@ void a_Bw_init(void) * Create a new browser window and return it. * (the new window is stored in browser_window[]) */ -BrowserWindow *a_Bw_new() +BrowserWindow *a_Bw_new(void) { BrowserWindow *bw; @@ -302,7 +302,7 @@ void a_Bw_cleanup(BrowserWindow *bw) /*--------------------------------------------------------------------------*/ -int a_Bw_num() +int a_Bw_num(void) { return num_bws; } diff --git a/src/bw.h b/src/bw.h index a043e1ea..d6967ff8 100644 --- a/src/bw.h +++ b/src/bw.h @@ -81,10 +81,10 @@ extern "C" { void a_Bw_init(void); -BrowserWindow *a_Bw_new(); +BrowserWindow *a_Bw_new(void); void a_Bw_free(BrowserWindow *bw); BrowserWindow *a_Bw_get(int i); -int a_Bw_num(); +int a_Bw_num(void); void a_Bw_add_client(BrowserWindow *bw, int Key, int Root); int a_Bw_remove_client(BrowserWindow *bw, int ClientKey); diff --git a/src/cache.c b/src/cache.c index acdeb8b4..8c05c0eb 100644 --- a/src/cache.c +++ b/src/cache.c @@ -1359,9 +1359,10 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry) /** * Callback function for Cache_delayed_process_queue. */ -static void Cache_delayed_process_queue_callback() +static void Cache_delayed_process_queue_callback(void *ptr) { CacheEntry_t *entry; + (void) ptr; /* Unused */ while ((entry = (CacheEntry_t *)dList_nth_data(DelayedQueue, 0))) { Cache_ref_data(entry); diff --git a/src/cookies.c b/src/cookies.c index 589c244f..c2381e04 100644 --- a/src/cookies.c +++ b/src/cookies.c @@ -2,7 +2,7 @@ * File: cookies.c * * Copyright 2001 Lars Clausen - * Jörgen Viksell + * Jörgen Viksell * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -132,7 +132,7 @@ void a_Cookies_init(void) /** * Flush cookies to disk and free all the memory allocated. */ -void a_Cookies_freeall() +void a_Cookies_freeall(void) { } diff --git a/src/decode.c b/src/decode.c index 974e1c39..0e95f386 100644 --- a/src/decode.c +++ b/src/decode.c @@ -304,7 +304,7 @@ DecodeTransfer *a_Decode_transfer_init(const char *format) return dc; } -static Decode *Decode_content_init_common() +static Decode *Decode_content_init_common(void) { z_stream *zs = dNew(z_stream, 1); Decode *dc = dNew(Decode, 1); diff --git a/src/dialog.cc b/src/dialog.cc index 70771be9..34928095 100644 --- a/src/dialog.cc +++ b/src/dialog.cc @@ -184,7 +184,7 @@ const char *a_Dialog_input(const char *title, const char *msg) if (!pm) { int n_it = dList_length(prefs.search_urls); pm = new Fl_Menu_Item[n_it+1]; - memset(pm, '\0', sizeof(*pm)); + memset(pm, '\0', (n_it + 1) * sizeof(Fl_Menu_Item)); for (int i = 0, j = 0; i < n_it; i++) { char *label, *url, *source; source = (char *)dList_nth_data(prefs.search_urls, i); diff --git a/src/dillo.cc b/src/dillo.cc index 889b5256..e9fbfdd7 100644 --- a/src/dillo.cc +++ b/src/dillo.cc @@ -125,6 +125,8 @@ static void raw_sigchld2(int signum) pid_t pid; int status; + (void) signum; /* Unused */ + while (1) { pid = waitpid(-1, &status, WNOHANG); if (pid > 0) { @@ -141,7 +143,6 @@ static void raw_sigchld2(int signum) break; } } - ++signum; /* compiler happiness */ } /** diff --git a/src/dns.c b/src/dns.c index 86b78c9d..188ee691 100644 --- a/src/dns.c +++ b/src/dns.c @@ -288,17 +288,7 @@ static void *Dns_server(void *data) if (error != 0) { dns_server[channel].status = error; - if (error == EAI_NONAME) - MSG("DNS error: HOST_NOT_FOUND\n"); - else if (error == EAI_AGAIN) - MSG("DNS error: TRY_AGAIN\n"); -#ifdef EAI_NODATA - /* Some FreeBSD don't have this anymore */ - else if (error == EAI_NODATA) - MSG("DNS error: NO_ADDRESS\n"); -#endif - else if (h_errno == EAI_FAIL) - MSG("DNS error: NO_RECOVERY\n"); + MSG("DNS error: %s\n", gai_strerror(error)); } else { Dns_note_hosts(hosts, res0); dns_server[channel].status = 0; diff --git a/src/history.c b/src/history.c index de77b5c9..49541dfd 100644 --- a/src/history.c +++ b/src/history.c @@ -33,7 +33,7 @@ static int history_size_max = 16; /** * Debug procedure. */ -void History_show() +void History_show(void) { int i; @@ -149,7 +149,7 @@ void a_History_set_title_by_url(const DilloUrl *url, const char *title) /** * Free all the memory used by this module */ -void a_History_freeall() +void a_History_freeall(void) { int i; diff --git a/src/hsts.c b/src/hsts.c index 435ccfb4..3ea82070 100644 --- a/src/hsts.c +++ b/src/hsts.c @@ -52,7 +52,7 @@ static void Hsts_free_policy(HstsData_t *p) dFree(p); } -void a_Hsts_freeall() +void a_Hsts_freeall(void) { if (prefs.http_strict_transport_security) { HstsData_t *policy; diff --git a/src/jpeg.c b/src/jpeg.c index 468891fc..59234d1d 100644 --- a/src/jpeg.c +++ b/src/jpeg.c @@ -119,13 +119,9 @@ static void Jpeg_close(DilloJpeg *jpeg, CacheClient_t *Client) Jpeg_free(jpeg); } -/* - * The proper signature is: - * static void init_source(j_decompress_ptr cinfo) - * (declaring it with no parameter avoids a compiler warning) - */ -static void init_source() +static void init_source(struct jpeg_decompress_struct *p) { + (void) p; /* unused */ } static boolean fill_input_buffer(j_decompress_ptr cinfo) @@ -181,8 +177,9 @@ static void skip_input_data(j_decompress_ptr cinfo, long num_bytes) * static void term_source(j_decompress_ptr cinfo) * (declaring it with no parameter avoids a compiler warning) */ -static void term_source() +static void term_source(struct jpeg_decompress_struct *p) { + (void) p; /* unused */ } void *a_Jpeg_new(DilloImage *Image, DilloUrl *url, int version) diff --git a/src/md5.c b/src/md5.c index 7b7d4e94..7af79d84 100644 --- a/src/md5.c +++ b/src/md5.c @@ -63,6 +63,7 @@ #include "md5.h" #include +#include #undef BYTE_ORDER /* 1 = big-endian, -1 = little-endian, 0 = unknown */ #ifdef ARCH_IS_BIG_ENDIAN @@ -171,7 +172,7 @@ md5_process(md5_state_t *pms, const md5_byte_t *data /*[64]*/) * On little-endian machines, we can process properly aligned * data without copying it. */ - if (!((data - (const md5_byte_t *)0) & 3)) { + if (((uintptr_t) data & 3) == 0) { /* data are properly aligned */ X = (const md5_word_t *)data; } else { diff --git a/src/menu.cc b/src/menu.cc index b045bf66..7cea24a7 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -397,7 +397,7 @@ void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url, if (cssUrls && cssUrls->size () > 0) { stylesheets = new Fl_Menu_Item[cssUrls->size() + 1]; - memset(stylesheets, '\0', sizeof(*stylesheets)); + memset(stylesheets, '\0', (cssUrls->size() + 1) * sizeof(Fl_Menu_Item)); for (j = 0; j < cssUrls->size(); j++) { DilloUrl *url = cssUrls->get(j); @@ -638,7 +638,7 @@ void a_Menu_history_popup(BrowserWindow *bw, int x, int y, int direction) ; pm = new Fl_Menu_Item[n + 1]; - memset(pm, '\0', sizeof(*pm)); + memset(pm, '\0', (n + 1) * sizeof(Fl_Menu_Item)); for (i = 0; i < n; i++) { pm[i].label(FL_NORMAL_LABEL, a_History_get_title(history_list[i], 1)); diff --git a/src/misc.c b/src/misc.c index d6fbb83b..9129f819 100644 --- a/src/misc.c +++ b/src/misc.c @@ -222,13 +222,13 @@ void a_Misc_parse_content_type(const char *type, char **major, char **minor, if (!(str = type)) return; - for (s = str; *s && isascii((uchar_t)*s) && !iscntrl((uchar_t)*s) && + for (s = str; *s && d_isascii((uchar_t)*s) && !iscntrl((uchar_t)*s) && !strchr(tspecials_space, *s); s++) ; if (major) *major = dStrndup(str, s - str); if (*s == '/') { - for (str = ++s; *s && isascii((uchar_t)*s) && !iscntrl((uchar_t)*s) && + for (str = ++s; *s && d_isascii((uchar_t)*s) && !iscntrl((uchar_t)*s) && !strchr(tspecials_space, *s); s++) ; if (minor) *minor = dStrndup(str, s - str); diff --git a/src/misc.h b/src/misc.h index 75f0f78a..5e52b5b3 100644 --- a/src/misc.h +++ b/src/misc.h @@ -8,6 +8,7 @@ extern "C" { #endif /* __cplusplus */ +#define d_isascii(c) (((c) & ~0x7f) == 0) char *a_Misc_escape_chars(const char *str, const char *esc_set); int a_Misc_expand_tabs(char **start, char *end, char *buf, int buflen); diff --git a/src/nanosvg.h b/src/nanosvg.h index 98b06bea..77617f65 100644 --- a/src/nanosvg.h +++ b/src/nanosvg.h @@ -125,7 +125,7 @@ typedef struct NSVGpaint { union { unsigned int color; NSVGgradient* gradient; - }; + } v; } NSVGpaint; typedef struct NSVGpath @@ -405,7 +405,7 @@ typedef struct NSVGgradientData union { NSVGlinearData linear; NSVGradialData radial; - }; + } grad; char spread; char units; float xform[6]; @@ -673,7 +673,7 @@ static void nsvg__deletePaths(NSVGpath* path) static void nsvg__deletePaint(NSVGpaint* paint) { if (paint->type == NSVG_PAINT_LINEAR_GRADIENT || paint->type == NSVG_PAINT_RADIAL_GRADIENT) - free(paint->gradient); + free(paint->v.gradient); } static void nsvg__deleteGradientData(NSVGgradientData* grad) @@ -875,10 +875,10 @@ static NSVGgradient* nsvg__createGradient(NSVGparser* p, const char* id, const f if (data->type == NSVG_PAINT_LINEAR_GRADIENT) { float x1, y1, x2, y2, dx, dy; - x1 = nsvg__convertToPixels(p, data->linear.x1, ox, sw); - y1 = nsvg__convertToPixels(p, data->linear.y1, oy, sh); - x2 = nsvg__convertToPixels(p, data->linear.x2, ox, sw); - y2 = nsvg__convertToPixels(p, data->linear.y2, oy, sh); + x1 = nsvg__convertToPixels(p, data->grad.linear.x1, ox, sw); + y1 = nsvg__convertToPixels(p, data->grad.linear.y1, oy, sh); + x2 = nsvg__convertToPixels(p, data->grad.linear.x2, ox, sw); + y2 = nsvg__convertToPixels(p, data->grad.linear.y2, oy, sh); // Calculate transform aligned to the line dx = x2 - x1; dy = y2 - y1; @@ -887,11 +887,11 @@ static NSVGgradient* nsvg__createGradient(NSVGparser* p, const char* id, const f grad->xform[4] = x1; grad->xform[5] = y1; } else { float cx, cy, fx, fy, r; - cx = nsvg__convertToPixels(p, data->radial.cx, ox, sw); - cy = nsvg__convertToPixels(p, data->radial.cy, oy, sh); - fx = nsvg__convertToPixels(p, data->radial.fx, ox, sw); - fy = nsvg__convertToPixels(p, data->radial.fy, oy, sh); - r = nsvg__convertToPixels(p, data->radial.r, 0, sl); + cx = nsvg__convertToPixels(p, data->grad.radial.cx, ox, sw); + cy = nsvg__convertToPixels(p, data->grad.radial.cy, oy, sh); + fx = nsvg__convertToPixels(p, data->grad.radial.fx, ox, sw); + fy = nsvg__convertToPixels(p, data->grad.radial.fy, oy, sh); + r = nsvg__convertToPixels(p, data->grad.radial.r, 0, sl); // Calculate transform aligned to the circle grad->xform[0] = r; grad->xform[1] = 0; grad->xform[2] = 0; grad->xform[3] = r; @@ -1001,8 +1001,8 @@ static void nsvg__addShape(NSVGparser* p) shape->fill.type = NSVG_PAINT_NONE; } else if (attr->hasFill == 1) { shape->fill.type = NSVG_PAINT_COLOR; - shape->fill.color = attr->fillColor; - shape->fill.color |= (unsigned int)(attr->fillOpacity*255) << 24; + shape->fill.v.color = attr->fillColor; + shape->fill.v.color |= (unsigned int)(attr->fillOpacity*255) << 24; } else if (attr->hasFill == 2) { shape->fill.type = NSVG_PAINT_UNDEF; } @@ -1012,8 +1012,8 @@ static void nsvg__addShape(NSVGparser* p) shape->stroke.type = NSVG_PAINT_NONE; } else if (attr->hasStroke == 1) { shape->stroke.type = NSVG_PAINT_COLOR; - shape->stroke.color = attr->strokeColor; - shape->stroke.color |= (unsigned int)(attr->strokeOpacity*255) << 24; + shape->stroke.v.color = attr->strokeColor; + shape->stroke.v.color |= (unsigned int)(attr->strokeOpacity*255) << 24; } else if (attr->hasStroke == 2) { shape->stroke.type = NSVG_PAINT_UNDEF; } @@ -2717,14 +2717,14 @@ static void nsvg__parseGradient(NSVGparser* p, const char** attr, signed char ty grad->units = NSVG_OBJECT_SPACE; grad->type = type; if (grad->type == NSVG_PAINT_LINEAR_GRADIENT) { - grad->linear.x1 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT); - grad->linear.y1 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT); - grad->linear.x2 = nsvg__coord(100.0f, NSVG_UNITS_PERCENT); - grad->linear.y2 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT); + grad->grad.linear.x1 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT); + grad->grad.linear.y1 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT); + grad->grad.linear.x2 = nsvg__coord(100.0f, NSVG_UNITS_PERCENT); + grad->grad.linear.y2 = nsvg__coord(0.0f, NSVG_UNITS_PERCENT); } else if (grad->type == NSVG_PAINT_RADIAL_GRADIENT) { - grad->radial.cx = nsvg__coord(50.0f, NSVG_UNITS_PERCENT); - grad->radial.cy = nsvg__coord(50.0f, NSVG_UNITS_PERCENT); - grad->radial.r = nsvg__coord(50.0f, NSVG_UNITS_PERCENT); + grad->grad.radial.cx = nsvg__coord(50.0f, NSVG_UNITS_PERCENT); + grad->grad.radial.cy = nsvg__coord(50.0f, NSVG_UNITS_PERCENT); + grad->grad.radial.r = nsvg__coord(50.0f, NSVG_UNITS_PERCENT); } nsvg__xformIdentity(grad->xform); @@ -2742,23 +2742,23 @@ static void nsvg__parseGradient(NSVGparser* p, const char** attr, signed char ty } else if (strcmp(attr[i], "gradientTransform") == 0) { nsvg__parseTransform(grad->xform, attr[i + 1]); } else if (strcmp(attr[i], "cx") == 0) { - grad->radial.cx = nsvg__parseCoordinateRaw(attr[i + 1]); + grad->grad.radial.cx = nsvg__parseCoordinateRaw(attr[i + 1]); } else if (strcmp(attr[i], "cy") == 0) { - grad->radial.cy = nsvg__parseCoordinateRaw(attr[i + 1]); + grad->grad.radial.cy = nsvg__parseCoordinateRaw(attr[i + 1]); } else if (strcmp(attr[i], "r") == 0) { - grad->radial.r = nsvg__parseCoordinateRaw(attr[i + 1]); + grad->grad.radial.r = nsvg__parseCoordinateRaw(attr[i + 1]); } else if (strcmp(attr[i], "fx") == 0) { - grad->radial.fx = nsvg__parseCoordinateRaw(attr[i + 1]); + grad->grad.radial.fx = nsvg__parseCoordinateRaw(attr[i + 1]); } else if (strcmp(attr[i], "fy") == 0) { - grad->radial.fy = nsvg__parseCoordinateRaw(attr[i + 1]); + grad->grad.radial.fy = nsvg__parseCoordinateRaw(attr[i + 1]); } else if (strcmp(attr[i], "x1") == 0) { - grad->linear.x1 = nsvg__parseCoordinateRaw(attr[i + 1]); + grad->grad.linear.x1 = nsvg__parseCoordinateRaw(attr[i + 1]); } else if (strcmp(attr[i], "y1") == 0) { - grad->linear.y1 = nsvg__parseCoordinateRaw(attr[i + 1]); + grad->grad.linear.y1 = nsvg__parseCoordinateRaw(attr[i + 1]); } else if (strcmp(attr[i], "x2") == 0) { - grad->linear.x2 = nsvg__parseCoordinateRaw(attr[i + 1]); + grad->grad.linear.x2 = nsvg__parseCoordinateRaw(attr[i + 1]); } else if (strcmp(attr[i], "y2") == 0) { - grad->linear.y2 = nsvg__parseCoordinateRaw(attr[i + 1]); + grad->grad.linear.y2 = nsvg__parseCoordinateRaw(attr[i + 1]); } else if (strcmp(attr[i], "spreadMethod") == 0) { if (strcmp(attr[i+1], "pad") == 0) grad->spread = NSVG_SPREAD_PAD; @@ -3050,14 +3050,14 @@ static void nsvg__scaleToViewbox(NSVGparser* p, const char* units) } if (shape->fill.type == NSVG_PAINT_LINEAR_GRADIENT || shape->fill.type == NSVG_PAINT_RADIAL_GRADIENT) { - nsvg__scaleGradient(shape->fill.gradient, tx,ty, sx,sy); - memcpy(t, shape->fill.gradient->xform, sizeof(float)*6); - nsvg__xformInverse(shape->fill.gradient->xform, t); + nsvg__scaleGradient(shape->fill.v.gradient, tx,ty, sx,sy); + memcpy(t, shape->fill.v.gradient->xform, sizeof(float)*6); + nsvg__xformInverse(shape->fill.v.gradient->xform, t); } if (shape->stroke.type == NSVG_PAINT_LINEAR_GRADIENT || shape->stroke.type == NSVG_PAINT_RADIAL_GRADIENT) { - nsvg__scaleGradient(shape->stroke.gradient, tx,ty, sx,sy); - memcpy(t, shape->stroke.gradient->xform, sizeof(float)*6); - nsvg__xformInverse(shape->stroke.gradient->xform, t); + nsvg__scaleGradient(shape->stroke.v.gradient, tx,ty, sx,sy); + memcpy(t, shape->stroke.v.gradient->xform, sizeof(float)*6); + nsvg__xformInverse(shape->stroke.v.gradient->xform, t); } shape->strokeWidth *= avgs; @@ -3080,7 +3080,7 @@ static void nsvg__createGradients(NSVGparser* p) float inv[6], localBounds[4]; nsvg__xformInverse(inv, shape->xform); nsvg__getLocalBounds(localBounds, shape, inv); - shape->fill.gradient = nsvg__createGradient(p, shape->fillGradient, localBounds, shape->xform, &shape->fill.type); + shape->fill.v.gradient = nsvg__createGradient(p, shape->fillGradient, localBounds, shape->xform, &shape->fill.type); } if (shape->fill.type == NSVG_PAINT_UNDEF) { shape->fill.type = NSVG_PAINT_NONE; @@ -3091,7 +3091,7 @@ static void nsvg__createGradients(NSVGparser* p) float inv[6], localBounds[4]; nsvg__xformInverse(inv, shape->xform); nsvg__getLocalBounds(localBounds, shape, inv); - shape->stroke.gradient = nsvg__createGradient(p, shape->strokeGradient, localBounds, shape->xform, &shape->stroke.type); + shape->stroke.v.gradient = nsvg__createGradient(p, shape->strokeGradient, localBounds, shape->xform, &shape->stroke.type); } if (shape->stroke.type == NSVG_PAINT_UNDEF) { shape->stroke.type = NSVG_PAINT_NONE; diff --git a/src/nanosvgrast.h b/src/nanosvgrast.h index 89a2e243..35175ee9 100644 --- a/src/nanosvgrast.h +++ b/src/nanosvgrast.h @@ -1288,11 +1288,11 @@ static void nsvg__initPaint(NSVGcachedPaint* cache, NSVGpaint* paint, float opac cache->type = paint->type; if (paint->type == NSVG_PAINT_COLOR) { - cache->colors[0] = nsvg__applyOpacity(paint->color, opacity); + cache->colors[0] = nsvg__applyOpacity(paint->v.color, opacity); return; } - grad = paint->gradient; + grad = paint->v.gradient; cache->spread = grad->spread; memcpy(cache->xform, grad->xform, sizeof(float)*6); diff --git a/src/nav.c b/src/nav.c index cddfe21b..7b620b66 100644 --- a/src/nav.c +++ b/src/nav.c @@ -555,7 +555,7 @@ static void Nav_save_cb(int Op, CacheClient_t *Client) a_UIcmd_set_msg(Web->bw, "File saved (%d Bytes)", st.st_size); } else { if ((Bytes = Client->BufSize - Web->SavedBytes) > 0) { - Bytes = fwrite(Client->Buf + Web->SavedBytes, 1, Bytes, Web->stream); + Bytes = fwrite((char *) Client->Buf + Web->SavedBytes, 1, Bytes, Web->stream); Web->SavedBytes += Bytes; } } diff --git a/src/timeout.hh b/src/timeout.hh index 5b7f4759..14f24e2a 100644 --- a/src/timeout.hh +++ b/src/timeout.hh @@ -9,7 +9,7 @@ typedef void (*TimeoutCb_t)(void *data); void a_Timeout_add(float t, TimeoutCb_t cb, void *cbdata); void a_Timeout_repeat(float t, TimeoutCb_t cb, void *cbdata); -void a_Timeout_remove(); +void a_Timeout_remove(void); #ifdef __cplusplus diff --git a/src/uicmd.hh b/src/uicmd.hh index ec630d65..0a5c8fb5 100644 --- a/src/uicmd.hh +++ b/src/uicmd.hh @@ -44,7 +44,7 @@ void a_UIcmd_stop(void *vbw); void a_UIcmd_tools(void *vbw, int x, int y); void a_UIcmd_save_link(BrowserWindow *bw, const DilloUrl *url); void a_UIcmd_open_file(void *vbw); -const char *a_UIcmd_select_file(); +const char *a_UIcmd_select_file(void); void a_UIcmd_search_dialog(void *vbw); const char *a_UIcmd_get_passwd(const char *user); void a_UIcmd_book(void *vbw); diff --git a/src/url.c b/src/url.c index 0c34d1d9..54569013 100644 --- a/src/url.c +++ b/src/url.c @@ -48,6 +48,7 @@ #include "url.h" #include "hsts.h" +#include "misc.h" #include "msg.h" static const char *HEX = "0123456789ABCDEF"; @@ -627,7 +628,7 @@ char *a_Url_encode_hex_str(const char *str) newstr = dNew(char, 6*strlen(str)+1); for (c = newstr; *str; str++) - if ((dIsalnum(*str) && isascii(*str)) || strchr(verbatim, *str)) + if ((dIsalnum(*str) && d_isascii(*str)) || strchr(verbatim, *str)) *c++ = *str; else if (*str == ' ') *c++ = '+'; -- cgit v1.2.3