1
1

Support building without locale.h

Slightly modified patch from Gianluigi Tiesi.
http://dev.yorhel.nl/ncdu/bug/47
Этот коммит содержится в:
Yorhel 2014-04-13 08:34:32 +02:00
родитель efece12cfe
Коммит 79213f0d63
3 изменённых файлов: 11 добавлений и 8 удалений

Просмотреть файл

@ -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
}