diff --git a/configure.ac b/configure.ac index b8a6bfd..4e87cf2 100644 --- a/configure.ac +++ b/configure.ac @@ -12,9 +12,11 @@ PKG_PROG_PKG_CONFIG # Check for header files. AC_CHECK_HEADERS( - [limits.h sys/time.h sys/types.h sys/stat.h dirent.h unistd.h fnmatch.h ncurses.h locale.h],[], + [limits.h sys/time.h sys/types.h sys/stat.h dirent.h unistd.h fnmatch.h ncurses.h],[], AC_MSG_ERROR([required header file not found])) +AC_CHECK_HEADERS(locale.h) + # Check for typedefs, structures, and compiler characteristics. AC_TYPE_INT64_T AC_TYPE_UINT64_T @@ -23,7 +25,7 @@ AC_STRUCT_ST_BLOCKS # Check for library functions. AC_CHECK_FUNCS( - [getcwd gettimeofday fnmatch chdir rmdir unlink lstat setlocale],[], + [getcwd gettimeofday fnmatch chdir rmdir unlink lstat],[], AC_MSG_ERROR([required function missing])) diff --git a/src/main.c b/src/main.c index 2e30d25..3426548 100644 --- a/src/main.c +++ b/src/main.c @@ -32,7 +32,6 @@ #include #include -#include #include @@ -255,7 +254,6 @@ static void init_nc() { /* main program */ int main(int argc, char **argv) { - setlocale(LC_ALL, ""); read_locale(); argv_parse(argc, argv); diff --git a/src/util.c b/src/util.c index ba28326..2028893 100644 --- a/src/util.c +++ b/src/util.c @@ -29,7 +29,9 @@ #include #include #include +#ifdef HAVE_LOCALE_H #include +#endif int winrows, wincols; int subwinr, subwinc; @@ -113,12 +115,13 @@ char *fullsize(int64_t from) { void read_locale() { + thou_sep = '.'; +#ifdef HAVE_LOCALE_H + setlocale(LC_ALL, ""); char *locale_thou_sep = localeconv()->thousands_sep; - if (locale_thou_sep && 1 == strlen(locale_thou_sep)) { + if(locale_thou_sep && 1 == strlen(locale_thou_sep)) thou_sep = locale_thou_sep[0]; - } else { - thou_sep = '.'; - } +#endif }