diff options
| author | Dan Nicolaescu | 2010-11-15 22:44:51 -0800 |
|---|---|---|
| committer | Dan Nicolaescu | 2010-11-15 22:44:51 -0800 |
| commit | d2762c86419d6d55bf59fd62ea1c9fa3525411c0 (patch) | |
| tree | e1ba41021fe7ba2f29a79a51f23785f352547dc2 /src | |
| parent | 0073e0313a029f5bba231a147f0d4f1bb029dd43 (diff) | |
| download | emacs-d2762c86419d6d55bf59fd62ea1c9fa3525411c0.tar.gz emacs-d2762c86419d6d55bf59fd62ea1c9fa3525411c0.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 13 | ||||
| -rw-r--r-- | src/mktime.c | 30 | ||||
| -rw-r--r-- | src/regex.c | 48 | ||||
| -rw-r--r-- | src/strftime.c | 49 |
4 files changed, 41 insertions, 99 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index af5bbf9e8fb..ca673be0074 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,16 @@ | |||
| 1 | 2010-11-16 Dan Nicolaescu <dann@ics.uci.edu> | ||
| 2 | |||
| 3 | * strftime.c (LOCALE_PARAM_DECL): Update for standard C. | ||
| 4 | (LOCALE_PARAM, LOCALE_PARAM_PROTO): Remove, unused. | ||
| 5 | (memcpy_lowcase, so_week_days, extra_args_spec, emacs_strftimeu): | ||
| 6 | Convert definitions to standard C. | ||
| 7 | * regex.c: Do not include <stdlib.h>, config.h does it. | ||
| 8 | Include unistd.h. | ||
| 9 | (xrealloc, init_syntax_once, re_match, regcomp, regexec) | ||
| 10 | (regerror, regfree): Convert definitions to standard C. | ||
| 11 | * mktime.c (my_mktime_localtime_r, ydhms_tm_diff, ranged_convert) | ||
| 12 | (__mktime_internal): Convert definitions to standard C. | ||
| 13 | |||
| 1 | 2010-11-15 Dan Nicolaescu <dann@ics.uci.edu> | 14 | 2010-11-15 Dan Nicolaescu <dann@ics.uci.edu> |
| 2 | 15 | ||
| 3 | * w32proc.c: | 16 | * w32proc.c: |
diff --git a/src/mktime.c b/src/mktime.c index 3570cecd451..ede151981f4 100644 --- a/src/mktime.c +++ b/src/mktime.c | |||
| @@ -110,9 +110,7 @@ const unsigned short int __mon_yday[2][13] = | |||
| 110 | localtime to localtime_r, since many localtime_r implementations | 110 | localtime to localtime_r, since many localtime_r implementations |
| 111 | are buggy. */ | 111 | are buggy. */ |
| 112 | static struct tm * | 112 | static struct tm * |
| 113 | my_mktime_localtime_r (t, tp) | 113 | my_mktime_localtime_r (const time_t *t, struct tm *tp) |
| 114 | const time_t *t; | ||
| 115 | struct tm *tp; | ||
| 116 | { | 114 | { |
| 117 | struct tm *l = localtime (t); | 115 | struct tm *l = localtime (t); |
| 118 | if (! l) | 116 | if (! l) |
| @@ -130,9 +128,7 @@ my_mktime_localtime_r (t, tp) | |||
| 130 | If TP is null, return a nonzero value. | 128 | If TP is null, return a nonzero value. |
| 131 | If overflow occurs, yield the low order bits of the correct answer. */ | 129 | If overflow occurs, yield the low order bits of the correct answer. */ |
| 132 | static time_t | 130 | static time_t |
| 133 | ydhms_tm_diff (year, yday, hour, min, sec, tp) | 131 | ydhms_tm_diff (int year, int yday, int hour, int min, int sec, const struct tm *tp) |
| 134 | int year, yday, hour, min, sec; | ||
| 135 | const struct tm *tp; | ||
| 136 | { | 132 | { |
| 137 | if (!tp) | 133 | if (!tp) |
| 138 | return 1; | 134 | return 1; |
| @@ -163,14 +159,8 @@ ydhms_tm_diff (year, yday, hour, min, sec, tp) | |||
| 163 | If *T is out of range for conversion, adjust it so that | 159 | If *T is out of range for conversion, adjust it so that |
| 164 | it is the nearest in-range value and then convert that. */ | 160 | it is the nearest in-range value and then convert that. */ |
| 165 | static struct tm * | 161 | static struct tm * |
| 166 | ranged_convert (convert, t, tp) | 162 | ranged_convert (struct tm *(*convert) (const time_t *, struct tm *), |
| 167 | #ifdef PROTOTYPES | 163 | time_t *t, struct tm *tp) |
| 168 | struct tm *(*convert) (const time_t *, struct tm *); | ||
| 169 | #else | ||
| 170 | struct tm *(*convert)(); | ||
| 171 | #endif | ||
| 172 | time_t *t; | ||
| 173 | struct tm *tp; | ||
| 174 | { | 164 | { |
| 175 | struct tm *r; | 165 | struct tm *r; |
| 176 | 166 | ||
| @@ -217,14 +207,8 @@ ranged_convert (convert, t, tp) | |||
| 217 | compared to what the result would be for UTC without leap seconds. | 207 | compared to what the result would be for UTC without leap seconds. |
| 218 | If *OFFSET's guess is correct, only one CONVERT call is needed. */ | 208 | If *OFFSET's guess is correct, only one CONVERT call is needed. */ |
| 219 | time_t | 209 | time_t |
| 220 | __mktime_internal (tp, convert, offset) | 210 | __mktime_internal (struct tm *tp, struct tm *(*convert) (const time_t *, struct tm *), |
| 221 | struct tm *tp; | 211 | time_t *offset) |
| 222 | #ifdef PROTOTYPES | ||
| 223 | struct tm *(*convert) (const time_t *, struct tm *); | ||
| 224 | #else | ||
| 225 | struct tm *(*convert)(); | ||
| 226 | #endif | ||
| 227 | time_t *offset; | ||
| 228 | { | 212 | { |
| 229 | time_t t, dt, t0, t1, t2; | 213 | time_t t, dt, t0, t1, t2; |
| 230 | struct tm tm; | 214 | struct tm tm; |
| @@ -558,5 +542,3 @@ compile-command: "gcc -DDEBUG -DHAVE_LIMITS_H -DSTDC_HEADERS -Wall -W -O -g mkti | |||
| 558 | End: | 542 | End: |
| 559 | */ | 543 | */ |
| 560 | 544 | ||
| 561 | /* arch-tag: 9456752f-7ddd-47cb-8286-fa807b1355ae | ||
| 562 | (do not change this comment) */ | ||
diff --git a/src/regex.c b/src/regex.c index 17158552a95..31f188efa99 100644 --- a/src/regex.c +++ b/src/regex.c | |||
| @@ -196,18 +196,14 @@ | |||
| 196 | even if config.h says that we can. */ | 196 | even if config.h says that we can. */ |
| 197 | # undef REL_ALLOC | 197 | # undef REL_ALLOC |
| 198 | 198 | ||
| 199 | # if defined STDC_HEADERS || defined _LIBC | 199 | # ifdef HAVE_UNISTD_H |
| 200 | # include <stdlib.h> | 200 | # include <unistd.h> |
| 201 | # else | ||
| 202 | char *malloc (); | ||
| 203 | char *realloc (); | ||
| 204 | # endif | 201 | # endif |
| 205 | 202 | ||
| 206 | /* When used in Emacs's lib-src, we need xmalloc and xrealloc. */ | 203 | /* When used in Emacs's lib-src, we need xmalloc and xrealloc. */ |
| 207 | 204 | ||
| 208 | void * | 205 | void * |
| 209 | xmalloc (size) | 206 | xmalloc (size_t size) |
| 210 | size_t size; | ||
| 211 | { | 207 | { |
| 212 | register void *val; | 208 | register void *val; |
| 213 | val = (void *) malloc (size); | 209 | val = (void *) malloc (size); |
| @@ -220,9 +216,7 @@ xmalloc (size) | |||
| 220 | } | 216 | } |
| 221 | 217 | ||
| 222 | void * | 218 | void * |
| 223 | xrealloc (block, size) | 219 | xrealloc (void *block, size_t size) |
| 224 | void *block; | ||
| 225 | size_t size; | ||
| 226 | { | 220 | { |
| 227 | register void *val; | 221 | register void *val; |
| 228 | /* We must call malloc explicitly when BLOCK is 0, since some | 222 | /* We must call malloc explicitly when BLOCK is 0, since some |
| @@ -435,7 +429,7 @@ extern char *re_syntax_table; | |||
| 435 | static char re_syntax_table[CHAR_SET_SIZE]; | 429 | static char re_syntax_table[CHAR_SET_SIZE]; |
| 436 | 430 | ||
| 437 | static void | 431 | static void |
| 438 | init_syntax_once () | 432 | init_syntax_once (void) |
| 439 | { | 433 | { |
| 440 | register int c; | 434 | register int c; |
| 441 | static int done = 0; | 435 | static int done = 0; |
| @@ -4978,11 +4972,8 @@ mutually_exclusive_p (struct re_pattern_buffer *bufp, const re_char *p1, const r | |||
| 4978 | /* re_match is like re_match_2 except it takes only a single string. */ | 4972 | /* re_match is like re_match_2 except it takes only a single string. */ |
| 4979 | 4973 | ||
| 4980 | int | 4974 | int |
| 4981 | re_match (bufp, string, size, pos, regs) | 4975 | re_match (struct re_pattern_buffer *bufp, const char *string, |
| 4982 | struct re_pattern_buffer *bufp; | 4976 | int size, int pos, struct re_registers *regs) |
| 4983 | const char *string; | ||
| 4984 | int size, pos; | ||
| 4985 | struct re_registers *regs; | ||
| 4986 | { | 4977 | { |
| 4987 | int result = re_match_2_internal (bufp, NULL, 0, (re_char*) string, size, | 4978 | int result = re_match_2_internal (bufp, NULL, 0, (re_char*) string, size, |
| 4988 | pos, regs, size); | 4979 | pos, regs, size); |
| @@ -6534,10 +6525,8 @@ re_exec (s) | |||
| 6534 | the return codes and their meanings.) */ | 6525 | the return codes and their meanings.) */ |
| 6535 | 6526 | ||
| 6536 | int | 6527 | int |
| 6537 | regcomp (preg, pattern, cflags) | 6528 | regcomp (regex_t *__restrict preg, const char *__restrict pattern, |
| 6538 | regex_t *__restrict preg; | 6529 | int cflags) |
| 6539 | const char *__restrict pattern; | ||
| 6540 | int cflags; | ||
| 6541 | { | 6530 | { |
| 6542 | reg_errcode_t ret; | 6531 | reg_errcode_t ret; |
| 6543 | reg_syntax_t syntax | 6532 | reg_syntax_t syntax |
| @@ -6619,12 +6608,8 @@ WEAK_ALIAS (__regcomp, regcomp) | |||
| 6619 | We return 0 if we find a match and REG_NOMATCH if not. */ | 6608 | We return 0 if we find a match and REG_NOMATCH if not. */ |
| 6620 | 6609 | ||
| 6621 | int | 6610 | int |
| 6622 | regexec (preg, string, nmatch, pmatch, eflags) | 6611 | regexec (const regex_t *__restrict preg, const char *__restrict string, |
| 6623 | const regex_t *__restrict preg; | 6612 | size_t nmatch, regmatch_t pmatch[__restrict_arr], int eflags) |
| 6624 | const char *__restrict string; | ||
| 6625 | size_t nmatch; | ||
| 6626 | regmatch_t pmatch[__restrict_arr]; | ||
| 6627 | int eflags; | ||
| 6628 | { | 6613 | { |
| 6629 | int ret; | 6614 | int ret; |
| 6630 | struct re_registers regs; | 6615 | struct re_registers regs; |
| @@ -6696,11 +6681,7 @@ WEAK_ALIAS (__regexec, regexec) | |||
| 6696 | error with msvc8 compiler. */ | 6681 | error with msvc8 compiler. */ |
| 6697 | 6682 | ||
| 6698 | size_t | 6683 | size_t |
| 6699 | regerror (err_code, preg, errbuf, errbuf_size) | 6684 | regerror (int err_code, const regex_t *preg, char *errbuf, size_t errbuf_size) |
| 6700 | int err_code; | ||
| 6701 | const regex_t *preg; | ||
| 6702 | char *errbuf; | ||
| 6703 | size_t errbuf_size; | ||
| 6704 | { | 6685 | { |
| 6705 | const char *msg; | 6686 | const char *msg; |
| 6706 | size_t msg_size; | 6687 | size_t msg_size; |
| @@ -6736,8 +6717,7 @@ WEAK_ALIAS (__regerror, regerror) | |||
| 6736 | /* Free dynamically allocated space used by PREG. */ | 6717 | /* Free dynamically allocated space used by PREG. */ |
| 6737 | 6718 | ||
| 6738 | void | 6719 | void |
| 6739 | regfree (preg) | 6720 | regfree (regex_t *preg) |
| 6740 | regex_t *preg; | ||
| 6741 | { | 6721 | { |
| 6742 | free (preg->buffer); | 6722 | free (preg->buffer); |
| 6743 | preg->buffer = NULL; | 6723 | preg->buffer = NULL; |
| @@ -6756,5 +6736,3 @@ WEAK_ALIAS (__regfree, regfree) | |||
| 6756 | 6736 | ||
| 6757 | #endif /* not emacs */ | 6737 | #endif /* not emacs */ |
| 6758 | 6738 | ||
| 6759 | /* arch-tag: 4ffd68ba-2a9e-435b-a21a-018990f9eeb2 | ||
| 6760 | (do not change this comment) */ | ||
diff --git a/src/strftime.c b/src/strftime.c index a7617427793..56c2a2c0fb0 100644 --- a/src/strftime.c +++ b/src/strftime.c | |||
| @@ -318,14 +318,10 @@ static const CHAR_T zeroes[16] = /* "0000000000000000" */ | |||
| 318 | # undef _NL_CURRENT | 318 | # undef _NL_CURRENT |
| 319 | # define _NL_CURRENT(category, item) \ | 319 | # define _NL_CURRENT(category, item) \ |
| 320 | (current->values[_NL_ITEM_INDEX (item)].string) | 320 | (current->values[_NL_ITEM_INDEX (item)].string) |
| 321 | # define LOCALE_PARAM , loc | ||
| 322 | # define LOCALE_ARG , loc | 321 | # define LOCALE_ARG , loc |
| 323 | # define LOCALE_PARAM_DECL __locale_t loc; | 322 | # define LOCALE_PARAM_DECL , __locale_t loc |
| 324 | # define LOCALE_PARAM_PROTO , __locale_t loc | ||
| 325 | # define HELPER_LOCALE_ARG , current | 323 | # define HELPER_LOCALE_ARG , current |
| 326 | #else | 324 | #else |
| 327 | # define LOCALE_PARAM | ||
| 328 | # define LOCALE_PARAM_PROTO | ||
| 329 | # define LOCALE_ARG | 325 | # define LOCALE_ARG |
| 330 | # define LOCALE_PARAM_DECL | 326 | # define LOCALE_PARAM_DECL |
| 331 | # ifdef _LIBC | 327 | # ifdef _LIBC |
| @@ -363,30 +359,16 @@ static const CHAR_T zeroes[16] = /* "0000000000000000" */ | |||
| 363 | more reliable way to accept other sets of digits. */ | 359 | more reliable way to accept other sets of digits. */ |
| 364 | #define ISDIGIT(Ch) ((unsigned int) (Ch) - L_('0') <= 9) | 360 | #define ISDIGIT(Ch) ((unsigned int) (Ch) - L_('0') <= 9) |
| 365 | 361 | ||
| 366 | static CHAR_T *memcpy_lowcase (CHAR_T *dest, const CHAR_T *src, | ||
| 367 | size_t len LOCALE_PARAM_PROTO); | ||
| 368 | |||
| 369 | static CHAR_T * | 362 | static CHAR_T * |
| 370 | memcpy_lowcase (dest, src, len LOCALE_PARAM) | 363 | memcpy_lowcase (CHAR_T *dest, const CHAR_T *src, size_t len LOCALE_PARAM_DECL) |
| 371 | CHAR_T *dest; | ||
| 372 | const CHAR_T *src; | ||
| 373 | size_t len; | ||
| 374 | LOCALE_PARAM_DECL | ||
| 375 | { | 364 | { |
| 376 | while (len-- > 0) | 365 | while (len-- > 0) |
| 377 | dest[len] = TOLOWER ((UCHAR_T) src[len], loc); | 366 | dest[len] = TOLOWER ((UCHAR_T) src[len], loc); |
| 378 | return dest; | 367 | return dest; |
| 379 | } | 368 | } |
| 380 | 369 | ||
| 381 | static CHAR_T *memcpy_uppcase (CHAR_T *dest, const CHAR_T *src, | ||
| 382 | size_t len LOCALE_PARAM_PROTO); | ||
| 383 | |||
| 384 | static CHAR_T * | 370 | static CHAR_T * |
| 385 | memcpy_uppcase (dest, src, len LOCALE_PARAM) | 371 | memcpy_uppcase (CHAR_T *dest, const CHAR_T *src, size_t len LOCALE_PARAM_DECL) |
| 386 | CHAR_T *dest; | ||
| 387 | const CHAR_T *src; | ||
| 388 | size_t len; | ||
| 389 | LOCALE_PARAM_DECL | ||
| 390 | { | 372 | { |
| 391 | while (len-- > 0) | 373 | while (len-- > 0) |
| 392 | dest[len] = TOUPPER ((UCHAR_T) src[len], loc); | 374 | dest[len] = TOUPPER ((UCHAR_T) src[len], loc); |
| @@ -437,9 +419,7 @@ static int iso_week_days (int, int); | |||
| 437 | __inline__ | 419 | __inline__ |
| 438 | #endif | 420 | #endif |
| 439 | static int | 421 | static int |
| 440 | iso_week_days (yday, wday) | 422 | iso_week_days (int yday, int wday) |
| 441 | int yday; | ||
| 442 | int wday; | ||
| 443 | { | 423 | { |
| 444 | /* Add enough to the first operand of % to make it nonnegative. */ | 424 | /* Add enough to the first operand of % to make it nonnegative. */ |
| 445 | int big_enough_multiple_of_7 = (-YDAY_MINIMUM / 7 + 2) * 7; | 425 | int big_enough_multiple_of_7 = (-YDAY_MINIMUM / 7 + 2) * 7; |
| @@ -470,7 +450,7 @@ static CHAR_T const month_name[][10] = | |||
| 470 | 450 | ||
| 471 | #ifdef my_strftime | 451 | #ifdef my_strftime |
| 472 | # define extra_args , ut, ns | 452 | # define extra_args , ut, ns |
| 473 | # define extra_args_spec int ut; int ns; | 453 | # define extra_args_spec , int ut, int ns |
| 474 | # define extra_args_spec_iso , int ut, int ns | 454 | # define extra_args_spec_iso , int ut, int ns |
| 475 | #else | 455 | #else |
| 476 | # ifdef COMPILE_WIDE | 456 | # ifdef COMPILE_WIDE |
| @@ -517,13 +497,8 @@ static CHAR_T const month_name[][10] = | |||
| 517 | anywhere, so to determine how many characters would be | 497 | anywhere, so to determine how many characters would be |
| 518 | written, use NULL for S and (size_t) UINT_MAX for MAXSIZE. */ | 498 | written, use NULL for S and (size_t) UINT_MAX for MAXSIZE. */ |
| 519 | size_t | 499 | size_t |
| 520 | my_strftime (s, maxsize, format, tp extra_args LOCALE_PARAM) | 500 | my_strftime (CHAR_T *s, size_t maxsize, const CHAR_T *format, |
| 521 | CHAR_T *s; | 501 | const struct tm *tp extra_args_spec LOCALE_PARAM_DECL) |
| 522 | size_t maxsize; | ||
| 523 | const CHAR_T *format; | ||
| 524 | const struct tm *tp; | ||
| 525 | extra_args_spec | ||
| 526 | LOCALE_PARAM_DECL | ||
| 527 | { | 502 | { |
| 528 | #if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL | 503 | #if defined _LIBC && defined USE_IN_EXTENDED_LOCALE_MODEL |
| 529 | struct locale_data *const current = loc->__locales[LC_TIME]; | 504 | struct locale_data *const current = loc->__locales[LC_TIME]; |
| @@ -1474,16 +1449,10 @@ libc_hidden_def (my_strftime) | |||
| 1474 | /* For Emacs we have a separate interface which corresponds to the normal | 1449 | /* For Emacs we have a separate interface which corresponds to the normal |
| 1475 | strftime function plus the ut argument, but without the ns argument. */ | 1450 | strftime function plus the ut argument, but without the ns argument. */ |
| 1476 | size_t | 1451 | size_t |
| 1477 | emacs_strftimeu (s, maxsize, format, tp, ut) | 1452 | emacs_strftimeu (char *s, size_t maxsize, const char *format, |
| 1478 | char *s; | 1453 | const struct tm *tp, int ut) |
| 1479 | size_t maxsize; | ||
| 1480 | const char *format; | ||
| 1481 | const struct tm *tp; | ||
| 1482 | int ut; | ||
| 1483 | { | 1454 | { |
| 1484 | return my_strftime (s, maxsize, format, tp, ut, 0); | 1455 | return my_strftime (s, maxsize, format, tp, ut, 0); |
| 1485 | } | 1456 | } |
| 1486 | #endif | 1457 | #endif |
| 1487 | 1458 | ||
| 1488 | /* arch-tag: 662bc9c4-f8e2-41b6-bf96-b8346d0ce0d8 | ||
| 1489 | (do not change this comment) */ | ||