1997-07-14 23:37  Ulrich Drepper  <drepper@cygnus.com>

	* inet/getnameinfo.c: Pretty print.
	Correctly enlarge buffers.

	* login/programs/utmpd.c: Use _() instead of gettext().

	* nis/nss_nisplus/nisplus-hosts.c: Optimize some uses of stpcpy away.
	* nis/nss_nisplus/nisplus-network.c: Likewise.
	* nis/nss_nisplus/nisplus-proto.c: Likewise.
	* nis/nss_nisplus/nisplus-rpc.c: Likewise.
	* nis/nss_nisplus/nisplus-service.c: Likewise.

	* sysdeps/alpha/fpu/bits/mathinline.h: Only define functions if
	__OPTIMIZE__.
	* sysdeps/powerpc/bits/mathinline.h: Likewise.
	* sysdeps/i386/fpu/bits/mathinline.h: Define ISO C9x comparison
	function always.
	* sysdeps/m68k/fpu/bits/mathinline.h: Likewise.
	* sysdeps/stub/bits/mathinline.h: Add conditionals to show how
	it should look like in real files.

	* sysdeps/generic/bits/select.h (__FD_ZERO): Don't use memset to
	prevent prototype trouble, use simple loop.
	* sysdeps/i386/bits/select.h [!__GNUC__] (__FD_ZERO): Likewise.

	* sysdeps/mips/mips64/Implies: Imply ieee754.

	* sysdeps/unix/sysv/linux/Makefile: Make sure bits/syscall.h is
	installed.
	* sysdeps/unix/sysv/linux/sys/syscal.h: Pretty print.

1997-07-14 00:25  Ulrich Drepper  <drepper@cygnus.com>

	* sysdeps/stub/bits/stdio_lim.h: Unify with standalone version.
	* sysdeps/standalone/bits/stdio_lim.h: Removed.
	Patch by Zack Weinberg <zack@rabi.phys.columbia.edu>.

1997-06-22  Paul Eggert  <eggert@twinsun.com>

	* time/strftime.c (strftime): Use tm_zone if available, even if _LIBC.

	* time/tzfile.c (__tzstring): New decl.
	(__tzfile_read, __tzfile_default): Set __tzname to permanent strings.
	(__tzfile_default): First two args are now const char *.

	* time/tzset.c (__tzstring): New function.
	(tz_rule): Name is now const char *.
	(struct tzstring_head): New type.
	(tzstring_list, tzstring_last_buffer_size): New static vars.
	(__tzset_internal): Time zone names are now permanent, not temporary.
This commit is contained in:
Ulrich Drepper 1997-07-14 21:49:20 +00:00
parent f21acc89c0
commit cd6ede759f
26 changed files with 3371 additions and 421 deletions

View File

@ -1,3 +1,55 @@
1997-07-14 23:37 Ulrich Drepper <drepper@cygnus.com>
* inet/getnameinfo.c: Pretty print.
Correctly enlarge buffers.
* login/programs/utmpd.c: Use _() instead of gettext().
* nis/nss_nisplus/nisplus-hosts.c: Optimize some uses of stpcpy away.
* nis/nss_nisplus/nisplus-network.c: Likewise.
* nis/nss_nisplus/nisplus-proto.c: Likewise.
* nis/nss_nisplus/nisplus-rpc.c: Likewise.
* nis/nss_nisplus/nisplus-service.c: Likewise.
* sysdeps/alpha/fpu/bits/mathinline.h: Only define functions if
__OPTIMIZE__.
* sysdeps/powerpc/bits/mathinline.h: Likewise.
* sysdeps/i386/fpu/bits/mathinline.h: Define ISO C9x comparison
function always.
* sysdeps/m68k/fpu/bits/mathinline.h: Likewise.
* sysdeps/stub/bits/mathinline.h: Add conditionals to show how
it should look like in real files.
* sysdeps/generic/bits/select.h (__FD_ZERO): Don't use memset to
prevent prototype trouble, use simple loop.
* sysdeps/i386/bits/select.h [!__GNUC__] (__FD_ZERO): Likewise.
* sysdeps/mips/mips64/Implies: Imply ieee754.
* sysdeps/unix/sysv/linux/Makefile: Make sure bits/syscall.h is
installed.
* sysdeps/unix/sysv/linux/sys/syscal.h: Pretty print.
1997-07-14 00:25 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/stub/bits/stdio_lim.h: Unify with standalone version.
* sysdeps/standalone/bits/stdio_lim.h: Removed.
Patch by Zack Weinberg <zack@rabi.phys.columbia.edu>.
1997-06-22 Paul Eggert <eggert@twinsun.com>
* time/strftime.c (strftime): Use tm_zone if available, even if _LIBC.
* time/tzfile.c (__tzstring): New decl.
(__tzfile_read, __tzfile_default): Set __tzname to permanent strings.
(__tzfile_default): First two args are now const char *.
* time/tzset.c (__tzstring): New function.
(tz_rule): Name is now const char *.
(struct tzstring_head): New type.
(tzstring_list, tzstring_last_buffer_size): New static vars.
(__tzset_internal): Time zone names are now permanent, not temporary.
1997-07-13 01:18 Ulrich Drepper <drepper@cygnus.com> 1997-07-13 01:18 Ulrich Drepper <drepper@cygnus.com>
* setjmp/setjmp.h: Define _setjmp and _longjmp also if __USE_XOPEN. * setjmp/setjmp.h: Define _setjmp and _longjmp also if __USE_XOPEN.

View File

@ -21,9 +21,16 @@
#endif #endif
/* This line MUST be split! Otherwise m4 will not change it. */ /* This line MUST be split! Otherwise m4 will not change it.
We don't use `memset' because this would require a prototype and
the array isn't too big. */
#define __FD_ZERO(set) \ #define __FD_ZERO(set) \
((void) memset ((__ptr_t) (set), 0, sizeof (fd_set))) do { \
unsigned int __i; \
for (__i = 0; __i < sizeof (__fd_set) / sizeof (__fd_mask); ++__i) \
((__fd_mask *) set)[__i] = '\0'; \
} while (0)
#define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d)) #define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d))
#define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d)) #define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d))
#define __FD_ISSET(d, set) ((set)->fds_bits[__FDELT(d)] & __FDMASK(d)) #define __FD_ISSET(d, set) ((set)->fds_bits[__FDELT(d)] & __FDMASK(d))

