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'
This commit is contained in:
Jehan 2021-03-22 21:06:20 +01:00
parent 5cf3c648fb
commit bffb7819d2

View File

@ -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++;