aboutsummaryrefslogtreecommitdiff
path: root/compat
diff options
context:
space:
mode:
authorĐoàn Trần Công Danh <congdanhqx@gmail.com>2021-04-24 08:05:37 +0700
committerDavid Bremner <david@tethera.net>2021-04-24 08:07:00 -0300
commit441a327051f5357175029709030a0ee51131379d (patch)
treefcb47d140f922b4036f0f763e25ede21b0783c3c /compat
parent62f03b6ab86bdc378198f9c1a86cb51ead289961 (diff)
compat: rename {,notmuch_}canonicalize_file_name
When compat canonicalize_file_name was introduced, it was limited to C code only because it was used by C code only during that time. >From 5ec6fd4d, (lib/open: check for split configuration when creating database., 2021-02-16), lib/open.cc, which is C++, relies on the existent of canonicalize_file_name. However, we can't blindly enable canonicalize_file_name for C++ code, because different implementation has different additional signature for C++ and users can arbitrarily add -DHAVE_CANONICALIZE_FILE_NAME=0 to {C,CXX}FLAGS. Let's move our implementation into a util library. Helped-by: Tomi Ollila <tomi.ollila@iki.fi> Signed-off-by: Đoàn Trần Công Danh <congdanhqx@gmail.com>
Diffstat (limited to 'compat')
-rw-r--r--compat/Makefile.local4
-rw-r--r--compat/canonicalize_file_name.c18
-rw-r--r--compat/compat.h8
3 files changed, 0 insertions, 30 deletions
diff --git a/compat/Makefile.local b/compat/Makefile.local
index 2ee1b399..c58ca746 100644
--- a/compat/Makefile.local
+++ b/compat/Makefile.local
@@ -5,10 +5,6 @@ extra_cflags += -I$(srcdir)/$(dir)
notmuch_compat_srcs :=
-ifneq ($(HAVE_CANONICALIZE_FILE_NAME),1)
-notmuch_compat_srcs += $(dir)/canonicalize_file_name.c
-endif
-
ifneq ($(HAVE_GETLINE),1)
notmuch_compat_srcs += $(dir)/getline.c $(dir)/getdelim.c
endif
diff --git a/compat/canonicalize_file_name.c b/compat/canonicalize_file_name.c
deleted file mode 100644
index 000f9e78..00000000
--- a/compat/canonicalize_file_name.c
+++ /dev/null
@@ -1,18 +0,0 @@
-#include "compat.h"
-#include <limits.h>
-#undef _GNU_SOURCE
-#include <stdlib.h>
-
-char *
-canonicalize_file_name (const char *path)
-{
-#ifdef PATH_MAX
- char *resolved_path = malloc (PATH_MAX + 1);
- if (resolved_path == NULL)
- return NULL;
-
- return realpath (path, resolved_path);
-#else
-#error undefined PATH_MAX _and_ missing canonicalize_file_name not supported
-#endif
-}
diff --git a/compat/compat.h b/compat/compat.h
index 8f15e585..59e91618 100644
--- a/compat/compat.h
+++ b/compat/compat.h
@@ -37,14 +37,6 @@ extern "C" {
#define _POSIX_PTHREAD_SEMANTICS 1
#endif
-#if ! HAVE_CANONICALIZE_FILE_NAME
-/* we only call this function from C, and this makes testing easier */
-#ifndef __cplusplus
-char *
-canonicalize_file_name (const char *path);
-#endif
-#endif
-
#if ! HAVE_GETLINE
#include <stdio.h>
#include <unistd.h>