2754
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -65,165 +65,197 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <arpa/inet.h> #include <arpa/inet.h>
#ifndef AF_LOCAL #ifndef AF_LOCAL
#define AF_LOCAL AF_UNIX # define AF_LOCAL AF_UNIX
#endif /* AF_LOCAL */ #endif /* AF_LOCAL */
#if HOSTTABLE #if HOSTTABLE
struct hostent *_addr2hostname_hosts(const char *, int, int); struct hostent *_addr2hostname_hosts (const char *, int, int);
#endif /* HOSTTABLE */ #endif /* HOSTTABLE */
#ifndef min #ifndef min
#define min(x,y) (((x) > (y)) ? (y) : (x)) # define min(x,y) (((x) > (y)) ? (y) : (x))
#endif /* min */ #endif /* min */
static const char *domain;
static char *nrl_domainname(void) static char *
nrl_domainname (void)
{ {
static const char *domain = NULL;
static int first = 1; static int first = 1;
if (first) { if (first)
{
__libc_lock_define_initialized (static, lock); __libc_lock_define_initialized (static, lock);
__libc_lock_lock (lock); __libc_lock_lock (lock);
if (first) { if (first)
{
char *c; char *c;
struct hostent *h, th; struct hostent *h, th;
int tmpbuflen = 1024; int tmpbuflen = 1024;
char *tmpbuf = __alloca(tmpbuflen); char *tmpbuf = alloca (tmpbuflen);
int herror; int herror;
first = 0; first = 0;
while (__gethostbyname_r("localhost", &th, tmpbuf, tmpbuflen, &h, while (__gethostbyname_r ("localhost", &th, tmpbuf, tmpbuflen, &h,
&herror)) { &herror))
if (herror == NETDB_INTERNAL) { {
if (errno == ERANGE) { if (herror == NETDB_INTERNAL && errno == ERANGE)
{
tmpbuflen *= 2; tmpbuflen *= 2;
tmpbuf = __alloca(tmpbuflen); tmpbuf = alloca (tmpbuflen);
} }
} else { else
break; break;
} }
}
if (h && (c = strchr(h->h_name, '.'))) { if (h && (c = strchr (h->h_name, '.')))
domain = __strdup (++c); domain = __strdup (++c);
goto ret; else
{
/* The name contains no domain information. Use the name
now to get more information. */
while (gethostname (tmpbuf, tmpbuflen))
{
tmpbuflen *= 2;
tmpbuf = alloca (tmpbuflen);
} }
while (gethostname (tmpbuf, tmpbuflen)) { if ((c = strchr (tmpbuf, '.')))
tmpbuflen *= 2; domain = __strdup (++c);
tmpbuf = __alloca (tmpbuflen); else
} {
if (c = strchr(tmpbuf, '.')) { /* We need to preserve the hostname. */
domain = __strdup(++c); const char *hstname = strdupa (tmpbuf);
goto ret;
}
while (__gethostbyname_r(tmpbuf, &th, tmpbuf, tmpbuflen, &h, while (__gethostbyname_r (hstname, &th, tmpbuf, tmpbuflen,
&herror)) { &h, &herror))
if (herror == NETDB_INTERNAL) { {
if (errno == ERANGE) { if (herror == NETDB_INTERNAL && errno == ERANGE)
{
tmpbuflen *= 2; tmpbuflen *= 2;
tmpbuf = __alloca(tmpbuflen); tmpbuf = alloca (tmpbuflen);
} }
} else { else
break; break;
} }
}
if (h && (c = strchr(h->h_name, '.'))) {
domain = __strdup(++c);
goto ret;
}
if (h && (c = strchr(h->h_name, '.')))
domain = __strdup (++c);
else
{ {
struct in_addr in_addr; struct in_addr in_addr;
in_addr.s_addr = htonl(0x7f000001); in_addr.s_addr = htonl (0x7f000001);
while (__gethostbyaddr_r((const char *)&in_addr, while (__gethostbyaddr_r ((const char *) &in_addr,
sizeof(struct in_addr), AF_INET, &th, tmpbuf, sizeof (struct in_addr),
tmpbuflen, &h, &herror)) { AF_INET, &th, tmpbuf,
if (herror == NETDB_INTERNAL) { tmpbuflen, &h, &herror))
if (errno == ERANGE) { {
if (herror == NETDB_INTERNAL && errno == ERANGE)
{
tmpbuflen *= 2; tmpbuflen *= 2;
tmpbuf = __alloca(tmpbuflen); tmpbuf = alloca (tmpbuflen);
} }
} else { else
break; break;
} }
}
if (h && (c = strchr(h->h_name, '.'))) { if (h && (c = strchr (h->h_name, '.')))
domain = __strdup(++c); domain = __strdup (++c);
goto ret; }
}
} }
} }
}
ret:
__libc_lock_unlock (lock); __libc_lock_unlock (lock);
} }
return domain; return domain;
}; };
int getnameinfo(const struct sockaddr *sa, size_t addrlen, char *host, size_t hostlen, char *serv, size_t servlen, int flags)
int
getnameinfo (const struct sockaddr *sa, size_t addrlen, char *host,
size_t hostlen, char *serv, size_t servlen, int flags)
{ {
int serrno = errno; int serrno = errno;
int tmpbuflen = 1024; int tmpbuflen = 1024;
int herrno; int herrno;
char *tmpbuf = __alloca(tmpbuflen); char *tmpbuf = alloca (tmpbuflen);
struct hostent th; struct hostent th;
if (!sa) if (sa == NULL)
return -1; return -1;
if (host && (hostlen > 0)) if (host != NULL && hostlen > 0)
switch(sa->sa_family) { switch(sa->sa_family)
{
case AF_INET: case AF_INET:
#if INET6 #if INET6
case AF_INET6: case AF_INET6:
#endif /* INET6 */ #endif /* INET6 */
if (!(flags & NI_NUMERICHOST)) { if (!(flags & NI_NUMERICHOST))
{
struct hostent *h = NULL; struct hostent *h = NULL;
#if HOSTTABLE #if HOSTTABLE
#if INET6 # if INET6
if (sa->sa_family == AF_INET6) if (sa->sa_family == AF_INET6)
h = _addr2hostname_hosts((void *)&(((struct sockaddr_in6 *)sa)->sin6_addr), sizeof(struct in6_addr), AF_INET6); h = _addr2hostname_hosts ((void *) &(((struct sockaddr_in6 *) sa)->sin6_addr),
sizeof(struct in6_addr), AF_INET6);
else else
#endif /* INET6 */ # endif /* INET6 */
h = _addr2hostname_hosts((void *)&(((struct sockaddr_in *)sa)->sin_addr), sizeof(struct in_addr), AF_INET); h = _addr2hostname_hosts ((void *)& (((struct sockaddr_in *) sa)->sin_addr),
sizeof(struct in_addr), AF_INET);
#endif /* HOSTTABLE */ #endif /* HOSTTABLE */
#if RESOLVER #if RESOLVER
if (!h) { if (h == NULL)
{
#if INET6 #if INET6
if (sa->sa_family == AF_INET6) { if (sa->sa_family == AF_INET6)
while (__gethostbyaddr_r((void *)&(((struct sockaddr_in6 *)sa)->sin6_addr), sizeof(struct in6_addr), AF_INET6, &th, tmpbuf, tmpbuflen, &h, &herrno)) { {
if (herrno == NETDB_INTERNAL) { while (__gethostbyaddr_r ((void *) &(((struct sockaddr_in6 *) sa)->sin6_addr),
if (errno == ERANGE) { sizeof(struct in6_addr),
AF_INET6, &th, tmpbuf, tmpbuflen,
&h, &herrno))
{
if (herrno == NETDB_INTERNAL)
{
if (errno == ERANGE)
{
tmpbuflen *= 2; tmpbuflen *= 2;
tmpbuf = __alloca(tmpbuflen); tmpbuf = alloca (tmpbuflen);
} else { }
__set_h_errno(herrno); else
{
__set_h_errno (herrno);
goto fail; goto fail;
} }
} else { }
else
{
break; break;
} }
} }
} else { }
else
{
#endif /* INET6 */ #endif /* INET6 */
while (__gethostbyaddr_r((void *)&(((struct sockaddr_in *)sa)->sin_addr), sizeof(struct in_addr), AF_INET, &th, tmpbuf, tmpbuflen, &h, &herrno)) { while (__gethostbyaddr_r ((void *) &(((struct sockaddr_in *)sa)->sin_addr),
if (errno == ERANGE) { sizeof(struct in_addr), AF_INET,
&th, tmpbuf, tmpbuflen,
&h, &herrno))
{
if (errno == ERANGE)
{
tmpbuflen *= 2; tmpbuflen *= 2;
tmpbuf = __alloca(tmpbuflen); tmpbuf = alloca (tmpbuflen);
} else { }
else
{
break; break;
} }
} }
@ -231,42 +263,54 @@ int getnameinfo(const struct sockaddr *sa, size_t addrlen, char *host, size_t ho
} }
#endif /* RESOLVER */ #endif /* RESOLVER */
if (h) { if (h)
if (flags & NI_NOFQDN) { {
if (flags & NI_NOFQDN)
{
char *c; char *c;
if ((c = nrl_domainname()) && (c = strstr(h->h_name, c)) && (c != h->h_name) && (*(--c) == '.')) { if ((c = nrl_domainname ()) && (c = strstr(h->h_name, c))
strncpy(host, h->h_name, min(hostlen, (size_t) (c - h->h_name))); && (c != h->h_name) && (*(--c) == '.'))
{
strncpy (host, h->h_name,
min(hostlen, (size_t) (c - h->h_name)));
break; break;
}; }
}; }
strncpy(host, h->h_name, hostlen); strncpy (host, h->h_name, hostlen);
break; break;
}; }
}; }
if (flags & NI_NAMEREQD) if (flags & NI_NAMEREQD)
goto fail; goto fail;
else
{ {
const char *c; const char *c;
#if INET6 #if INET6
if (sa->sa_family == AF_INET6) if (sa->sa_family == AF_INET6)
c = inet_ntop(AF_INET6, (void *)&(((struct sockaddr_in6 *)sa)->sin6_addr), host, hostlen); c = inet_ntop (AF_INET6,
(void *) &(((struct sockaddr_in6 *) sa)->sin6_addr),
host, hostlen);
else else
#endif /* INET6 */ #endif /* INET6 */
c = inet_ntop(AF_INET, (void *)&(((struct sockaddr_in *)sa)->sin_addr), host, hostlen); c = inet_ntop (AF_INET,
(void *) &(((struct sockaddr_in *) sa)->sin_addr),
host, hostlen);
if (!c) if (!c)
goto fail; goto fail;
}; }
break; break;
#if LOCAL #if LOCAL
case AF_LOCAL: case AF_LOCAL:
if (!(flags & NI_NUMERICHOST)) { if (!(flags & NI_NUMERICHOST))
{
struct utsname utsname; struct utsname utsname;
if (!uname(&utsname)) { if (!uname (&utsname))
strncpy(host, utsname.nodename, hostlen); {
strncpy (host, utsname.nodename, hostlen);
break; break;
}; };
}; };
@ -274,46 +318,60 @@ int getnameinfo(const struct sockaddr *sa, size_t addrlen, char *host, size_t ho
if (flags & NI_NAMEREQD) if (flags & NI_NAMEREQD)
goto fail; goto fail;
strncpy(host, "localhost", hostlen); strncpy (host, "localhost", hostlen);
break; break;
#endif /* LOCAL */ #endif /* LOCAL */
default: default:
return -1; return -1;
}; }
if (serv && (servlen > 0)) if (serv && (servlen > 0))
switch(sa->sa_family) { switch(sa->sa_family)
{
case AF_INET: case AF_INET:
#if INET6 #if INET6
case AF_INET6: case AF_INET6:
#endif /* INET6 */ #endif /* INET6 */
if (!(flags & NI_NUMERICSERV)) { if (!(flags & NI_NUMERICSERV))
{
struct servent *s, ts; struct servent *s, ts;
while (__getservbyport_r(((struct sockaddr_in *)sa)->sin_port, ((flags & NI_DGRAM) ? "udp" : "tcp"), &ts, tmpbuf, tmpbuflen, &s)) { while (__getservbyport_r (((struct sockaddr_in *) sa)->sin_port,
if (herrno == NETDB_INTERNAL) { ((flags & NI_DGRAM) ? "udp" : "tcp"),
if (errno == ERANGE) { &ts, tmpbuf, tmpbuflen, &s))
{
if (herrno == NETDB_INTERNAL)
{
if (errno == ERANGE)
{
tmpbuflen *= 2; tmpbuflen *= 2;
tmpbuf = __alloca(tmpbuflen); tmpbuf = __alloca(tmpbuflen);
} else { }
else
goto fail; goto fail;
} }
} else { else
{
break; break;
} }
} }
if (s) { if (s)
{
strncpy(serv, s->s_name, servlen); strncpy(serv, s->s_name, servlen);
break; break;
}; }
}; }
snprintf(serv, servlen, "%d", ntohs(((struct sockaddr_in *)sa)->sin_port)); snprintf (serv, servlen, "%d",
ntohs (((struct sockaddr_in *) sa)->sin_port));
break; break;
#if LOCAL #if LOCAL
case AF_LOCAL: case AF_LOCAL:
strncpy(serv, ((struct sockaddr_un *)sa)->sun_path, servlen); strncpy (serv, ((struct sockaddr_un *) sa)->sun_path, servlen);
break; break;
#endif /* LOCAL */ #endif /* LOCAL */
}; }
if (host && (hostlen > 0)) if (host && (hostlen > 0))
host[hostlen-1] = 0; host[hostlen-1] = 0;
if (serv && (servlen > 0)) if (serv && (servlen > 0))

View File

@ -44,7 +44,7 @@
#endif #endif
/* Get libc version number. */ /* Get libc version number. */
#include "../../version.h" #include <version.h>
#define PACKAGE _libc_intl_domainname #define PACKAGE _libc_intl_domainname
@ -119,12 +119,12 @@ main (int argc, char *argv[])
if (do_version) if (do_version)
{ {
printf ("utmpd (GNU %s) %s\n", PACKAGE, VERSION); printf ("utmpd (GNU %s) %s\n", PACKAGE, VERSION);
printf (gettext ("\ printf (_("\
Copyright (C) %s Free Software Foundation, Inc.\n\ Copyright (C) %s Free Software Foundation, Inc.\n\
This is free software; see the source for copying conditions. There is NO\n\ This is free software; see the source for copying conditions. There is NO\n\
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
"), "1997"); "), "1997");
printf (gettext ("Written by %s.\n"), "Mark Kettenis"); printf (_("Written by %s.\n"), "Mark Kettenis");
exit (EXIT_SUCCESS); exit (EXIT_SUCCESS);
} }
@ -190,18 +190,18 @@ static void
usage (int status) usage (int status)
{ {
if (status != EXIT_SUCCESS) if (status != EXIT_SUCCESS)
fprintf (stderr, gettext ("Try `%s --help' for more information.\n"), fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_invocation_name); program_invocation_name);
else else
{ {
printf (gettext ("\ printf (_("\
Usage: %s [OPTION]...\n\ Usage: %s [OPTION]...\n\
-d, --debug do not fork and display messages on the current tty\n\ -d, --debug do not fork and display messages on the current tty\n\
-h, --help display this help and exit\n\ -h, --help display this help and exit\n\
-V, --version output version information and exit\n"), -V, --version output version information and exit\n"),
program_invocation_name); program_invocation_name);
fputs (gettext ("\ fputs (_("\
Report bugs to <kettenis@phys.uva.nl>.\n"), Report bugs using the `glibcbug' script to <bugs@gnu.ai.mit.edu>.\n"),
stdout); stdout);
} }
@ -399,4 +399,3 @@ write_pid (const char *file)
return 0; return 0;
} }

View File

@ -1,5 +1,5 @@
%% TeX macros to handle Texinfo files. %% TeX macros to handle Texinfo files.
%% $Id: texinfo.tex,v 2.208 1997/07/11 01:01:45 drepper Exp $ %% $Id: texinfo.tex,v 2.209 1997/07/13 12:07:01 drepper Exp $
% Copyright (C) 1985, 86, 88, 90, 91, 92, 93, % Copyright (C) 1985, 86, 88, 90, 91, 92, 93,
% 94, 95, 96, 97 Free Software Foundation, Inc. % 94, 95, 96, 97 Free Software Foundation, Inc.
@ -36,7 +36,7 @@
% This automatically updates the version number based on RCS. % This automatically updates the version number based on RCS.
\def\deftexinfoversion$#1: #2 ${\def\texinfoversion{#2}} \def\deftexinfoversion$#1: #2 ${\def\texinfoversion{#2}}
\deftexinfoversion$Revision: 2.208 $ \deftexinfoversion$Revision: 2.209 $
\message{Loading texinfo package [Version \texinfoversion]:} \message{Loading texinfo package [Version \texinfoversion]:}
% If in a .fmt file, print the version number % If in a .fmt file, print the version number
@ -1152,7 +1152,7 @@ where each line of input produces a line of output.}
\setfont\titlesc\scbshape{10}{\magstep4} \setfont\titlesc\scbshape{10}{\magstep4}
\font\titlei=cmmi12 scaled \magstep3 \font\titlei=cmmi12 scaled \magstep3
\font\titlesy=cmsy10 scaled \magstep4 \font\titlesy=cmsy10 scaled \magstep4
\let\authorrm = \secrm \def\authorrm{\secrm}
% Chapter (and unnumbered) fonts (17.28pt). % Chapter (and unnumbered) fonts (17.28pt).
\setfont\chaprm\rmbshape{12}{\magstep2} \setfont\chaprm\rmbshape{12}{\magstep2}

View File

@ -118,7 +118,7 @@ _nss_nisplus_parse_hostent (nis_result *result, int af, struct hostent *host,
__set_errno (ERANGE); __set_errno (ERANGE);
return 0; return 0;
} }
p = stpcpy(p, " "); *p++ = ' ';
p = stpncpy (p, NISENTRYVAL (i, 1, result), p = stpncpy (p, NISENTRYVAL (i, 1, result),
NISENTRYLEN (i, 1, result)); NISENTRYLEN (i, 1, result));
*p = '\0'; *p = '\0';

View File

@ -89,7 +89,7 @@ _nss_nisplus_parse_netent (nis_result *result, struct netent *network,
__set_errno (ERANGE); __set_errno (ERANGE);
return 0; return 0;
} }
p = stpcpy(p, " "); *p++ = ' ';
p = stpncpy (p, NISENTRYVAL (i, 1, result), p = stpncpy (p, NISENTRYVAL (i, 1, result),
NISENTRYLEN (i, 1, result)); NISENTRYLEN (i, 1, result));
*p = '\0'; *p = '\0';

