meson: fix unit tests and "Invalid byte sequence in conversion input"

Check if strerror_r returns a char * and define STRERROR_R_CHAR_P
if so, which is needed by g_strerror() since c8e268b

https://bugzilla.gnome.org/show_bug.cgi?id=784000
This commit is contained in:
Tim-Philipp Müller 2017-07-19 10:34:45 +01:00
parent f8a88a768d
commit 2ac8079b94
2 changed files with 20 additions and 0 deletions

View File

@ -398,6 +398,9 @@
/* Define to 1 if you have the `strerror_r' function. */
#mesondefine HAVE_STRERROR_R
/* Define if strerror_r returns char * */
#mesondefine STRERROR_R_CHAR_P
/* Define to 1 if you have the <strings.h> header file. */
#mesondefine HAVE_STRINGS_H

View File

@ -339,6 +339,23 @@ foreach f : functions
endif
endforeach
# Check whether strerror_r returns char *
if have_func_strerror_r
if cc.compiles('''#define _GNU_SOURCE
#include <string.h>
int func (void) {
char error_string[256];
char *ptr = strerror_r (-2, error_string, 256);
char c = *strerror_r (-2, error_string, 256);
return c != 0 && ptr != (void*) 0L;
}
''',
name : 'strerror_r() returns char *')
glib_conf.set('STRERROR_R_CHAR_P', 1,
description: 'Defined if strerror_r returns char *')
endif
endif
# Special-case these functions that have alternative names on Windows/MSVC
if cc.has_function('snprintf') or cc.has_header_symbol('stdio.h', 'snprintf')
glib_conf.set('HAVE_SNPRINTF', 1)