Mercurial > emacs
comparison src/regex.c @ 111558:a673d202fe46
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.
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Mon, 15 Nov 2010 22:44:51 -0800 |
parents | b8fde5ef9e14 |
children | 417b1e4d63cd 7df2e30d72ec |
comparison
equal
deleted
inserted
replaced
111557:8bb6a226933b | 111558:a673d202fe46 |
---|---|
194 /* If we are not linking with Emacs proper, | 194 /* If we are not linking with Emacs proper, |
195 we can't use the relocating allocator | 195 we can't use the relocating allocator |
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); |
214 if (!val && size) | 210 if (!val && size) |
215 { | 211 { |
218 } | 214 } |
219 return val; | 215 return val; |
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 |
229 reallocs don't do this. */ | 223 reallocs don't do this. */ |
230 if (! block) | 224 if (! block) |
433 # else /* not SYNTAX_TABLE */ | 427 # else /* not SYNTAX_TABLE */ |
434 | 428 |
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; |
442 | 436 |
443 if (done) | 437 if (done) |
4976 | 4970 |
4977 #ifndef emacs /* Emacs never uses this. */ | 4971 #ifndef emacs /* Emacs never uses this. */ |
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); |
4989 return result; | 4980 return result; |
4990 } | 4981 } |
6532 | 6523 |
6533 It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for | 6524 It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for |
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 |
6544 = (cflags & REG_EXTENDED) ? | 6533 = (cflags & REG_EXTENDED) ? |
6545 RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC; | 6534 RE_SYNTAX_POSIX_EXTENDED : RE_SYNTAX_POSIX_BASIC; |
6617 string; if REG_NOTEOL is set, then $ does not match at the end. | 6606 string; if REG_NOTEOL is set, then $ does not match at the end. |
6618 | 6607 |
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; |
6631 regex_t private_preg; | 6616 regex_t private_preg; |
6632 int len = strlen (string); | 6617 int len = strlen (string); |
6694 | 6679 |
6695 ERR_CODE was previously called ERRCODE, but that name causes an | 6680 ERR_CODE was previously called ERRCODE, but that name causes an |
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; |
6707 | 6688 |
6708 if (err_code < 0 | 6689 if (err_code < 0 |
6734 | 6715 |
6735 | 6716 |
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; |
6744 | 6724 |
6745 preg->allocated = 0; | 6725 preg->allocated = 0; |
6754 } | 6734 } |
6755 WEAK_ALIAS (__regfree, regfree) | 6735 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) */ |