diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/corestringlist.h | 1 | ||||
-rw-r--r-- | utils/idna.c | 8 | ||||
-rw-r--r-- | utils/inet.h | 11 | ||||
-rw-r--r-- | utils/log.c | 4 | ||||
-rw-r--r-- | utils/nscolour.c | 31 | ||||
-rw-r--r-- | utils/nsoption.c | 13 | ||||
-rw-r--r-- | utils/utf8.c | 3 | ||||
-rw-r--r-- | utils/utils.h | 27 |
8 files changed, 70 insertions, 28 deletions
diff --git a/utils/corestringlist.h b/utils/corestringlist.h index b253b3b56..5cdbb3af7 100644 --- a/utils/corestringlist.h +++ b/utils/corestringlist.h @@ -167,6 +167,7 @@ CORESTRING_LWC_VALUE(application_octet_stream, "application/octet-stream"); CORESTRING_LWC_VALUE(image_gif, "image/gif"); CORESTRING_LWC_VALUE(image_png, "image/png"); CORESTRING_LWC_VALUE(image_jpeg, "image/jpeg"); +CORESTRING_LWC_VALUE(image_jxl, "image/jxl"); CORESTRING_LWC_VALUE(image_bmp, "image/bmp"); CORESTRING_LWC_VALUE(image_vnd_microsoft_icon, "image/vnd.microsoft.icon"); CORESTRING_LWC_VALUE(image_webp, "image/webp"); diff --git a/utils/idna.c b/utils/idna.c index 628ef1fac..3ce3e1be1 100644 --- a/utils/idna.c +++ b/utils/idna.c @@ -440,7 +440,7 @@ static bool idna__is_valid(int32_t *label, size_t len) /* 4. Check characters not DISALLOWED by RFC5892 */ if (idna_prop == IDNA_P_DISALLOWED) { NSLOG(netsurf, INFO, - "Check failed: character %"PRIsizet" (%x) is DISALLOWED", + "Check failed: character %"PRIsizet" (%"PRIx32") is DISALLOWED", i, label[i]); return false; @@ -450,7 +450,7 @@ static bool idna__is_valid(int32_t *label, size_t len) if (idna_prop == IDNA_P_CONTEXTJ) { if (idna__contextj_rule(label, i, len) == false) { NSLOG(netsurf, INFO, - "Check failed: character %"PRIsizet" (%x) does not conform to CONTEXTJ rule", + "Check failed: character %"PRIsizet" (%"PRIx32") does not conform to CONTEXTJ rule", i, label[i]); return false; @@ -462,7 +462,7 @@ static bool idna__is_valid(int32_t *label, size_t len) if (idna_prop == IDNA_P_CONTEXTO) { if (idna__contexto_rule(label[i]) == false) { NSLOG(netsurf, INFO, - "Check failed: character %"PRIsizet" (%x) has no CONTEXTO rule defined", + "Check failed: character %"PRIsizet" (%"PRIx32") has no CONTEXTO rule defined", i, label[i]); return false; @@ -472,7 +472,7 @@ static bool idna__is_valid(int32_t *label, size_t len) /* 7. Check characters are not UNASSIGNED */ if (idna_prop == IDNA_P_UNASSIGNED) { NSLOG(netsurf, INFO, - "Check failed: character %"PRIsizet" (%x) is UNASSIGNED", + "Check failed: character %"PRIsizet" (%"PRIx32") is UNASSIGNED", i, label[i]); return false; diff --git a/utils/inet.h b/utils/inet.h index da1798432..29010efc1 100644 --- a/utils/inet.h +++ b/utils/inet.h @@ -40,6 +40,15 @@ #include <arpa/inet.h> #include <sys/select.h> +#define ns_close_socket close + +#ifdef WITH_AMISSL +/* AmiSSL needs everything to be using bsdsocket directly to avoid conflicts */ +#include <proto/bsdsocket.h> +#undef ns_close_socket +#define ns_close_socket CloseSocket +#endif + #else #include <winsock2.h> @@ -49,6 +58,8 @@ #define EAFNOSUPPORT WSAEAFNOSUPPORT #endif +#define ns_close_socket closesocket + #endif diff --git a/utils/log.c b/utils/log.c index 8cc42a35f..a083b5720 100644 --- a/utils/log.c +++ b/utils/log.c @@ -286,7 +286,7 @@ nserror nslog_init(nslog_ensure_t *ensure, int *pargc, char **argv) /* exported interface documented in utils/log.h */ nserror -nslog_set_filter_by_options() +nslog_set_filter_by_options(void) { if (verbose_log) return nslog_set_filter(nsoption_charp(verbose_filter)); @@ -296,7 +296,7 @@ nslog_set_filter_by_options() /* exported interface documented in utils/log.h */ void -nslog_finalise() +nslog_finalise(void) { NSLOG(netsurf, INFO, "Finalising logging, please report any further messages"); diff --git a/utils/nscolour.c b/utils/nscolour.c index a07175201..5a772b8a6 100644 --- a/utils/nscolour.c +++ b/utils/nscolour.c @@ -28,6 +28,7 @@ #include <stddef.h> #include <stdbool.h> +#include "netsurf/inttypes.h" #include "netsurf/plot_style.h" #include "utils/errors.h" @@ -211,49 +212,49 @@ nserror nscolour_get_stylesheet(const char **stylesheet_out) ret = snprintf(buffer, sizeof(buffer), ".ns-odd-bg {\n" - "\tbackground-color: #%06x;\n" + "\tbackground-color: #%06"PRIx32";\n" "}\n" ".ns-odd-bg-hover {\n" - "\tbackground-color: #%06x;\n" + "\tbackground-color: #%06"PRIx32";\n" "}\n" ".ns-odd-fg {\n" - "\tcolor: #%06x;\n" + "\tcolor: #%06"PRIx32";\n" "}\n" ".ns-odd-fg-subtle {\n" - "\tcolor: #%06x;\n" + "\tcolor: #%06"PRIx32";\n" "}\n" ".ns-odd-fg-faded {\n" - "\tcolor: #%06x;\n" + "\tcolor: #%06"PRIx32";\n" "}\n" ".ns-odd-fg-good {\n" - "\tcolor: #%06x;\n" + "\tcolor: #%06"PRIx32";\n" "}\n" ".ns-odd-fg-bad {\n" - "\tcolor: #%06x;\n" + "\tcolor: #%06"PRIx32";\n" "}\n" ".ns-even-bg {\n" - "\tbackground-color: #%06x;\n" + "\tbackground-color: #%06"PRIx32";\n" "}\n" ".ns-even-bg-hover {\n" - "\tbackground-color: #%06x;\n" + "\tbackground-color: #%06"PRIx32";\n" "}\n" ".ns-even-fg {\n" - "\tcolor: #%06x;\n" + "\tcolor: #%06"PRIx32";\n" "}\n" ".ns-even-fg-subtle {\n" - "\tcolor: #%06x;\n" + "\tcolor: #%06"PRIx32";\n" "}\n" ".ns-even-fg-faded {\n" - "\tcolor: #%06x;\n" + "\tcolor: #%06"PRIx32";\n" "}\n" ".ns-even-fg-good {\n" - "\tcolor: #%06x;\n" + "\tcolor: #%06"PRIx32";\n" "}\n" ".ns-even-fg-bad {\n" - "\tcolor: #%06x;\n" + "\tcolor: #%06"PRIx32";\n" "}\n" ".ns-border {\n" - "\tborder-color: #%06x;\n" + "\tborder-color: #%06"PRIx32";\n" "}\n", colour_rb_swap(nscolours[NSCOLOUR_WIN_ODD_BG]), colour_rb_swap(nscolours[NSCOLOUR_WIN_ODD_BG_HOVER]), diff --git a/utils/nsoption.c b/utils/nsoption.c index a8a29b3bf..7306dee1b 100644 --- a/utils/nsoption.c +++ b/utils/nsoption.c @@ -32,6 +32,7 @@ #include <string.h> #include <strings.h> +#include "netsurf/inttypes.h" #include "netsurf/plot_style.h" #include "utils/errors.h" #include "utils/log.h" @@ -112,7 +113,7 @@ strtooption(const char *value, struct nsoption_s *option) break; case OPTION_COLOUR: - if (sscanf(value, "%x", &rgbcolour) == 1) { + if (sscanf(value, "%"SCNx32"", &rgbcolour) == 1) { option->value.c = (((0x000000FF & rgbcolour) << 16) | ((0x0000FF00 & rgbcolour) << 0) | ((0x00FF0000 & rgbcolour) >> 16)); @@ -323,7 +324,7 @@ nsoption_output(FILE *fp, rgbcolour = (((0x000000FF & opts[entry].value.c) << 16) | ((0x0000FF00 & opts[entry].value.c) << 0) | ((0x00FF0000 & opts[entry].value.c) >> 16)); - fprintf(fp, "%s:%06x\n", + fprintf(fp, "%s:%06"PRIx32"\n", opts[entry].key, rgbcolour); @@ -387,10 +388,10 @@ nsoption_output_value_html(struct nsoption_s *option, slen = snprintf(string + pos, size - pos, "<span style=\"font-family:Monospace;\">" - "#%06X" + "#%06"PRIX32 "</span> " - "<span style=\"background-color: #%06x; " - "border: 1px solid #%06x; " + "<span style=\"background-color: #%06"PRIx32"; " + "border: 1px solid #%06"PRIx32"; " "display: inline-block; " "width: 1em; height: 1em;\">" "</span>", @@ -459,7 +460,7 @@ nsoption_output_value_text(struct nsoption_s *option, rgbcolour = (((0x000000FF & option->value.c) << 16) | ((0x0000FF00 & option->value.c) << 0) | ((0x00FF0000 & option->value.c) >> 16)); - slen = snprintf(string + pos, size - pos, "%06x", rgbcolour); + slen = snprintf(string + pos, size - pos, "%06"PRIx32, rgbcolour); break; case OPTION_STRING: diff --git a/utils/utf8.c b/utils/utf8.c index 7091ad405..3eedd0810 100644 --- a/utils/utf8.c +++ b/utils/utf8.c @@ -32,6 +32,7 @@ #include "utils/log.h" #include "utils/utf8.h" +#include "netsurf/inttypes.h" #include "netsurf/utf8.h" #include "desktop/gui_internal.h" @@ -346,7 +347,7 @@ utf8_convert_html_chunk(iconv_t cd, return NSERROR_NOMEM; ucs4 = utf8_to_ucs4(chunk, inlen); - esclen = snprintf(escape, sizeof(escape), "&#x%06x;", ucs4); + esclen = snprintf(escape, sizeof(escape), "&#x%06"PRIx32";", ucs4); pescape = escape; ret = iconv(cd, (void *) &pescape, &esclen, (void *) out, outlen); diff --git a/utils/utils.h b/utils/utils.h index 3995071cd..cb9e04b45 100644 --- a/utils/utils.h +++ b/utils/utils.h @@ -89,4 +89,31 @@ */ bool is_dir(const char *path); +/** + * switch fall through + */ +#if defined __cplusplus && defined __has_cpp_attribute + #if __has_cpp_attribute(fallthrough) && __cplusplus >= __has_cpp_attribute(fallthrough) + #define fallthrough [[fallthrough]] + #elif __has_cpp_attribute(gnu::fallthrough) && __STDC_VERSION__ >= __has_cpp_attribute(gnu::fallthrough) + #define fallthrough [[gnu::fallthrough]] + #elif __has_cpp_attribute(clang::fallthrough) && __STDC_VERSION__ >= __has_cpp_attribute(clang::fallthrough) + #define fallthrough [[clang::fallthrough]] + #endif +#elif defined __STDC_VERSION__ && defined __has_c_attribute + #if __has_c_attribute(fallthrough) && __STDC_VERSION__ >= __has_c_attribute(fallthrough) + #define fallthrough [[fallthrough]] + #endif +#endif +#if !defined fallthrough && defined __has_attribute + #if __has_attribute(__fallthrough__) + #define fallthrough __attribute__((__fallthrough__)) + #endif +#endif +#if !defined fallthrough +/* early gcc and clang have no implicit fallthrough warning */ + #define fallthrough do {} while(0) +#endif + + #endif |