View File

@ -85,7 +85,7 @@ _nss_nisplus_parse_protoent (nis_result * result, struct protoent *proto,
{ {
if (NISENTRYLEN (i, 1, result) + 2 > room_left) if (NISENTRYLEN (i, 1, result) + 2 > room_left)
goto no_more_room; goto no_more_room;
p = stpcpy(p, " "); *p++ = ' ';
p = stpncpy (p, NISENTRYVAL (i, 1, result), p = stpncpy (p, NISENTRYVAL (i, 1, result),
NISENTRYLEN (i, 1, result)); NISENTRYLEN (i, 1, result));
*p = '\0'; *p = '\0';

View File

@ -82,7 +82,7 @@ _nss_nisplus_parse_rpcent (nis_result *result, struct rpcent *rpc,
{ {
if (NISENTRYLEN (i, 1, result) + 2 > room_left) if (NISENTRYLEN (i, 1, result) + 2 > room_left)
goto no_more_room; goto no_more_room;
p = stpcpy(p, " "); *p++ = ' ';
p = stpncpy (p, NISENTRYVAL (i, 1, result), p = stpncpy (p, NISENTRYVAL (i, 1, result),
NISENTRYLEN (i, 1, result)); NISENTRYLEN (i, 1, result));
*p = '\0'; *p = '\0';

View File

@ -91,7 +91,7 @@ _nss_nisplus_parse_servent (nis_result *result, struct servent *serv,
{ {
if (NISENTRYLEN (i, 1, result) + 2 > room_left) if (NISENTRYLEN (i, 1, result) + 2 > room_left)
goto no_more_room; goto no_more_room;
p = stpcpy(p, " "); *p++ = ' ';
p = stpncpy (p, NISENTRYVAL (i, 1, result), p = stpncpy (p, NISENTRYVAL (i, 1, result),
NISENTRYLEN (i, 1, result)); NISENTRYLEN (i, 1, result));
*p = '\0'; *p = '\0';

View File

@ -18,7 +18,8 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#if defined (__GNUC__) && !defined (__NO_MATH_INLINES) #ifdef __GNUC__
#if !defined __NO_MATH_INLINES && defined __OPTIMIZE__
extern __inline double extern __inline double
__copysign (double __x, double __y) __copysign (double __x, double __y)
@ -42,3 +43,4 @@ atan (double __x)
} }
#endif #endif
#endif

View File

@ -21,9 +21,16 @@
#endif #endif
/* This line MUST be split! Otherwise m4 will not change it. */ /* This line MUST be split! Otherwise m4 will not change it.
We don't use `memset' because this would require a prototype and
the array isn't too big. */
#define __FD_ZERO(set) \ #define __FD_ZERO(set) \
((void) memset ((__ptr_t) (set), 0, sizeof (fd_set))) do { \
unsigned int __i; \
for (__i = 0; __i < sizeof (__fd_set) / sizeof (__fd_mask); ++__i) \
((__fd_mask *) set)[__i] = '\0'; \
} while (0)
#define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d)) #define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d))
#define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d)) #define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d))
#define __FD_ISSET(d, set) ((set)->fds_bits[__FDELT(d)] & __FDMASK(d)) #define __FD_ISSET(d, set) ((set)->fds_bits[__FDELT(d)] & __FDMASK(d))

View File

@ -48,8 +48,14 @@
#else /* ! GNU CC */ #else /* ! GNU CC */
/* We don't use `memset' because this would require a prototype and
the array isn't too big. */
#define __FD_ZERO(set) \ #define __FD_ZERO(set) \
((void) memset ((__ptr_t) (set), 0, sizeof (fd_set))) do { \
unsigned int __i; \
for (__i = 0; __i < sizeof (__fd_set) / sizeof (__fd_mask); ++__i) \
((__fd_mask *) set)[__i] = '\0'; \
} while (0)
#define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d)) #define __FD_SET(d, set) ((set)->fds_bits[__FDELT(d)] |= __FDMASK(d))
#define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d)) #define __FD_CLR(d, set) ((set)->fds_bits[__FDELT(d)] &= ~__FDMASK(d))
#define __FD_ISSET(d, set) ((set)->fds_bits[__FDELT(d)] & __FDMASK(d)) #define __FD_ISSET(d, set) ((set)->fds_bits[__FDELT(d)] & __FDMASK(d))

View File

@ -21,7 +21,56 @@
#ifndef _BITS_MATHINLINE_H #ifndef _BITS_MATHINLINE_H
#define _BITS_MATHINLINE_H 1 #define _BITS_MATHINLINE_H 1
#if defined __GNUG__ && \
#if defined __USE_ISOC9X && defined __GNUC__ && __GNUC__ >= 2
/* ISO C 9X defines some macros to perform unordered comparisons. The
ix87 FPU supports this with special opcodes and we should use them.
These must not be inline functions since we have to be able to handle
all floating-point types. */
# define isgreater(x, y) \
({ int result; \
__asm__ ("fucompp; fnstsw; andb $0x45, %%ah; setz %%al;" \
"andl $0xff, %0" \
: "=a" (result) : "t" (x), "u" (y) : "cc"); \
result; })
# define isgreaterequal(x, y) \
({ int result; \
__asm__ ("fucompp; fnstsw; testb $0x05, %%ah; setz %%al;" \
"andl $0xff, %0" \
: "=a" (result) : "t" (x), "u" (y) : "cc"); \
result; })
# define isless(x, y) \
({ int result; \
__asm__ ("fucompp; fnstsw; xorb $0x01, %%ah; testb $0x45, %%ah;" \
"setz %%al; andl $0xff, %0" \
: "=a" (result) : "t" (x), "u" (y) : "cc"); \
result; })
# define islessequal(x, y) \
({ int result; \
__asm__ ("fucompp; fnstsw; xorb $0x01, %%ah; testb $0x05, %%ah;" \
"setz %%al; andl $0xff, %0" \
: "=a" (result) : "t" (x), "u" (y) : "cc"); \
result; })
# define islessgreater(x, y) \
({ int result; \
__asm__ ("fucompp; fnstsw; testb $0x44, %%ah; setz %%al;" \
"andl $0xff, %0" \
: "=a" (result) : "t" (x), "u" (y) : "cc"); \
result; })
# define isunordered(x, y) \
({ int result; \
__asm__ ("fucompp; fnstsw; sahf; setp %%al; andl $0xff, %0" \
: "=a" (result) : "t" (x), "u" (y) : "cc"); \
result; })
#endif
#if defined __GNUC__ && \
(__GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ <= 7)) (__GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ <= 7))
/* gcc 2.7.2 and 2.7.2.1 have problems with inlining `long double' /* gcc 2.7.2 and 2.7.2.1 have problems with inlining `long double'
functions so we disable this now. */ functions so we disable this now. */
@ -29,8 +78,9 @@
# define __NO_MATH_INLINES # define __NO_MATH_INLINES
#endif #endif
#ifdef __GNUC__ #ifdef __GNUC__
#ifndef __NO_MATH_INLINES #if !defined __NO_MATH_INLINES && defined __OPTIMIZE__
#ifdef __cplusplus #ifdef __cplusplus
# define __MATH_INLINE __inline # define __MATH_INLINE __inline
@ -258,10 +308,8 @@ __log2 (double __x)
{ {
register double __value; register double __value;
__asm __volatile__ __asm __volatile__
("fld1\n\t" ("fyl2x"
"fxch\n\t" : "=t" (__value) : "0" (__x), "u" (1.0));
"fyl2x"
: "=t" (__value) : "0" (__x));
return __value; return __value;
} }
@ -441,7 +489,10 @@ logb (double __x)
return __value; return __value;
} }
#endif
#ifdef __USE_MISC
__MATH_INLINE double drem (double __x, double __y); __MATH_INLINE double drem (double __x, double __y);
__MATH_INLINE double __MATH_INLINE double
drem (double __x, double __y) drem (double __x, double __y)
@ -471,55 +522,6 @@ __finite (double __x)
return __result; return __result;
} }
/* ISO C 9X defines some macros to perform unordered comparisons. The
ix87 FPU supports this with special opcodes and we should use them.
These must not be inline functions since we have to be able to handle
all floating-point types. */
# define isgreater(x, y) \
({ int result; \
__asm__ ("fucompp; fnstsw; andb $0x45, %%ah; setz %%al;" \
"andl $0xff, %0" \
: "=a" (result) : "t" (x), "u" (y) : "cc"); \
result; })
# define isgreaterequal(x, y) \
({ int result; \
__asm__ ("fucompp; fnstsw; testb $0x05, %%ah; setz %%al;" \
"andl $0xff, %0" \
: "=a" (result) : "t" (x), "u" (y) : "cc"); \
result; })
# define isless(x, y) \
({ int result; \
__asm__ ("fucompp; fnstsw; xorb $0x01, %%ah; testb $0x45, %%ah;" \
"setz %%al; andl $0xff, %0" \
: "=a" (result) : "t" (x), "u" (y) : "cc"); \
result; })
# define islessequal(x, y) \
({ int result; \
__asm__ ("fucompp; fnstsw; xorb $0x01, %%ah; testb $0x05, %%ah;" \
"setz %%al; andl $0xff, %0" \
: "=a" (result) : "t" (x), "u" (y) : "cc"); \
result; })
# define islessgreater(x, y) \
({ int result; \
__asm__ ("fucompp; fnstsw; testb $0x44, %%ah; setz %%al;" \
"andl $0xff, %0" \
: "=a" (result) : "t" (x), "u" (y) : "cc"); \
result; })
# define isunordered(x, y) \
({ int result; \
__asm__ ("fucompp; fnstsw; sahf; setp %%al; andl $0xff, %0" \
: "=a" (result) : "t" (x), "u" (y) : "cc"); \
result; })
#endif
#ifdef __USE_MISC
__MATH_INLINE double coshm1 (double __x); __MATH_INLINE double coshm1 (double __x);
__MATH_INLINE double __MATH_INLINE double
coshm1 (double __x) coshm1 (double __x)

View File

@ -19,18 +19,69 @@
#ifdef __GNUC__ #ifdef __GNUC__
#include <sys/cdefs.h> #ifdef __USE_ISOC9X
/* ISO C 9X defines some macros to perform unordered comparisons. The
m68k FPU supports this with special opcodes and we should use them.
These must not be inline functions since we have to be able to handle
all floating-point types. */
# define isgreater(x, y) \
__extension__ \
({ char __result; \
__asm__ ("fcmp%.x %2,%1; fsogt %0" \
: "=dm" (__result) : "f" (x), "f" (y)); \
(int) __result; })
# define isgreaterequal(x, y) \
__extension__ \
({ char __result; \
__asm__ ("fcmp%.x %2,%1; fsoge %0" \
: "=dm" (__result) : "f" (x), "f" (y)); \
(int) __result; })
# define isless(x, y) \
__extension__ \
({ char __result; \
__asm__ ("fcmp%.x %2,%1; fsolt %0" \
: "=dm" (__result) : "f" (x), "f" (y)); \
(int) __result; })
# define islessequal(x, y) \
__extension__ \
({ char __result; \
__asm__ ("fcmp%.x %2,%1; fsole %0" \
: "=dm" (__result) : "f" (x), "f" (y)); \
(int) __result; })
# define islessgreater(x, y) \
__extension__ \
({ char __result; \
__asm__ ("fcmp%.x %2,%1; fsogl %0" \
: "=dm" (__result) : "f" (x), "f" (y)); \
(int) __result; })
# define isunordered(x, y) \
__extension__ \
({ char __result; \
__asm__ ("fcmp%.x %2,%1; fsun %0" \
: "=dm" (__result) : "f" (x), "f" (y)); \
(int) __result; })
#endif
#if (!defined __NO_MATH_INLINES && defined __OPTIMIZE__) \
|| defined __LIBC_M81_MATH_INLINES
#ifdef __LIBC_M81_MATH_INLINES #ifdef __LIBC_M81_MATH_INLINES
/* This is used when defining the functions themselves. Define them with /* This is used when defining the functions themselves. Define them with
__ names, and with `static inline' instead of `extern inline' so the __ names, and with `static inline' instead of `extern inline' so the
bodies will always be used, never an external function call. */ bodies will always be used, never an external function call. */
#define __m81_u(x) __CONCAT(__,x) # define __m81_u(x) __CONCAT(__,x)
#define __m81_inline static __inline # define __m81_inline static __inline
#else #else
#define __m81_u(x) x # define __m81_u(x) x
#define __m81_inline extern __inline # define __m81_inline extern __inline
#define __M81_MATH_INLINES 1 # define __M81_MATH_INLINES 1
#endif #endif
/* Define a const math function. */ /* Define a const math function. */
@ -385,55 +436,7 @@ __inline_forward(void,sincosl,
#undef __inline_forward #undef __inline_forward
#undef __inline_forward_c #undef __inline_forward_c
#ifdef __USE_ISOC9X
/* ISO C 9X defines some macros to perform unordered comparisons. The
m68k FPU supports this with special opcodes and we should use them.
These must not be inline functions since we have to be able to handle
all floating-point types. */
# define isgreater(x, y) \
__extension__ \
({ char __result; \
__asm__ ("fcmp%.x %2,%1; fsogt %0" \
: "=dm" (__result) : "f" (x), "f" (y)); \
(int) __result; })
# define isgreaterequal(x, y) \
__extension__ \
({ char __result; \
__asm__ ("fcmp%.x %2,%1; fsoge %0" \
: "=dm" (__result) : "f" (x), "f" (y)); \
(int) __result; })
# define isless(x, y) \
__extension__ \
({ char __result; \
__asm__ ("fcmp%.x %2,%1; fsolt %0" \
: "=dm" (__result) : "f" (x), "f" (y)); \
(int) __result; })
# define islessequal(x, y) \
__extension__ \
({ char __result; \
__asm__ ("fcmp%.x %2,%1; fsole %0" \
: "=dm" (__result) : "f" (x), "f" (y)); \
(int) __result; })
# define islessgreater(x, y) \
__extension__ \
({ char __result; \
__asm__ ("fcmp%.x %2,%1; fsogl %0" \
: "=dm" (__result) : "f" (x), "f" (y)); \
(int) __result; })
# define isunordered(x, y) \
__extension__ \
({ char __result; \
__asm__ ("fcmp%.x %2,%1; fsun %0" \
: "=dm" (__result) : "f" (x), "f" (y)); \
(int) __result; })
#endif
#endif /* !__NO_MATH_INLINES && __OPTIMIZE__ */ #endif /* !__NO_MATH_INLINES && __OPTIMIZE__ */
#endif
#endif /* GCC. */ #endif /* GCC. */

View File

@ -1 +1,3 @@
wordsize-64 wordsize-64
# MIPS uses IEEE 754 floating point.
ieee754

View File

@ -17,16 +17,13 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#ifndef __MATH_H
#define __MATH_H
#ifdef __GNUC__ #ifdef __GNUC__
#ifndef __NO_MATH_INLINES #if !defined __NO_MATH_INLINES && defined __OPTIMIZE__
#ifdef __cplusplus #ifdef __cplusplus
#define __MATH_INLINE __inline # define __MATH_INLINE __inline
#else #else
#define __MATH_INLINE extern __inline # define __MATH_INLINE extern __inline
#endif #endif
__MATH_INLINE double __sgn1 (double __x); __MATH_INLINE double __sgn1 (double __x);
@ -64,7 +61,5 @@ fabs (double __x)
return __value; return __value;
} }
#endif /* __NO_MATH_INLINES */ #endif /* __NO_MATH_INLINES && __OPTIMZE__ */
#endif /* __GNUC__ */ #endif /* __GNUC__ */
#endif /* __MATH_H */

