File: biffnames

package info (click to toggle)
gnumeric 1.12.57-1.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 111,496 kB
  • sloc: ansic: 296,601; xml: 56,363; perl: 6,615; sh: 5,288; makefile: 2,981; yacc: 1,341; python: 389
file content (33 lines) | stat: -rwxr-xr-x 684 bytes parent folder | download | duplicates (7)
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
#!/usr/bin/perl -w

my %names;

while (<STDIN>) {
    chomp;
    s{/\*.*\*/}{ };
    if (/^\s*\#\s*define\s+([A-Za-z_][A-Za-z_0-9]*)\s+(.*\S)\s*/) {
	my $name = $1;
	my $opcode = $2;

	if (exists $names{$opcode}) {
	    $names{$opcode} .= "/$name";
	} else {
	    $names{$opcode} .= $name;
	}
    }
}

print "#include <stdlib.h>\n";
print "#include <biff-types.h>\n";
print "\n";
print "const char *\n";
print "biff_opcode_name (unsigned int opcode)\n";
print "{\n";
print "  switch (opcode) {\n";
foreach my $opcode (sort keys %names) {
    my $name = $names{$opcode};
    print "  case $opcode: return \"$name\";\n";
}
print "  default: return NULL;\n";
print "  }\n";
print "}\n";