Commit d2762c86 authored by Dan Nicolaescu's avatar Dan Nicolaescu
Browse files

Convert definitions to standard C.

* src/strftime.c (LOCALE_PARAM_DECL): Update for standard C.
(LOCALE_PARAM, LOCALE_PARAM_PROTO): Remove, unused.
(memcpy_lowcase, so_week_days, extra_args_spec, emacs_strftimeu):
Convert definitions to standard C.
* src/regex.c: Do not include <stdlib.h>, config.h does it.
Include unistd.h.
(xrealloc, init_syntax_once, re_match, regcomp, regexec)
(regerror, regfree): Convert definitions to standard C.
* src/mktime.c (my_mktime_localtime_r, ydhms_tm_diff, ranged_convert)
(__mktime_internal): Convert definitions to standard C.
parent 0073e031
2010-11-16 Dan Nicolaescu <dann@ics.uci.edu>
* strftime.c (LOCALE_PARAM_DECL): Update for standard C.
(LOCALE_PARAM, LOCALE_PARAM_PROTO): Remove, unused.
(memcpy_lowcase, so_week_days, extra_args_spec, emacs_strftimeu):
Convert definitions to standard C.
* regex.c: Do not include <stdlib.h>, config.h does it.
Include unistd.h.
(xrealloc, init_syntax_once, re_match, regcomp, regexec)
(regerror, regfree): Convert definitions to standard C.
* mktime.c (my_mktime_localtime_r, ydhms_tm_diff, ranged_convert)
(__mktime_internal): Convert definitions to standard C.
2010-11-15 Dan Nicolaescu <dann@ics.uci.edu> 2010-11-15 Dan Nicolaescu <dann@ics.uci.edu>
   
