diff options
| author | Paul Eggert | 2012-05-21 08:36:54 -0700 |
|---|---|---|
| committer | Paul Eggert | 2012-05-21 08:36:54 -0700 |
| commit | 261cb4bb750143d8078bb27a343e0d9560b884df (patch) | |
| tree | 0d295abf946d52c178be2f7b95e85bfcc5fc63cc /src/regex.c | |
| parent | ff23cd9f452b6d2b5001a67d7b14e0af7f61b194 (diff) | |
| download | emacs-261cb4bb750143d8078bb27a343e0d9560b884df.tar.gz emacs-261cb4bb750143d8078bb27a343e0d9560b884df.zip | |
Assume C89 or later.
* configure.in (AC_C_PROTOTYPES, AC_C_VOLATILE, AC_C_CONST)
(POINTER_TYPE, PROTOTYPES): Remove.
* admin/CPP-DEFINES: Remove NULL, const.
* lib-src/etags.c (static, const): Remove macros.
(PTR): Remove; all uses replaced with void *. Omit needless casts.
* src/alloc.c, src/buffer.c, lisp.h: Replace POINTER_TYPE with void.
* alloc.c (overrun_check_malloc, overrun_check_realloc, xmalloc)
(xrealloc):
* buffer.c (mmap_free_1, mmap_enlarge): Omit needless casts.
* editfns.c, fns.c, gmalloc.c, insdel.c, sysdep.c, termcap.c (NULL):
* textprop.c, tparam.c (NULL): Remove.
* ralloc.c, vm-limit.c (POINTER): Assume void * works.
* regex.c (SIGN_EXTEND_CHAR): Assume signed char works.
* regex.h (_RE_ARGS): Remove. All uses rewritten to use prototypes.
* unexelf.c (ElfBitsW): Assume c89 preprocessor or better.
* xterm.c (input_signal_count): Assume volatile works.
Diffstat (limited to 'src/regex.c')
| -rw-r--r-- | src/regex.c | 83 |
1 files changed, 31 insertions, 52 deletions
diff --git a/src/regex.c b/src/regex.c index d16a5148054..f9a12a3c2dc 100644 --- a/src/regex.c +++ b/src/regex.c | |||
| @@ -434,17 +434,7 @@ init_syntax_once (void) | |||
| 434 | 434 | ||
| 435 | #endif /* not emacs */ | 435 | #endif /* not emacs */ |
| 436 | 436 | ||
| 437 | /* We remove any previous definition of `SIGN_EXTEND_CHAR', | 437 | #define SIGN_EXTEND_CHAR(c) ((signed char) (c)) |
| 438 | since ours (we hope) works properly with all combinations of | ||
| 439 | machines, compilers, `char' and `unsigned char' argument types. | ||
| 440 | (Per Bothner suggested the basic approach.) */ | ||
| 441 | #undef SIGN_EXTEND_CHAR | ||
| 442 | #if __STDC__ | ||
| 443 | # define SIGN_EXTEND_CHAR(c) ((signed char) (c)) | ||
| 444 | #else /* not __STDC__ */ | ||
| 445 | /* As in Harbison and Steele. */ | ||
| 446 | # define SIGN_EXTEND_CHAR(c) ((((unsigned char) (c)) ^ 128) - 128) | ||
| 447 | #endif | ||
| 448 | 438 | ||
| 449 | /* Should we use malloc or alloca? If REGEX_MALLOC is not defined, we | 439 | /* Should we use malloc or alloca? If REGEX_MALLOC is not defined, we |
| 450 | use `alloca' instead of `malloc'. This is because using malloc in | 440 | use `alloca' instead of `malloc'. This is because using malloc in |
| @@ -553,12 +543,12 @@ typedef char boolean; | |||
| 553 | #define false 0 | 543 | #define false 0 |
| 554 | #define true 1 | 544 | #define true 1 |
| 555 | 545 | ||
| 556 | static regoff_t re_match_2_internal _RE_ARGS ((struct re_pattern_buffer *bufp, | 546 | static regoff_t re_match_2_internal (struct re_pattern_buffer *bufp, |
| 557 | re_char *string1, size_t size1, | 547 | re_char *string1, size_t size1, |
| 558 | re_char *string2, size_t size2, | 548 | re_char *string2, size_t size2, |
| 559 | ssize_t pos, | 549 | ssize_t pos, |
| 560 | struct re_registers *regs, | 550 | struct re_registers *regs, |
| 561 | ssize_t stop)); | 551 | ssize_t stop); |
| 562 | 552 | ||
| 563 | /* These are the command codes that appear in compiled regular | 553 | /* These are the command codes that appear in compiled regular |
| 564 | expressions. Some opcodes are followed by argument bytes. A | 554 | expressions. Some opcodes are followed by argument bytes. A |
| @@ -735,11 +725,8 @@ typedef enum | |||
| 735 | } while (0) | 725 | } while (0) |
| 736 | 726 | ||
| 737 | #ifdef DEBUG | 727 | #ifdef DEBUG |
| 738 | static void extract_number _RE_ARGS ((int *dest, re_char *source)); | ||
| 739 | static void | 728 | static void |
| 740 | extract_number (dest, source) | 729 | extract_number (int *dest, re_char *source) |
| 741 | int *dest; | ||
| 742 | re_char *source; | ||
| 743 | { | 730 | { |
| 744 | int temp = SIGN_EXTEND_CHAR (*(source + 1)); | 731 | int temp = SIGN_EXTEND_CHAR (*(source + 1)); |
| 745 | *dest = *source & 0377; | 732 | *dest = *source & 0377; |
| @@ -763,12 +750,8 @@ extract_number (dest, source) | |||
| 763 | } while (0) | 750 | } while (0) |
| 764 | 751 | ||
| 765 | #ifdef DEBUG | 752 | #ifdef DEBUG |
| 766 | static void extract_number_and_incr _RE_ARGS ((int *destination, | ||
| 767 | re_char **source)); | ||
| 768 | static void | 753 | static void |
| 769 | extract_number_and_incr (destination, source) | 754 | extract_number_and_incr (int *destination, re_char **source) |
| 770 | int *destination; | ||
| 771 | re_char **source; | ||
| 772 | { | 755 | { |
| 773 | extract_number (destination, *source); | 756 | extract_number (destination, *source); |
| 774 | *source += 2; | 757 | *source += 2; |
| @@ -1672,25 +1655,22 @@ do { \ | |||
| 1672 | 1655 | ||
| 1673 | /* Subroutine declarations and macros for regex_compile. */ | 1656 | /* Subroutine declarations and macros for regex_compile. */ |
| 1674 | 1657 | ||
| 1675 | static reg_errcode_t regex_compile _RE_ARGS ((re_char *pattern, size_t size, | 1658 | static reg_errcode_t regex_compile (re_char *pattern, size_t size, |
| 1676 | reg_syntax_t syntax, | 1659 | reg_syntax_t syntax, |
| 1677 | struct re_pattern_buffer *bufp)); | 1660 | struct re_pattern_buffer *bufp); |
| 1678 | static void store_op1 _RE_ARGS ((re_opcode_t op, unsigned char *loc, int arg)); | 1661 | static void store_op1 (re_opcode_t op, unsigned char *loc, int arg); |
| 1679 | static void store_op2 _RE_ARGS ((re_opcode_t op, unsigned char *loc, | 1662 | static void store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2); |
| 1680 | int arg1, int arg2)); | 1663 | static void insert_op1 (re_opcode_t op, unsigned char *loc, |
| 1681 | static void insert_op1 _RE_ARGS ((re_opcode_t op, unsigned char *loc, | 1664 | int arg, unsigned char *end); |
| 1682 | int arg, unsigned char *end)); | 1665 | static void insert_op2 (re_opcode_t op, unsigned char *loc, |
| 1683 | static void insert_op2 _RE_ARGS ((re_opcode_t op, unsigned char *loc, | 1666 | int arg1, int arg2, unsigned char *end); |
| 1684 | int arg1, int arg2, unsigned char *end)); | 1667 | static boolean at_begline_loc_p (re_char *pattern, re_char *p, |
| 1685 | static boolean at_begline_loc_p _RE_ARGS ((re_char *pattern, | 1668 | reg_syntax_t syntax); |
| 1686 | re_char *p, | 1669 | static boolean at_endline_loc_p (re_char *p, re_char *pend, |
| 1687 | reg_syntax_t syntax)); | 1670 | reg_syntax_t syntax); |
| 1688 | static boolean at_endline_loc_p _RE_ARGS ((re_char *p, | 1671 | static re_char *skip_one_char (re_char *p); |
| 1689 | re_char *pend, | 1672 | static int analyse_first (re_char *p, re_char *pend, |
| 1690 | reg_syntax_t syntax)); | 1673 | char *fastmap, const int multibyte); |
| 1691 | static re_char *skip_one_char _RE_ARGS ((re_char *p)); | ||
| 1692 | static int analyse_first _RE_ARGS ((re_char *p, re_char *pend, | ||
| 1693 | char *fastmap, const int multibyte)); | ||
| 1694 | 1674 | ||
| 1695 | /* Fetch the next character in the uncompiled pattern, with no | 1675 | /* Fetch the next character in the uncompiled pattern, with no |
| 1696 | translation. */ | 1676 | translation. */ |
| @@ -2442,9 +2422,8 @@ regex_grow_registers (int num_regs) | |||
| 2442 | 2422 | ||
| 2443 | #endif /* not MATCH_MAY_ALLOCATE */ | 2423 | #endif /* not MATCH_MAY_ALLOCATE */ |
| 2444 | 2424 | ||
| 2445 | static boolean group_in_compile_stack _RE_ARGS ((compile_stack_type | 2425 | static boolean group_in_compile_stack (compile_stack_type compile_stack, |
| 2446 | compile_stack, | 2426 | regnum_t regnum); |
| 2447 | regnum_t regnum)); | ||
| 2448 | 2427 | ||
| 2449 | /* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. | 2428 | /* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX. |
| 2450 | Returns one of error codes defined in `regex.h', or zero for success. | 2429 | Returns one of error codes defined in `regex.h', or zero for success. |
| @@ -4554,10 +4533,10 @@ WEAK_ALIAS (__re_search_2, re_search_2) | |||
| 4554 | 4533 | ||
| 4555 | /* Declarations and macros for re_match_2. */ | 4534 | /* Declarations and macros for re_match_2. */ |
| 4556 | 4535 | ||
| 4557 | static int bcmp_translate _RE_ARGS ((re_char *s1, re_char *s2, | 4536 | static int bcmp_translate (re_char *s1, re_char *s2, |
| 4558 | register ssize_t len, | 4537 | register ssize_t len, |
| 4559 | RE_TRANSLATE_TYPE translate, | 4538 | RE_TRANSLATE_TYPE translate, |
| 4560 | const int multibyte)); | 4539 | const int multibyte); |
| 4561 | 4540 | ||
| 4562 | /* This converts PTR, a pointer into one of the search strings `string1' | 4541 | /* This converts PTR, a pointer into one of the search strings `string1' |
| 4563 | and `string2' into an offset from the beginning of that string. */ | 4542 | and `string2' into an offset from the beginning of that string. */ |