diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/format.c | 4 | ||||
| -rw-r--r-- | src/opt.c | 14 | ||||
| -rw-r--r-- | src/proc.c | 7 | ||||
| -rw-r--r-- | src/socket.c | 12 | ||||
| -rw-r--r-- | src/string.c | 11 | ||||
| -rw-r--r-- | src/tc-netio.c | 1 | ||||
| -rw-r--r-- | src/tc-proc.c | 1 | ||||
| -rw-r--r-- | src/tc-socket.c | 1 | ||||
| -rw-r--r-- | src/tc-string.c | 1 |
9 files changed, 37 insertions, 15 deletions
diff --git a/src/format.c b/src/format.c index 985a527..18e3f5e 100644 --- a/src/format.c +++ b/src/format.c @@ -153,9 +153,9 @@ EXPORT_SYMBOL int HXformat_add(struct HXformat_map *blk, const char *key, static __inline__ char *HX_strchr0(const char *s, char c) { - char *ret = strchr(s, c); + const char *ret = strchr(s, c); if (ret != NULL) - return ret; + return const_cast1(char *, ret); return const_cast1(char *, s) + strlen(s); } @@ -7,6 +7,9 @@ * General Public License as published by the Free Software Foundation; * either version 2.1 or (at your option) any later version. */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif #include <errno.h> #include <limits.h> #include <stdbool.h> @@ -15,6 +18,9 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#ifdef HAVE_STRINGS_H +# include <strings.h> +#endif #include <libHX/ctype_helper.h> #include <libHX/deque.h> #include <libHX/map.h> @@ -561,13 +567,13 @@ static int HX_getopt_long(const char *cur, struct HX_getopt_vars *par) return -EINVAL; } *value = '\0'; - value = strchr(cur, '='); - if (value == nullptr) { + const char *cvalue = strchr(cur, '='); + if (cvalue == nullptr) { /* Cannot happen either */ free(key); return -EINVAL; } - ++value; + ++cvalue; par->cbi.current = lookup_long_pfx(par->cbi.table, key + 2); if (par->cbi.current == &HXopt_ambig_prefix) { ret = HX_getopt_error(HXOPT_E_AMBIG_PREFIX, key, par->flags); @@ -591,7 +597,7 @@ static int HX_getopt_long(const char *cur, struct HX_getopt_vars *par) free(key); par->cbi.flags = HXOPTCB_BY_LONG; - par->cbi.data = value; + par->cbi.data = const_cast(char *, cvalue); /* * Not possible to use %HXOPT_I_ASSIGN due to transience of @key. Thus * manually call do_assign now rather than in the superordinate @@ -1,6 +1,6 @@ /* * Process management - * Copyright Jan Engelhardt, 2008-2009 + * Copyright Jan Engelhardt, 2026 * * This file is part of libHX. libHX is free software; you can * redistribute it and/or modify it under the terms of the GNU Lesser @@ -10,6 +10,10 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif +#define _DEFAULT_SOURCE +#ifdef __CYGWIN__ +# define _BSD_SOURCE /* initgroups */ +#endif #include "internal.h" #include <errno.h> #include <limits.h> @@ -21,7 +25,6 @@ #ifdef _WIN32 # include <winsock2.h> #endif - #if defined(HAVE_INITGROUPS) && defined(HAVE_SETGID) #include <grp.h> #include <pwd.h> diff --git a/src/socket.c b/src/socket.c index fe813f5..47c7e38 100644 --- a/src/socket.c +++ b/src/socket.c @@ -1,6 +1,6 @@ /* * Socket-related functions - * Copyright Jan Engelhardt, 2021 + * Copyright Jan Engelhardt, 2026 * * This file is part of libHX. libHX is free software; you can * redistribute it and/or modify it under the terms of the GNU Lesser @@ -10,6 +10,10 @@ #ifdef HAVE_CONFIG_H # include "config.h" #endif +#define _POSIX_C_SOURCE 999900L /* cygwin-need:freeaddrinfo */ +#ifdef __OpenBSD__ +# define _BSD_SOURCE +#endif #include <errno.h> #include <limits.h> #include <stdlib.h> @@ -262,11 +266,11 @@ int HX_local_listen(const char *path) struct sockaddr_un u; if (strlen(path) >= sizeof(u.sun_path)) return -EINVAL; - u.sun_family = AF_LOCAL; + u.sun_family = AF_UNIX; strcpy(u.sun_path, path); struct addrinfo r = {}; r.ai_flags = AI_PASSIVE; - r.ai_family = AF_LOCAL; + r.ai_family = AF_UNIX; r.ai_socktype = SOCK_STREAM; r.ai_addrlen = sizeof(u) - sizeof(u.sun_path) + strlen(u.sun_path) + 1; r.ai_addr = reinterpret_cast(struct sockaddr *, &u); @@ -289,7 +293,7 @@ int HX_local_listen(const char *path) if (!S_ISSOCK(sb.st_mode)) return -ENOTSOCK; - int testfd = socket(AF_LOCAL, SOCK_STREAM | PLATFORM_SKFLAGS, 0); + int testfd = socket(AF_UNIX, SOCK_STREAM | PLATFORM_SKFLAGS, 0); if (testfd < 0) return -errno; ret = connect(testfd, r.ai_addr, r.ai_addrlen); diff --git a/src/string.c b/src/string.c index e9c162d..445b466 100644 --- a/src/string.c +++ b/src/string.c @@ -7,6 +7,9 @@ * General Public License as published by the Free Software Foundation; * either version 2.1 or (at your option) any later version. */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif #include <errno.h> #include <limits.h> #include <math.h> /* nextafter */ @@ -16,6 +19,9 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#ifdef HAVE_STRINGS_H +# include <strings.h> +#endif #include <libHX/ctype_helper.h> #include <libHX/string.h> #include "internal.h" @@ -176,7 +182,6 @@ EXPORT_SYMBOL void *HX_memmem(const void *vspace, size_t spacesize, const char *space = vspace, *point = vpoint; const char *head, *end; size_t tailsize; - char *tail; if (pointsize == 0) return const_cast1(void *, vspace); @@ -185,9 +190,9 @@ EXPORT_SYMBOL void *HX_memmem(const void *vspace, size_t spacesize, /* Do a BM-style trailer search and reduce calls to memcmp */ head = space + (pointsize - 1); - tail = memchr(head, point[pointsize-1], spacesize - (pointsize - 1)); + const char *tail = memchr(head, point[pointsize-1], spacesize - (pointsize - 1)); if (tail == NULL || pointsize == 1) - return tail; + return const_cast1(char *, tail); end = space + spacesize; do { head = tail - pointsize + 1; diff --git a/src/tc-netio.c b/src/tc-netio.c index 4510d0a..d3c2929 100644 --- a/src/tc-netio.c +++ b/src/tc-netio.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: MIT #define WIN32_LEAN_AND_MEAN 1 +#define _POSIX_C_SOURCE 999900L /* cygwin-need:freeaddrinfo */ #ifdef __cplusplus # include <cstdlib> # include <cstdio> diff --git a/src/tc-proc.c b/src/tc-proc.c index c17b232..9af1eba 100644 --- a/src/tc-proc.c +++ b/src/tc-proc.c @@ -1,4 +1,5 @@ // SPDX-License-Identifier: MIT +#define _POSIX_C_SOURCE 999900L /* cygwin:fdopen */ #ifdef __cplusplus # include <cerrno> # include <cstdio> diff --git a/src/tc-socket.c b/src/tc-socket.c index 2c140a1..dafe509 100644 --- a/src/tc-socket.c +++ b/src/tc-socket.c @@ -1,4 +1,5 @@ // SPDX-License-Identifier: MIT +#define _POSIX_C_SOURCE 999900L #include <errno.h> #include <stdio.h> #include <stdlib.h> diff --git a/src/tc-string.c b/src/tc-string.c index 1c67ede..7c3034d 100644 --- a/src/tc-string.c +++ b/src/tc-string.c @@ -1,5 +1,6 @@ /* long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing long line for testing */ // SPDX-License-Identifier: MIT +#define _POSIX_C_SOURCE 909900L #ifndef __cplusplus # include <assert.h> # include <errno.h> |
