Merge branch 'vendor/OPENSSH' (early part)
[dragonfly.git] / gnu / lib / libregex / test / tregress.c
1 /* tregress.c: reported bugs.  The `t' just makes the filename not have
2    a common prefix with `regex.c', so completion works better.  */
3
4 #include "test.h"
5
6
7 boolean pause_at_error = true;
8
9 char *
10 itoa (i)
11     int i;
12 {
13   char *a = xmalloc (21); /* sign + 19 digits (enough for 64 bits) + null */
14
15   sprintf (a, "%d", i);
16   return a;
17 }
18
19
20 static void
21 simple_fail (routine, pat, buf, str, ret)
22     const char *routine;
23     const char *pat;
24     struct re_pattern_buffer *buf;
25     const char *str;
26     char *ret;
27 {
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);
32
33   if (pause_at_error)
34     {
35       fprintf (stderr, "RET to continue: ");
36       (void) getchar ();
37     }
38 }
39
40
41 /* Abbreviate the most common calls.  */
42
43 static void
44 simple_compile (pat, buf)
45     const char *pat;
46     struct re_pattern_buffer *buf;
47 {
48   const char *ret = re_compile_pattern (pat, strlen (pat), buf);
49
50   if (ret != NULL) simple_fail ("compile", pat, buf, NULL, ret);
51 }
52
53
54 static void
55 simple_fastmap (pat)
56     const char *pat;
57 {
58   struct re_pattern_buffer buf;
59   char fastmap[256];
60   int ret;
61
62   buf.allocated = 0;
63   buf.buffer = buf.translate = NULL;
64   buf.fastmap = fastmap;
65
66   simple_compile (pat, &buf);
67
68   ret = re_compile_fastmap (&buf);
69
70   if (ret != 0) simple_fail ("fastmap compile", pat, &buf, NULL, itoa (ret));
71 }
72
73
74 #define SIMPLE_MATCH(pat, str) do_match (pat, str, strlen (str))
75 #define SIMPLE_NONMATCH(pat, str) do_match (pat, str, -1)
76
77 static void
78 do_match (pat, str, expected)
79     const char *pat, *str;
80     int expected;
81 {
82   int ret;
83   unsigned len;
84   struct re_pattern_buffer buf;
85
86   buf.allocated = 0;
87   buf.buffer = buf.translate = buf.fastmap = NULL;
88
89   simple_compile (pat, &buf);
90
91   len = strlen (str);
92
93   ret = re_match_2 (&buf, NULL, 0, str, len, 0, NULL, len);
94
95   if (ret != expected) simple_fail ("match", pat, &buf, str, itoa (ret));
96 }
97
98
99 static void
100 simple_search (pat, str, correct_startpos)
101     const char *pat, *str;
102     int correct_startpos;
103 {
104   int ret;
105   unsigned len;
106   struct re_pattern_buffer buf;
107
108   buf.allocated = 0;
109   buf.buffer = buf.translate = buf.fastmap = NULL;
110
111   simple_compile (pat, &buf);
112
113   len = strlen (str);
114
115   ret = re_search_2 (&buf, NULL, 0, str, len, 0, len, NULL, len);
116
117   if (ret != correct_startpos)
118     simple_fail ("match", pat, &buf, str, itoa (ret));
119 }
120 \f
121 /* Past bugs people have reported.  */
122
123 void
124 test_regress ()
125 {
126   extern char upcase[];
127   struct re_pattern_buffer buf;
128   unsigned len;
129   struct re_registers regs;
130   int ret;
131   char *fastmap = xmalloc (256);
132
133   buf.translate = NULL;
134   buf.fastmap = NULL;
135   buf.allocated = 0;
136   buf.buffer = NULL;
137
138   printf ("\nStarting regression tests.\n");
139   t = regress_test;
140
141   test_should_match = true;
142   re_set_syntax (RE_SYNTAX_EMACS);
143
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;
148
149   /* meyering@cs.utexas.edu  Nov  6 22:34:41 1992  */
150   simple_search ("\\w+", "a", 0);
151
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;
158
159   /* mike@skinner.cs.uoregon.edu  1 Sep 92 01:45:22  */
160   SIMPLE_MATCH ("^^$", "^");
161
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);
167
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);
173
174   /* trq@dionysos.thphys.ox.ac.uk, 31 Aug 92.  (simplified) */
175   simple_fastmap ("^.*\n[  ]*");
176
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);
183
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");
189
190   /* jimb, 13 Aug 92.  */
191   SIMPLE_MATCH ("[\001-\177]", "\177");
192
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");
199
200   /* bwoelfel@widget.seas.upenn.edu, 25 Jul 92.  */
201   SIMPLE_MATCH ("^\\([ab]+\\|bc\\)+", "abc");
202
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)
208       != NULL)
209     printf ("date dump compile failed.\n");
210   regs.num_regs = 0;
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, &regs, 24) != 10)
214     printf ("date dump search failed.\n");
215   buf.fastmap = 0;
216   buf.translate = 0;
217
218
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);
223
224
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)
230       != NULL)
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");
234
235 #define CASE_SET_PATTERN2 "[`-|]"
236   if (re_compile_pattern (CASE_SET_PATTERN2, strlen (CASE_SET_PATTERN2), &buf)
237       != NULL)
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");
241
242   buf.translate = NULL;
243
244
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");
251
252
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)
259       != NULL)
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");
263
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),
267       &buf) != NULL)
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");
271
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\\)"
277   free (buf.fastmap);
278   buf.fastmap = 0;
279   if (re_compile_pattern (ALLOC_REG_PATTERN, strlen (ALLOC_REG_PATTERN), &buf)
280       != NULL)
281     printf ("register allocation didn't compile.\n");
282   if (re_match (&buf, "abc", 3, 0, &regs) != 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");
286
287   {
288     int *old_regstart = regs.start;
289     int *old_regend = regs.end;
290
291     if (re_match (&buf, "abc", 3, 0, &regs) != 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");
297   }
298
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, &regs) != 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");
307
308   /* jla's bug (with string-match), 5 Feb 92.  */
309   TEST_SEARCH ("\\`[ \t\n]*", "jla@challenger (Joseph Arceneaux)", 0, 100);
310
311   /* jwz@lucid.com, 8 March 1992 (re-search-forward).  (His is the
312      second.)  These are not supposed to match.  */
313 #if 0
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);
323
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] */
337
338
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");
347
348   buf.translate = 0;
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, &regs) != 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");
358
359   TEST_REGISTERS ("\\(a\\)*a", "aaa", 0, 3, 1, 2, -1, -1);
360   test_fastmap ("^\\([^ \n]+:\n\\)+\\([^ \n]+:\\)", " \n", 1, 0);
361
362   /* 40 lines, 48 a's in each line.  */
363   test_match ("^\\([^ \n]+:\n\\)+\\([^ \n]+:\\)",
364               "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
365 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
366 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
367 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
368 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
369 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabb");
410
411
412   /* Dave G. bug: Reference to a subexpression which didn't match.
413      Should fail. */
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");
426
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");
431
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\\)",
435               "one-and-four");
436   test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)",
437               "two-and-three");
438
439   test_should_match = 1;
440   re_set_syntax (RE_SYNTAX_EMACS);
441   test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)",
442               "one-and-three");
443   test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)",
444               "two-and-four");
445
446   TEST_REGISTERS (":\\(.*\\)", ":/", 0, 2, 1, 2, -1, -1);
447
448   /* Bug with `upcase' translation table, from Nico Josuttis
449      <nico@bredex.de> */
450   test_should_match = 1;
451   test_case_fold ("[a-a]", "a");
452
453   printf ("\nFinished regression tests.\n");
454 }
455
456
457 \f
458 /*
459 Local variables:
460 make-backup-files: t
461 version-control: t
462 trim-versions-without-asking: nil
463 End:
464 */