diff --git a/Makefile b/Makefile index fc23a5f4..2d267a60 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,9 @@ PREFIX ?= /usr/local BUILD_DIR ?= build MESON ?= meson NINJA ?= ninja +C_STD ?= c17 MESON_SETUP_ARGS ?= +MESON_SETUP_ARGS += -Dc_std=$(C_STD) MESON_COMPILE_ARGS ?= MESON_INSTALL_ARGS ?= diff --git a/meson.build b/meson.build index 8383b0ba..c03fe3bd 100644 --- a/meson.build +++ b/meson.build @@ -2,7 +2,7 @@ project('zoitechat', 'c', version: '2.17.3', meson_version: '>= 0.47.0', default_options: [ - 'c_std=gnu89', + 'c_std=c17', 'buildtype=debugoptimized', 'warning_level=1', ] diff --git a/src/common/dcc.c b/src/common/dcc.c index 9d073f15..c293ac41 100644 --- a/src/common/dcc.c +++ b/src/common/dcc.c @@ -323,8 +323,8 @@ dcc_lookup_proxy (char *host, struct sockaddr_in *addr) h = gethostbyname (host); if (h != NULL && h->h_length == 4 && h->h_addr_list[0] != NULL) { - memcpy (&addr->sin_addr, h->h_addr, 4); - memcpy (&cache_addr, h->h_addr, 4); + memcpy (&addr->sin_addr, h->h_addr_list[0], 4); + memcpy (&cache_addr, h->h_addr_list[0], 4); cache_host = g_strdup (host); /* cppcheck-suppress memleak */ return TRUE; diff --git a/src/common/history.c b/src/common/history.c index c6529f30..3b50b0ca 100644 --- a/src/common/history.c +++ b/src/common/history.c @@ -16,6 +16,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include #include #include #include "history.h" @@ -24,7 +25,7 @@ void history_add (struct history *his, char *text) { free (his->lines[his->realpos]); - his->lines[his->realpos] = strdup (text); + his->lines[his->realpos] = g_strdup(text); his->realpos++; if (his->realpos == HISTORY_SIZE) his->realpos = 0; diff --git a/src/common/inbound.c b/src/common/inbound.c index fc1fa3cc..5c7dc92d 100644 --- a/src/common/inbound.c +++ b/src/common/inbound.c @@ -1424,9 +1424,9 @@ inbound_foundip (session *sess, char *ip, const message_tags_data *tags_data) HostAddr = gethostbyname (ip); if (HostAddr) { - sess->server->dcc_ip = ((struct in_addr *) HostAddr->h_addr)->s_addr; + sess->server->dcc_ip = ((struct in_addr *) HostAddr->h_addr_list[0])->s_addr; EMIT_SIGNAL_TIMESTAMP (XP_TE_FOUNDIP, sess->server->server_session, - inet_ntoa (*((struct in_addr *) HostAddr->h_addr)), + inet_ntoa (*((struct in_addr *) HostAddr->h_addr_list[0])), NULL, NULL, NULL, 0, tags_data->timestamp); } } diff --git a/src/common/network.c b/src/common/network.c index 52e7ece5..60dc7e50 100644 --- a/src/common/network.c +++ b/src/common/network.c @@ -17,9 +17,16 @@ */ /* ipv4 and ipv6 networking functions with a common interface */ +#define _POSIX_C_SOURCE 200112L +#ifdef _WIN32 +# include +#else +# include +#endif #include "config.h" +#include #include #include #include @@ -121,11 +128,11 @@ net_resolve (netstore * ns, char *hostname, int port, char **real_host) ipstring, sizeof (ipstring), NULL, 0, NI_NUMERICHOST); if (ns->ip6_hostent->ai_canonname) - *real_host = strdup (ns->ip6_hostent->ai_canonname); + *real_host = g_strdup(ns->ip6_hostent->ai_canonname); else - *real_host = strdup (hostname); + *real_host = g_strdup(hostname); - return strdup (ipstring); + return g_strdup(ipstring); } /* the only thing making this interface unclean, this shitty sok4, sok6 business */ diff --git a/src/common/proto-irc.c b/src/common/proto-irc.c index 97fb1987..6a4e68bb 100644 --- a/src/common/proto-irc.c +++ b/src/common/proto-irc.c @@ -1353,29 +1353,29 @@ process_named_msg (session *sess, char *type, char *word[], char *word_eol[], switch (t) { case WORDL('C','A','P','\0'): - if (strncasecmp (word[4], "ACK", 3) == 0) + if (g_ascii_strncasecmp(word[4], "ACK", 3) == 0) { inbound_cap_ack (serv, word[1], word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5], tags_data); } - else if (strncasecmp (word[4], "LS", 2) == 0 || strncasecmp (word[4], "NEW", 3) == 0) + else if (g_ascii_strncasecmp(word[4], "LS", 2) == 0 || g_ascii_strncasecmp(word[4], "NEW", 3) == 0) { inbound_cap_ls (serv, word[1], word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5], tags_data); } - else if (strncasecmp (word[4], "NAK", 3) == 0) + else if (g_ascii_strncasecmp(word[4], "NAK", 3) == 0) { inbound_cap_nak (serv, word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5], tags_data); } - else if (strncasecmp (word[4], "LIST", 4) == 0) + else if (g_ascii_strncasecmp(word[4], "LIST", 4) == 0) { inbound_cap_list (serv, word[1], word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5], tags_data); } - else if (strncasecmp (word[4], "DEL", 3) == 0) + else if (g_ascii_strncasecmp(word[4], "DEL", 3) == 0) { inbound_cap_del (serv, word[1], word[5][0] == ':' ? word_eol[5] + 1 : word_eol[5], diff --git a/src/fe-gtk/fkeys.c b/src/fe-gtk/fkeys.c index bef7e9b5..914c0283 100644 --- a/src/fe-gtk/fkeys.c +++ b/src/fe-gtk/fkeys.c @@ -1184,7 +1184,7 @@ key_action_page_switch (GtkWidget * wid, GdkEventKey * evt, char *d1, if (!len) return 1; - if (strcasecmp(d1, "auto") == 0) + if (g_ascii_strcasecmp(d1, "auto") == 0) { /* Auto switch makes no sense in detached sessions */ if (!sess->gui->is_tab) diff --git a/src/fe-text/fe-text.c b/src/fe-text/fe-text.c index e385a8f9..60ef4595 100644 --- a/src/fe-text/fe-text.c +++ b/src/fe-text/fe-text.c @@ -17,7 +17,7 @@ */ #include "config.h" - +#include #include #include #include @@ -538,7 +538,7 @@ fe_args (int argc, char *argv[]) if (arg_cfgdir) /* we want filesystem encoding */ { g_free (xdir); - xdir = strdup (arg_cfgdir); + xdir = g_strdup(arg_cfgdir); if (xdir[strlen (xdir) - 1] == '/') xdir[strlen (xdir) - 1] = 0; g_free (arg_cfgdir);