summaryrefslogtreecommitdiffstats
path: root/src/bfstd.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-05-07 13:07:45 -0400
committerTavian Barnes <tavianator@tavianator.com>2024-05-07 13:07:45 -0400
commit39b51c6d6e947778bf2b63fc9586a3236665881e (patch)
treeb1665af50717e114427bf857c5422b30faaa4728 /src/bfstd.c
parente514ebc67f0ece9b24d9cd7e5478d12297d0efcf (diff)
downloadbfs-39b51c6d6e947778bf2b63fc9586a3236665881e.tar.xz
build: Add checks for strtofflags() and string_to_flags()
Diffstat (limited to 'src/bfstd.c')
-rw-r--r--src/bfstd.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/bfstd.c b/src/bfstd.c
index f8ce871..0ac3a72 100644
--- a/src/bfstd.c
+++ b/src/bfstd.c
@@ -637,8 +637,14 @@ error:
return NULL;
}
+#if BFS_HAS_STRTOFFLAGS
+# define BFS_STRTOFFLAGS strtofflags
+#elif BFS_HAS_STRING_TO_FLAGS
+# define BFS_STRTOFFLAGS string_to_flags
+#endif
+
int xstrtofflags(const char **str, unsigned long long *set, unsigned long long *clear) {
-#if BSD && !__GNU__
+#ifdef BFS_STRTOFFLAGS
char *str_arg = (char *)*str;
#if __OpenBSD__
@@ -649,11 +655,7 @@ int xstrtofflags(const char **str, unsigned long long *set, unsigned long long *
bfs_fflags_t set_arg = 0;
bfs_fflags_t clear_arg = 0;
-#if __NetBSD__
- int ret = string_to_flags(&str_arg, &set_arg, &clear_arg);
-#else
- int ret = strtofflags(&str_arg, &set_arg, &clear_arg);
-#endif
+ int ret = BFS_STRTOFFLAGS(&str_arg, &set_arg, &clear_arg);
*str = str_arg;
*set = set_arg;
@@ -663,7 +665,7 @@ int xstrtofflags(const char **str, unsigned long long *set, unsigned long long *
errno = EINVAL;
}
return ret;
-#else // !BSD
+#else // !BFS_STRTOFFLAGS
errno = ENOTSUP;
return -1;
#endif