Skip to content
Snippets Groups Projects
Commit 79213f0d authored by Yorhel's avatar Yorhel
Browse files

Support building without locale.h

Slightly modified patch from Gianluigi Tiesi.
http://dev.yorhel.nl/ncdu/bug/47
parent efece12c
No related branches found
No related tags found
No related merge requests found
......@@ -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]))
......
......@@ -32,7 +32,6 @@
#include <unistd.h>
#include <sys/time.h>
#include <locale.h>
#include <yopt.h>
......@@ -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);
......
......@@ -29,7 +29,9 @@
#include <stdlib.h>
#include <ncurses.h>
#include <stdarg.h>
#ifdef HAVE_LOCALE_H
#include <locale.h>
#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
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment