File: rx.c

package info (click to toggle)
rplay 3.3.2-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,132 kB
  • sloc: ansic: 42,169; makefile: 1,282; perl: 742; tcl: 345; sh: 311; java: 220
file content (85 lines) | stat: -rw-r--r-- 1,824 bytes parent folder | download | duplicates (15)
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
/*	Copyright (C) 1995, 1996 Tom Lord
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Library General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Library General Public License for more details.
 * 
 * You should have received a copy of the GNU Library General Public License
 * along with this software; see the file COPYING.  If not, write to
 * the Free Software Foundation, 59 Temple Place - Suite 330, 
 * Boston, MA 02111-1307, USA. 
 */



#include "rx.h"
#include "rxall.h"
#include "rxhash.h"
#include "rxnfa.h"
#include "rxsuper.h"



const char rx_version_string[] = "GNU Rx version 1.5";


#ifdef __STDC__
struct rx *
rx_make_rx (int cset_size)
#else
struct rx *
rx_make_rx (cset_size)
     int cset_size;
#endif
{
  static int rx_id = 0;
  struct rx * new_rx;
  new_rx = (struct rx *)malloc (sizeof (*new_rx));
  rx_bzero ((char *)new_rx, sizeof (*new_rx));
  new_rx->rx_id = rx_id++;
  new_rx->cache = rx_default_cache;
  new_rx->local_cset_size = cset_size;
  new_rx->instruction_table = rx_id_instruction_table;
  new_rx->next_nfa_id = 0;
  return new_rx;
}

#ifdef __STDC__
void
rx_free_rx (struct rx * rx)
#else
void
rx_free_rx (rx)
     struct rx * rx;
#endif
{
  if (rx->start_set)
    rx->start_set->starts_for = 0;
  rx_free_nfa (rx);
  free (rx);
}


#ifdef __STDC__
void
rx_bzero (char * mem, int size)
#else
void
rx_bzero (mem, size)
     char * mem;
     int size;
#endif
{
  while (size)
    {
      *mem = 0;
      ++mem;
      --size;
    }
}