File: tregress.c

package info (click to toggle)
lyskom-server 2.1.2-16
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid, trixie
  • size: 10,572 kB
  • sloc: ansic: 51,006; exp: 12,368; sh: 10,501; python: 2,927; makefile: 1,025; yacc: 466; awk: 340; lisp: 271; lex: 218; sed: 50
file content (464 lines) | stat: -rw-r--r-- 18,247 bytes parent folder | download | duplicates (21)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
/* tregress.c: reported bugs.  The `t' just makes the filename not have
   a common prefix with `regex.c', so completion works better.  */

#include "test.h"


boolean pause_at_error = true;

char *
itoa (i)
    int i;
{
  char *a = xmalloc (21); /* sign + 19 digits (enough for 64 bits) + null */
  
  sprintf (a, "%d", i);
  return a;
}


static void
simple_fail (routine, pat, buf, str, ret)
    const char *routine;
    const char *pat;
    struct re_pattern_buffer *buf;
    const char *str;
    char *ret;
{
  fprintf (stderr, "Failed %s (return = %s).\n", routine, ret);
  if (str && *str) fprintf (stderr, "   String = %s\n", str);
  fprintf (stderr, "  Pattern = %s\n", pat);
  print_compiled_pattern (buf);
  
  if (pause_at_error)
    {
      fprintf (stderr, "RET to continue: ");
      (void) getchar ();
    }
}


/* Abbreviate the most common calls.  */

static void
simple_compile (pat, buf)
    const char *pat;
    struct re_pattern_buffer *buf;
{
  const char *ret = re_compile_pattern (pat, strlen (pat), buf);
  
  if (ret != NULL) simple_fail ("compile", pat, buf, NULL, ret);
}


static void
simple_fastmap (pat)
    const char *pat;
{
  struct re_pattern_buffer buf;
  char fastmap[256];
  int ret;
  
  buf.allocated = 0;
  buf.buffer = buf.translate = NULL;
  buf.fastmap = fastmap;
  
  simple_compile (pat, &buf);
  
  ret = re_compile_fastmap (&buf);

  if (ret != 0) simple_fail ("fastmap compile", pat, &buf, NULL, itoa (ret));
}


#define SIMPLE_MATCH(pat, str) do_match (pat, str, strlen (str))
#define SIMPLE_NONMATCH(pat, str) do_match (pat, str, -1)

static void
do_match (pat, str, expected)
    const char *pat, *str;
    int expected;
{
  int ret;
  unsigned len;
  struct re_pattern_buffer buf;

  buf.allocated = 0;
  buf.buffer = buf.translate = buf.fastmap = NULL;
  
  simple_compile (pat, &buf);

  len = strlen (str);
  
  ret = re_match_2 (&buf, NULL, 0, str, len, 0, NULL, len);
  
  if (ret != expected) simple_fail ("match", pat, &buf, str, itoa (ret));
}


static void
simple_search (pat, str, correct_startpos)
    const char *pat, *str;
    int correct_startpos;
{
  int ret;
  unsigned len;
  struct re_pattern_buffer buf;

  buf.allocated = 0;
  buf.buffer = buf.translate = buf.fastmap = NULL;
  
  simple_compile (pat, &buf);

  len = strlen (str);
  
  ret = re_search_2 (&buf, NULL, 0, str, len, 0, len, NULL, len);
  
  if (ret != correct_startpos)
    simple_fail ("match", pat, &buf, str, itoa (ret));
}

/* Past bugs people have reported.  */

