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 ...@@ -12,9 +12,11 @@ PKG_PROG_PKG_CONFIG
# Check for header files. # Check for header files.
AC_CHECK_HEADERS( 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_MSG_ERROR([required header file not found]))
AC_CHECK_HEADERS(locale.h)
# Check for typedefs, structures, and compiler characteristics. # Check for typedefs, structures, and compiler characteristics.
AC_TYPE_INT64_T AC_TYPE_INT64_T
AC_TYPE_UINT64_T AC_TYPE_UINT64_T
...@@ -23,7 +25,7 @@ AC_STRUCT_ST_BLOCKS ...@@ -23,7 +25,7 @@ AC_STRUCT_ST_BLOCKS
# Check for library functions. # Check for library functions.
AC_CHECK_FUNCS( AC_CHECK_FUNCS(
[getcwd gettimeofday fnmatch chdir rmdir unlink lstat setlocale],[], [getcwd gettimeofday fnmatch chdir rmdir unlink lstat],[],
AC_MSG_ERROR([required function missing])) AC_MSG_ERROR([required function missing]))
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include <unistd.h> #include <unistd.h>
#include <sys/time.h> #include <sys/time.h>
#include <locale.h>
#include <yopt.h> #include <yopt.h>
...@@ -255,7 +254,6 @@ static void init_nc() { ...@@ -255,7 +254,6 @@ static void init_nc() {
/* main program */ /* main program */
int main(int argc, char **argv) { int main(int argc, char **argv) {
setlocale(LC_ALL, "");
read_locale(); read_locale();
argv_parse(argc, argv); argv_parse(argc, argv);
......
...@@ -29,7 +29,9 @@ ...@@ -29,7 +29,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <ncurses.h> #include <ncurses.h>
#include <stdarg.h> #include <stdarg.h>
#ifdef HAVE_LOCALE_H
#include <locale.h> #include <locale.h>
#endif
int winrows, wincols; int winrows, wincols;
int subwinr, subwinc; int subwinr, subwinc;
...@@ -113,12 +115,13 @@ char *fullsize(int64_t from) { ...@@ -113,12 +115,13 @@ char *fullsize(int64_t from) {
void read_locale() { void read_locale() {
thou_sep = '.';
#ifdef HAVE_LOCALE_H
setlocale(LC_ALL, "");
char *locale_thou_sep = localeconv()->thousands_sep; 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]; thou_sep = locale_thou_sep[0];
} else { #endif
thou_sep = '.';
}
} }
......
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