This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Remove the C89 checking with gcc
[perl5.git] / regcomp.pl
CommitLineData
36bb303b
NC
1BEGIN {
2 # Get function prototypes
9ad884cb 3 require 'regen_lib.pl';
36bb303b 4}
d09b2d29
IZ
5#use Fatal qw(open close rename chmod unlink);
6open DESC, 'regcomp.sym';
7$ind = 0;
8
9while (<DESC>) {
10 next if /^\s*($|\#)/;
11 $ind++;
12 chomp;
13 ($name[$ind], $desc, $rest[$ind]) = split /\t+/, $_, 3;
14 ($type[$ind], $code[$ind], $args[$ind], $longj[$ind])
15 = split /[,\s]\s*/, $desc, 4;
16}
17close DESC;
18$tot = $ind;
3dab1dad
YO
19die "Too many regexp opcodes! Maximum is 256, but there are $tot in file!"
20 if $tot>256;
d09b2d29
IZ
21
22$tmp_h = 'tmp_reg.h';
23
24unlink $tmp_h if -f $tmp_h;
25
26open OUT, ">$tmp_h";
dfb1454f 27binmode OUT;
d09b2d29
IZ
28
29print OUT <<EOP;
37442d52
RGS
30/* -*- buffer-read-only: t -*-
31 !!!!!!! DO NOT EDIT THIS FILE !!!!!!!
9b155405 32 This file is built by regcomp.pl from regcomp.sym.
d09b2d29
IZ
33 Any changes made here will be lost!
34*/
35
36EOP
37
38$ind = 0;
39while (++$ind <= $tot) {
40 $oind = $ind - 1;
41 $hind = sprintf "%#4x", $oind;
42 print OUT <<EOP;
43#define $name[$ind] $oind /* $hind $rest[$ind] */
44EOP
45}
46
47print OUT <<EOP;
40a82448 48#define REGNODE_MAX $oind
d09b2d29
IZ
49
50#ifndef DOINIT
22c35a8c 51EXTCONST U8 PL_regkind[];
d09b2d29 52#else
22c35a8c 53EXTCONST U8 PL_regkind[] = {
d09b2d29
IZ
54EOP
55
56$ind = 0;
57while (++$ind <= $tot) {
58 print OUT <<EOP;
59 $type[$ind], /* $name[$ind] */
60EOP
61}
62
63print OUT <<EOP;
64};
65#endif
66
67
68#ifdef REG_COMP_C
29de9391 69static const U8 regarglen[] = {
d09b2d29
IZ
70EOP
71
72$ind = 0;
73while (++$ind <= $tot) {
74 $size = 0;
75 $size = "EXTRA_SIZE(struct regnode_$args[$ind])" if $args[$ind];
76
77 print OUT <<EOP;
78 $size, /* $name[$ind] */
79EOP
80}
81
82print OUT <<EOP;
83};
84
29de9391 85static const char reg_off_by_arg[] = {
d09b2d29
IZ
86EOP
87
88$ind = 0;
89while (++$ind <= $tot) {
90 $size = $longj[$ind] || 0;
9b155405 91
d09b2d29
IZ
92 print OUT <<EOP;
93 $size, /* $name[$ind] */
94EOP
95}
96
97print OUT <<EOP;
98};
9b155405
IZ
99
100#ifdef DEBUGGING
29de9391 101static const char * const reg_name[] = {
9b155405
IZ
102EOP
103
104$ind = 0;
105while (++$ind <= $tot) {
106 $hind = sprintf "%#4x", $ind-1;
107 $size = $longj[$ind] || 0;
108
109 print OUT <<EOP;
110 "$name[$ind]", /* $hind */
111EOP
112}
113
114print OUT <<EOP;
115};
116
29de9391 117static const int reg_num = $tot;
9b155405
IZ
118
119#endif /* DEBUGGING */
d09b2d29
IZ
120#endif /* REG_COMP_C */
121
37442d52 122/* ex: set ro: */
d09b2d29
IZ
123EOP
124
36bb303b 125close OUT or die "close $tmp_h: $!";
d09b2d29 126
36bb303b 127safer_rename $tmp_h, 'regnodes.h';