void
test_regress ()
{
  extern char upcase[];
  struct re_pattern_buffer buf;
  unsigned len;
  struct re_registers regs;
  int ret;
  char *fastmap = xmalloc (256);  
  
  buf.translate = NULL;
  buf.fastmap = NULL;
  buf.allocated = 0;
  buf.buffer = NULL;

  printf ("\nStarting regression tests.\n");
  t = regress_test;

  test_should_match = true;
  re_set_syntax (RE_SYNTAX_EMACS);

  /* enami@sys.ptg.sony.co.jp  10 Nov 92 15:19:02 JST  */
  buf.translate = upcase;
  SIMPLE_MATCH ("[A-[]", "A");
  buf.translate = NULL;
  
  /* meyering@cs.utexas.edu  Nov  6 22:34:41 1992  */
  simple_search ("\\w+", "a", 0);
   
  /* jimb@occs.cs.oberlin.edu  10 Sep 92 00:42:33  */
  buf.translate = upcase;
  SIMPLE_MATCH ("[\001-\377]", "\001");
  SIMPLE_MATCH ("[\001-\377]", "a");
  SIMPLE_MATCH ("[\001-\377]", "\377");
  buf.translate = NULL;

  /* mike@skinner.cs.uoregon.edu  1 Sep 92 01:45:22  */
  SIMPLE_MATCH ("^^$", "^");
  
  /* pclink@qld.tne.oz.au  Sep  7 22:42:36 1992  */
  re_set_syntax (RE_INTERVALS);
  SIMPLE_MATCH ("^a\\{3\\}$", "aaa");
  SIMPLE_NONMATCH ("^a\\{3\\}$", "aa");
  re_set_syntax (RE_SYNTAX_EMACS);
  
  /* pclink@qld.tne.oz.au, 31 Aug 92.  (conjecture) */
  re_set_syntax (RE_INTERVALS);
  simple_search ("a\\{1,3\\}b", "aaab", 0);
  simple_search ("a\\{1,3\\}b", "aaaab", 1);
  re_set_syntax (RE_SYNTAX_EMACS);

  /* trq@dionysos.thphys.ox.ac.uk, 31 Aug 92.  (simplified) */
  simple_fastmap ("^.*\n[  ]*");
  
  /* wind!greg@plains.NoDak.edu, 25 Aug 92.  (simplified) */
  re_set_syntax (RE_INTERVALS);
  SIMPLE_MATCH ("[a-zA-Z]*.\\{5\\}", "xN0000");
  SIMPLE_MATCH ("[a-zA-Z]*.\\{5\\}$", "systemxN0000");
  SIMPLE_MATCH ("\\([a-zA-Z]*\\).\\{5\\}$", "systemxN0000");
  re_set_syntax (RE_SYNTAX_EMACS);
  
  /* jimb, 18 Aug 92.  Don't use \000, so `strlen' (in our testing
     routines) will work.  (This still tickles the bug jimb reported.)  */
  SIMPLE_MATCH ("[\001-\377]", "\001");
  SIMPLE_MATCH ("[\001-\377]", "a");
  SIMPLE_MATCH ("[\001-\377]", "\377");

  /* jimb, 13 Aug 92.  */
  SIMPLE_MATCH ("[\001-\177]", "\177");

  /* Tests based on bwoelfel's below.  */
  SIMPLE_MATCH ("\\(a\\|ab\\)*", "aab");
  SIMPLE_MATCH ("\\(a\\|ab\\)+", "aab");
  SIMPLE_MATCH ("\\(a*\\|ab\\)+", "aab");
  SIMPLE_MATCH ("\\(a+\\|ab\\)+", "aab");
  SIMPLE_MATCH ("\\(a?\\|ab\\)+", "aab");

  /* bwoelfel@widget.seas.upenn.edu, 25 Jul 92.  */
  SIMPLE_MATCH ("^\\([ab]+\\|bc\\)+", "abc");

  /* jla, 3 Jul 92.  Core dump in re_search_2.  */
  buf.fastmap = fastmap;
  buf.translate = upcase;
#define DATEDUMP_PATTERN " *[0-9]*:"
  if (re_compile_pattern (DATEDUMP_PATTERN, strlen (DATEDUMP_PATTERN), &buf)
      != NULL)
    printf ("date dump compile failed.\n");
  regs.num_regs = 0;
  regs.start = regs.end = NULL;
  if (re_search_2 (&buf, NULL, 0, "Thu Jul  2 18:34:18 1992",
                   24, 3, 21, &regs, 24) != 10)
    printf ("date dump search failed.\n");
  buf.fastmap = 0;
  buf.translate = 0;


  /* rms, 4 Jul 1992.  Pattern is much slower in Emacs 19.  Fastmap
     should be only a backslash.  */
#define BEGINEND_PATTERN "\\(\\\\begin\\s *{\\)\\|\\(\\\\end\\s *{\\)"
  test_fastmap (BEGINEND_PATTERN, "\\", false, 0);


  /* kaoru@is.s.u-tokyo.ac.jp, 27 Jun 1992.  Code for [a-z] (in regex.c)
     should translate the whole set.  */
  buf.translate = upcase;
#define CASE_SET_PATTERN "[ -`]"
  if (re_compile_pattern (CASE_SET_PATTERN, strlen (CASE_SET_PATTERN), &buf)
      != NULL)
    printf ("case set compile failed.\n");
  if (re_match_2 (&buf, "K", 1, "", 0, 0, NULL, 1) != 1)
    printf ("case set match failed.\n");

#define CASE_SET_PATTERN2 "[`-|]"
  if (re_compile_pattern (CASE_SET_PATTERN2, strlen (CASE_SET_PATTERN2), &buf)
      != NULL)
    printf ("case set2 compile failed.\n");
  if (re_match_2 (&buf, "K", 1, "", 0, 0, NULL, 1) != 1)
    printf ("case set2 match failed.\n");

  buf.translate = NULL;


  /* jimb, 27 Jun 92.  Problems with gaps in the string.  */
#define GAP_PATTERN "x.*y.*z"
  if (re_compile_pattern (GAP_PATTERN, strlen (GAP_PATTERN), &buf) != NULL)
    printf ("gap didn't compile.\n");
  if (re_match_2 (&buf, "x-", 2, "y-z-", 4, 0, NULL, 6) != 5)
    printf ("gap match failed.\n");


  /* jimb, 19 Jun 92.  Since `beginning of word' matches at the
     beginning of the string, then searching ought to find it there.
     If `re_compile_fastmap' is not called, then it works ok.  */
  buf.fastmap = fastmap;
#define BOW_BEG_PATTERN "\\<"
  if (re_compile_pattern (BOW_BEG_PATTERN, strlen (BOW_BEG_PATTERN), &buf)
      != NULL)
    printf ("begword-begstring didn't compile.\n");
  if (re_search (&buf, "foo", 3, 0, 3, NULL) != 0)
    printf ("begword-begstring search failed.\n");

  /* Same bug report, different null-matching pattern.  */
#define EMPTY_ANCHOR_PATTERN "^$"
  if (re_compile_pattern (EMPTY_ANCHOR_PATTERN, strlen (EMPTY_ANCHOR_PATTERN),
      &buf) != NULL)
    printf ("empty anchor didn't compile.\n");
  if (re_search (&buf, "foo\n\nbar", 8, 0, 8, NULL) != 4)
    printf ("empty anchor search failed.\n");

  /* jimb@occs.cs.oberlin.edu, 21 Apr 92.  After we first allocate
     registers for a particular re_pattern_buffer, we might have to
     reallocate more registers on subsequent calls -- and we should be
     reusing the same memory.  */
#define ALLOC_REG_PATTERN "\\(abc\\)"
  free (buf.fastmap);
  buf.fastmap = 0;
  if (re_compile_pattern (ALLOC_REG_PATTERN, strlen (ALLOC_REG_PATTERN), &buf)
      != NULL)
    printf ("register allocation didn't compile.\n");
  if (re_match (&buf, "abc", 3, 0, &regs) != 3)
    printf ("register allocation didn't match.\n");
  if (regs.start[1] != 0 || regs.end[1] != 3)
    printf ("register allocation reg #1 wrong.\n");

  {
    int *old_regstart = regs.start;
    int *old_regend = regs.end;

    if (re_match (&buf, "abc", 3, 0, &regs) != 3)
      printf ("register reallocation didn't match.\n");
    if (regs.start[1] != 0 || regs.end[1] != 3
        || old_regstart[1] != 0 || old_regend[1] != 3
        || regs.start != old_regstart || regs.end != old_regend)
      printf ("register reallocation registers wrong.\n");
  }

  /* jskudlarek@std.MENTORG.COM, 21 Apr 92 (string-match).  */
#define JSKUD_PATTERN "[^/]+\\(/[^/.]+\\)?/[0-9]+$"
  if (re_compile_pattern (JSKUD_PATTERN, strlen (JSKUD_PATTERN), &buf) != NULL)
    printf ("jskud test didn't compile.\n");
  if (re_search (&buf, "a/1", 3, 0, 3, &regs) != 0)
    printf ("jskud test didn't match.\n");
  if (regs.start[1] != -1 || regs.end[1] != -1)
    printf ("jskud test, reg #1 wrong.\n");

  /* jla's bug (with string-match), 5 Feb 92.  */
  TEST_SEARCH ("\\`[ \t\n]*", "jla@challenger (Joseph Arceneaux)", 0, 100);
  
  /* jwz@lucid.com, 8 March 1992 (re-search-forward).  (His is the
     second.)  These are not supposed to match.  */
#if 0
  /* This one fails quickly, because we can change the maybe_pop_jump
     from the + to a pop_failure_pop, because of the c's.  */
  TEST_SEARCH ("^\\(To\\|CC\\):\\([^c]*\\)+co",
"To: hbs%titanic@lucid.com (Harlan Sexton)\n\
Cc: eb@thalidomide, jlm@thalidomide\n\
Subject: Re: so is this really as horrible an idea as it seems to me?\n\
In-Reply-To: Harlan Sexton's message of Sun 8-Mar-92 11:00:06 PST <9203081900.AA24794@titanic.lucid>\n\
References: <9203080736.AA05869@thalidomide.lucid>\n\
	<9203081900.AA24794@titanic.lucid>", 0, 5000);

  /* This one takes a long, long time to complete, because we have to
     keep the failure points around because we might backtrack.  */
  TEST_SEARCH ("^\\(To\\|CC\\):\\(.*\n.*\\)+co",
               /* "X-Windows: The joke that kills.\n\
FCC:  /u/jwz/VM/inbox\n\
From: Jamie Zawinski <jwz@lucid.com>\n\ */
"To: hbs%titanic@lucid.com (Harlan Sexton)\n\
Cc: eb@thalidomide, jlm@thalidomide\n\
Subject: Re: so is this really as horrible an idea as it seems to me?\n\
In-Reply-To: Harlan Sexton's message of Sun 8-Mar-92 11:00:06 PST <9203081900.AA24794@titanic.lucid>\n\
References: <9203080736.AA05869@thalidomide.lucid>\n\
	<9203081900.AA24794@titanic.lucid>", 0, 5000);
#endif /* 0 [failed searches] */

  
  /* macrakis' bugs.  */
  buf.translate = upcase; /* message of 24 Jan 91 */
  if (re_compile_pattern ("[!-`]", 5, &buf) != NULL)
    printf ("Range test didn't compile.\n");
  if (re_match (&buf, "A", 1, 0, NULL) != 1)
    printf ("Range test #1 didn't match.\n");
  if (re_match (&buf, "a", 1, 0, NULL) != 1)
    printf ("Range test #2 didn't match.\n");

  buf.translate = 0;
#define FAO_PATTERN "\\(f\\(.\\)o\\)+"
  if (re_compile_pattern (FAO_PATTERN, strlen (FAO_PATTERN), &buf) != NULL)
    printf ("faofdx test didn't compile.\n");
  if (re_search (&buf, "faofdx", 6, 0, 6, &regs) != 0)
    printf ("faofdx test didn't match.\n");
  if (regs.start[1] != 0 || regs.end[1] != 3)
    printf ("faofdx test, reg #1 wrong.\n");
  if (regs.start[2] != 1 || regs.end[2] != 2)
    printf ("faofdx test, reg #2 wrong.\n");
  
  TEST_REGISTERS ("\\(a\\)*a", "aaa", 0, 3, 1, 2, -1, -1);
  test_fastmap ("^\\([^ \n]+:\n\\)+\\([^ \n]+:\\)", " \n", 1, 0);

  /* 40 lines, 48 a's in each line.  */
  test_match ("^\\([^ \n]+:\n\\)+\\([^ \n]+:\\)",
	      "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa:\n\
aaaaaaaaaaaaaaaa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set_syntax (RE_NO_BK_PARENS | RE_NO_BK_VBAR);
  test_match ("(ooooooooooone())-annnnnnnnnnnd-(twooooooooooo\\2)", 
               "ooooooooooone-annnnnnnnnnnd-twooooooooooo");
  test_match ("(o|t)", "o");
  test_match ("(o()|t)", "o");
  test_match ("(o|t)", "o");
  test_match ("(ooooooooooooooo|tttttttttttttttt())", "ooooooooooooooo");
  test_match ("(o|t())", "o");
  test_match ("(o()|t())", "o");
  test_match ("(ooooooooooooooooooooooooone()|twooooooooooooooooooooooooo())", "ooooooooooooooooooooooooone");
  test_match ("(o()|t())-a-(t\\2|f\\3)", "o-a-t");
  test_match ("(o()|t())-a-(t\\2|f\\3)", "t-a-f");

  test_should_match = 0; 
  test_match ("(foo(bar)|second)\\2", "second");
  test_match ("(o()|t())-a-(t\\2|f\\3)", "t-a-t");
  test_match ("(o()|t())-a-(t\\2|f\\3)", "o-a-f");

  re_set_syntax (RE_SYNTAX_EMACS);
  test_match ("\\(foo\\(bar\\)\\|second\\)\\2", "secondbar");
  test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)", 
	      "one-and-four");
  test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)", 
	      "two-and-three");
  
  test_should_match = 1;
  re_set_syntax (RE_SYNTAX_EMACS);
  test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)", 
	      "one-and-three");
  test_match ("\\(one\\(\\)\\|two\\(\\)\\)-and-\\(three\\2\\|four\\3\\)", 
	      "two-and-four");

  TEST_REGISTERS (":\\(.*\\)", ":/", 0, 2, 1, 2, -1, -1);

  /* Bug with `upcase' translation table, from Nico Josuttis
     <nico@bredex.de> */
  test_should_match = 1;
  test_case_fold ("[a-a]", "a");

  printf ("\nFinished regression tests.\n");
}



/*
Local variables:
make-backup-files: t
version-control: t
trim-versions-without-asking: nil
End:
*/