mirror of
https://sourceware.org/git/glibc.git
synced 2025-12-24 17:51:17 +03:00
update from main archive 961211
Thu Dec 12 03:32:21 1996 Ulrich Drepper <drepper@cygnus.com> * libio/_G_config.h: Add definition of _G_int16_t, _G_int32_t, _G_uint16_t, _G_uin32_t, _G_HAVE_BOOL, _G_HAVE_MMAP, and _G_ARGS. Change libio buffer handling to allocate internal buffers using mmap if possible. * libio/filedoalloc.c (_IO_file_doallocate): Change call to ALLOC_BUF. * libio/genops.c (_IO_setb, _IO_default_finish): Change call to FREE_BUF. (_IO_default_doallocate): Change call to ALLOC_BUF. * libio/libioP.h: Change definition of ALLOC_BUF and FREE_BUF to use mmap/munmap when possible. * libio/memstream.c: Don't use ALLOC_BUF, but directly malloc. * libio/vasprintf.c: Likewise. Patch by HJ Lu. * libio/libio.h: Define NULL as __null only for gcc-2.8 and up. * libio/libioP.h: Likewise. * libio/fileops.c (_IO_file_read, _IO_file_write): Don't restart syscall when EINTR was returned. Necessary for POSIX.1. * libio/strops.c (_IO_str_overflow): Add cast to prevent warning. * new-malloc/malloc.c (heap_trim): Correctly place parentheses to prevent warnings. * nis/Makefile: Remove rules for bsd-tools which are not part of glibc. Patch by Thorsten Kukuk. * nis/ypclnt.c: Add prototype for xdr_free. Add const to first parameter for __yp_bind. * nis/nss_compat/compat-pwd.c (getpwent_next_netgr, getpwent_next_nis, getpwent_next_file): Variable `p2len' must have type size_t. * nis/nss_nis/nis-alias.c: Add casts to prevent warnings. * nis/nss_nis/nis-ethers.c: Likewise. * nis/nss_nis/nis-grp.c: Likewise. * nis/nss_nis/nis-hosts.c: Likewise. * nis/nss_nis/nis-network.c: Likewise. * nis/nss_nis/nis-proto.c: Likewise. * nis/nss_nis/nis-pwd.c: Likewise. * nis/nss_nis/nis-rpc.c: Likewise. * nis/nss_nis/nis-service.c: Likewise. * nis/nss_nis/nis-spwd.c: Likewise. * nis/rpcsvc/yp_prot.h (ypreq_key): Change type of members to `const char *'. (ypmaplist): Change member names to `map' and `next' and provide #defines for old names. Patch by Thorsten Kukuk. * nss/nss_files/files-parse.c (parse_line, parse_list): Change type for `datalen' parameter to size_t. * shsdow/lckpwdf.c: Use fcntl forlocking, not flock. * stdio-common/printf.c [USE_IN_LIBIO]: Provide alias _IO_printf for printf. * stdio-common/sscanf.c [USE_IN_LIBIO]: Provide alias _IO_sscanf for sscanf. Patch by HJ Lu. * stdio-common/tmpfile.c: Update copyright. * stdio-common/vfscanf.c: Correctly handle EINTR error from fgetc function. Don't eat white space for `C' format. * stdlib/tst-strtol.c [~0UL != 0xffffffff]: Fix typo in test data. * sysdeps/generic/abort.c: Update copyright. De-ANSI-declfy. * sysdeps/i386/abort.c: Removed. This version does not use signal SIGABRT. * sysdeps/i386/fpu/__math.h: Define __NO_MATH_INLINES if not using gcc-2.8 or up. Patch by HJ Lu. * sysdeps/posix/tempname.c: Test for error but EEXIST after open call. If EMFILE, ENFILE, or EINTR return with error. Wed Dec 11 14:43:52 1996 Ulrich Drepper <drepper@cygnus.com> * gnu-versions.h: Set _GNU_OBSTACK_INTERFACE_VERSION back to 1. We are compatible again. * new-malloc/obstack.h (struct obstack): Add back alloc_failed bit even though it is not used. * malloc/obstack.h: Likewise. * new-malloc/obstack.c (_obstack_begin, _obstack_begin_1): Initialize alloc_failed bit to 0. * time/strftime.c: Extend for Emacs' needs. Recognize field width, %P format and `0' modifier. Tue Dec 10 21:20:44 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * Makerules (make-link): Don't discard exit codes of intermediate commands. Always use rellns-sh if symbolic links are available. Tue Dec 10 20:09:51 1996 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/unix/sysv/linux/netinet/in.h: Enclose #include <linux/in.h> in __BEGIN_DECLS/__END_DECLS to avoid linkage conflict of ntohs etc. in <asm/byteorder.h>.
This commit is contained in:
102
time/strftime.c
102
time/strftime.c
@@ -33,6 +33,7 @@
|
||||
# include "../locale/localeinfo.h"
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <sys/types.h> /* Some systems define `time_t' here. */
|
||||
|
||||
#ifdef TIME_WITH_SYS_TIME
|
||||
@@ -161,20 +162,59 @@ localtime_r (t, tp)
|
||||
#endif /* ! defined (_LIBC) */
|
||||
|
||||
|
||||
#define add(n, f) \
|
||||
static const char spaces[16] = " ";
|
||||
#define add(n, f) \
|
||||
do \
|
||||
{ \
|
||||
i += (n); \
|
||||
int _n = (n); \
|
||||
int _delta = width - _n; \
|
||||
i += _n + (_delta > 0 ? _delta : 0); \
|
||||
if (i >= maxsize) \
|
||||
return 0; \
|
||||
else \
|
||||
if (p) \
|
||||
{ \
|
||||
while (_delta > 0) \
|
||||
{ \
|
||||
int _this = _delta > 16 ? 16 : _delta; \
|
||||
memcpy (p, spaces, _this); \
|
||||
p += _this; \
|
||||
_delta -= _this; \
|
||||
} \
|
||||
f; \
|
||||
p += (n); \
|
||||
p += _n; \
|
||||
} \
|
||||
} while (0)
|
||||
#define cpy(n, s) add ((n), memcpy((PTR) p, (PTR) (s), (n)))
|
||||
|
||||
#define cpy(n, s) \
|
||||
add ((n), \
|
||||
if (to_lowcase) \
|
||||
memcpy_lowcase (p, (s), _n); \
|
||||
else \
|
||||
memcpy ((PTR) p, (PTR) (s), _n))
|
||||
|
||||
|
||||
|
||||
#ifdef _LIBC
|
||||
# define TOUPPER(Ch) toupper (Ch)
|
||||
# define TOLOWER(Ch) tolower (Ch)
|
||||
#else
|
||||
# define TOUPPER(Ch) (islower (Ch) ? toupper (Ch) : (Ch))
|
||||
# define TOLOWER(Ch) (isupper (Ch) ? tolower (Ch) : (Ch))
|
||||
#endif
|
||||
|
||||
static char *memcpy_lowcase __P ((char *dest, const char *src, size_t len));
|
||||
|
||||
static char *
|
||||
memcpy_lowcase (dest, src, len)
|
||||
char *dest;
|
||||
const char *src;
|
||||
size_t len;
|
||||
{
|
||||
while (len-- > 0)
|
||||
dest[len] = TOLOWER (src[len]);
|
||||
return dest;
|
||||
}
|
||||
|
||||
#if ! HAVE_TM_GMTOFF
|
||||
/* Yield the difference between *A and *B,
|
||||
@@ -254,7 +294,7 @@ strftime (s, maxsize, format, tp)
|
||||
char *s;
|
||||
size_t maxsize;
|
||||
const char *format;
|
||||
register const struct tm *tp;
|
||||
const struct tm *tp;
|
||||
{
|
||||
int hour12 = tp->tm_hour;
|
||||
#ifdef _NL_CURRENT
|
||||
@@ -281,9 +321,9 @@ strftime (s, maxsize, format, tp)
|
||||
size_t month_len = strlen (f_month);
|
||||
const char *zone;
|
||||
size_t zonelen;
|
||||
register size_t i = 0;
|
||||
register char *p = s;
|
||||
register const char *f;
|
||||
size_t i = 0;
|
||||
char *p = s;
|
||||
const char *f;
|
||||
|
||||
zone = 0;
|
||||
#if HAVE_TM_ZONE
|
||||
@@ -315,6 +355,8 @@ strftime (s, maxsize, format, tp)
|
||||
char buf[1 + (sizeof (int) < sizeof (time_t)
|
||||
? INT_STRLEN_BOUND (time_t)
|
||||
: INT_STRLEN_BOUND (int))];
|
||||
int width = -1;
|
||||
int to_lowcase = 0;
|
||||
|
||||
#if DO_MULTIBYTE
|
||||
|
||||
@@ -391,18 +433,35 @@ strftime (s, maxsize, format, tp)
|
||||
|
||||
/* Check for flags that can modify a number format. */
|
||||
++f;
|
||||
switch (*f)
|
||||
while (1)
|
||||
{
|
||||
case '_':
|
||||
case '-':
|
||||
pad = *f++;
|
||||
break;
|
||||
switch (*f)
|
||||
{
|
||||
case '_':
|
||||
case '-':
|
||||
case '0':
|
||||
pad = *f++;
|
||||
break;
|
||||
|
||||
default:
|
||||
pad = 0;
|
||||
default:
|
||||
pad = 0;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* As a GNU extension we allow to specify the field width. */
|
||||
if (isdigit (*f))
|
||||
{
|
||||
width = 0;
|
||||
do
|
||||
{
|
||||
width *= 10;
|
||||
width += *f - '0';
|
||||
}
|
||||
while (isdigit (*++f));
|
||||
}
|
||||
|
||||
/* Check for modifiers. */
|
||||
switch (*f)
|
||||
{
|
||||
@@ -468,10 +527,10 @@ strftime (s, maxsize, format, tp)
|
||||
|
||||
subformat:
|
||||
{
|
||||
size_t len = strftime (p, maxsize - i, subfmt, tp);
|
||||
size_t len = strftime (NULL, maxsize - i, subfmt, tp);
|
||||
if (len == 0 && *subfmt)
|
||||
return 0;
|
||||
add (len, ;);
|
||||
add (len, strftime (p, maxsize - i, subfmt, tp));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -527,8 +586,9 @@ strftime (s, maxsize, format, tp)
|
||||
jump to one of these two labels. */
|
||||
|
||||
do_number_spacepad:
|
||||
/* Force `_' flag. */
|
||||
pad = '_';
|
||||
/* Force `_' flag unless overwritten by `0' flag. */
|
||||
if (pad != '0')
|
||||
pad = '_';
|
||||
|
||||
do_number:
|
||||
/* Format the number according to the MODIFIER flag. */
|
||||
@@ -638,6 +698,10 @@ strftime (s, maxsize, format, tp)
|
||||
add (1, *p = '\n');
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
to_lowcase = 1;
|
||||
/* FALLTHROUGH */
|
||||
|
||||
case 'p':
|
||||
cpy (ap_len, ampm);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user