blob: 7bba2b19a491d1e8369d6e811273b19699dc951e (
plain)
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
|
#!/usr/bin/perl -w
#
# macros.pl produce macros.c from standard.mac
#
# The Netwide Assembler is copyright (C) 1996 Simon Tatham and
# Julian Hall. All rights reserved. The software is
# redistributable under the license given in the file "LICENSE"
# distributed in the NASM archive.
use strict;
my $fname;
my $line = 0;
my $index = 0;
my $tasm_count;
undef $tasm_count;
open(OUTPUT,">macros.c") or die "unable to open macros.c\n";
print OUTPUT "/*\n";
print OUTPUT " * Do not edit - this file auto-generated by macros.pl from:\n";
print OUTPUT " * ", join(' ', @ARGV), "\n";
print OUTPUT " */\n";
print OUTPUT "\n";
print OUTPUT "#include \"tables.h\"\n";
print OUTPUT "\n";
print OUTPUT "const char * const nasm_stdmac[] = {";
foreach $fname ( @ARGV ) {
open(INPUT,$fname) or die "unable to open $fname\n";
print OUTPUT "\n /* From $fname */\n";
while (<INPUT>) {
$line++;
chomp;
if (m/^\s*\*END\*TASM\*MACROS\*\s*$/) {
$tasm_count = $index;
print OUTPUT " /* End of TASM macros */\n";
} elsif (m/^\s*((\s*([^\"\';\s]+|\"[^\"]*\"|\'[^\']*\'))*)\s*(;.*)?$/) {
$_ = $1;
s/\\/\\\\/g;
s/"/\\"/g;
if (length > 0) {
print OUTPUT " \"$_\",\n";
$index++;
}
} else {
die "$fname:$line: error unterminated quote";
}
}
close(INPUT);
}
print OUTPUT "\n NULL\n};\n\n";
$tasm_count = $index unless ( defined($tasm_count) );
print OUTPUT "const char * const * nasm_stdmac_after_tasm = ",
"&nasm_stdmac[$tasm_count];\n";
close(OUTPUT);
|