Index: libc/misc/regex/Makefile.in =================================================================== --- libc/misc/regex/Makefile.in (revision 24146) +++ libc/misc/regex/Makefile.in (working copy) @@ -10,6 +10,7 @@ CSRC := regex_old.c else CSRC := regex.c endif +CSRC += re_syntax_options.c MISC_REGEX_DIR := $(top_srcdir)libc/misc/regex MISC_REGEX_OUT := $(top_builddir)libc/misc/regex Index: libc/misc/regex/regex_old.c =================================================================== --- libc/misc/regex/regex_old.c (revision 24146) +++ libc/misc/regex/regex_old.c (working copy) @@ -1337,13 +1337,7 @@ convert_mbs_to_wcs ( #else /* not INSIDE_RECURSION */ -/* Set by `re_set_syntax' to the current regexp syntax to recognize. Can - also be assigned to arbitrarily: each pattern buffer stores its own - syntax, so it can be changed between regex compilations. */ -/* This has no initializer because initialized variables in Emacs - become read-only after dumping. */ -reg_syntax_t re_syntax_options; - +extern __typeof(re_syntax_options) __re_syntax_options attribute_hidden; /* Specify the precise syntax of regexps for compilation. This provides for compatibility for various utilities which historically have @@ -1355,9 +1349,9 @@ reg_syntax_t re_syntax_options; reg_syntax_t re_set_syntax (reg_syntax_t syntax) { - reg_syntax_t ret = re_syntax_options; + reg_syntax_t ret = __re_syntax_options; - re_syntax_options = syntax; + __re_syntax_options = syntax; # ifdef DEBUG if (syntax & RE_DEBUG) debug = 1; @@ -7931,10 +7925,10 @@ re_compile_pattern ( # ifdef MBS_SUPPORT if (MB_CUR_MAX != 1) - ret = wcs_regex_compile (pattern, length, re_syntax_options, bufp); + ret = wcs_regex_compile (pattern, length, __re_syntax_options, bufp); else # endif - ret = byte_regex_compile (pattern, length, re_syntax_options, bufp); + ret = byte_regex_compile (pattern, length, __re_syntax_options, bufp); if (!ret) return NULL; @@ -7992,10 +7986,10 @@ re_comp (const char *s) # ifdef MBS_SUPPORT if (MB_CUR_MAX != 1) - ret = wcs_regex_compile (s, strlen (s), re_syntax_options, &re_comp_buf); + ret = wcs_regex_compile (s, strlen (s), __re_syntax_options, &re_comp_buf); else # endif - ret = byte_regex_compile (s, strlen (s), re_syntax_options, &re_comp_buf); + ret = byte_regex_compile (s, strlen (s), __re_syntax_options, &re_comp_buf); if (!ret) return NULL; Index: libc/misc/regex/regcomp.c =================================================================== --- libc/misc/regex/regcomp.c (revision 24146) +++ libc/misc/regex/regcomp.c (working copy) @@ -121,6 +121,8 @@ static void free_token (re_token_t *node static reg_errcode_t free_tree (void *extra, bin_tree_t *node); static reg_errcode_t mark_opt_subexp (void *extra, bin_tree_t *node); +extern __typeof(re_syntax_options) __re_syntax_options attribute_hidden; + /* This table gives an error message for each of the error codes listed in regex.h. Obviously the order here has to be same as there. POSIX doesn't require that we do anything for REG_NOERROR, @@ -221,12 +223,12 @@ re_compile_pattern (pattern, length, buf /* And GNU code determines whether or not to get register information by passing null for the REGS argument to re_match, etc., not by setting no_sub, unless RE_NO_SUB is set. */ - bufp->no_sub = !!(re_syntax_options & RE_NO_SUB); + bufp->no_sub = !!(__re_syntax_options & RE_NO_SUB); /* Match anchors at newline. */ bufp->newline_anchor = 1; - ret = re_compile_internal (bufp, pattern, length, re_syntax_options); + ret = re_compile_internal (bufp, pattern, length, __re_syntax_options); if (!ret) return NULL; @@ -236,14 +238,6 @@ re_compile_pattern (pattern, length, buf strong_alias(__re_compile_pattern, re_compile_pattern) #endif -/* Set by `re_set_syntax' to the current regexp syntax to recognize. Can - also be assigned to arbitrarily: each pattern buffer stores its own - syntax, so it can be changed between regex compilations. */ -/* This has no initializer because initialized variables in Emacs - become read-only after dumping. */ -reg_syntax_t re_syntax_options; - - /* Specify the precise syntax of regexps for compilation. This provides for compatibility for various utilities which historically have different, incompatible syntaxes. @@ -255,9 +249,9 @@ reg_syntax_t re_set_syntax (syntax) reg_syntax_t syntax; { - reg_syntax_t ret = re_syntax_options; + reg_syntax_t ret = __re_syntax_options; - re_syntax_options = syntax; + __re_syntax_options = syntax; return ret; } #if defined _LIBC || defined __UCLIBC__ @@ -684,7 +678,7 @@ re_comp (s) /* Match anchors at newlines. */ re_comp_buf.newline_anchor = 1; - ret = re_compile_internal (&re_comp_buf, s, strlen (s), re_syntax_options); + ret = re_compile_internal (&re_comp_buf, s, strlen (s), __re_syntax_options); if (!ret) return NULL;