summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2017-09-10 17:02:51 +0900
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-09-10 17:02:51 +0900
commit0f80fb185e438a45c734c158c67f479ee4a837bc (patch)
tree3dc0418a29fb1d392e6e759c2fb46cf8c50ec764 /t
parentMerge branch 'rs/t4062-obsd' into maint (diff)
parenttest-path-utils: handle const parameter of basename and dirname (diff)
downloadtgif-0f80fb185e438a45c734c158c67f479ee4a837bc.tar.xz
Merge branch 'rs/in-obsd-basename-dirname-take-const' into maint
Portability fix. * rs/in-obsd-basename-dirname-take-const: test-path-utils: handle const parameter of basename and dirname
Diffstat (limited to 't')
-rw-r--r--t/helper/test-path-utils.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c
index 1ebe0f750c..2b3c5092a1 100644
--- a/t/helper/test-path-utils.c
+++ b/t/helper/test-path-utils.c
@@ -38,6 +38,20 @@ struct test_data {
const char *alternative; /* output: ... or this. */
};
+/*
+ * Compatibility wrappers for OpenBSD, whose basename(3) and dirname(3)
+ * have const parameters.
+ */
+static char *posix_basename(char *path)
+{
+ return basename(path);
+}
+
+static char *posix_dirname(char *path)
+{
+ return dirname(path);
+}
+
static int test_function(struct test_data *data, char *(*func)(char *input),
const char *funcname)
{
@@ -251,10 +265,10 @@ int cmd_main(int argc, const char **argv)
}
if (argc == 2 && !strcmp(argv[1], "basename"))
- return test_function(basename_data, basename, argv[1]);
+ return test_function(basename_data, posix_basename, argv[1]);
if (argc == 2 && !strcmp(argv[1], "dirname"))
- return test_function(dirname_data, dirname, argv[1]);
+ return test_function(dirname_data, posix_dirname, argv[1]);
fprintf(stderr, "%s: unknown function name: %s\n", argv[0],
argv[1] ? argv[1] : "(there was none)");