diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2013-07-10 16:23:57 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2013-07-10 16:23:57 -0700 |
commit | 29abe551a0d9137718cd21732c9dc383d6493d71 (patch) | |
tree | 9730894ac27692871e3c7cba38fcb4df6412d8bc /src/regex.c | |
parent | 3d70c5cfa9aae030c5ab8e8e612319a6645cf659 (diff) |
Port to C89.
* lib-src/ebrowse.c (USAGE): Remove macro with too-long string literal ...
(usage_message): ... and replace it with this new static constant
containing multiple literals. All uses changed.
* lib-src/emacsclient.c (print_help_and_exit):
Rewrite to avoid string literals longer than the C89 limits.
(start_daemon_and_retry_set_socket):
Rewrite to avoid non-constant array initializer.
* lib-src/make-docfile.c (enum global_type): Omit trailing comma.
* src/bytecode.c (BYTE_CODE_THREADED): Do not define if __STRICT_ANSI__.
(B__dummy__): New dummy symbol, to pacify C89.
* src/dbusbind.c (XD_DEBUG_MESSAGE): Omit debugging on C89 hosts, since
they can't grok varargs macros.
* src/dispnew.c (add_window_display_history)
(add_frame_display_history):
* src/print.c (print_object):
* src/xdisp.c (debug_method_add):
Use %p printf format only for void pointers.
* src/emacs.c (usage_message): New constant, replacing ...
(USAGE1, USAGE2, USAGE3): Remove; they were too long for C89.
(main): Adjust to usage reorg.
* src/fns.c (syms_of_fns):
* src/profiler.c (syms_of_profiler):
Don't use non-constant struct initializers.
* src/gnutls.h (gnutls_initstage_t):
* src/lisp.h (enum Lisp_Fwd_Type):
* src/lread.c (lisp_file_lexically_bound_p):
* src/xsettings.c (anonymous enum):
Remove trailing comma.
* src/xsettings.c (apply_xft_settings): Use %f, not %lf; %lf is a C99ism.
* src/lisp.h (ENUM_BF): Use unsigned if pedantic.
(DEFUN_FUNCTION_INIT): New macro, that falls back on a cast if pre-C99.
(DEFUN): Use it.
* src/regex.c (const_re_char): New type, to pacify strict C89.
All uses of 'const re_char' replaced to use it.
* src/regex.h (_Restrict_): Rename from __restrict, to avoid clash
with glibc when strict C89. This change is imported from gnulib.
All uses changed.
(_Restrict_arr_): Rename from __restrict_arr, similarly.
* src/sysdep.c (time_from_jiffies) [!HAVE_LONG_LONG_INT]:
Omit GNU_LINUX implementation, since it requires long long.
* src/xterm.c (x_draw_underwave):
Do not assume the traditional order of struct's members.
(x_term_init): Rewrite to avoid the need for non-constant structure
initializers.
Diffstat (limited to 'src/regex.c')
-rw-r--r-- | src/regex.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/src/regex.c b/src/regex.c index 79fb28ba12..39adb080ef 100644 --- a/src/regex.c +++ b/src/regex.c @@ -531,8 +531,10 @@ init_syntax_once (void) /* Type of source-pattern and string chars. */ #ifdef _MSC_VER typedef unsigned char re_char; +typedef const re_char const_re_char; #else typedef const unsigned char re_char; +typedef re_char const_re_char; #endif typedef char boolean; @@ -2015,7 +2017,7 @@ struct range_table_work_area /* Map a string to the char class it names (if any). */ re_wctype_t -re_wctype (const re_char *str) +re_wctype (const_re_char *str) { const char *string = (const char *) str; if (STREQ (string, "alnum")) return RECC_ALNUM; @@ -2409,7 +2411,8 @@ do { \ } while (0) static reg_errcode_t -regex_compile (const re_char *pattern, size_t size, reg_syntax_t syntax, struct re_pattern_buffer *bufp) +regex_compile (const_re_char *pattern, size_t size, reg_syntax_t syntax, + struct re_pattern_buffer *bufp) { /* We fetch characters from PATTERN here. */ register re_wchar_t c, c1; @@ -3765,7 +3768,7 @@ insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, unsigned cha least one character before the ^. */ static boolean -at_begline_loc_p (const re_char *pattern, const re_char *p, reg_syntax_t syntax) +at_begline_loc_p (const_re_char *pattern, const_re_char *p, reg_syntax_t syntax) { re_char *prev = p - 2; boolean odd_backslashes; @@ -3806,7 +3809,7 @@ at_begline_loc_p (const re_char *pattern, const re_char *p, reg_syntax_t syntax) at least one character after the $, i.e., `P < PEND'. */ static boolean -at_endline_loc_p (const re_char *p, const re_char *pend, reg_syntax_t syntax) +at_endline_loc_p (const_re_char *p, const_re_char *pend, reg_syntax_t syntax) { re_char *next = p; boolean next_backslash = *next == '\\'; @@ -3850,7 +3853,8 @@ group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum) Return -1 if fastmap was not updated accurately. */ static int -analyse_first (const re_char *p, const re_char *pend, char *fastmap, const int multibyte) +analyse_first (const_re_char *p, const_re_char *pend, char *fastmap, + const int multibyte) { int j, k; boolean not; @@ -4594,7 +4598,7 @@ static int bcmp_translate (re_char *s1, re_char *s2, /* If the operation is a match against one or more chars, return a pointer to the next operation, else return NULL. */ static re_char * -skip_one_char (const re_char *p) +skip_one_char (const_re_char *p) { switch (*p++) { @@ -4636,7 +4640,7 @@ skip_one_char (const re_char *p) /* Jump over non-matching operations. */ static re_char * -skip_noops (const re_char *p, const re_char *pend) +skip_noops (const_re_char *p, const_re_char *pend) { int mcnt; while (p < pend) @@ -4663,7 +4667,8 @@ skip_noops (const re_char *p, const re_char *pend) /* Non-zero if "p1 matches something" implies "p2 fails". */ static int -mutually_exclusive_p (struct re_pattern_buffer *bufp, const re_char *p1, const re_char *p2) +mutually_exclusive_p (struct re_pattern_buffer *bufp, const_re_char *p1, + const_re_char *p2) { re_opcode_t op2; const boolean multibyte = RE_MULTIBYTE_P (bufp); @@ -4922,8 +4927,8 @@ WEAK_ALIAS (__re_match_2, re_match_2) /* This is a separate function so that we can force an alloca cleanup afterwards. */ static regoff_t -re_match_2_internal (struct re_pattern_buffer *bufp, const re_char *string1, - size_t size1, const re_char *string2, size_t size2, +re_match_2_internal (struct re_pattern_buffer *bufp, const_re_char *string1, + size_t size1, const_re_char *string2, size_t size2, ssize_t pos, struct re_registers *regs, ssize_t stop) { /* General temporaries. */ @@ -6265,7 +6270,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, const re_char *string1, bytes; nonzero otherwise. */ static int -bcmp_translate (const re_char *s1, const re_char *s2, register ssize_t len, +bcmp_translate (const_re_char *s1, const_re_char *s2, register ssize_t len, RE_TRANSLATE_TYPE translate, const int target_multibyte) { register re_char *p1 = s1, *p2 = s2; @@ -6434,7 +6439,7 @@ re_exec (const char *s) the return codes and their meanings.) */ reg_errcode_t -regcomp (regex_t *__restrict preg, const char *__restrict pattern, +regcomp (regex_t *_Restrict_ preg, const char *_Restrict_ pattern, int cflags) { reg_errcode_t ret; @@ -6515,8 +6520,8 @@ WEAK_ALIAS (__regcomp, regcomp) We return 0 if we find a match and REG_NOMATCH if not. */ reg_errcode_t -regexec (const regex_t *__restrict preg, const char *__restrict string, - size_t nmatch, regmatch_t pmatch[__restrict_arr], int eflags) +regexec (const regex_t *_Restrict_ preg, const char *_Restrict_ string, + size_t nmatch, regmatch_t pmatch[_Restrict_arr_], int eflags) { regoff_t ret; struct re_registers regs; |