~clint-fewbar/ubuntu/precise/squid3/ignore-sighup-early

« back to all changes in this revision

Viewing changes to src/mk-string-arrays.pl

  • Committer: Bazaar Package Importer
  • Author(s): Luigi Gangitano
  • Date: 2006-11-11 10:32:06 UTC
  • Revision ID: james.westby@ubuntu.com-20061111103206-f3p0r9g0vq44rp3r
Tags: upstream-3.0.PRE5
ImportĀ upstreamĀ versionĀ 3.0.PRE5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#******************************************************************************
 
2
# $Id: mk-string-arrays.pl,v 1.5 2003/01/23 00:37:23 robertc Exp $
 
3
#
 
4
# File:         mk-strs.pl
 
5
#
 
6
# Author:       Max Okumoto <okumoto@ucsd.edu>
 
7
#
 
8
# Abstract:     This perl script parses enums and builds an array of
 
9
#               printable strings.
 
10
#
 
11
# Warning:      The parser is very simplistic, and will prob not work for
 
12
#               things other than squid.
 
13
#******************************************************************************
 
14
 
 
15
$pat{'err_type'} = "err_type_str";
 
16
$pat{'icp_opcode'} = "icp_opcode_str";
 
17
$pat{'swap_log_op'} = "swap_log_op_str";
 
18
$pat{'lookup_t'} = "lookup_t_str";
 
19
 
 
20
$state = 0;     # start state
 
21
while (<>) {
 
22
        if ($state == 0) {
 
23
                # Looking for start of typedef
 
24
                if (/^typedef enum /) {
 
25
                        $count = 0;     # enum index
 
26
                        $state = 1;
 
27
                }
 
28
                next;
 
29
 
 
30
        } elsif ($state == 1) {
 
31
                # Looking for end of typedef
 
32
                if (/^} /) {
 
33
                        ($b, $t) = split(/[ \t;]/, $_);
 
34
                        if (defined($pat{$t})) {
 
35
                                print "const char *$pat{$t}\[\] = \n";
 
36
                                print "{\n";
 
37
                                for ($i = 0; $i < $count; $i++) {
 
38
                                        printf "\t\"%s\"%s\n",
 
39
                                                $ea[$i],
 
40
                                                $i == $count - 1 ? '' : ',';
 
41
                                }
 
42
                                print "};\n";
 
43
                                print "\n";
 
44
                        }
 
45
                        $state = 0;
 
46
                } else {
 
47
                        ($e) = split(' ', $_);
 
48
                        $e =~ s/,//;
 
49
                        $ea[$count] = $e;
 
50
                        $count++;
 
51
                }
 
52
                next;
 
53
        }
 
54
}
 
55
 
 
56
exit 0;