aboutsummaryrefslogtreecommitdiffstats
path: root/src/regex.c
diff options
context:
space:
mode:
authorDan Nicolaescu2010-07-04 00:50:25 -0700
committerDan Nicolaescu2010-07-04 00:50:25 -0700
commit971de7fb158335fbda39525feb2d7776a26bc030 (patch)
tree605333d85f16e35bb06baffcb66ac49f4ec0dce9 /src/regex.c
parentb8463cbfbe2c5183cf40772df2746e58b787ddeb (diff)
downloademacs-971de7fb158335fbda39525feb2d7776a26bc030.tar.gz
emacs-971de7fb158335fbda39525feb2d7776a26bc030.zip
Convert (most) functions in src to standard C.
* src/alloc.c: Convert function definitions to standard C. * src/atimer.c: * src/bidi.c: * src/bytecode.c: * src/callint.c: * src/callproc.c: * src/casefiddle.c: * src/casetab.c: * src/category.c: * src/ccl.c: * src/character.c: * src/charset.c: * src/chartab.c: * src/cmds.c: * src/coding.c: * src/composite.c: * src/data.c: * src/dbusbind.c: * src/dired.c: * src/dispnew.c: * src/doc.c: * src/doprnt.c: * src/ecrt0.c: * src/editfns.c: * src/fileio.c: * src/filelock.c: * src/filemode.c: * src/fns.c: * src/font.c: * src/fontset.c: * src/frame.c: * src/fringe.c: * src/ftfont.c: * src/ftxfont.c: * src/gtkutil.c: * src/indent.c: * src/insdel.c: * src/intervals.c: * src/keymap.c: * src/lread.c: * src/macros.c: * src/marker.c: * src/md5.c: * src/menu.c: * src/minibuf.c: * src/prefix-args.c: * src/print.c: * src/ralloc.c: * src/regex.c: * src/region-cache.c: * src/scroll.c: * src/search.c: * src/sound.c: * src/strftime.c: * src/syntax.c: * src/sysdep.c: * src/termcap.c: * src/terminal.c: * src/terminfo.c: * src/textprop.c: * src/tparam.c: * src/undo.c: * src/unexelf.c: * src/window.c: * src/xfaces.c: * src/xfns.c: * src/xfont.c: * src/xftfont.c: * src/xgselect.c: * src/xmenu.c: * src/xrdb.c: * src/xselect.c: * src/xsettings.c: * src/xsmfns.c: * src/xterm.c: Likewise.
Diffstat (limited to 'src/regex.c')
-rw-r--r--src/regex.c125
1 files changed, 26 insertions, 99 deletions
diff --git a/src/regex.c b/src/regex.c
index 46065dda9e6..67efee37d82 100644
--- a/src/regex.c
+++ b/src/regex.c
@@ -1321,8 +1321,7 @@ reg_syntax_t re_syntax_options;
1321 defined in regex.h. We return the old syntax. */ 1321 defined in regex.h. We return the old syntax. */
1322 1322
1323reg_syntax_t 1323reg_syntax_t
1324re_set_syntax (syntax) 1324re_set_syntax (reg_syntax_t syntax)
1325 reg_syntax_t syntax;
1326{ 1325{
1327 reg_syntax_t ret = re_syntax_options; 1326 reg_syntax_t ret = re_syntax_options;
1328 1327
@@ -1335,8 +1334,7 @@ WEAK_ALIAS (__re_set_syntax, re_set_syntax)
1335static re_char *whitespace_regexp; 1334static re_char *whitespace_regexp;
1336 1335
1337void 1336void
1338re_set_whitespace_regexp (regexp) 1337re_set_whitespace_regexp (const char *regexp)
1339 const char *regexp;
1340{ 1338{
1341 whitespace_regexp = (re_char *) regexp; 1339 whitespace_regexp = (re_char *) regexp;
1342} 1340}
@@ -2149,8 +2147,7 @@ struct range_table_work_area
2149 2147
2150/* Map a string to the char class it names (if any). */ 2148/* Map a string to the char class it names (if any). */
2151re_wctype_t 2149re_wctype_t
2152re_wctype (str) 2150re_wctype (const re_char *str)
2153 re_char *str;
2154{ 2151{
2155 const char *string = str; 2152 const char *string = str;
2156 if (STREQ (string, "alnum")) return RECC_ALNUM; 2153 if (STREQ (string, "alnum")) return RECC_ALNUM;
@@ -2175,9 +2172,7 @@ re_wctype (str)
2175 2172
2176/* True if CH is in the char class CC. */ 2173/* True if CH is in the char class CC. */
2177boolean 2174boolean
2178re_iswctype (ch, cc) 2175re_iswctype (int ch, re_wctype_t cc)
2179 int ch;
2180 re_wctype_t cc;
2181{ 2176{
2182 switch (cc) 2177 switch (cc)
2183 { 2178 {
@@ -2207,8 +2202,7 @@ re_iswctype (ch, cc)
2207/* Return a bit-pattern to use in the range-table bits to match multibyte 2202/* Return a bit-pattern to use in the range-table bits to match multibyte
2208 chars of class CC. */ 2203 chars of class CC. */
2209static int 2204static int
2210re_wctype_to_bit (cc) 2205re_wctype_to_bit (re_wctype_t cc)
2211 re_wctype_t cc;
2212{ 2206{
2213 switch (cc) 2207 switch (cc)
2214 { 2208 {
@@ -2232,8 +2226,7 @@ re_wctype_to_bit (cc)
2232/* Actually extend the space in WORK_AREA. */ 2226/* Actually extend the space in WORK_AREA. */
2233 2227
2234static void 2228static void
2235extend_range_table_work_area (work_area) 2229extend_range_table_work_area (struct range_table_work_area *work_area)
2236 struct range_table_work_area *work_area;
2237{ 2230{
2238 work_area->allocated += 16 * sizeof (int); 2231 work_area->allocated += 16 * sizeof (int);
2239 if (work_area->table) 2232 if (work_area->table)
@@ -2557,11 +2550,7 @@ do { \
2557 } while (0) 2550 } while (0)
2558 2551
2559static reg_errcode_t 2552static reg_errcode_t
2560regex_compile (pattern, size, syntax, bufp) 2553regex_compile (const re_char *pattern, size_t size, reg_syntax_t syntax, struct re_pattern_buffer *bufp)
2561 re_char *pattern;
2562 size_t size;
2563 reg_syntax_t syntax;
2564 struct re_pattern_buffer *bufp;
2565{ 2554{
2566 /* We fetch characters from PATTERN here. */ 2555 /* We fetch characters from PATTERN here. */
2567 register re_wchar_t c, c1; 2556 register re_wchar_t c, c1;
@@ -3875,10 +3864,7 @@ regex_compile (pattern, size, syntax, bufp)
3875/* Store OP at LOC followed by two-byte integer parameter ARG. */ 3864/* Store OP at LOC followed by two-byte integer parameter ARG. */
3876 3865
3877static void 3866static void
3878store_op1 (op, loc, arg) 3867store_op1 (re_opcode_t op, unsigned char *loc, int arg)
3879 re_opcode_t op;
3880 unsigned char *loc;
3881 int arg;
3882{ 3868{
3883 *loc = (unsigned char) op; 3869 *loc = (unsigned char) op;
3884 STORE_NUMBER (loc + 1, arg); 3870 STORE_NUMBER (loc + 1, arg);
@@ -3888,10 +3874,7 @@ store_op1 (op, loc, arg)
3888/* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */ 3874/* Like `store_op1', but for two two-byte parameters ARG1 and ARG2. */
3889 3875
3890static void 3876static void
3891store_op2 (op, loc, arg1, arg2) 3877store_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2)
3892 re_opcode_t op;
3893 unsigned char *loc;
3894 int arg1, arg2;
3895{ 3878{
3896 *loc = (unsigned char) op; 3879 *loc = (unsigned char) op;
3897 STORE_NUMBER (loc + 1, arg1); 3880 STORE_NUMBER (loc + 1, arg1);
@@ -3903,11 +3886,7 @@ store_op2 (op, loc, arg1, arg2)
3903 for OP followed by two-byte integer parameter ARG. */ 3886 for OP followed by two-byte integer parameter ARG. */
3904 3887
3905static void 3888static void
3906insert_op1 (op, loc, arg, end) 3889insert_op1 (re_opcode_t op, unsigned char *loc, int arg, unsigned char *end)
3907 re_opcode_t op;
3908 unsigned char *loc;
3909 int arg;
3910 unsigned char *end;
3911{ 3890{
3912 register unsigned char *pfrom = end; 3891 register unsigned char *pfrom = end;
3913 register unsigned char *pto = end + 3; 3892 register unsigned char *pto = end + 3;
@@ -3922,11 +3901,7 @@ insert_op1 (op, loc, arg, end)
3922/* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */ 3901/* Like `insert_op1', but for two two-byte parameters ARG1 and ARG2. */
3923 3902
3924static void 3903static void
3925insert_op2 (op, loc, arg1, arg2, end) 3904insert_op2 (re_opcode_t op, unsigned char *loc, int arg1, int arg2, unsigned char *end)
3926 re_opcode_t op;
3927 unsigned char *loc;
3928 int arg1, arg2;
3929 unsigned char *end;
3930{ 3905{
3931 register unsigned char *pfrom = end; 3906 register unsigned char *pfrom = end;
3932 register unsigned char *pto = end + 5; 3907 register unsigned char *pto = end + 5;
@@ -3943,9 +3918,7 @@ insert_op2 (op, loc, arg1, arg2, end)
3943 least one character before the ^. */ 3918 least one character before the ^. */
3944 3919
3945static boolean 3920static boolean
3946at_begline_loc_p (pattern, p, syntax) 3921at_begline_loc_p (const re_char *pattern, const re_char *p, reg_syntax_t syntax)
3947 re_char *pattern, *p;
3948 reg_syntax_t syntax;
3949{ 3922{
3950 re_char *prev = p - 2; 3923 re_char *prev = p - 2;
3951 boolean prev_prev_backslash = prev > pattern && prev[-1] == '\\'; 3924 boolean prev_prev_backslash = prev > pattern && prev[-1] == '\\';
@@ -3967,9 +3940,7 @@ at_begline_loc_p (pattern, p, syntax)
3967 at least one character after the $, i.e., `P < PEND'. */ 3940 at least one character after the $, i.e., `P < PEND'. */
3968 3941
3969static boolean 3942static boolean
3970at_endline_loc_p (p, pend, syntax) 3943at_endline_loc_p (const re_char *p, const re_char *pend, reg_syntax_t syntax)
3971 re_char *p, *pend;
3972 reg_syntax_t syntax;
3973{ 3944{
3974 re_char *next = p; 3945 re_char *next = p;
3975 boolean next_backslash = *next == '\\'; 3946 boolean next_backslash = *next == '\\';
@@ -3989,9 +3960,7 @@ at_endline_loc_p (p, pend, syntax)
3989 false if it's not. */ 3960 false if it's not. */
3990 3961
3991static boolean 3962static boolean
3992group_in_compile_stack (compile_stack, regnum) 3963group_in_compile_stack (compile_stack_type compile_stack, regnum_t regnum)
3993 compile_stack_type compile_stack;
3994 regnum_t regnum;
3995{ 3964{
3996 int this_element; 3965 int this_element;
3997 3966
@@ -4015,10 +3984,7 @@ group_in_compile_stack (compile_stack, regnum)
4015 Return -1 if fastmap was not updated accurately. */ 3984 Return -1 if fastmap was not updated accurately. */
4016 3985
4017static int 3986static int
4018analyse_first (p, pend, fastmap, multibyte) 3987analyse_first (const re_char *p, const re_char *pend, char *fastmap, const const int multibyte)
4019 re_char *p, *pend;
4020 char *fastmap;
4021 const int multibyte;
4022{ 3988{
4023 int j, k; 3989 int j, k;
4024 boolean not; 3990 boolean not;
@@ -4330,8 +4296,7 @@ analyse_first (p, pend, fastmap, multibyte)
4330 Returns 0 if we succeed, -2 if an internal error. */ 4296 Returns 0 if we succeed, -2 if an internal error. */
4331 4297
4332int 4298int
4333re_compile_fastmap (bufp) 4299re_compile_fastmap (struct re_pattern_buffer *bufp)
4334 struct re_pattern_buffer *bufp;
4335{ 4300{
4336 char *fastmap = bufp->fastmap; 4301 char *fastmap = bufp->fastmap;
4337 int analysis; 4302 int analysis;
@@ -4361,11 +4326,7 @@ re_compile_fastmap (bufp)
4361 freeing the old data. */ 4326 freeing the old data. */
4362 4327
4363void 4328void
4364re_set_registers (bufp, regs, num_regs, starts, ends) 4329re_set_registers (struct re_pattern_buffer *bufp, struct re_registers *regs, unsigned int num_regs, regoff_t *starts, regoff_t *ends)
4365 struct re_pattern_buffer *bufp;
4366 struct re_registers *regs;
4367 unsigned num_regs;
4368 regoff_t *starts, *ends;
4369{ 4330{
4370 if (num_regs) 4331 if (num_regs)
4371 { 4332 {
@@ -4389,11 +4350,7 @@ WEAK_ALIAS (__re_set_registers, re_set_registers)
4389 doesn't let you say where to stop matching. */ 4350 doesn't let you say where to stop matching. */
4390 4351
4391int 4352int
4392re_search (bufp, string, size, startpos, range, regs) 4353re_search (struct re_pattern_buffer *bufp, const char *string, int size, int startpos, int range, struct re_registers *regs)
4393 struct re_pattern_buffer *bufp;
4394 const char *string;
4395 int size, startpos, range;
4396 struct re_registers *regs;
4397{ 4354{
4398 return re_search_2 (bufp, NULL, 0, string, size, startpos, range, 4355 return re_search_2 (bufp, NULL, 0, string, size, startpos, range,
4399 regs, size); 4356 regs, size);
@@ -4434,14 +4391,7 @@ WEAK_ALIAS (__re_search, re_search)
4434 stack overflow). */ 4391 stack overflow). */
4435 4392
4436int 4393int
4437re_search_2 (bufp, str1, size1, str2, size2, startpos, range, regs, stop) 4394re_search_2 (struct re_pattern_buffer *bufp, const char *str1, int size1, const char *str2, int size2, int startpos, int range, struct re_registers *regs, int stop)
4438 struct re_pattern_buffer *bufp;
4439 const char *str1, *str2;
4440 int size1, size2;
4441 int startpos;
4442 int range;
4443 struct re_registers *regs;
4444 int stop;
4445{ 4395{
4446 int val; 4396 int val;
4447 re_char *string1 = (re_char*) str1; 4397 re_char *string1 = (re_char*) str1;
@@ -4775,8 +4725,7 @@ static int bcmp_translate _RE_ARGS((re_char *s1, re_char *s2,
4775/* If the operation is a match against one or more chars, 4725/* If the operation is a match against one or more chars,
4776 return a pointer to the next operation, else return NULL. */ 4726 return a pointer to the next operation, else return NULL. */
4777static re_char * 4727static re_char *
4778skip_one_char (p) 4728skip_one_char (const re_char *p)
4779 re_char *p;
4780{ 4729{
4781 switch (SWITCH_ENUM_CAST (*p++)) 4730 switch (SWITCH_ENUM_CAST (*p++))
4782 { 4731 {
@@ -4818,8 +4767,7 @@ skip_one_char (p)
4818 4767
4819/* Jump over non-matching operations. */ 4768/* Jump over non-matching operations. */
4820static re_char * 4769static re_char *
4821skip_noops (p, pend) 4770skip_noops (const re_char *p, const re_char *pend)
4822 re_char *p, *pend;
4823{ 4771{
4824 int mcnt; 4772 int mcnt;
4825 while (p < pend) 4773 while (p < pend)
@@ -4846,9 +4794,7 @@ skip_noops (p, pend)
4846 4794
4847/* Non-zero if "p1 matches something" implies "p2 fails". */ 4795/* Non-zero if "p1 matches something" implies "p2 fails". */
4848static int 4796static int
4849mutually_exclusive_p (bufp, p1, p2) 4797mutually_exclusive_p (struct re_pattern_buffer *bufp, const re_char *p1, const re_char *p2)
4850 struct re_pattern_buffer *bufp;
4851 re_char *p1, *p2;
4852{ 4798{
4853 re_opcode_t op2; 4799 re_opcode_t op2;
4854 const boolean multibyte = RE_MULTIBYTE_P (bufp); 4800 const boolean multibyte = RE_MULTIBYTE_P (bufp);
@@ -5086,13 +5032,7 @@ Lisp_Object re_match_object;
5086 matched substring. */ 5032 matched substring. */
5087 5033
5088int 5034int
5089re_match_2 (bufp, string1, size1, string2, size2, pos, regs, stop) 5035re_match_2 (struct re_pattern_buffer *bufp, const char *string1, int size1, const char *string2, int size2, int pos, struct re_registers *regs, int stop)
5090 struct re_pattern_buffer *bufp;
5091 const char *string1, *string2;
5092 int size1, size2;
5093 int pos;
5094 struct re_registers *regs;
5095 int stop;
5096{ 5036{
5097 int result; 5037 int result;
5098 5038
@@ -5114,13 +5054,7 @@ WEAK_ALIAS (__re_match_2, re_match_2)
5114/* This is a separate function so that we can force an alloca cleanup 5054/* This is a separate function so that we can force an alloca cleanup
5115 afterwards. */ 5055 afterwards. */
5116static int 5056static int
5117re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop) 5057re_match_2_internal (struct re_pattern_buffer *bufp, const re_char *string1, int size1, const re_char *string2, int size2, int pos, struct re_registers *regs, int stop)
5118 struct re_pattern_buffer *bufp;
5119 re_char *string1, *string2;
5120 int size1, size2;
5121 int pos;
5122 struct re_registers *regs;
5123 int stop;
5124{ 5058{
5125 /* General temporaries. */ 5059 /* General temporaries. */
5126 int mcnt; 5060 int mcnt;
@@ -6451,11 +6385,7 @@ re_match_2_internal (bufp, string1, size1, string2, size2, pos, regs, stop)
6451 bytes; nonzero otherwise. */ 6385 bytes; nonzero otherwise. */
6452 6386
6453static int 6387static int
6454bcmp_translate (s1, s2, len, translate, target_multibyte) 6388bcmp_translate (const re_char *s1, const re_char *s2, register int len, Lisp_Object translate, const const int target_multibyte)
6455 re_char *s1, *s2;
6456 register int len;
6457 RE_TRANSLATE_TYPE translate;
6458 const int target_multibyte;
6459{ 6389{
6460 register re_char *p1 = s1, *p2 = s2; 6390 register re_char *p1 = s1, *p2 = s2;
6461 re_char *p1_end = s1 + len; 6391 re_char *p1_end = s1 + len;
@@ -6496,10 +6426,7 @@ bcmp_translate (s1, s2, len, translate, target_multibyte)
6496 We call regex_compile to do the actual compilation. */ 6426 We call regex_compile to do the actual compilation. */
6497 6427
6498const char * 6428const char *
6499re_compile_pattern (pattern, length, bufp) 6429re_compile_pattern (const char *pattern, size_t length, struct re_pattern_buffer *bufp)
6500 const char *pattern;
6501 size_t length;
6502 struct re_pattern_buffer *bufp;
6503{ 6430{
6504 reg_errcode_t ret; 6431 reg_errcode_t ret;
6505 6432