View File

@ -1,26 +0,0 @@
/* Copyright (C) 1994, 1997 Free Software Foundation, Inc.
Ported to standalone by Joel Sherrill jsherril@redstone-emh2.army.mil,
On-Line Applications Research Corporation.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#define L_tmpnam 1
#define TMPMAX 0
#define L_ctermid 1
#define L_cuserid 1
#define FOPEN_MAX 16
#define FILENAME_MAX 14

View File

@ -4,3 +4,9 @@
This file should define __MATH_INLINES if functions are actually defined as This file should define __MATH_INLINES if functions are actually defined as
inlines. */ inlines. */
#if !defined __NO_MATH_INLINES && defined __OPTIMIZE__
/* Here goes the real code. */
#endif

View File

@ -1,4 +1,37 @@
/* Copyright (C) 1994, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* <bits/stdio_lim.h>: stdio limits for non-POSIX systems.
* Never include this file directly; use <stdio.h> instead.
*/
#ifndef _BITS_STDIO_LIM_H
#define _BITS_STDIO_LIM_H
#define L_tmpnam 1 #define L_tmpnam 1
#define TMPMAX 0 #define TMP_MAX 0
#ifdef __USE_POSIX
#define L_ctermid 1
#define L_cuserid 1
#endif
#define FOPEN_MAX 16 #define FOPEN_MAX 16
#define FILENAME_MAX 14 #define FILENAME_MAX 14
#endif

