mirror of https://github.com/fltk/fltk
Replace setenv() with putenv() on old systems (+937)
Add system check for setenv() function in configure and CMake.
This commit is contained in:
parent
1d43ae0b0a
commit
d3a3ab40b7
|
@ -204,6 +204,8 @@ CHECK_FUNCTION_EXISTS (strlcat HAVE_STRLCAT)
|
|||
CHECK_FUNCTION_EXISTS (strlcpy HAVE_STRLCPY)
|
||||
CHECK_FUNCTION_EXISTS (vsnprintf HAVE_VSNPRINTF)
|
||||
|
||||
check_function_exists(setenv HAVE_SETENV)
|
||||
|
||||
if(HAVE_SCANDIR AND NOT HAVE_SCANDIR_POSIX)
|
||||
set(MSG "POSIX compatible scandir")
|
||||
message(STATUS "Looking for ${MSG}")
|
||||
|
|
|
@ -240,6 +240,14 @@
|
|||
|
||||
#cmakedefine01 USE_POLL
|
||||
|
||||
/*
|
||||
* HAVE_SETENV:
|
||||
*
|
||||
* Whether or not POSIX setenv() is available from stdlib.h.
|
||||
*/
|
||||
|
||||
#cmakedefine01 HAVE_SETENV
|
||||
|
||||
/*
|
||||
* Do we have various image libraries?
|
||||
*/
|
||||
|
|
|
@ -239,6 +239,14 @@
|
|||
|
||||
#define USE_POLL 0
|
||||
|
||||
/*
|
||||
* HAVE_SETENV:
|
||||
*
|
||||
* Whether or not POSIX setenv() is available from stdlib.h.
|
||||
*/
|
||||
|
||||
#define HAVE_SETENV 0
|
||||
|
||||
/*
|
||||
* Do we have various image libraries?
|
||||
*/
|
||||
|
|
|
@ -620,6 +620,9 @@ AC_CHECK_FUNCS([strcasecmp strlcat strlcpy])
|
|||
AC_CHECK_HEADERS([locale.h])
|
||||
AC_CHECK_FUNCS([localeconv])
|
||||
|
||||
dnl HP-UX 11.11 does not provide setenv()
|
||||
AC_CHECK_FUNCS([setenv])
|
||||
|
||||
|
||||
dnl FLTK library uses math library functions...
|
||||
AC_SEARCH_LIBS([pow], [m])
|
||||
|
|
|
@ -75,9 +75,26 @@ Fl_X11_Screen_Driver::Fl_X11_Screen_Driver() : Fl_Unix_Screen_Driver() {
|
|||
key_table_size = 0;
|
||||
}
|
||||
|
||||
void Fl_X11_Screen_Driver::display(const char *d)
|
||||
{
|
||||
if (d) setenv("DISPLAY", d, 1);
|
||||
void Fl_X11_Screen_Driver::display(const char *d) {
|
||||
if (!d) return;
|
||||
// Issue #937:
|
||||
// setenv() is available since POSIX.1-2001
|
||||
// https://pubs.opengroup.org/onlinepubs/009604499/functions/setenv.html
|
||||
#if HAVE_SETENV
|
||||
setenv("DISPLAY", d, 1);
|
||||
#else // HAVE_SETENV
|
||||
// Use putenv() for old systems (similar to FLTK 1.3)
|
||||
static char e[1024];
|
||||
strcpy(e, "DISPLAY=");
|
||||
strlcat(e, d, sizeof(e));
|
||||
for (char *c = e + 8; *c != ':'; c++) {
|
||||
if (!*c) {
|
||||
strlcat(e,":0.0",sizeof(e));
|
||||
break;
|
||||
}
|
||||
}
|
||||
putenv(e);
|
||||
#endif // HAVE_SETENV
|
||||
}
|
||||
|
||||
void fl_x11_use_display(Display *d) {
|
||||
|
|
Loading…
Reference in New Issue