* w32proc.c: * w32proc.c:
......
...@@ -110,9 +110,7 @@ const unsigned short int __mon_yday[2][13] = ...@@ -110,9 +110,7 @@ const unsigned short int __mon_yday[2][13] =
localtime to localtime_r, since many localtime_r implementations localtime to localtime_r, since many localtime_r implementations
are buggy. */ are buggy. */
static struct tm * static struct tm *
my_mktime_localtime_r (t, tp) my_mktime_localtime_r (const time_t *t, struct tm *tp)
const time_t *t;
struct tm *tp;
{ {
struct tm *l = localtime (t); struct tm *l = localtime (t);
if (! l) if (! l)
...@@ -130,9 +128,7 @@ my_mktime_localtime_r (t, tp) ...@@ -130,9 +128,7 @@ my_mktime_localtime_r (t, tp)
If TP is null, return a nonzero value. If TP is null, return a nonzero value.
If overflow occurs, yield the low order bits of the correct answer. */ If overflow occurs, yield the low order bits of the correct answer. */
static time_t static time_t
ydhms_tm_diff (year, yday, hour, min, sec, tp) ydhms_tm_diff (int year, int yday, int hour, int min, int sec, const struct tm *tp)
int year, yday, hour, min, sec;
const struct tm *tp;
{ {
if (!tp) if (!tp)
return 1; return 1;
...@@ -163,14 +159,8 @@ ydhms_tm_diff (year, yday, hour, min, sec, tp) ...@@ -163,14 +159,8 @@ ydhms_tm_diff (year, yday, hour, min, sec, tp)
If *T is out of range for conversion, adjust it so that If *T is out of range for conversion, adjust it so that
it is the nearest in-range value and then convert that. */ it is the nearest in-range value and then convert that. */
static struct tm * static struct tm *
ranged_convert (convert, t, tp) ranged_convert (struct tm *(*convert) (const time_t *, struct tm *),
#ifdef PROTOTYPES time_t *t, struct tm *tp)
struct tm *(*convert) (const time_t *, struct tm *);
#else
struct tm *(*convert)();
#endif
time_t *t;
struct tm *tp;
{ {
struct tm *r; struct tm *r;
...@@ -217,14 +207,8 @@ ranged_convert (convert, t, tp) ...@@ -217,14 +207,8 @@ ranged_convert (convert, t, tp)
compared to what the result would be for UTC without leap seconds. compared to what the result would be for UTC without leap seconds.
If *OFFSET's guess is correct, only one CONVERT call is needed. */ If *OFFSET's guess is correct, only one CONVERT call is needed. */
time_t time_t
__mktime_internal (tp, convert, offset) __mktime_internal (struct tm *tp, struct tm *(*convert) (const time_t *, struct tm *),
struct tm *tp; time_t *offset)
#ifdef PROTOTYPES
struct tm *(*convert) (const time_t *, struct tm *);
#else
struct tm *(*convert)();
#endif
time_t *offset;
{ {
time_t t, dt, t0, t1, t2; time_t t, dt, t0, t1, t2;
struct tm tm; struct tm tm;
...@@ -558,5 +542,3 @@ compile-command: "gcc -DDEBUG -DHAVE_LIMITS_H -DSTDC_HEADERS -Wall -W -O -g mkti ...@@ -558,5 +542,3 @@ compile-command: "gcc -DDEBUG -DHAVE_LIMITS_H -DSTDC_HEADERS -Wall -W -O -g mkti
End: End:
*/ */
/* arch-tag: 9456752f-7ddd-47cb-8286-fa807b1355ae
(do not change this comment) */
...@@ -196,18 +196,14 @@ ...@@ -196,18 +196,14 @@
even if config.h says that we can. */ even if config.h says that we can. */
# undef REL_ALLOC # undef REL_ALLOC
# if defined STDC_HEADERS || defined _LIBC # ifdef HAVE_UNISTD_H
# include <stdlib.h> # include <unistd.h>
# else
char *malloc ();
char *realloc ();
# endif # endif
/* When used in Emacs's lib-src, we need xmalloc and xrealloc. */ /* When used in Emacs's lib-src, we need xmalloc and xrealloc. */
void * void *
xmalloc (size) xmalloc (size_t size)
size_t size;
{ {
register void *val; register void *val;
val = (void *) malloc (size); val = (void *) malloc (size);
...@@ -220,9 +216,7 @@ xmalloc (size) ...@@ -220,9 +216,7 @@ xmalloc (size)
} }
void * void *
xrealloc (block, size) xrealloc (void *block, size_t size)
void *block;
size_t size;
{ {
register void *val; register void *val;
/* We must call malloc explicitly when BLOCK is 0, since some /* We must call malloc explicitly when BLOCK is 0, since some
...@@ -435,7 +429,7 @@ extern char *re_syntax_table; ...@@ -435,7 +429,7 @@ extern char *re_syntax_table;
static char re_syntax_table[CHAR_SET_SIZE]; static char re_syntax_table[CHAR_SET_SIZE];
static void static void
init_syntax_once () init_syntax_once (void)
{ {
register int c; register int c;
static int done = 0; static int done = 0;
...@@ -4978,11 +4972,8 @@ mutually_exclusive_p (struct re_pattern_buffer *bufp, const re_char *p1, const r ...@@ -4978,11 +4972,8 @@ mutually_exclusive_p (struct re_pattern_buffer *bufp, const re_char *p1, const r
/* re_match is like re_match_2 except it takes only a single string. */ /* re_match is like re_match_2 except it takes only a single string. */
int int
re_match (bufp, string, size, pos, regs) re_match (struct re_pattern_buffer *bufp, const char *string,
struct re_pattern_buffer *bufp; int size, int pos, struct re_registers *regs)
const char *string;
int size, pos;
struct re_registers *regs;
{ {
int result = re_match_2_internal (bufp, NULL, 0, (re_char*) string, size, int result = re_match_2_internal (bufp, NULL, 0, (re_char*) string, size,
pos, regs, size); pos, regs, size);
...@@ -6534,10 +6525,8 @@ re_exec (s) ...@@ -6534,10 +6525,8 @@ re_exec (s)
the return codes and their meanings.) */ the return codes and their meanings.) */
int int
regcomp (preg, pattern, cflags) regcomp (regex_t *__restrict preg, const char *__restrict pattern,
regex_t *__restrict preg; int cflags)
const char *__restrict pattern;
int cflags;
{ {
reg_errcode_t ret; reg_errcode_t ret;
reg_syntax_t syntax reg_syntax_t syntax
...@@ -6619,12 +6608,8 @@ WEAK_ALIAS (__regcomp, regcomp) ...@@ -6619,12 +6608,8 @@ WEAK_ALIAS (__regcomp, regcomp)
We return 0 if we find a match and REG_NOMATCH if not. */ We return 0 if we find a match and REG_NOMATCH if not. */
int int
regexec (preg, string, nmatch, pmatch, eflags) regexec (const regex_t *__restrict preg, const char *__restrict string,
const regex_t *__restrict preg; size_t nmatch, regmatch_t pmatch[__restrict_arr], int eflags)
const char *__restrict string;
size_t nmatch;
regmatch_t pmatch[__restrict_arr];
int eflags;
{ {
int ret; int ret;
struct re_registers regs; struct re_registers regs;
...@@ -6696,11 +6681,7 @@ WEAK_ALIAS (__regexec, regexec) ...@@ -6696,11 +6681,7 @@ WEAK_ALIAS (__regexec, regexec)
error with msvc8 compiler. */ error with msvc8 compiler. */
size_t size_t
regerror (err_code, preg, errbuf, errbuf_size) regerror (int err_code, const regex_t *preg, char *errbuf, size_t errbuf_size)
int err_code;
const regex_t *preg;
char *errbuf;
size_t errbuf_size;
{ {
const char *msg; const char *msg;
size_t msg_size; size_t msg_size;
...@@ -6736,8 +6717,7 @@ WEAK_ALIAS (__regerror, regerror) ...@@ -6736,8 +6717,7 @@ WEAK_ALIAS (__regerror, regerror)
/* Free dynamically allocated space used by PREG. */ /* Free dynamically allocated space used by PREG. */
void void
regfree (preg) regfree (regex_t *preg)
regex_t *preg;
{ {
free (preg->buffer); free (preg->buffer);
preg->buffer = NULL; preg->buffer = NULL;
...@@ -6756,5 +6736,3 @@ WEAK_ALIAS (__regfree, regfree) ...@@ -6756,5 +6736,3 @@ WEAK_ALIAS (__regfree, regfree)
#endif /* not emacs */ #endif /* not emacs */
/* arch-tag: 4ffd68ba-2a9e-435b-a21a-018990f9eeb2
(do not change this comment) */
...@@ -318,14 +318,10 @@ static const CHAR_T zeroes[16] = /* "0000000000000000" */ ...@@ -318,14 +318,10 @@ static const CHAR_T zeroes[16] = /* "0000000000000000" */
# undef _NL_CURRENT # undef _NL_CURRENT
# define _NL_CURRENT(category, item) \ # define _NL_CURRENT(category, item) \
(current->values[_NL_ITEM_INDEX (item)].string) (current->values[_NL_ITEM_INDEX (item)].string)
# define LOCALE_PARAM , loc
# define LOCALE_ARG , loc # define LOCALE_ARG , loc
# define LOCALE_PARAM_DECL __locale_t loc; # define LOCALE_PARAM_DECL , __locale_t loc
# define LOCALE_PARAM_PROTO , __locale_t loc
# define HELPER_LOCALE_ARG , current # define HELPER_LOCALE_ARG , current
#else #else
# define LOCALE_PARAM
# define LOCALE_PARAM_PROTO
# define LOCALE_ARG # define LOCALE_ARG
# define LOCALE_PARAM_DECL # define LOCALE_PARAM_DECL
# ifdef _LIBC # ifdef _LIBC
...@@ -363,30 +359,16 @@ static const CHAR_T zeroes[16] = /* "0000000000000000" */ ...@@ -363,30 +359,16 @@ static const CHAR_T zeroes[16] = /* "0000000000000000" */
more reliable way to accept other sets of digits. */ more reliable way to accept other sets of digits. */
#define ISDIGIT(Ch) ((unsigned int) (Ch) - L_('0') <= 9) #define ISDIGIT(Ch) ((unsigned int) (Ch) - L_('0') <= 9)
static CHAR_T *memcpy_lowcase (CHAR_T *dest, const CHAR_T *src,
size_t len LOCALE_PARAM_PROTO);
static CHAR_T * static CHAR_T *
memcpy_lowcase (dest, src, len LOCALE_PARAM) memcpy_lowcase (CHAR_T *dest, const CHAR_T *src, size_t len LOCALE_PARAM_DECL)
CHAR_T *dest;
const CHAR_T *src;
size_t len;
LOCALE_PARAM_DECL
{ {
while (len-- > 0) while (len-- > 0)
dest[len] = TOLOWER ((UCHAR_T) src[len], loc); dest[len] = TOLOWER ((UCHAR_T) src[len], loc);
return dest; return dest;
} }
static CHAR_T *memcpy_uppcase (CHAR_T *dest, const CHAR_T *src,
size_t len LOCALE_PARAM_PROTO);
static CHAR_T * static CHAR_T *
memcpy_uppcase (dest, src, len LOCALE_PARAM) memcpy_uppcase (CHAR_T *dest, const CHAR_T *src, size_t len LOCALE_PARAM_DECL)
CHAR_T *dest;
const CHAR_T *src;
size_t len;
LOCALE_PARAM_DECL
{ {
while (len-- > 0) while (len-- > 0)
dest[len] = TOUPPER ((UCHAR_T) src[len], loc); dest[len] = TOUPPER ((UCHAR_T) src[len], loc);
...@@ -437,9 +419,7 @@ static int iso_week_days (int, int); ...@@ -437,9 +419,7 @@ static int iso_week_days (int, int);
__inline__ __inline__
#endif #endif
static int static int
iso_week_days (yday, wday) iso_week_days (int yday, int wday)
int yday;
int wday;
{ {
/* Add enough to the first operand of % to make it nonnegative. */ /* Add enough to the first operand of % to make it nonnegative. */
int big_enough_multiple_of_7 = (-YDAY_MINIMUM / 7 + 2) * 7; int big_enough_multiple_of_7 = (-YDAY_MINIMUM / 7 + 2) * 7;
...@@ -470,7 +450,7 @@ static CHAR_T const month_name[][10] = ...@@ -470,7 +450,7 @@ static CHAR_T const month_name[][10] =
#ifdef my_strftime #ifdef my_strftime
# define extra_args , ut, ns # define extra_args , ut, ns
# define extra_args_spec int ut; int ns; # define extra_args_spec , int ut, int ns
# define extra_args_spec_iso , int ut, int ns # define extra_args_spec_iso , int ut, int ns
#else #else
# ifdef COMPILE_WIDE # ifdef COMPILE_WIDE
...@@ -517,13 +497,8 @@ static CHAR_T const month_name[][10] = ...@@ -517,13 +497,8 @@ static CHAR_T const month_name[][10] =
anywhere, so to determine how many characters would be anywhere, so to determine how many characters would be
written, use NULL for S and (size_t) UINT_MAX for MAXSIZE. */ written, use NULL for S and (size_t) UINT_MAX for MAXSIZE. */
size_t size_t
my_strftime (s, maxsize, format, tp extra_args LOCALE_PARAM) my_strftime (CHAR_T *s, size_t maxsize, const CHAR_T *format,
CHAR_T *s; const struct tm *tp extra_args_spec LOCALE_PARAM_DECL)
size_t maxsize;
const CHAR_T *format;
const struct tm *tp;
extra_args_spec
LOCALE_PARAM_DECL
{ {
#if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL #if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL
struct locale_data *const current = loc->__locales[LC_TIME]; struct locale_data *const current = loc->__locales[LC_TIME];
...@@ -1474,16 +1449,10 @@ libc_hidden_def (my_strftime) ...@@ -1474,16 +1449,10 @@ libc_hidden_def (my_strftime)
/* For Emacs we have a separate interface which corresponds to the normal /* For Emacs we have a separate interface which corresponds to the normal
strftime function plus the ut argument, but without the ns argument. */ strftime function plus the ut argument, but without the ns argument. */
size_t size_t
emacs_strftimeu (s, maxsize, format, tp, ut) emacs_strftimeu (char *s, size_t maxsize, const char *format,
char *s; const struct tm *tp, int ut)
size_t maxsize;
const char *format;
const struct tm *tp;
int ut;
{ {
return my_strftime (s, maxsize, format, tp, ut, 0); return my_strftime (s, maxsize, format, tp, ut, 0);
} }
#endif #endif
/* arch-tag: 662bc9c4-f8e2-41b6-bf96-b8346d0ce0d8
(do not change this comment) */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment