1 /* tregress.c: reported bugs. The `t' just makes the filename not have
2 a common prefix with `regex.c', so completion works better. */
7 boolean pause_at_error = true;
13 char *a = xmalloc (21); /* sign + 19 digits (enough for 64 bits) + null */
21 simple_fail (routine, pat, buf, str, ret)
24 struct re_pattern_buffer *buf;
28 fprintf (stderr, "Failed %s (return = %s).\n", routine, ret);
29 if (str && *str) fprintf (stderr, " String = %s\n", str);
30 fprintf (stderr, " Pattern = %s\n", pat);
31 print_compiled_pattern (buf);
35 fprintf (stderr, "RET to continue: ");
41 /* Abbreviate the most common calls. */
44 simple_compile (pat, buf)
46 struct re_pattern_buffer *buf;
48 const char *ret = re_compile_pattern (pat, strlen (pat), buf);
50 if (ret != NULL) simple_fail ("compile", pat, buf, NULL, ret);
58 struct re_pattern_buffer buf;
63 buf.buffer = buf.translate = NULL;
64 buf.fastmap = fastmap;
66 simple_compile (pat, &buf);
68 ret = re_compile_fastmap (&buf);
70 if (ret != 0) simple_fail ("fastmap compile", pat, &buf, NULL, itoa (ret));
74 #define SIMPLE_MATCH(pat, str) do_match (pat, str, strlen (str))
75 #define SIMPLE_NONMATCH(pat, str) do_match (pat, str, -1)
78 do_match (pat, str, expected)
79 const char *pat, *str;
84 struct re_pattern_buffer buf;
87 buf.buffer = buf.translate = buf.fastmap = NULL;
89 simple_compile (pat, &buf);
93 ret = re_match_2 (&buf, NULL, 0, str, len, 0, NULL, len);
95 if (ret != expected) simple_fail ("match", pat, &buf, str, itoa (ret));
100 simple_search (pat, str, correct_startpos)
101 const char *pat, *str;
102 int correct_startpos;
106 struct re_pattern_buffer buf;
109 buf.buffer = buf.translate = buf.fastmap = NULL;
111 simple_compile (pat, &buf);
115 ret = re_search_2 (&buf, NULL, 0, str, len, 0, len, NULL, len);
117 if (ret != correct_startpos)
118 simple_fail ("match", pat, &buf, str, itoa (ret));
121 /* Past bugs people have reported. */
126 extern char upcase[];
127 struct re_pattern_buffer buf;
129 struct re_registers regs;
131 char *fastmap = xmalloc (256);
133 buf.translate = NULL;
138 printf ("\nStarting regression tests.\n");
141 test_should_match = true;
142 re_set_syntax (RE_SYNTAX_EMACS);
144 /* enami@sys.ptg.sony.co.jp 10 Nov 92 15:19:02 JST */
145 buf.translate = upcase;
146 SIMPLE_MATCH ("[A-[]", "A");
147 buf.translate = NULL;
149 /* meyering@cs.utexas.edu Nov 6 22:34:41 1992 */
150 simple_search ("\\w+", "a", 0);
152 /* jimb@occs.cs.oberlin.edu 10 Sep 92 00:42:33 */
153 buf.translate = upcase;
154 SIMPLE_MATCH ("[\001-\377]", "\001");
155 SIMPLE_MATCH ("[\001-\377]", "a");
156 SIMPLE_MATCH ("[\001-\377]", "\377");
157 buf.translate = NULL;
159 /* mike@skinner.cs.uoregon.edu 1 Sep 92 01:45:22 */
160 SIMPLE_MATCH ("^^$", "^");
162 /* pclink@qld.tne.oz.au Sep 7 22:42:36 1992 */
163 re_set_syntax (RE_INTERVALS);
164 SIMPLE_MATCH ("^a\\{3\\}$", "aaa");
165 SIMPLE_NONMATCH ("^a\\{3\\}$", "aa");
166 re_set_syntax (RE_SYNTAX_EMACS);
168 /* pclink@qld.tne.oz.au, 31 Aug 92. (conjecture) */
169 re_set_syntax (RE_INTERVALS);
170 simple_search ("a\\{1,3\\}b", "aaab", 0);
171 simple_search ("a\\{1,3\\}b", "aaaab", 1);
172 re_set_syntax (RE_SYNTAX_EMACS);
174 /* trq@dionysos.thphys.ox.ac.uk, 31 Aug 92. (simplified) */
175 simple_fastmap ("^.*\n[ ]*");
177 /* wind!greg@plains.NoDak.edu, 25 Aug 92. (simplified) */
178 re_set_syntax (RE_INTERVALS);
179 SIMPLE_MATCH ("[a-zA-Z]*.\\{5\\}", "xN0000");
180 SIMPLE_MATCH ("[a-zA-Z]*.\\{5\\}$", "systemxN0000");
181 SIMPLE_MATCH ("\\([a-zA-Z]*\\).\\{5\\}$", "systemxN0000");
182 re_set_syntax (RE_SYNTAX_EMACS);
184 /* jimb, 18 Aug 92. Don't use \000, so `strlen' (in our testing
185 routines) will work. (This still tickles the bug jimb reported.) */
186 SIMPLE_MATCH ("[\001-\377]", "\001");
187 SIMPLE_MATCH ("[\001-\377]", "a");
188 SIMPLE_MATCH ("[\001-\377]", "\377");
190 /* jimb, 13 Aug 92. */
191 SIMPLE_MATCH ("[\001-\177]", "\177");
193 /* Tests based on bwoelfel's below. */
194 SIMPLE_MATCH ("\\(a\\|ab\\)*", "aab");
195 SIMPLE_MATCH ("\\(a\\|ab\\)+", "aab");
196 SIMPLE_MATCH ("\\(a*\\|ab\\)+", "aab");
197 SIMPLE_MATCH ("\\(a+\\|ab\\)+", "aab");
198 SIMPLE_MATCH ("\\(a?\\|ab\\)+", "aab");
200 /* bwoelfel@widget.seas.upenn.edu, 25 Jul 92. */
201 SIMPLE_MATCH ("^\\([ab]+\\|bc\\)+", "abc");
203 /* jla, 3 Jul 92. Core dump in re_search_2. */
204 buf.fastmap = fastmap;
205 buf.translate = upcase;
206 #define DATEDUMP_PATTERN " *[0-9]*:"
207 if (re_compile_pattern (DATEDUMP_PATTERN, strlen (DATEDUMP_PATTERN), &buf)
209 printf ("date dump compile failed.\n");
211 regs.start = regs.end = NULL;
212 if (re_search_2 (&buf, NULL, 0, "Thu Jul 2 18:34:18 1992",
213 24, 3, 21, ®s, 24) != 10)
214 printf ("date dump search failed.\n");
219 /* rms, 4 Jul 1992. Pattern is much slower in Emacs 19. Fastmap
220 should be only a backslash. */
221 #define BEGINEND_PATTERN "\\(\\\\begin\\s *{\\)\\|\\(\\\\end\\s *{\\)"
222 test_fastmap (BEGINEND_PATTERN, "\\", false, 0);
225 /* kaoru@is.s.u-tokyo.ac.jp, 27 Jun 1992. Code for [a-z] (in regex.c)
226 should translate the whole set. */
227 buf.translate = upcase;
228 #define CASE_SET_PATTERN "[ -`]"
229 if (re_compile_pattern (CASE_SET_PATTERN, strlen (CASE_SET_PATTERN), &buf)
231 printf ("case set compile failed.\n");
232 if (re_match_2 (&buf, "K", 1, "", 0, 0, NULL, 1) != 1)
233 printf ("case set match failed.\n");
235 #define CASE_SET_PATTERN2 "[`-|]"
236 if (re_compile_pattern (CASE_SET_PATTERN2, strlen (CASE_SET_PATTERN2), &buf)
238 printf ("case set2 compile failed.\n");
239 if (re_match_2 (&buf, "K", 1, "", 0, 0, NULL, 1) != 1)
240 printf ("case set2 match failed.\n");
242 buf.translate = NULL;
245 /* jimb, 27 Jun 92. Problems with gaps in the string. */
246 #define GAP_PATTERN "x.*y.*z"
247 if (re_compile_pattern (GAP_PATTERN, strlen (GAP_PATTERN), &buf) != NULL)
248 printf ("gap didn't compile.\n");
249 if (re_match_2 (&buf, "x-", 2, "y-z-", 4, 0, NULL, 6) != 5)
250 printf ("gap match failed.\n");
253 /* jimb, 19 Jun 92. Since `beginning of word' matches at the
254 beginning of the string, then searching ought to find it there.
255 If `re_compile_fastmap' is not called, then it works ok. */
256 buf.fastmap = fastmap;
257 #define BOW_BEG_PATTERN "\\<"
258 if (re_compile_pattern (BOW_BEG_PATTERN, strlen (BOW_BEG_PATTERN), &buf)
260 printf ("begword-begstring didn't compile.\n");
261 if (re_search (&buf, "foo", 3, 0, 3, NULL) != 0)
262 printf ("begword-begstring search failed.\n");
264 /* Same bug report, different null-matching pattern. */
265 #define EMPTY_ANCHOR_PATTERN "^$"
266 if (re_compile_pattern (EMPTY_ANCHOR_PATTERN, strlen (EMPTY_ANCHOR_PATTERN),
268 printf ("empty anchor didn't compile.\n");
269 if (re_search (&buf, "foo\n\nbar", 8, 0, 8, NULL) != 4)
270 printf ("empty anchor search failed.\n");
272 /* jimb@occs.cs.oberlin.edu, 21 Apr 92. After we first allocate
273 registers for a particular re_pattern_buffer, we might have to
274 reallocate more registers on subsequent calls -- and we should be
275 reusing the same memory. */
276 #define ALLOC_REG_PATTERN "\\(abc\\)"
279 if (re_compile_pattern (ALLOC_REG_PATTERN, strlen (ALLOC_REG_PATTERN), &buf)
281 printf ("register allocation didn't compile.\n");
282 if (re_match (&buf, "abc", 3, 0, ®s) != 3)
283 printf ("register allocation didn't match.\n");
284 if (regs.start[1] != 0 || regs.end[1] != 3)
285 printf ("register allocation reg #1 wrong.\n");
288 int *old_regstart = regs.start;
289 int *old_regend = regs.end;
291 if (re_match (&buf, "abc", 3, 0, ®s) != 3)
292 printf ("register reallocation didn't match.\n");
293 if (regs.start[1] != 0 || regs.end[1] != 3
294 || old_regstart[1] != 0 || old_regend[1] != 3
295 || regs.start != old_regstart || regs.end != old_regend)
296 printf ("register reallocation registers wrong.\n");
299 /* jskudlarek@std.MENTORG.COM, 21 Apr 92 (string-match). */
300 #define JSKUD_PATTERN "[^/]+\\(/[^/.]+\\)?/[0-9]+$"
301 if (re_compile_pattern (JSKUD_PATTERN, strlen (JSKUD_PATTERN), &buf) != NULL)
302 printf ("jskud test didn't compile.\n");
303 if (re_search (&buf, "a/1", 3, 0, 3, ®s) != 0)
304 printf ("jskud test didn't match.\n");
305 if (regs.start[1] != -1 || regs.end[1] != -1)
306 printf ("jskud test, reg #1 wrong.\n");
308 /* jla's bug (with string-match), 5 Feb 92. */
309 TEST_SEARCH ("\\`[ \t\n]*", "jla@challenger (Joseph Arceneaux)", 0, 100);
311 /* jwz@lucid.com, 8 March 1992 (re-search-forward). (His is the
312 second.) These are not supposed to match. */
314 /* This one fails quickly, because we can change the maybe_pop_jump
315 from the + to a pop_failure_pop, because of the c's. */
316 TEST_SEARCH ("^\\(To\\|CC\\):\\([^c]*\\)+co",
317 "To: hbs%titanic@lucid.com (Harlan Sexton)\n\
318 Cc: eb@thalidomide, jlm@thalidomide\n\
319 Subject: Re: so is this really as horrible an idea as it seems to me?\n\
320 In-Reply-To: Harlan Sexton's message of Sun 8-Mar-92 11:00:06 PST <9203081900.AA24794@titanic.lucid>\n\
321 References: <9203080736.AA05869@thalidomide.lucid>\n\
322 <9203081900.AA24794@titanic.lucid>", 0, 5000);
324 /* This one takes a long, long time to complete, because we have to
325 keep the failure points around because we might backtrack. */
326 TEST_SEARCH ("^\\(To\\|CC\\):\\(.*\n.*\\)+co",
327 /* "X-Windows: The joke that kills.\n\
328 FCC: /u/jwz/VM/inbox\n\
329 From: Jamie Zawinski <jwz@lucid.com>\n\ */
330 "To: hbs%titanic@lucid.com (Harlan Sexton)\n\
331 Cc: eb@thalidomide, jlm@thalidomide\n\
332 Subject: Re: so is this really as horrible an idea as it seems to me?\n\
333 In-Reply-To: Harlan Sexton's message of Sun 8-Mar-92 11:00:06 PST <9203081900.AA24794@titanic.lucid>\n\
334 References: <9203080736.AA05869@thalidomide.lucid>\n\
335 <9203081900.AA24794@titanic.lucid>", 0, 5000);
336 #endif /* 0 [failed searches] */
339 /* macrakis' bugs. */
340 buf.translate = upcase; /* message of 24 Jan 91 */
341 if (re_compile_pattern ("[!-`]", 5, &buf) != NULL)
342 printf ("Range test didn't compile.\n");
343 if (re_match (&buf, "A", 1, 0, NULL) != 1)
344 printf ("Range test #1 didn't match.\n");
345 if (re_match (&buf, "a", 1, 0, NULL) != 1)
346 printf ("Range test #2 didn't match.\n");
349 #define FAO_PATTERN "\\(f\\(.\\)o\\)+"
350 if (re_compile_pattern (FAO_PATTERN, strlen (FAO_PATTERN), &buf) != NULL)
351 printf ("faofdx test didn't compile.\n");
352 if (re_search (&buf, "faofdx", 6, 0, 6, ®s) != 0)
353 printf ("faofdx test didn't match.\n");
354 if (regs.start[1] != 0 || regs.end[1] != 3)
355 printf ("faofdx test, reg #1 wrong.\n");
356 if (regs.start[2] != 1 || regs.end[2] != 2)
357 printf ("faofdx test, reg #2 wrong.\n");
359 TEST_REGISTERS ("\\(a\\)*a", "aaa", 0, 3, 1, 2, -1, -1);
360 test_fastmap ("^\\([^ \n]+:\n\\)+\\([^ \n]+:\\)", " \n", 1, 0);
362 /* 40 lines, 48 a's in each line. */
363 test_match ("^\\([^ \n]+:\n\\)+\\([^ \n]+:\\)",
364 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
365 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
366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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabb");
412 /* Dave G. bug: Reference to a subexpression which didn't match.
414 re_set_syntax (RE_NO_BK_PARENS | RE_NO_BK_VBAR);
415 test_match ("(ooooooooooone())-annnnnnnnnnnd-(twooooooooooo\\2)",
416 "ooooooooooone-annnnnnnnnnnd-twooooooooooo");
417 test_match ("(o|t)", "o");
418 test_match ("(o()|t)", "o");
419 test_match ("(o|t)", "o");
420 test_match ("(ooooooooooooooo|tttttttttttttttt())", "ooooooooooooooo");
421 test_match ("(o|t())", "o");
422 test_match ("(o()|t())", "o");
423 test_match ("(ooooooooooooooooooooooooone()|twooooooooooooooooooooooooo())", "ooooooooooooooooooooooooone");
424 test_match ("(o()|t())-a-(t\\2|f\\3)", "o-a-t");
425 test_match ("(o()|t())-a-(t\\2|f\\3)", "t-a-f");
427 test_should_match = 0;
428 test_match ("(foo(bar)|second)\\2", "second");
429 test_match ("(o()|t())-a-(t\\2|f\\3)", "t-a-t");
430 test_match ("(o()|t())-a-(t\\2|f\\3)", "o-a-f");
432 re_set_syntax (RE_SYNTAX_EMACS);
433 test_match ("\\(foo\\(bar\\)\\|second\\)\\2", "secondbar");
434 test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)",
436 test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)",
439 test_should_match = 1;
440 re_set_syntax (RE_SYNTAX_EMACS);
441 test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)",
443 test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)",
446 TEST_REGISTERS (":\\(.*\\)", ":/", 0, 2, 1, 2, -1, -1);
448 /* Bug with `upcase' translation table, from Nico Josuttis
450 test_should_match = 1;
451 test_case_fold ("[a-a]", "a");
453 printf ("\nFinished regression tests.\n");
462 trim-versions-without-asking: nil