diff options
author | Jehan <jehan@girinstud.io> | 2021-03-22 21:06:20 +0100 |
---|---|---|
committer | Jehan <jehan@girinstud.io> | 2022-12-14 00:24:53 +0100 |
commit | bffb7819d2af14610965429bbe324673a87aa4ae (patch) | |
tree | 85fe108670364f660a9d8b214d5e4acc8808ade4 | |
parent | 5cf3c648fbb8dd0baeb40660b555c967778d845f (diff) |
test: fix test binary build for Windows.
realpath() doesn't exist on Windows. Replace it with _fullpath() which
does the same thing, as far as I can see (at least for creating an
absolute path, it doesn't seem to canonicalize the path, or the docs
doesn't say it, yet since we are controlling the arguments from our
CMake script, it's not a big problem anyway).
This fixed the CI build for Windows failing with:
> undefined reference to `realpath'
-rw-r--r-- | test/uchardet-tests.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/test/uchardet-tests.c b/test/uchardet-tests.c index 26ea04c..7b50f7b 100644 --- a/test/uchardet-tests.c +++ b/test/uchardet-tests.c @@ -45,6 +45,13 @@ #define BUFFER_SIZE 65536 +#if defined(_WIN32) || defined(__CYGWIN__) +#define realpath(filename,unused) _fullpath(NULL, filename, 0) +#define SEP '\\' +#else +#define SEP '/' +#endif + void detect(FILE *fp, char **charset, char **lang) { @@ -116,13 +123,13 @@ main(int argc, char ** argv) path = realpath(filename, NULL); assert(path); - expected_charset = strrchr(path, '/'); + expected_charset = strrchr(path, SEP); assert(expected_charset); *expected_charset = '\0'; expected_charset++; expected_charset = strtok(expected_charset, "."); - expected_lang = strrchr(path, '/'); + expected_lang = strrchr(path, SEP); assert(expected_lang); expected_lang++; |