From 458d1dc75d75af2535bc533dba21f61f0b9ae8fe Mon Sep 17 00:00:00 2001 From: Matthias Melcher Date: Sun, 24 Jul 2005 18:41:30 +0000 Subject: [PATCH] Attempt to make 'localeconv()' part of the configuration process. VC6 works, but I'll need feedback for all other platforms... . Trying OS X in a few minutes. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@4454 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- CMakeLists.txt | 2 ++ borlandc/config.h | 7 +++++++ configh.cmake.in | 7 +++++++ configh.in | 7 +++++++ configure.in | 3 +++ makefiles/config.mingw | 7 +++++++ makefiles/config.os2x | 7 +++++++ src/Fl_Input.cxx | 12 +++++++++++- vcnet/config.h | 7 +++++++ visualc/config.h | 7 +++++++ watcom/config.h | 7 +++++++ 11 files changed, 72 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c7fc4325f..5d2455598 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,6 +85,7 @@ CHECK_INCLUDE_FILE_CONCAT("OpenGL/glu.h" HAVE_OPENGL_GLU_H) CHECK_INCLUDE_FILE_CONCAT("dirent.h" HAVE_DIRENT_H) CHECK_INCLUDE_FILE_CONCAT("stdio.h" HAVE_STDIO_H) CHECK_INCLUDE_FILE_CONCAT("strings.h" HAVE_STRINGS_H) +CHECK_INCLUDE_FILE_CONCAT("locale.h" HAVE_LOCALE_H) CHECK_INCLUDE_FILE_CONCAT("sys/dir.h" HAVE_SYS_DIR_H) CHECK_INCLUDE_FILE_CONCAT("sys/ndir.h" HAVE_SYS_NDIR_H) CHECK_INCLUDE_FILE_CONCAT("sys/select.h" HAVE_SYS_SELECT_H) @@ -105,6 +106,7 @@ CHECK_SYMBOL_EXISTS(strlcpy "${PROJECT_INCLUDES}" HAVE_STRLCPY) CHECK_SYMBOL_EXISTS(vsnprintf "${PROJECT_INCLUDES}" HAVE_VSNPRINTF) CHECK_SYMBOL_EXISTS(snprintf "${PROJECT_INCLUDES}" HAVE_SNPRINTF) CHECK_SYMBOL_EXISTS(scandir "${PROJECT_INCLUDES}" HAVE_SCANDIR) +CHECK_SYMBOL_EXISTS(localeconv "${PROJECT_INCLUDES}" HAVE_LOCALECONV) INCLUDE(CheckTypeSize) diff --git a/borlandc/config.h b/borlandc/config.h index 8add48878..607bba8ce 100644 --- a/borlandc/config.h +++ b/borlandc/config.h @@ -162,6 +162,13 @@ /* #undef HAVE_STRLCAT */ /* #undef HAVE_STRLCPY */ +/* + * Do we have POSIX locale support? + */ + +#define HAVE_LOCALE_H 1 +#define HAVE_LOCALECONV 1 + /* * HAVE_SYS_SELECT_H: * diff --git a/configh.cmake.in b/configh.cmake.in index d230df5f3..ee5b4605e 100644 --- a/configh.cmake.in +++ b/configh.cmake.in @@ -189,6 +189,13 @@ #cmakedefine HAVE_STRLCAT @HAVE_STRLCAT@ #cmakedefine HAVE_STRLCPY @HAVE_STRLCPY@ +/* + * 'locale' functions + */ + +#cmakedefine HAVE_LOCALE_H @HAVE_LOCALE_H@ +#cmakedefine HAVE_LOCALECONV @HAVE_LOCALECONV@ + /* * HAVE_SYS_SELECT_H: * diff --git a/configh.in b/configh.in index 4679e45c1..3f8146933 100644 --- a/configh.in +++ b/configh.in @@ -189,6 +189,13 @@ #undef HAVE_STRLCAT #undef HAVE_STRLCPY +/* + * Do we have POSIX locale support? + */ + +#undef HAVE_LOCALE_H +#undef HAVE_LOCALECONV + /* * HAVE_SYS_SELECT_H: * diff --git a/configure.in b/configure.in index 7c6aaf855..e1a6cf4e5 100644 --- a/configure.in +++ b/configure.in @@ -369,6 +369,9 @@ AC_CHECK_FUNC(snprintf,[ AC_CHECK_HEADER(strings.h, AC_DEFINE(HAVE_STRINGS_H)) AC_CHECK_FUNCS(strcasecmp strlcat strlcpy) +AC_CHECK_HEADER(locale.h, AC_DEFINE(HAVE_LOCALE_H)) +AC_CHECK_FUNCS(localeconv) + dnl FLTK library uses math library functions... AC_SEARCH_LIBS(pow, m) diff --git a/makefiles/config.mingw b/makefiles/config.mingw index 6f8486c25..f6b5b3d1e 100644 --- a/makefiles/config.mingw +++ b/makefiles/config.mingw @@ -168,6 +168,13 @@ /* #undef HAVE_STRLCAT */ /* #undef HAVE_STRLCPY */ +/* + * Do we have POSIX locale support? + */ + +#define HAVE_LOCALE_H 1 +#define HAVE_LOCALECONV 1 + /* * HAVE_SYS_SELECT_H: * diff --git a/makefiles/config.os2x b/makefiles/config.os2x index 0fc4c52fc..868a428af 100644 --- a/makefiles/config.os2x +++ b/makefiles/config.os2x @@ -165,6 +165,13 @@ /* #undef HAVE_STRLCAT*/ /* #undef HAVE_STRLCPY*/ +/* + * Do we have POSIX locale support? + */ + +#define HAVE_LOCALE_H 1 +#define HAVE_LOCALECONV 1 + /* * HAVE_SYS_SELECT_H: * diff --git a/src/Fl_Input.cxx b/src/Fl_Input.cxx index 93f278bbb..4bf5ee2b5 100644 --- a/src/Fl_Input.cxx +++ b/src/Fl_Input.cxx @@ -33,13 +33,17 @@ #include #include -#include #include #include #include #include #include "flstring.h" +#ifdef HAVE_LOCALE_H +# include +#endif + + void Fl_Input::draw() { if (input_type() == FL_HIDDEN_INPUT) return; Fl_Boxtype b = box(); @@ -69,8 +73,12 @@ int Fl_Input::shift_up_down_position(int p) { // into account (for example, continental Europe uses a comma instead // of a decimal point). For back compatibility reasons, we always // allow the decimal point. +#ifdef HAVE_LOCALECONV static char *standard_fp_chars = ".eE+-"; static char *legal_fp_chars = 0L; +#else +static char *legal_fp_chars = ".eE+-"; +#endif int Fl_Input::handle_key() { @@ -86,6 +94,7 @@ int Fl_Input::handle_key() { Fl::compose_reset(); // ignore any foreign letters... // initialize the list of legal characters inside a floating point number +#ifdef HAVE_LOCALECONV if (!legal_fp_chars) { int len = strlen(standard_fp_chars); struct lconv *lc = localeconv(); @@ -106,6 +115,7 @@ int Fl_Input::handle_key() { if (lc->negative_sign) strcat(legal_fp_chars, lc->negative_sign); } } +#endif // This is complex to allow "0xff12" hex to be typed: if (!position() && (ascii == '+' || ascii == '-') || diff --git a/vcnet/config.h b/vcnet/config.h index 05867eaf0..e5a25f105 100644 --- a/vcnet/config.h +++ b/vcnet/config.h @@ -152,6 +152,13 @@ /*#undef HAVE_STRLCAT*/ /*#undef HAVE_STRLCPY*/ +/* + * Do we have POSIX locale support? + */ + +#define HAVE_LOCALE_H 1 +#define HAVE_LOCALECONV 1 + /* * HAVE_POLL: * diff --git a/visualc/config.h b/visualc/config.h index 05867eaf0..e5a25f105 100644 --- a/visualc/config.h +++ b/visualc/config.h @@ -152,6 +152,13 @@ /*#undef HAVE_STRLCAT*/ /*#undef HAVE_STRLCPY*/ +/* + * Do we have POSIX locale support? + */ + +#define HAVE_LOCALE_H 1 +#define HAVE_LOCALECONV 1 + /* * HAVE_POLL: * diff --git a/watcom/config.h b/watcom/config.h index 7aebfbe85..0952b5073 100644 --- a/watcom/config.h +++ b/watcom/config.h @@ -162,6 +162,13 @@ /* #undef HAVE_STRLCAT */ /* #undef HAVE_STRLCPY */ +/* + * Do we have POSIX locale support? + */ + +#define HAVE_LOCALE_H 1 +#define HAVE_LOCALECONV 1 + /* * HAVE_SYS_SELECT_H: *