~ubuntu-branches/debian/squeeze/erlang/squeeze

« back to all changes in this revision

Viewing changes to lib/common_test/priv/rx-1.5/rgx-perf/regexec012/runtests.c

  • Committer: Bazaar Package Importer
  • Author(s): Sergei Golovan
  • Date: 2009-05-07 15:07:37 UTC
  • mfrom: (1.2.1 upstream) (5.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20090507150737-i4yb5elwinm7r0hc
Tags: 1:13.b-dfsg1-1
* Removed another bunch of non-free RFCs from original tarball
  (closes: #527053).
* Fixed build-dependencies list by adding missing comma. This requires
  libsctp-dev again. Also, added libsctp1 dependency to erlang-base and
  erlang-base-hipe packages because the shared library is loaded via
  dlopen now and cannot be added using dh_slibdeps (closes: #526682).
* Weakened dependency of erlang-webtool on erlang-observer to recommends
  to avoid circular dependencies (closes: #526627).
* Added solaris-i386 to HiPE enabled architectures.
* Made script sources in /usr/lib/erlang/erts-*/bin directory executable,
  which is more convenient if a user wants to create a target Erlang system.
* Shortened extended description line for erlang-dev package to make it
  fit 80x25 terminals.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*      Copyright (C) 1995, 1996 Tom Lord
2
 
 * 
3
 
 * This program is free software; you can redistribute it and/or modify
4
 
 * it under the terms of the GNU Library General Public License as published by
5
 
 * the Free Software Foundation; either version 2, or (at your option)
6
 
 * any later version.
7
 
 * 
8
 
 * This program is distributed in the hope that it will be useful,
9
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
 * GNU Library General Public License for more details.
12
 
 * 
13
 
 * You should have received a copy of the GNU Library General Public License
14
 
 * along with this software; see the file COPYING.  If not, write to
15
 
 * the Free Software Foundation, 59 Temple Place - Suite 330, 
16
 
 * Boston, MA 02111-1307, USA. 
17
 
 */
18
 
 
19
 
 
20
 
 
21
 
#include <stdio.h>
22
 
#include "regex.h"
23
 
 
24
 
 
25
 
 
26
 
struct a_test
27
 
{
28
 
  int expected;
29
 
  char * pattern;
30
 
  unsigned char * data;
31
 
};
32
 
 
33
 
struct a_test the_tests[] = 
34
 
{
35
 
#include "testcases.h"
36
 
  {-1, 0, 0}
37
 
};
38
 
 
39
 
 
40
 
 
41
 
 
42
 
void
43
 
run_a_test (id, t)
44
 
     int id;
45
 
     struct a_test * t;
46
 
{
47
 
  static char * last_pattern = 0;
48
 
  static regex_t r;
49
 
  int err;
50
 
  char errmsg[100];
51
 
  int x;
52
 
  regmatch_t regs[10];
53
 
 
54
 
  if (!last_pattern || strcmp (last_pattern, t->pattern))
55
 
    {
56
 
      if (last_pattern)
57
 
        {
58
 
          regfree (&r);
59
 
          last_pattern = 0;
60
 
        }
61
 
      err = regcomp (&r, t->pattern, REG_EXTENDED);
62
 
      if (err)
63
 
        {
64
 
          if (t->expected)
65
 
            return;
66
 
          regerror (err, &r, errmsg, 100);
67
 
          printf ("test %d\n", id);
68
 
          puts (errmsg);
69
 
          return;
70
 
        }
71
 
      last_pattern = t->pattern;
72
 
    }
73
 
      
74
 
  err = regexec (&r, t->data, 10, regs, 0);
75
 
 
76
 
  if (err != t->expected)
77
 
    {
78
 
      printf ("### test %d\n", id);
79
 
      printf ("### pattern \"%s\" data \"%s\" wanted %d got %d\n",
80
 
              t->pattern, t->data, t->expected, err);
81
 
      for (x = 0; x < 10; ++x)
82
 
        printf ("### reg %d == (%d, %d) %.*s\n",
83
 
                x,
84
 
                regs[x].rm_so,
85
 
                regs[x].rm_eo,
86
 
                regs[x].rm_eo - regs[x].rm_so,
87
 
                t->data + regs[x].rm_so);
88
 
    }
89
 
 
90
 
}
91
 
 
92
 
 
93
 
 
94
 
main(argc, argv)
95
 
     int argc;
96
 
     char * argv[];
97
 
{
98
 
  int x;
99
 
  int lo;
100
 
  int hi;
101
 
  int reps;
102
 
 
103
 
  reps = (getenv ("RXREPS")
104
 
          ? atoi (getenv ("RXREPS"))
105
 
          : 1);
106
 
 
107
 
#if 0
108
 
  {
109
 
    union dbmalloptarg val;
110
 
    val.i = 1; dbmallopt (MALLOC_CKCHAIN, &val);
111
 
  }
112
 
#endif
113
 
 
114
 
  lo = 0;
115
 
  hi = (sizeof (the_tests) / sizeof (the_tests[0])) - 1;
116
 
 
117
 
  if (argc > 1)
118
 
    {
119
 
      lo = atoi (argv[1]);
120
 
      hi = lo + 1;
121
 
 
122
 
      if (argc > 2)
123
 
        hi = atoi (argv[2]);
124
 
    }
125
 
 
126
 
  for (x = lo; x < hi; ++x)
127
 
    {
128
 
      {
129
 
        int q;
130
 
        printf ("#%d\n", x);
131
 
        for (q = 0; q < reps; ++q)
132
 
          run_a_test (x, &the_tests[x]);
133
 
      }
134
 
    }
135
 
  {
136
 
    if (exit (0))
137
 
      print_rexp ();
138
 
  }
139
 
}
140
 
 
141