mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-29 08:11:08 +00:00
6b87a5642c
* sysdeps/mach/hurd/chown.c: Use INTDEF for __chown. * sysdeps/unix/sysv/aix/chown.c: Likewise. * sysdeps/unix/grantpt.c: Use INTUSE for __chown calls. * sysdeps/unix/sysv/linux/m68k/chown.c: Likewise. * sysdeps/unix/sysv/linux/powerpc/chown.c: Likewise. * sysdeps/unix/sysv/linux/i386/chown.c: Use INTDEF2 to define __chown_internal. * sysdeps/unix/sysv/linux/s390/s390-32//chown.c: Likewise. * intl/dcngettext.c [_LIBC]: Use INTUSE for __dcngettext. * intl/dngettext.c [_LIBC] (DCNGETTEXT): Use INTUSE. * intl/ngettext.c: Likewise. * include/sys/socket.h: Declare __connect_internal and define __connect macro if not NOT_IN_libc. * sysdeps/mach/hurd/connect.c: Use INTDEF for __connect. * sysdeps/unix/sysv/aix/connect.c: Likewise. * sysdeps/unix/sysv/linux/connect.S: Add __connect_internal alias. * include/unistd.h: Declare __close_internal and define __close macro if not NOT_IN_libc. * libio/libioP.h (JUMO0, JUMP1, JUMP2, JUMP3, WJUMP0, WJUMP1, WJUMP2, WJUMP3): Add extra parenthesis to avoid expanding element names with macors like __close. * sysdeps/unix/syscalls.list: Add __close_internal alias. * include/unistd.h: Declare __dup2_internal and define __dup2 macro if not NOT_IN_libc. * sysdeps/mach/hurd/dup2.c: Use INTDEF for __dup2. * sysdeps/posix/dup2.c: Use INTDEF for __dup2. * sysdeps/unix/syscalls.list: Add __dup2_internal alias. * include/unistd.h: Declare __fork_internal and define __fork macro if not NOT_IN_libc. * sysdeps/mach/hurd/fork.c: Use INTDEF for __fork. * sysdeps/unix/sysv/aix/fork.c: Likewise. * sysdeps/unix/sysv/linux/syscalls.list: Add __fork_internal alias. * include/stdio_ext.h: Declare __fsetlocking_internal and define __fsetlocking macro to use it if not NOT_IN_libc. * libio/__fsetlocking.c: Use INTDEF for __fsetlocking. * libio/__fbufsize.c: Correct copyright. * libio/__flbf.c: Likewise. * libio/__fpending.c: Likewise. * libio/__fpurge.c: Likewise. * libio/__freadable.c: Likewise. * libio/__freading.c: Likewise. * libio/__fsetlocking.c: Likewise. * libio/__fwritable.c: Likewise. * libio/__fwriting.c: Likewise. * include/stdio.h: Declare __asprintf_internal and define __asprintf macro to use it if not NOT_IN_libc. * stdio-common/asprintf.c: Use INTDEF for __asprintf. * include/mntent.h: Declare __setmntent_internal, __getmntent_r_internal, __endmntent_internal. Define __setmntent, __getmntent_r, and __endmntent macros to use these functions if not NOT_IN_libc. * misc/mntent_r.c: Use INTDEF for __setmntent, __getmntent_r, and __endmntent. * include/math.h: Declare __finite_internal, __finitef_internal, and __finitel_internal. Redefine isfinite macro if in libc or libm using these functions. * sysdeps/generic/s_ldexp.c: Use INTUSE for __finite calls. * sysdeps/generic/s_ldexpf.c: Use INTUSE for __finitef calls. * sysdeps/generic/s_ldexpl.c: Use INTUSE for __finitel calls. * sysdeps/i386/fpu/s_finite.S: Define _internal alias. * sysdeps/i386/fpu/s_finitef.S: Likewise. * sysdeps/i386/fpu/s_finitel.S: Likewise. * sysdeps/ieee754/dbl-64/s_finite.c: Likewise. * sysdeps/ieee754/flt-32/s_finitef.c: Likewise. * sysdeps/ieee754/ldbl-128/s_finitel.c: Likewise. * sysdeps/ieee754/ldbl-96/s_finitel.c: Likewise. * include/fcntl.h: Declare __fcntl_internal. Define __fcntl macro to use this function if not NOT_IN_libc. * libio/iofdopen.c (_IO_fcntl): Use INTUSE. * sysdeps/generic/fcntl.c: Use INTDEF for __fcntl. * sysdeps/mach/hurd/fcntl.c: Likewise. * sysdeps/unix/sysv/aix/fcntl.c: Likewise. * sysdeps/unix/sysv/linux/i386/fcntl.c: Likewise. * include/argz.h: Declare __argz_count_internal and __argz_stringify_internal. * intl/l10nflist.c [_LIBC]: Use INTUSE for __argz_count and __argz_stringify. * string/argz-count.c: Use INTDEF for __argz_count. * string/argz-stringify.c: Use INTDEF for __argz_stringify. * include/stdlib.h: Declare __cxa_atexit_internal and define __cxa_atexit macro if not NOT_IN_libc. * stdlib/cxa_atexit.c: Use INTDEF for __cxa_atexit. * dlfcn/Makefile: Define NOT_IN_libc when compiling modcxaatexit.c. * assert/assert.c: Use INTDEF for __assert_fail. * assert/__assert.c: Use INTUSE for call to __assert_fail. * include/assert.h: Declare __assert_fail_internal.
411 lines
10 KiB
C
411 lines
10 KiB
C
/* Copyright (C) 1995-1999, 2000, 2001, 2002 Free Software Foundation, Inc.
|
||
This file is part of the GNU C Library.
|
||
Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
|
||
|
||
The GNU C Library is free software; you can redistribute it and/or
|
||
modify it under the terms of the GNU Lesser General Public
|
||
License as published by the Free Software Foundation; either
|
||
version 2.1 of the License, or (at your option) any later version.
|
||
|
||
The GNU C Library is distributed in the hope that it will be useful,
|
||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
Lesser General Public License for more details.
|
||
|
||
You should have received a copy of the GNU Lesser General Public
|
||
License along with the GNU C Library; if not, write to the Free
|
||
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||
02111-1307 USA. */
|
||
|
||
/* Tell glibc's <string.h> to provide a prototype for stpcpy().
|
||
This must come before <config.h> because <config.h> may include
|
||
<features.h>, and once <features.h> has been included, it's too late. */
|
||
#ifndef _GNU_SOURCE
|
||
# define _GNU_SOURCE 1
|
||
#endif
|
||
|
||
#ifdef HAVE_CONFIG_H
|
||
# include <config.h>
|
||
#endif
|
||
|
||
#include <string.h>
|
||
|
||
#if defined _LIBC || defined HAVE_ARGZ_H
|
||
# include <argz.h>
|
||
#endif
|
||
#include <ctype.h>
|
||
#include <sys/types.h>
|
||
#include <stdlib.h>
|
||
|
||
#include "loadinfo.h"
|
||
|
||
/* On some strange systems still no definition of NULL is found. Sigh! */
|
||
#ifndef NULL
|
||
# if defined __STDC__ && __STDC__
|
||
# define NULL ((void *) 0)
|
||
# else
|
||
# define NULL 0
|
||
# endif
|
||
#endif
|
||
|
||
/* @@ end of prolog @@ */
|
||
|
||
#ifdef _LIBC
|
||
/* Rename the non ANSI C functions. This is required by the standard
|
||
because some ANSI C functions will require linking with this object
|
||
file and the name space must not be polluted. */
|
||
# ifndef stpcpy
|
||
# define stpcpy(dest, src) __stpcpy(dest, src)
|
||
# endif
|
||
#else
|
||
# ifndef HAVE_STPCPY
|
||
static char *stpcpy PARAMS ((char *dest, const char *src));
|
||
# endif
|
||
#endif
|
||
|
||
/* Define function which are usually not available. */
|
||
|
||
#if !defined _LIBC && !defined HAVE___ARGZ_COUNT
|
||
/* Returns the number of strings in ARGZ. */
|
||
static size_t argz_count__ PARAMS ((const char *argz, size_t len));
|
||
|
||
static size_t
|
||
argz_count__ (argz, len)
|
||
const char *argz;
|
||
size_t len;
|
||
{
|
||
size_t count = 0;
|
||
while (len > 0)
|
||
{
|
||
size_t part_len = strlen (argz);
|
||
argz += part_len + 1;
|
||
len -= part_len + 1;
|
||
count++;
|
||
}
|
||
return count;
|
||
}
|
||
# undef __argz_count
|
||
# define __argz_count(argz, len) argz_count__ (argz, len)
|
||
#else
|
||
# ifdef _LIBC
|
||
# define __argz_count(argz, len) INTUSE(__argz_count) (argz, len)
|
||
# endif
|
||
#endif /* !_LIBC && !HAVE___ARGZ_COUNT */
|
||
|
||
#if !defined _LIBC && !defined HAVE___ARGZ_STRINGIFY
|
||
/* Make '\0' separated arg vector ARGZ printable by converting all the '\0's
|
||
except the last into the character SEP. */
|
||
static void argz_stringify__ PARAMS ((char *argz, size_t len, int sep));
|
||
|
||
static void
|
||
argz_stringify__ (argz, len, sep)
|
||
char *argz;
|
||
size_t len;
|
||
int sep;
|
||
{
|
||
while (len > 0)
|
||
{
|
||
size_t part_len = strlen (argz);
|
||
argz += part_len;
|
||
len -= part_len + 1;
|
||
if (len > 0)
|
||
*argz++ = sep;
|
||
}
|
||
}
|
||
# undef __argz_stringify
|
||
# define __argz_stringify(argz, len, sep) argz_stringify__ (argz, len, sep)
|
||
#else
|
||
# ifdef _LIBC
|
||
# define __argz_stringify(argz, len, sep) \
|
||
INTUSE(__argz_stringify) (argz, len, sep)
|
||
# endif
|
||
#endif /* !_LIBC && !HAVE___ARGZ_STRINGIFY */
|
||
|
||
#if !defined _LIBC && !defined HAVE___ARGZ_NEXT
|
||
static char *argz_next__ PARAMS ((char *argz, size_t argz_len,
|
||
const char *entry));
|
||
|
||
static char *
|
||
argz_next__ (argz, argz_len, entry)
|
||
char *argz;
|
||
size_t argz_len;
|
||
const char *entry;
|
||
{
|
||
if (entry)
|
||
{
|
||
if (entry < argz + argz_len)
|
||
entry = strchr (entry, '\0') + 1;
|
||
|
||
return entry >= argz + argz_len ? NULL : (char *) entry;
|
||
}
|
||
else
|
||
if (argz_len > 0)
|
||
return argz;
|
||
else
|
||
return 0;
|
||
}
|
||
# undef __argz_next
|
||
# define __argz_next(argz, len, entry) argz_next__ (argz, len, entry)
|
||
#endif /* !_LIBC && !HAVE___ARGZ_NEXT */
|
||
|
||
|
||
/* Return number of bits set in X. */
|
||
static int pop PARAMS ((int x));
|
||
|
||
static inline int
|
||
pop (x)
|
||
int x;
|
||
{
|
||
/* We assume that no more than 16 bits are used. */
|
||
x = ((x & ~0x5555) >> 1) + (x & 0x5555);
|
||
x = ((x & ~0x3333) >> 2) + (x & 0x3333);
|
||
x = ((x >> 4) + x) & 0x0f0f;
|
||
x = ((x >> 8) + x) & 0xff;
|
||
|
||
return x;
|
||
}
|
||
|
||
|
||
struct loaded_l10nfile *
|
||
_nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len, mask, language,
|
||
territory, codeset, normalized_codeset, modifier, special,
|
||
sponsor, revision, filename, do_allocate)
|
||
struct loaded_l10nfile **l10nfile_list;
|
||
const char *dirlist;
|
||
size_t dirlist_len;
|
||
int mask;
|
||
const char *language;
|
||
const char *territory;
|
||
const char *codeset;
|
||
const char *normalized_codeset;
|
||
const char *modifier;
|
||
const char *special;
|
||
const char *sponsor;
|
||
const char *revision;
|
||
const char *filename;
|
||
int do_allocate;
|
||
{
|
||
char *abs_filename;
|
||
struct loaded_l10nfile *last = NULL;
|
||
struct loaded_l10nfile *retval;
|
||
char *cp;
|
||
size_t entries;
|
||
int cnt;
|
||
|
||
/* Allocate room for the full file name. */
|
||
abs_filename = (char *) malloc (dirlist_len
|
||
+ strlen (language)
|
||
+ ((mask & TERRITORY) != 0
|
||
? strlen (territory) + 1 : 0)
|
||
+ ((mask & XPG_CODESET) != 0
|
||
? strlen (codeset) + 1 : 0)
|
||
+ ((mask & XPG_NORM_CODESET) != 0
|
||
? strlen (normalized_codeset) + 1 : 0)
|
||
+ (((mask & XPG_MODIFIER) != 0
|
||
|| (mask & CEN_AUDIENCE) != 0)
|
||
? strlen (modifier) + 1 : 0)
|
||
+ ((mask & CEN_SPECIAL) != 0
|
||
? strlen (special) + 1 : 0)
|
||
+ (((mask & CEN_SPONSOR) != 0
|
||
|| (mask & CEN_REVISION) != 0)
|
||
? (1 + ((mask & CEN_SPONSOR) != 0
|
||
? strlen (sponsor) + 1 : 0)
|
||
+ ((mask & CEN_REVISION) != 0
|
||
? strlen (revision) + 1 : 0)) : 0)
|
||
+ 1 + strlen (filename) + 1);
|
||
|
||
if (abs_filename == NULL)
|
||
return NULL;
|
||
|
||
retval = NULL;
|
||
last = NULL;
|
||
|
||
/* Construct file name. */
|
||
memcpy (abs_filename, dirlist, dirlist_len);
|
||
__argz_stringify (abs_filename, dirlist_len, ':');
|
||
cp = abs_filename + (dirlist_len - 1);
|
||
*cp++ = '/';
|
||
cp = stpcpy (cp, language);
|
||
|
||
if ((mask & TERRITORY) != 0)
|
||
{
|
||
*cp++ = '_';
|
||
cp = stpcpy (cp, territory);
|
||
}
|
||
if ((mask & XPG_CODESET) != 0)
|
||
{
|
||
*cp++ = '.';
|
||
cp = stpcpy (cp, codeset);
|
||
}
|
||
if ((mask & XPG_NORM_CODESET) != 0)
|
||
{
|
||
*cp++ = '.';
|
||
cp = stpcpy (cp, normalized_codeset);
|
||
}
|
||
if ((mask & (XPG_MODIFIER | CEN_AUDIENCE)) != 0)
|
||
{
|
||
/* This component can be part of both syntaces but has different
|
||
leading characters. For CEN we use `+', else `@'. */
|
||
*cp++ = (mask & CEN_AUDIENCE) != 0 ? '+' : '@';
|
||
cp = stpcpy (cp, modifier);
|
||
}
|
||
if ((mask & CEN_SPECIAL) != 0)
|
||
{
|
||
*cp++ = '+';
|
||
cp = stpcpy (cp, special);
|
||
}
|
||
if ((mask & (CEN_SPONSOR | CEN_REVISION)) != 0)
|
||
{
|
||
*cp++ = ',';
|
||
if ((mask & CEN_SPONSOR) != 0)
|
||
cp = stpcpy (cp, sponsor);
|
||
if ((mask & CEN_REVISION) != 0)
|
||
{
|
||
*cp++ = '_';
|
||
cp = stpcpy (cp, revision);
|
||
}
|
||
}
|
||
|
||
*cp++ = '/';
|
||
stpcpy (cp, filename);
|
||
|
||
/* Look in list of already loaded domains whether it is already
|
||
available. */
|
||
last = NULL;
|
||
for (retval = *l10nfile_list; retval != NULL; retval = retval->next)
|
||
if (retval->filename != NULL)
|
||
{
|
||
int compare = strcmp (retval->filename, abs_filename);
|
||
if (compare == 0)
|
||
/* We found it! */
|
||
break;
|
||
if (compare < 0)
|
||
{
|
||
/* It's not in the list. */
|
||
retval = NULL;
|
||
break;
|
||
}
|
||
|
||
last = retval;
|
||
}
|
||
|
||
if (retval != NULL || do_allocate == 0)
|
||
{
|
||
free (abs_filename);
|
||
return retval;
|
||
}
|
||
|
||
retval = (struct loaded_l10nfile *)
|
||
malloc (sizeof (*retval) + (__argz_count (dirlist, dirlist_len)
|
||
* (1 << pop (mask))
|
||
* sizeof (struct loaded_l10nfile *)));
|
||
if (retval == NULL)
|
||
return NULL;
|
||
|
||
retval->filename = abs_filename;
|
||
retval->decided = (__argz_count (dirlist, dirlist_len) != 1
|
||
|| ((mask & XPG_CODESET) != 0
|
||
&& (mask & XPG_NORM_CODESET) != 0));
|
||
retval->data = NULL;
|
||
|
||
if (last == NULL)
|
||
{
|
||
retval->next = *l10nfile_list;
|
||
*l10nfile_list = retval;
|
||
}
|
||
else
|
||
{
|
||
retval->next = last->next;
|
||
last->next = retval;
|
||
}
|
||
|
||
entries = 0;
|
||
/* If the DIRLIST is a real list the RETVAL entry corresponds not to
|
||
a real file. So we have to use the DIRLIST separation mechanism
|
||
of the inner loop. */
|
||
cnt = __argz_count (dirlist, dirlist_len) == 1 ? mask - 1 : mask;
|
||
for (; cnt >= 0; --cnt)
|
||
if ((cnt & ~mask) == 0
|
||
&& ((cnt & CEN_SPECIFIC) == 0 || (cnt & XPG_SPECIFIC) == 0)
|
||
&& ((cnt & XPG_CODESET) == 0 || (cnt & XPG_NORM_CODESET) == 0))
|
||
{
|
||
/* Iterate over all elements of the DIRLIST. */
|
||
char *dir = NULL;
|
||
|
||
while ((dir = __argz_next ((char *) dirlist, dirlist_len, dir))
|
||
!= NULL)
|
||
retval->successor[entries++]
|
||
= _nl_make_l10nflist (l10nfile_list, dir, strlen (dir) + 1, cnt,
|
||
language, territory, codeset,
|
||
normalized_codeset, modifier, special,
|
||
sponsor, revision, filename, 1);
|
||
}
|
||
retval->successor[entries] = NULL;
|
||
|
||
return retval;
|
||
}
|
||
|
||
/* Normalize codeset name. There is no standard for the codeset
|
||
names. Normalization allows the user to use any of the common
|
||
names. The return value is dynamically allocated and has to be
|
||
freed by the caller. */
|
||
const char *
|
||
_nl_normalize_codeset (codeset, name_len)
|
||
const char *codeset;
|
||
size_t name_len;
|
||
{
|
||
int len = 0;
|
||
int only_digit = 1;
|
||
char *retval;
|
||
char *wp;
|
||
size_t cnt;
|
||
|
||
for (cnt = 0; cnt < name_len; ++cnt)
|
||
if (isalnum ((unsigned char) codeset[cnt]))
|
||
{
|
||
++len;
|
||
|
||
if (isalpha ((unsigned char) codeset[cnt]))
|
||
only_digit = 0;
|
||
}
|
||
|
||
retval = (char *) malloc ((only_digit ? 3 : 0) + len + 1);
|
||
|
||
if (retval != NULL)
|
||
{
|
||
if (only_digit)
|
||
wp = stpcpy (retval, "iso");
|
||
else
|
||
wp = retval;
|
||
|
||
for (cnt = 0; cnt < name_len; ++cnt)
|
||
if (isalpha ((unsigned char) codeset[cnt]))
|
||
*wp++ = tolower ((unsigned char) codeset[cnt]);
|
||
else if (isdigit ((unsigned char) codeset[cnt]))
|
||
*wp++ = codeset[cnt];
|
||
|
||
*wp = '\0';
|
||
}
|
||
|
||
return (const char *) retval;
|
||
}
|
||
|
||
|
||
/* @@ begin of epilog @@ */
|
||
|
||
/* We don't want libintl.a to depend on any other library. So we
|
||
avoid the non-standard function stpcpy. In GNU C Library this
|
||
function is available, though. Also allow the symbol HAVE_STPCPY
|
||
to be defined. */
|
||
#if !_LIBC && !HAVE_STPCPY
|
||
static char *
|
||
stpcpy (dest, src)
|
||
char *dest;
|
||
const char *src;
|
||
{
|
||
while ((*dest++ = *src++) != '\0')
|
||
/* Do nothing. */ ;
|
||
return dest - 1;
|
||
}
|
||
#endif
|