Commit e5652268 authored by Paul Eggert's avatar Paul Eggert

Rename src/regex.c to src/regex-emacs.c.

This is in preparation for using Gnulib regex for etags,
to avoid collisions in include directives.
* src/regex-emacs.c: Rename from src/regex.c.
* src/regex-emacs.h: Rename from src/regex.h.  All uses changed.
* test/src/regex-emacs-tests.el: Rename from test/src/regex-tests.el.
parent ba8eb994
......@@ -37,7 +37,7 @@ Kenichi Handa
Mule
Stefan Monnier
src/regex.c
src/regex-emacs.c
src/syntax.c
src/keymap.c
font-lock/jit-lock/syntax
......
......@@ -57,7 +57,7 @@ Each entry has the form (FUNCTION . FUNCTIONS-IT-CALLS).")
"keymap.c" "sysdep.c" "buffer.c" "filelock.c"
"insdel.c" "marker.c" "minibuf.c" "fileio.c"
"dired.c" "cmds.c" "casefiddle.c"
"indent.c" "search.c" "regex.c" "undo.c"
"indent.c" "search.c" "regex-emacs.c" "undo.c"
"alloc.c" "data.c" "doc.c" "editfns.c"
"callint.c" "eval.c" "fns.c" "print.c" "lread.c"
"syntax.c" "unexcoff.c"
......
......@@ -361,13 +361,13 @@ TAGS: etags${EXEEXT} ${tagsfiles}
../lib/libgnu.a: $(config_h)
$(MAKE) -C ../lib all
regex.o: $(srcdir)/../src/regex.c $(srcdir)/../src/regex.h $(config_h)
regex-emacs.o: $(srcdir)/../src/regex-emacs.c $(srcdir)/../src/regex-emacs.h $(config_h)
$(AM_V_CC)$(CC) -c $(CPP_CFLAGS) $<
etags_deps = ${srcdir}/etags.c regex.o $(NTLIB) $(config_h)
etags_deps = ${srcdir}/etags.c regex-emacs.o $(NTLIB) $(config_h)
etags_cflags = -DEMACS_NAME="\"GNU Emacs\"" -DVERSION="\"${version}\"" -o $@
etags_libs = regex.o $(NTLIB) $(LOADLIBES)
etags_libs = regex-emacs.o $(NTLIB) $(LOADLIBES)
etags${EXEEXT}: ${etags_deps}
$(AM_V_CCLD)$(CC) ${ALL_CFLAGS} $(etags_cflags) $< $(etags_libs)
......
......@@ -135,7 +135,7 @@ char pot_etags_version[] = "@(#) pot revision number is 17.38.1.4";
#endif
#include <getopt.h>
#include <regex.h>
#include <regex-emacs.h>
/* Define CTAGS to make the program "ctags" compatible with the usual one.
Leave it undefined to make the program "etags", which makes emacs-style
......
......@@ -214,7 +214,7 @@ from which to start."
(when (> spaces 0)
(push (char-fold--make-space-string spaces) out))
(let ((regexp (apply #'concat (nreverse out))))
;; Limited by `MAX_BUF_SIZE' in `regex.c'.
;; Limited by `MAX_BUF_SIZE' in `regex-emacs.c'.
(if (> (length regexp) 5000)
(regexp-quote string)
regexp))))
......
......@@ -391,7 +391,7 @@ base_obj = dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \
emacs.o keyboard.o macros.o keymap.o sysdep.o \
buffer.o filelock.o insdel.o marker.o \
minibuf.o fileio.o dired.o \
cmds.o casetab.o casefiddle.o indent.o search.o regex.o undo.o \
cmds.o casetab.o casefiddle.o indent.o search.o regex-emacs.o undo.o \
alloc.o data.o doc.o editfns.o callint.o \
eval.o floatfns.o fns.o font.o print.o lread.o $(MODULES_OBJ) \
syntax.o $(UNEXEC_OBJ) bytecode.o \
......
......@@ -144,7 +144,8 @@ set_case_table (Lisp_Object table, bool standard)
set_char_table_extras (table, 2, eqv);
}
/* This is so set_image_of_range_1 in regex.c can find the EQV table. */
/* This is so set_image_of_range_1 in regex-emacs.c can find the EQV
table. */
set_char_table_extras (canon, 2, eqv);
if (standard)
......
......@@ -203,7 +203,7 @@ extern void _DebPrint (const char *fmt, ...);
#endif
#ifdef emacs /* Don't do this for lib-src. */
/* Tell regex.c to use a type compatible with Emacs. */
/* Tell regex-emacs.c to use a type compatible with Emacs. */
#define RE_TRANSLATE_TYPE Lisp_Object
#define RE_TRANSLATE(TBL, C) char_table_translate (TBL, C)
#define RE_TRANSLATE_P(TBL) (!EQ (TBL, make_number (0)))
......
......@@ -71,7 +71,7 @@ cmds.o: cmds.c syntax.h buffer.h character.h commands.h window.h lisp.h \
pre-crt0.o: pre-crt0.c
dbusbind.o: dbusbind.c termhooks.h frame.h keyboard.h lisp.h $(config_h)
dired.o: dired.c commands.h buffer.h lisp.h $(config_h) character.h charset.h \
coding.h regex.h systime.h blockinput.h atimer.h composite.h \
coding.h regex-emacs.h systime.h blockinput.h atimer.h composite.h \
../lib/filemode.h ../lib/unistd.h globals.h
dispnew.o: dispnew.c systime.h commands.h process.h frame.h coding.h \
window.h buffer.h termchar.h termopts.h termhooks.h cm.h \
......@@ -169,20 +169,21 @@ process.o: process.c process.h buffer.h window.h termhooks.h termopts.h \
blockinput.h atimer.h coding.h msdos.h nsterm.h composite.h \
keyboard.h lisp.h globals.h $(config_h) character.h xgselect.h sysselect.h \
../lib/unistd.h gnutls.h
regex.o: regex.c syntax.h buffer.h lisp.h globals.h $(config_h) regex.h \
regex-emacs.o: regex-emacs.c syntax.h buffer.h lisp.h globals.h \
$(config_h) regex-emacs.h \
category.h character.h
region-cache.o: region-cache.c buffer.h region-cache.h \
lisp.h globals.h $(config_h)
scroll.o: scroll.c termchar.h dispextern.h frame.h msdos.h keyboard.h \
termhooks.h lisp.h globals.h $(config_h) systime.h coding.h composite.h \
window.h
search.o: search.c regex.h commands.h buffer.h region-cache.h syntax.h \
search.o: search.c regex-emacs.h commands.h buffer.h region-cache.h syntax.h \
blockinput.h atimer.h systime.h category.h character.h charset.h \
$(INTERVALS_H) lisp.h globals.h $(config_h)
sound.o: sound.c dispextern.h syssignal.h lisp.h globals.h $(config_h) \
atimer.h systime.h ../lib/unistd.h msdos.h
syntax.o: syntax.c syntax.h buffer.h commands.h category.h character.h \
keymap.h regex.h $(INTERVALS_H) lisp.h globals.h $(config_h)
keymap.h regex-emacs.h $(INTERVALS_H) lisp.h globals.h $(config_h)
sysdep.o: sysdep.c syssignal.h systty.h systime.h syswait.h blockinput.h \
process.h dispextern.h termhooks.h termchar.h termopts.h coding.h \
frame.h atimer.h window.h msdos.h dosfns.h keyboard.h cm.h lisp.h \
......
......@@ -84,7 +84,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include "composite.h"
#include "dispextern.h"
#include "ptr-bounds.h"
#include "regex.h"
#include "regex-emacs.h"
#include "sheap.h"
#include "syntax.h"
#include "sysselect.h"
......@@ -846,9 +846,9 @@ main (int argc, char **argv)
{
rlim_t lim = rlim.rlim_cur;
/* Approximate the amount regex.c needs per unit of
/* Approximate the amount regex-emacs.c needs per unit of
emacs_re_max_failures, then add 33% to cover the size of the
smaller stacks that regex.c successively allocates and
smaller stacks that regex-emacs.c successively allocates and
discards on its way to the maximum. */
int min_ratio = 20 * sizeof (char *);
int ratio = min_ratio + min_ratio / 3;
......@@ -887,7 +887,7 @@ main (int argc, char **argv)
lim = newlim;
}
}
/* If the stack is big enough, let regex.c more of it before
/* If the stack is big enough, let regex-emacs.c more of it before
falling back to heap allocation. */
emacs_re_safe_alloca = max
(min (lim - extra, SIZE_MAX) * (min_ratio / ratio),
......
......@@ -53,7 +53,8 @@
#include <stdlib.h>
#ifdef emacs
/* We need this for `regex.h', and perhaps for the Emacs include files. */
/* We need this for `regex-emacs.h', and perhaps for the Emacs include
files. */
# include <sys/types.h>
#endif
......@@ -289,7 +290,7 @@ enum syntaxcode { Swhitespace = 0, Sword = 1, Ssymbol = 2 };
#endif
/* Get the interface, including the syntax bits. */
#include "regex.h"
#include "regex-emacs.h"
/* isalpha etc. are used for the character classes. */
#include <ctype.h>
......@@ -1157,7 +1158,7 @@ reg_syntax_t re_syntax_options;
different, incompatible syntaxes.
The argument SYNTAX is a bit mask comprised of the various bits
defined in regex.h. We return the old syntax. */
defined in regex-emacs.h. We return the old syntax. */
reg_syntax_t
re_set_syntax (reg_syntax_t syntax)
......@@ -1172,7 +1173,7 @@ WEAK_ALIAS (__re_set_syntax, re_set_syntax)
#endif
/* 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.
in regex-emacs.h. Obviously the order here has to be same as there.
POSIX doesn't require that we do anything for REG_NOERROR,
but why not be nice? */
......@@ -1474,28 +1475,28 @@ do { \
char *destination; \
/* Must be int, so when we don't save any registers, the arithmetic \
of 0 + -1 isn't done as unsigned. */ \
\
\
DEBUG_STATEMENT (nfailure_points_pushed++); \
DEBUG_PRINT ("\nPUSH_FAILURE_POINT:\n"); \
DEBUG_PRINT (" Before push, next avail: %zd\n", (fail_stack).avail); \
DEBUG_PRINT (" size: %zd\n", (fail_stack).size);\
\
\
ENSURE_FAIL_STACK (NUM_NONREG_ITEMS); \
\
\
DEBUG_PRINT ("\n"); \
\
\
DEBUG_PRINT (" Push frame index: %zd\n", fail_stack.frame); \
PUSH_FAILURE_INT (fail_stack.frame); \
\
\
DEBUG_PRINT (" Push string %p: \"", string_place); \
DEBUG_PRINT_DOUBLE_STRING (string_place, string1, size1, string2, size2);\
DEBUG_PRINT ("\"\n"); \
PUSH_FAILURE_POINTER (string_place); \
\
\
DEBUG_PRINT (" Push pattern %p: ", pattern); \
DEBUG_PRINT_COMPILED_PATTERN (bufp, pattern, pend); \
PUSH_FAILURE_POINTER (pattern); \
\
\
/* Close the frame by moving the frame pointer past it. */ \
fail_stack.frame = fail_stack.avail; \
} while (0)
......@@ -1822,7 +1823,7 @@ struct range_table_work_area
#define SETUP_ASCII_RANGE(work_area, FROM, TO) \
do { \
int C0, C1; \
\
\
for (C0 = (FROM); C0 <= (TO); C0++) \
{ \
C1 = TRANSLATE (C0); \
......@@ -1843,7 +1844,7 @@ struct range_table_work_area
do { \
int C0, C1, C2, I; \
int USED = RANGE_TABLE_WORK_USED (work_area); \
\
\
for (C0 = (FROM); C0 <= (TO); C0++) \
{ \
C1 = RE_CHAR_TO_MULTIBYTE (C0); \
......@@ -1882,7 +1883,7 @@ struct range_table_work_area
#define SETUP_MULTIBYTE_RANGE(work_area, FROM, TO) \
do { \
int C0, C1, C2, I, USED = RANGE_TABLE_WORK_USED (work_area); \
\
\
SET_RANGE_TABLE_WORK_AREA ((work_area), (FROM), (TO)); \
for (C0 = (FROM); C0 <= (TO); C0++) \
{ \
......@@ -1896,7 +1897,7 @@ struct range_table_work_area
{ \
int from = RANGE_TABLE_WORK_ELT (work_area, I); \
int to = RANGE_TABLE_WORK_ELT (work_area, I + 1); \
\
\
if (C1 >= from - 1 && C1 <= to + 1) \
{ \
if (C1 == from - 1) \
......@@ -2371,7 +2372,7 @@ static boolean group_in_compile_stack (compile_stack_type compile_stack,
regnum_t regnum);
/* `regex_compile' compiles PATTERN (of length SIZE) according to SYNTAX.
Returns one of error codes defined in `regex.h', or zero for success.
Returns one of error codes defined in `regex-emacs.h', or zero for success.
If WHITESPACE_REGEXP is given (only #ifdef emacs), it is used instead of
a space character in PATTERN.
......@@ -2714,15 +2715,15 @@ regex_compile (re_char *pattern, size_t size,
if (!zero_times_ok && simple)
{ /* Since simple * loops can be made faster by using
on_failure_keep_string_jump, we turn simple P+
into PP* if P is simple. */
unsigned char *p1, *p2;
startoffset = b - laststart;
GET_BUFFER_SPACE (startoffset);
p1 = b; p2 = laststart;
while (p2 < p1)
*b++ = *p2++;
zero_times_ok = 1;
on_failure_keep_string_jump, we turn simple P+
into PP* if P is simple. */
unsigned char *p1, *p2;
startoffset = b - laststart;
GET_BUFFER_SPACE (startoffset);
p1 = b; p2 = laststart;
while (p2 < p1)
*b++ = *p2++;
zero_times_ok = 1;
}
GET_BUFFER_SPACE (6);
......@@ -6217,7 +6218,7 @@ re_match_2_internal (struct re_pattern_buffer *bufp, re_char *string1,
FREE_VARIABLES ();
return -1; /* Failure to match. */
return -1; /* Failure to match. */
}
/* Subroutine definitions for re_match_2. */
......@@ -6400,7 +6401,7 @@ re_exec (const char *s)
routine will report only success or failure, and nothing about the
registers.
It returns 0 if it succeeds, nonzero if it doesn't. (See regex.h for
It returns 0 if it succeeds, nonzero if it doesn't. (See regex-emacs.h for
the return codes and their meanings.) */
reg_errcode_t
......
......@@ -160,9 +160,9 @@ typedef unsigned long reg_syntax_t;
/* If this bit is set, turn on internal regex debugging.
If not set, and debugging was on, turn it off.
This only works if regex.c is compiled -DDEBUG.
This only works if regex-emacs.c is compiled -DDEBUG.
We define this bit always, so that all that's needed to turn on
debugging is to recompile regex.c; the calling code can always have
debugging is to recompile regex-emacs.c; the calling code can always have
this bit set, and it won't affect anything in the normal case. */
#define RE_DEBUG (RE_NO_NEWLINE_ANCHOR << 1)
......@@ -317,7 +317,7 @@ extern ptrdiff_t emacs_re_safe_alloca;
/* If any error codes are removed, changed, or added, update the
`re_error_msg' table in regex.c. */
`re_error_msg' table in regex-emacs.c. */
typedef enum
{
#ifdef _XOPEN_SOURCE
......@@ -650,5 +650,5 @@ typedef int re_wchar_t;
#endif /* not WIDE_CHAR_SUPPORT */
#endif /* regex.h */
#endif /* regex-emacs.h */
......@@ -30,7 +30,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include "blockinput.h"
#include "intervals.h"
#include "regex.h"
#include "regex-emacs.h"
#define REGEXP_CACHE_SIZE 20
......@@ -290,7 +290,8 @@ looking_at_1 (Lisp_Object string, bool posix)
if (running_asynch_code)
save_search_regs ();
/* This is so set_image_of_range_1 in regex.c can find the EQV table. */
/* This is so set_image_of_range_1 in regex-emacs.c can find the EQV
table. */
set_char_table_extras (BVAR (current_buffer, case_canon_table), 2,
BVAR (current_buffer, case_eqv_table));
......@@ -410,7 +411,8 @@ string_match_1 (Lisp_Object regexp, Lisp_Object string, Lisp_Object start,
pos_byte = string_char_to_byte (string, pos);
}
/* This is so set_image_of_range_1 in regex.c can find the EQV table. */
/* This is so set_image_of_range_1 in regex-emacs.c can find the EQV
table. */
set_char_table_extras (BVAR (current_buffer, case_canon_table), 2,
BVAR (current_buffer, case_eqv_table));
......@@ -1062,7 +1064,8 @@ search_command (Lisp_Object string, Lisp_Object bound, Lisp_Object noerror,
lim_byte = CHAR_TO_BYTE (lim);
}
/* This is so set_image_of_range_1 in regex.c can find the EQV table. */
/* This is so set_image_of_range_1 in regex-emacs.c can find the EQV
table. */
set_char_table_extras (BVAR (current_buffer, case_canon_table), 2,
BVAR (current_buffer, case_eqv_table));
......
......@@ -23,7 +23,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include "lisp.h"
#include "character.h"
#include "buffer.h"
#include "regex.h"
#include "regex-emacs.h"
#include "syntax.h"
#include "intervals.h"
#include "category.h"
......@@ -267,9 +267,10 @@ SETUP_SYNTAX_TABLE (ptrdiff_t from, ptrdiff_t count)
If it is t (which is only used in fast_c_string_match_ignore_case),
ignore properties altogether.
This is meant for regex.c to use. For buffers, regex.c passes arguments
to the UPDATE_SYNTAX_TABLE functions which are relative to BEGV.
So if it is a buffer, we set the offset field to BEGV. */
This is meant for regex-emacs.c to use. For buffers, regex-emacs.c
passes arguments to the UPDATE_SYNTAX_TABLE functions which are
relative to BEGV. So if it is a buffer, we set the offset field to
BEGV. */
void
SETUP_SYNTAX_TABLE_FOR_OBJECT (Lisp_Object object,
......@@ -3729,7 +3730,7 @@ syms_of_syntax (void)
staticpro (&gl_state.current_syntax_table);
staticpro (&gl_state.old_prop);
/* Defined in regex.c. */
/* Defined in regex-emacs.c. */
staticpro (&re_match_object);
DEFSYM (Qscan_error, "scan-error");
......
......@@ -19,7 +19,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#ifndef THREAD_H
#define THREAD_H
#include "regex.h"
#include "regex-emacs.h"
#ifdef WINDOWSNT
#include <sys/socket.h>
......
;;; regex-tests.el --- tests for regex.c functions -*- lexical-binding: t -*-
;;; regex-emacs-tests.el --- tests for regex-emacs.c -*- lexical-binding: t -*-
;; Copyright (C) 2015-2018 Free Software Foundation, Inc.
......@@ -24,7 +24,7 @@
(defvar regex-tests--resources-dir
(concat (concat (file-name-directory (or load-file-name buffer-file-name))
"/regex-resources/"))
"Path to regex-resources directory next to the \"regex-tests.el\" file.")
"Path to regex-resources directory next to the \"regex-emacs-tests.el\" file.")
(ert-deftest regex-word-cc-fallback-test ()
"Test that \"[[:cc:]]*x\" matches \"x\" (bug#24020).
......@@ -683,4 +683,4 @@ This evaluates the TESTS test cases from glibc."
(should-not (string-match "\\`x\\{65535\\}" (make-string 65534 ?x)))
(should-error (string-match "\\`x\\{65536\\}" "X") :type 'invalid-regexp))
;;; regex-tests.el ends here
;;; regex-emacs-tests.el ends here
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment