Skip to content

Instantly share code, notes, and snippets.

@hnw
Created September 27, 2013 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hnw/6725536 to your computer and use it in GitHub Desktop.
Save hnw/6725536 to your computer and use it in GitHub Desktop.
diff -c -r tar-1.26-orig/gnu/human.c tar-1.26/gnu/human.c
*** tar-1.26-orig/gnu/human.c 2011-03-12 18:14:29.000000000 +0900
--- tar-1.26/gnu/human.c 2013-09-27 11:45:30.000000000 +0900
***************
*** 23,29 ****
#include "human.h"
! #include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
--- 23,34 ----
#include "human.h"
! #if HAVE_LOCALE_H
! # include <locale.h>
! #endif
! #if !HAVE_SETLOCALE
! # define setlocale(category, locale) /* empty */
! #endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
***************
*** 176,181 ****
--- 181,187 ----
size_t decimal_pointlen = 1;
char const *grouping = "";
char const *thousands_sep = "";
+ #if HAVE_SETLOCALE
struct lconv const *l = localeconv ();
size_t pointlen = strlen (l->decimal_point);
if (0 < pointlen && pointlen <= MB_LEN_MAX)
***************
*** 186,191 ****
--- 192,198 ----
grouping = l->grouping;
if (strlen (l->thousands_sep) <= MB_LEN_MAX)
thousands_sep = l->thousands_sep;
+ #endif
psuffix = buf + LONGEST_HUMAN_READABLE - HUMAN_READABLE_SUFFIX_LENGTH_MAX;
p = psuffix;
diff -c -r tar-1.26-orig/gnu/nl_langinfo.c tar-1.26/gnu/nl_langinfo.c
*** tar-1.26-orig/gnu/nl_langinfo.c 2011-03-12 18:14:31.000000000 +0900
--- tar-1.26/gnu/nl_langinfo.c 2013-09-27 11:44:51.000000000 +0900
***************
*** 26,32 ****
--- 26,34 ----
/* Override nl_langinfo with support for added nl_item values. */
+ #if HAVE_LOCALE_H
# include <locale.h>
+ #endif
# include <string.h>
# undef nl_langinfo
***************
*** 39,48 ****
# if GNULIB_defined_CODESET
case CODESET:
{
! const char *locale;
static char buf[2 + 10 + 1];
locale = setlocale (LC_CTYPE, NULL);
if (locale != NULL && locale[0] != '\0')
{
/* If the locale name contains an encoding after the dot, return
--- 41,52 ----
# if GNULIB_defined_CODESET
case CODESET:
{
! const char *locale = NULL;
static char buf[2 + 10 + 1];
+ #if HAVE_SETLOCALE
locale = setlocale (LC_CTYPE, NULL);
+ #endif
if (locale != NULL && locale[0] != '\0')
{
/* If the locale name contains an encoding after the dot, return
***************
*** 154,162 ****
--- 158,174 ----
# endif
/* nl_langinfo items of the LC_NUMERIC category */
case RADIXCHAR:
+ #if HAVE_SETLOCALE
return localeconv () ->decimal_point;
+ #else
+ return ".";
+ #endif
case THOUSEP:
+ #if HAVE_SETLOCALE
return localeconv () ->thousands_sep;
+ #else
+ return ",";
+ #endif
/* nl_langinfo items of the LC_TIME category.
TODO: Really use the locale. */
case D_T_FMT:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment