1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-03 12:35:02 +00:00

Merge local fixes

This commit is contained in:
Andrey A. Chernov 2003-08-30 14:19:09 +00:00
parent b14bc0052c
commit d85d259173
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=119586
2 changed files with 33 additions and 38 deletions

View File

@ -1,13 +1,16 @@
$FreeBSD$
GNU Sort
originals can be found at: ftp://alpha.gnu.org/gnu/textutils/
originals can be found at: ftp://ftp.gnu.org/gnu/textutils/
Configure by:
./configure --disable-nls
Imported by:
cvs import \
-m "Virgin import (trimmed) of GNU Sort, textutils 2.0.21" \
src/contrib/gnu-sort FSF SORT_v2_0_21
-m "Virgin import (trimmed) of GNU Sort, textutils 2.1" \
src/contrib/gnu-sort FSF SORT_v2_1
ache@FreeBSD.org
8 June 2002
30 Aug 2003

View File

@ -1,5 +1,6 @@
/* hard-locale.c -- Determine whether a locale is hard.
Copyright 1997, 1998, 1999 Free Software Foundation, Inc.
Copyright (C) 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -20,41 +21,26 @@
# include <config.h>
#endif
#if __GNUC__
# define alloca __builtin_alloca
#else
# ifdef HAVE_ALLOCA_H
# include <alloca.h>
# else
# ifdef _AIX
# pragma alloca
# else
# ifdef _WIN32
# include <malloc.h>
# include <io.h>
# else
# ifndef alloca
char *alloca ();
# endif
# endif
# endif
# endif
#endif
#if HAVE_LOCALE_H
# include <locale.h>
#endif
#if HAVE_STDLIB_H
# include <stdlib.h>
#endif
#if HAVE_STRING_H
# include <string.h>
#endif
#include "hard-locale.h"
/* Return nonzero if the current CATEGORY locale is hard, i.e. if you
can't get away with assuming traditional C or POSIX behavior. */
int
hard_locale (int category)
{
#if ! (defined ENABLE_NLS && HAVE_SETLOCALE)
#if ! HAVE_SETLOCALE
return 0;
#else
@ -63,22 +49,28 @@ hard_locale (int category)
if (p)
{
# if defined(__FreeBSD__) || (defined __GLIBC__ && __GLIBC__ >= 2)
# if defined(__FreeBSD__) || (defined __GLIBC__ && 2 <= __GLIBC__)
if (strcmp (p, "C") == 0 || strcmp (p, "POSIX") == 0)
hard = 0;
# else
char *locale = alloca (strlen (p) + 1);
strcpy (locale, p);
char *locale = malloc (strlen (p) + 1);
if (locale)
{
strcpy (locale, p);
/* Temporarily set the locale to the "C" and "POSIX" locales to
find their names, so that we can determine whether one or the
other is the caller's locale. */
if (((p = setlocale (category, "C")) && strcmp (p, locale) == 0)
|| ((p = setlocale (category, "POSIX")) && strcmp (p, locale) == 0))
hard = 0;
/* Temporarily set the locale to the "C" and "POSIX" locales
to find their names, so that we can determine whether one
or the other is the caller's locale. */
if (((p = setlocale (category, "C"))
&& strcmp (p, locale) == 0)
|| ((p = setlocale (category, "POSIX"))
&& strcmp (p, locale) == 0))
hard = 0;
/* Restore the caller's locale. */
setlocale (category, locale);
/* Restore the caller's locale. */
setlocale (category, locale);
free (locale);
}
# endif
}