View File

@ -13,6 +13,8 @@ sysdep_headers += sys/mount.h sys/acct.h sys/sysctl.h sys/mtio.h \
sys/debugreg.h sys/kd.h sys/soundcard.h sys/vt.h \ sys/debugreg.h sys/kd.h sys/soundcard.h sys/vt.h \
sys/quota.h sys/quota.h
install-others += $(inst_includedir)/bits/syscall.h
# Generate the list of SYS_* macros for the system calls (__NR_* macros). # Generate the list of SYS_* macros for the system calls (__NR_* macros).
$(objpfx)syscall-%.h $(objpfx)syscall-%.d: ../sysdeps/unix/sysv/linux/sys/syscall.h $(objpfx)syscall-%.h $(objpfx)syscall-%.d: ../sysdeps/unix/sysv/linux/sys/syscall.h
rm -f $(@:.h=.d) rm -f $(@:.h=.d)
@ -24,6 +26,13 @@ $(objpfx)syscall-%.h $(objpfx)syscall-%.d: ../sysdeps/unix/sysv/linux/sys/syscal
sed -n >> $(@:.d=.h).new \ sed -n >> $(@:.d=.h).new \
's@^#define __NR_\([^ ]*\) .*$$@#define SYS_\1 __NR_\1@p' 's@^#define __NR_\([^ ]*\) .*$$@#define SYS_\1 __NR_\1@p'
mv -f $(@:.d=.h).new $(@:.d=.h) mv -f $(@:.d=.h).new $(@:.d=.h)
$(inst_includedir)/bits/syscall.h: $(objpfx)syscall-list.h
$(make-target-directory)
if test -r $@ && cmp -s $< $@; \
then echo 'bits/syscall.h unchanged'; \
else $(INSTALL_DATA) $< $@; fi
ifndef no_deps ifndef no_deps
# Get the generated list of dependencies (probably /usr/include/asm/unistd.h). # Get the generated list of dependencies (probably /usr/include/asm/unistd.h).
-include $(objpfx)syscall-list.d -include $(objpfx)syscall-list.d

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1995, 1996 Free Software Foundation, Inc. /* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or The GNU C Library is free software; you can redistribute it and/or
@ -29,7 +29,7 @@
programs expect the traditional form `SYS_<name>'. So in building libc programs expect the traditional form `SYS_<name>'. So in building libc
we scan the kernel's list and produce <bits/syscall.h> with macros for we scan the kernel's list and produce <bits/syscall.h> with macros for
all the `SYS_' names. */ all the `SYS_' names. */
#include <bits/syscall.h> # include <bits/syscall.h>
#endif #endif
#endif #endif

View File

@ -424,15 +424,13 @@ strftime (s, maxsize, format, tp)
const char *f; const char *f;
zone = NULL; zone = NULL;
#if !defined _LIBC && HAVE_TM_ZONE #if HAVE_TM_ZONE
/* XXX We have some problems here. First, the string pointed to by /* The POSIX test suite assumes that setting
tm_zone is dynamically allocated while loading the zone data. But
when another zone is loaded since the information in TP were
computed this would be a stale pointer.
The second problem is the POSIX test suite which assumes setting
the environment variable TZ to a new value before calling strftime() the environment variable TZ to a new value before calling strftime()
will influence the result (the %Z format) even if the information in will influence the result (the %Z format) even if the information in
TP is computed with a totally different time zone. --drepper@gnu */ TP is computed with a totally different time zone.
This is bogus: though POSIX allows bad behavior like this,
POSIX does not require it. Do the right thing instead. */
zone = (const char *) tp->tm_zone; zone = (const char *) tp->tm_zone;
#endif #endif
#if HAVE_TZNAME #if HAVE_TZNAME

View File

@ -43,6 +43,8 @@ struct leap
long int change; /* Seconds of correction to apply. */ long int change; /* Seconds of correction to apply. */
}; };
extern const char * __tzstring (const char *); /* Defined in tzset.c. */
static struct ttinfo *find_transition (time_t timer); static struct ttinfo *find_transition (time_t timer);
static void compute_tzname_max (size_t); static void compute_tzname_max (size_t);
@ -267,9 +269,9 @@ __tzfile_read (const char *file)
info = find_transition (0); info = find_transition (0);
for (i = 0; i < num_types && i < sizeof (__tzname) / sizeof (__tzname[0]); for (i = 0; i < num_types && i < sizeof (__tzname) / sizeof (__tzname[0]);
++i) ++i)
__tzname[types[i].isdst] = &zone_names[types[i].idx]; __tzname[types[i].isdst] = __tzstring (&zone_names[types[i].idx]);
if (info->isdst < sizeof (__tzname) / sizeof (__tzname[0])) if (info->isdst < sizeof (__tzname) / sizeof (__tzname[0]))
__tzname[info->isdst] = &zone_names[info->idx]; __tzname[info->isdst] = __tzstring (&zone_names[info->idx]);
compute_tzname_max (chars); compute_tzname_max (chars);
@ -285,7 +287,8 @@ __tzfile_read (const char *file)
from the TZDEFRULES file. */ from the TZDEFRULES file. */
void void
__tzfile_default (char *std, char *dst, long int stdoff, long int dstoff) __tzfile_default (const char *std, const char *dst,
long int stdoff, long int dstoff)
{ {
size_t stdlen, dstlen, i; size_t stdlen, dstlen, i;
long int rule_offset, rule_stdoff, rule_dstoff; long int rule_offset, rule_stdoff, rule_dstoff;
@ -372,8 +375,8 @@ __tzfile_default (char *std, char *dst, long int stdoff, long int dstoff)
types[1].isdst = 1; types[1].isdst = 1;
/* Reset the zone names to point to the user's names. */ /* Reset the zone names to point to the user's names. */
__tzname[0] = &zone_names[0]; __tzname[0] = (char *) std;
__tzname[1] = &zone_names[stdlen]; __tzname[1] = (char *) dst;
compute_tzname_max (stdlen + dstlen); compute_tzname_max (stdlen + dstlen);
} }
@ -455,7 +458,7 @@ __tzfile_compute (time_t timer, long int *leap_correct, int *leap_hit)
void void
compute_tzname_max (size_t chars) compute_tzname_max (size_t chars)
{ {
extern size_t __tzname_cur_max; /* Defined in __tzset.c. */ extern size_t __tzname_cur_max; /* Defined in tzset.c. */
const char *p; const char *p;

View File

@ -31,8 +31,9 @@ extern const unsigned short int __mon_yday[2][13];
extern int __use_tzfile; extern int __use_tzfile;
extern void __tzfile_read __P ((const char *file)); extern void __tzfile_read __P ((const char *file));
extern void __tzfile_default __P ((char *std, char *dst, extern void __tzfile_default __P ((const char *std, const char *dst,
long int stdoff, long int dstoff)); long int stdoff, long int dstoff));
extern const char * __tzstring __P ((const char *string));
extern int __tz_compute __P ((time_t timer, const struct tm *tm)); extern int __tz_compute __P ((time_t timer, const struct tm *tm));
char *__tzname[2] = { (char *) "GMT", (char *) "GMT" }; char *__tzname[2] = { (char *) "GMT", (char *) "GMT" };
@ -53,7 +54,7 @@ weak_alias (__timezone, timezone)
timezone given in the POSIX standard TZ envariable. */ timezone given in the POSIX standard TZ envariable. */
typedef struct typedef struct
{ {
char *name; const char *name;
/* When to change. */ /* When to change. */
enum { J0, J1, M } type; /* Interpretation of: */ enum { J0, J1, M } type; /* Interpretation of: */
@ -74,6 +75,68 @@ static tz_rule tz_rules[2];
static int compute_change __P ((tz_rule *rule, int year)); static int compute_change __P ((tz_rule *rule, int year));
/* Header for a list of buffers containing time zone strings. */
struct tzstring_head
{
struct tzstring_head *next;
/* The buffer itself immediately follows the header.
The buffer contains zero or more (possibly overlapping) strings.
The last string is followed by 2 '\0's instead of the usual 1. */
};
/* First in a list of buffers containing time zone strings.
All the buffers but the last are read-only. */
static struct
{
struct tzstring_head head;
char data[48];
} tzstring_list;
/* Size of the last buffer in the list, not counting its header. */
static size_t tzstring_last_buffer_size = sizeof tzstring_list.data;
/* Allocate a time zone string with given contents.
The string will never be moved or deallocated.
However, its contents may be shared with other such strings. */
const char *
__tzstring (string)
const char *string;
{
struct tzstring_head *h = &tzstring_list.head;
size_t needed;
char *p;
/* Look through time zone string list for a duplicate of this one. */
for (h = &tzstring_list.head; ; h = h->next)
{
for (p = (char *) (h + 1); p[0] | p[1]; p++)
if (strcmp (p, string) == 0)
return p;
if (! h->next)
break;
}
/* No duplicate was found. Copy to the end of this buffer if there's room;
otherwise, append a large-enough new buffer to the list and use it. */
p++;
needed = strlen (string) + 2; /* Need 2 trailing '\0's after last string. */
if ((size_t) ((char *) (h + 1) + tzstring_last_buffer_size - p) < needed)
{
size_t buffer_size = tzstring_last_buffer_size;
while ((buffer_size *= 2) < needed)
continue;
if (! (h = h->next = malloc (sizeof *h + buffer_size)))
return NULL;
h->next = NULL;
tzstring_last_buffer_size = buffer_size;
p = (char *) (h + 1);
}
strncpy (p, string, needed);
return p;
}
static char *old_tz = NULL; static char *old_tz = NULL;
/* Interpret the TZ envariable. */ /* Interpret the TZ envariable. */
@ -85,6 +148,7 @@ __tzset_internal (always)
static int is_initialized = 0; static int is_initialized = 0;
register const char *tz; register const char *tz;
register size_t l; register size_t l;
char *tzbuf;
unsigned short int hh, mm, ss; unsigned short int hh, mm, ss;
unsigned short int whichrule; unsigned short int whichrule;
@ -112,12 +176,6 @@ __tzset_internal (always)
/* No change, simply return. */ /* No change, simply return. */
return; return;
/* Free old storage. */
if (tz_rules[0].name != NULL && *tz_rules[0].name != '\0')
free ((void *) tz_rules[0].name);
if (tz_rules[1].name != NULL && *tz_rules[1].name != '\0' &&
tz_rules[1].name != tz_rules[0].name)
free ((void *) tz_rules[1].name);
tz_rules[0].name = NULL; tz_rules[0].name = NULL;
tz_rules[1].name = NULL; tz_rules[1].name = NULL;
@ -135,16 +193,7 @@ __tzset_internal (always)
if (tz == NULL || *tz == '\0') if (tz == NULL || *tz == '\0')
{ {
static const char UTC[] = "UTC"; tz_rules[0].name = tz_rules[1].name = "UTC";
size_t len = sizeof UTC;
tz_rules[0].name = (char *) malloc (len);
if (tz_rules[0].name == NULL)
return;
tz_rules[1].name = (char *) malloc (len);
if (tz_rules[1].name == NULL)
return;
memcpy ((void *) tz_rules[0].name, UTC, len);
memcpy ((void *) tz_rules[1].name, UTC, len);
tz_rules[0].type = tz_rules[1].type = J0; tz_rules[0].type = tz_rules[1].type = J0;
tz_rules[0].m = tz_rules[0].n = tz_rules[0].d = 0; tz_rules[0].m = tz_rules[0].n = tz_rules[0].d = 0;
tz_rules[1].m = tz_rules[1].n = tz_rules[1].d = 0; tz_rules[1].m = tz_rules[1].n = tz_rules[1].d = 0;
@ -157,11 +206,11 @@ __tzset_internal (always)
/* Clear out old state and reset to unnamed UTC. */ /* Clear out old state and reset to unnamed UTC. */
memset (tz_rules, 0, sizeof tz_rules); memset (tz_rules, 0, sizeof tz_rules);
tz_rules[0].name = tz_rules[1].name = (char *) ""; tz_rules[0].name = tz_rules[1].name = "";
/* Get the standard timezone name. */ /* Get the standard timezone name. */
tz_rules[0].name = (char *) malloc (strlen (tz) + 1); tzbuf = malloc (strlen (tz) + 1);
if (tz_rules[0].name == NULL) if (! tzbuf)
{ {
/* Clear the old tz name so we will try again. */ /* Clear the old tz name so we will try again. */
free (old_tz); free (old_tz);
@ -169,25 +218,23 @@ __tzset_internal (always)
return; return;
} }
if (sscanf (tz, "%[^0-9,+-]", tz_rules[0].name) != 1 || if (sscanf (tz, "%[^0-9,+-]", tzbuf) != 1 ||
(l = strlen(tz_rules[0].name)) < 3) (l = strlen (tzbuf)) < 3)
{ {
free (tz_rules[0].name); free (tzbuf);
tz_rules[0].name = (char *) "";
return; return;
} }
{ tz_rules[0].name = __tzstring (tzbuf);
char *n = realloc ((void *) tz_rules[0].name, l + 1);
if (n != NULL)
tz_rules[0].name = n;
}
tz += l; tz += l;
/* Figure out the standard offset from UTC. */ /* Figure out the standard offset from UTC. */
if (*tz == '\0' || (*tz != '+' && *tz != '-' && !isdigit (*tz))) if (*tz == '\0' || (*tz != '+' && *tz != '-' && !isdigit (*tz)))
{
free (tzbuf);
return; return;
}
if (*tz == '-' || *tz == '+') if (*tz == '-' || *tz == '+')
tz_rules[0].offset = *tz++ == '-' ? 1L : -1L; tz_rules[0].offset = *tz++ == '-' ? 1L : -1L;
@ -196,6 +243,7 @@ __tzset_internal (always)
switch (sscanf (tz, "%hu:%hu:%hu", &hh, &mm, &ss)) switch (sscanf (tz, "%hu:%hu:%hu", &hh, &mm, &ss))
{ {
default: default:
free (tzbuf);
return; return;
case 1: case 1:
mm = 0; mm = 0;
@ -218,23 +266,14 @@ __tzset_internal (always)
/* Get the DST timezone name (if any). */ /* Get the DST timezone name (if any). */
if (*tz != '\0') if (*tz != '\0')
{ {
char *n = malloc (strlen (tz) + 1); char *n = tzbuf + strlen (tzbuf) + 1;
if (n != NULL) if (sscanf (tz, "%[^0-9,+-]", n) != 1 ||
{ (l = strlen (n)) < 3)
tz_rules[1].name = n;
if (sscanf (tz, "%[^0-9,+-]", tz_rules[1].name) != 1 ||
(l = strlen (tz_rules[1].name)) < 3)
{
free (n);
tz_rules[1].name = (char *) "";
goto done_names; /* Punt on name, set up the offsets. */ goto done_names; /* Punt on name, set up the offsets. */
}
n = realloc ((void *) tz_rules[1].name, l + 1); tz_rules[1].name = __tzstring (n);
if (n != NULL)
tz_rules[1].name = n;
tz += l; tz += l;
}
/* Figure out the DST offset from GMT. */ /* Figure out the DST offset from GMT. */
if (*tz == '-' || *tz == '+') if (*tz == '-' || *tz == '+')
@ -271,6 +310,7 @@ __tzset_internal (always)
tz_rules[1].name = tz_rules[0].name; tz_rules[1].name = tz_rules[0].name;
done_names: done_names:
free (tzbuf);
if (*tz == '\0' || (tz[0] == ',' && tz[1] == '\0')) if (*tz == '\0' || (tz[0] == ',' && tz[1] == '\0'))
{ {