From addf390dade7222ee4a0183c413937065f3d0ea7 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 12 Sep 2003 19:22:07 +0000 Subject: [PATCH] Remove K&R cruft. --- lib/strftime.c | 163 ++++++++------------------------------------------------- m4/strftime.m4 | 8 ++- 2 files changed, 25 insertions(+), 146 deletions(-) diff --git a/lib/strftime.c b/lib/strftime.c index 1e026649d..66f273297 100644 --- a/lib/strftime.c +++ b/lib/strftime.c @@ -22,7 +22,6 @@ #endif #ifdef _LIBC -# define HAVE_LIMITS_H 1 # define HAVE_MBLEN 1 # define HAVE_MBRLEN 1 # define HAVE_STRUCT_ERA_ENTRY 1 @@ -31,14 +30,9 @@ # define HAVE_TZNAME 1 # define HAVE_TZSET 1 # define MULTIBYTE_IS_FORMAT_SAFE 1 -# define STDC_HEADERS 1 # include "../locale/localeinfo.h" #endif -#if defined emacs && !defined HAVE_BCOPY -# define HAVE_MEMCPY 1 -#endif - #include #include /* Some systems define `time_t' here. */ @@ -76,19 +70,10 @@ extern char *tzname[]; static const mbstate_t mbstate_zero; #endif -#if HAVE_LIMITS_H -# include -#endif - -#if STDC_HEADERS -# include -# include -# include -#else -# ifndef HAVE_MEMCPY -# define memcpy(d, s, n) bcopy ((s), (d), (n)) -# endif -#endif +#include +#include +#include +#include #ifdef COMPILE_WIDE # include @@ -106,11 +91,7 @@ extern char *tzname[]; # define L_(Str) Str # define NLW(Sym) Sym -# if !defined STDC_HEADERS && !defined HAVE_MEMCPY -# define MEMCPY(d, s, n) bcopy ((s), (d), (n)) -# else -# define MEMCPY(d, s, n) memcpy ((d), (s), (n)) -# endif +# define MEMCPY(d, s, n) memcpy (d, s, n) # define STRLEN(s) strlen (s) # ifdef _LIBC @@ -122,30 +103,6 @@ extern char *tzname[]; # endif #endif -#ifndef __P -# if defined __GNUC__ || (defined __STDC__ && __STDC__) -# define __P(args) args -# else -# define __P(args) () -# endif /* GCC. */ -#endif /* Not __P. */ - -#ifndef PTR -# ifdef __STDC__ -# define PTR void * -# else -# define PTR char * -# endif -#endif - -#ifndef CHAR_BIT -# define CHAR_BIT 8 -#endif - -#ifndef NULL -# define NULL 0 -#endif - #define TYPE_SIGNED(t) ((t) -1 < 0) /* Bound on length of the string representing an integer value of type t. @@ -184,55 +141,12 @@ extern char *tzname[]; #endif -#if !defined memset && !defined HAVE_MEMSET && !defined _LIBC -/* Some systems lack the `memset' function and we don't want to - introduce additional dependencies. */ -/* The SGI compiler reportedly barfs on the trailing null - if we use a string constant as the initializer. 28 June 1997, rms. */ -static const CHAR_T spaces[16] = /* " " */ -{ - L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' '), - L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' '),L_(' ') -}; -static const CHAR_T zeroes[16] = /* "0000000000000000" */ -{ - L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0'), - L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0'),L_('0') -}; - -# define memset_space(P, Len) \ - do { \ - int _len = (Len); \ - \ - do \ - { \ - int _this = _len > 16 ? 16 : _len; \ - (P) = MEMPCPY ((P), spaces, _this * sizeof (CHAR_T)); \ - _len -= _this; \ - } \ - while (_len > 0); \ - } while (0) - -# define memset_zero(P, Len) \ - do { \ - int _len = (Len); \ - \ - do \ - { \ - int _this = _len > 16 ? 16 : _len; \ - (P) = MEMPCPY ((P), zeroes, _this * sizeof (CHAR_T)); \ - _len -= _this; \ - } \ - while (_len > 0); \ - } while (0) +#ifdef COMPILE_WIDE +# define memset_space(P, Len) (wmemset (P, L' ', Len), (P) += (Len)) +# define memset_zero(P, Len) (wmemset (P, L'0', Len), (P) += (Len)) #else -# ifdef COMPILE_WIDE -# define memset_space(P, Len) (wmemset ((P), L' ', (Len)), (P) += (Len)) -# define memset_zero(P, Len) (wmemset ((P), L'0', (Len)), (P) += (Len)) -# else -# define memset_space(P, Len) (memset ((P), ' ', (Len)), (P) += (Len)) -# define memset_zero(P, Len) (memset ((P), '0', (Len)), (P) += (Len)) -# endif +# define memset_space(P, Len) (memset (P, ' ', Len), (P) += (Len)) +# define memset_zero(P, Len) (memset (P, '0', Len), (P) += (Len)) #endif #define add(n, f) \ @@ -265,7 +179,7 @@ static const CHAR_T zeroes[16] = /* "0000000000000000" */ else if (to_uppcase) \ memcpy_uppcase (p, (s), _n LOCALE_ARG); \ else \ - MEMCPY ((PTR) p, (const PTR) (s), _n)) + MEMCPY ((void *) p, (void const *) (s), _n)) #ifdef COMPILE_WIDE # ifndef USE_IN_EXTENDED_LOCALE_MODEL @@ -294,16 +208,12 @@ static const CHAR_T zeroes[16] = /* "0000000000000000" */ # undef _NL_CURRENT # define _NL_CURRENT(category, item) \ (current->values[_NL_ITEM_INDEX (item)].string) -# define LOCALE_PARAM , loc # define LOCALE_ARG , loc -# define LOCALE_PARAM_DECL __locale_t loc; # define LOCALE_PARAM_PROTO , __locale_t loc # define HELPER_LOCALE_ARG , current #else -# define LOCALE_PARAM # define LOCALE_PARAM_PROTO # define LOCALE_ARG -# define LOCALE_PARAM_DECL # ifdef _LIBC # define HELPER_LOCALE_ARG , _NL_CURRENT_DATA (LC_TIME) # else @@ -339,30 +249,18 @@ static const CHAR_T zeroes[16] = /* "0000000000000000" */ more reliable way to accept other sets of digits. */ #define ISDIGIT(Ch) ((unsigned int) (Ch) - L_('0') <= 9) -static CHAR_T *memcpy_lowcase __P ((CHAR_T *dest, const CHAR_T *src, - size_t len LOCALE_PARAM_PROTO)); - static CHAR_T * -memcpy_lowcase (dest, src, len LOCALE_PARAM) - CHAR_T *dest; - const CHAR_T *src; - size_t len; - LOCALE_PARAM_DECL +memcpy_lowcase (CHAR_T *dest, const CHAR_T *src, + size_t len LOCALE_PARAM_PROTO) { while (len-- > 0) dest[len] = TOLOWER ((UCHAR_T) src[len], loc); return dest; } -static CHAR_T *memcpy_uppcase __P ((CHAR_T *dest, const CHAR_T *src, - size_t len LOCALE_PARAM_PROTO)); - static CHAR_T * -memcpy_uppcase (dest, src, len LOCALE_PARAM) - CHAR_T *dest; - const CHAR_T *src; - size_t len; - LOCALE_PARAM_DECL +memcpy_uppcase (CHAR_T *dest, const CHAR_T *src, + size_t len LOCALE_PARAM_PROTO) { while (len-- > 0) dest[len] = TOUPPER ((UCHAR_T) src[len], loc); @@ -374,11 +272,8 @@ memcpy_uppcase (dest, src, len LOCALE_PARAM) /* Yield the difference between *A and *B, measured in seconds, ignoring leap seconds. */ # define tm_diff ftime_tm_diff -static int tm_diff __P ((const struct tm *, const struct tm *)); static int -tm_diff (a, b) - const struct tm *a; - const struct tm *b; +tm_diff (const struct tm *, const struct tm *) { /* Compute intervening leap days correctly even if year is negative. Take care to avoid int overflow in leap day calculations, @@ -408,14 +303,11 @@ tm_diff (a, b) #define ISO_WEEK_START_WDAY 1 /* Monday */ #define ISO_WEEK1_WDAY 4 /* Thursday */ #define YDAY_MINIMUM (-366) -static int iso_week_days __P ((int, int)); #ifdef __GNUC__ __inline__ #endif static int -iso_week_days (yday, wday) - int yday; - int wday; +iso_week_days (int yday, int wday) { /* Add enough to the first operand of % to make it nonnegative. */ int big_enough_multiple_of_7 = (-YDAY_MINIMUM / 7 + 2) * 7; @@ -451,8 +343,7 @@ static CHAR_T const month_name[][10] = #ifdef my_strftime # define extra_args , ut, ns -# define extra_args_spec int ut; int ns; -# define extra_args_spec_iso , int ut, int ns +# define extra_args_spec , int ut, int ns #else # ifdef COMPILE_WIDE # define my_strftime wcsftime @@ -463,7 +354,6 @@ static CHAR_T const month_name[][10] = # endif # define extra_args # define extra_args_spec -# define extra_args_spec_iso /* We don't have this information in general. */ # define ut 0 # define ns 0 @@ -484,13 +374,8 @@ static CHAR_T const month_name[][10] = anywhere, so to determine how many characters would be written, use NULL for S and (size_t) UINT_MAX for MAXSIZE. */ size_t -my_strftime (s, maxsize, format, tp extra_args LOCALE_PARAM) - CHAR_T *s; - size_t maxsize; - const CHAR_T *format; - const struct tm *tp; - extra_args_spec - LOCALE_PARAM_DECL +my_strftime (CHAR_T *s, size_t maxsize, const CHAR_T *format, + const struct tm *tp extra_args_spec LOCALE_PARAM_PROTO) { #if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL struct locale_data *const current = loc->__locales[LC_TIME]; @@ -1437,12 +1322,8 @@ libc_hidden_def (my_strftime) /* For Emacs we have a separate interface which corresponds to the normal strftime function plus the ut argument, but without the ns argument. */ size_t -emacs_strftimeu (s, maxsize, format, tp, ut) - char *s; - size_t maxsize; - const char *format; - const struct tm *tp; - int ut; +emacs_strftimeu (char *s, size_t maxsize, const char *format, + const struct tm *tp, int ut) { return my_strftime (s, maxsize, format, tp, ut, 0); } diff --git a/m4/strftime.m4 b/m4/strftime.m4 index 84a1996ae..dfcf320bd 100644 --- a/m4/strftime.m4 +++ b/m4/strftime.m4 @@ -1,4 +1,4 @@ -#serial 20 +#serial 21 dnl This macro is intended to be used solely in this file. dnl These are the prerequisite macros for GNU's strftime.c replacement. @@ -7,9 +7,8 @@ AC_DEFUN([_jm_STRFTIME_PREREQS], dnl strftime.c uses the underyling system strftime if it exists. AC_FUNC_STRFTIME - AC_CHECK_HEADERS_ONCE(limits.h) - AC_CHECK_FUNCS_ONCE(memcpy mempcpy) - AC_CHECK_FUNCS(tzset memset) + AC_CHECK_FUNCS_ONCE(mempcpy) + AC_CHECK_FUNCS(tzset) # This defines (or not) HAVE_TZNAME and HAVE_TM_ZONE. AC_STRUCT_TIMEZONE @@ -29,7 +28,6 @@ AC_DEFUN([jm_FUNC_GNU_STRFTIME], _jm_STRFTIME_PREREQS AC_REQUIRE([AC_C_CONST])dnl - AC_REQUIRE([AC_HEADER_STDC])dnl AC_CHECK_HEADERS_ONCE(sys/time.h) AC_DEFINE([my_strftime], [nstrftime], [Define to the name of the strftime replacement function.]) -- 2.11.0