0
0
mirror of https://github.com/netwide-assembler/nasm.git synced 2025-09-22 10:43:39 -04:00

Make the macros table "unsigned char"

It gets less ugly if we make the macros table "unsigned char".
This commit is contained in:
H. Peter Anvin
2008-06-25 14:54:14 -07:00
parent 7b5aad8498
commit 7e50d232ba
4 changed files with 14 additions and 14 deletions

View File

@@ -26,7 +26,7 @@ sub charcify(@) {
foreach $o (unpack("C*", join('',@_))) { foreach $o (unpack("C*", join('',@_))) {
$c = pack("C", $o); $c = pack("C", $o);
if ($o < 32 || $o > 126 || $c eq '"' || $c eq "\\") { if ($o < 32 || $o > 126 || $c eq '"' || $c eq "\\") {
$l .= sprintf("(char)%3d,", $o); $l .= sprintf("%3d,", $o);
} else { } else {
$l .= "\'".$c."\',"; $l .= "\'".$c."\',";
} }
@@ -48,7 +48,7 @@ print OUT "#include \"tables.h\"\n";
print OUT "#include \"nasmlib.h\"\n"; print OUT "#include \"nasmlib.h\"\n";
print OUT "#include \"hashtbl.h\"\n"; print OUT "#include \"hashtbl.h\"\n";
print OUT "\n"; print OUT "\n";
print OUT "const char nasm_stdmac[] = {"; print OUT "const unsigned char nasm_stdmac[] = {";
my $npkg = 0; my $npkg = 0;
my @pkg_list = (); my @pkg_list = ();
@@ -73,7 +73,7 @@ foreach $fname ( @ARGV ) {
printf OUT " /* %4d */ 0\n", $index++; printf OUT " /* %4d */ 0\n", $index++;
print OUT "};\n"; print OUT "};\n";
$index = 0; $index = 0;
printf OUT "const char %s_stdmac[] = {\n", $out_alias[0]; printf OUT "const unsigned char %s_stdmac[] = {\n", $out_alias[0];
print OUT " /* From $fname */\n"; print OUT " /* From $fname */\n";
$lastname = $fname; $lastname = $fname;
push(@out_list, $out_alias[0]); push(@out_list, $out_alias[0]);
@@ -86,7 +86,7 @@ foreach $fname ( @ARGV ) {
printf OUT " /* %4d */ 0\n", $index++; printf OUT " /* %4d */ 0\n", $index++;
print OUT "};\n"; print OUT "};\n";
$index = 0; $index = 0;
printf OUT "static const char nasm_stdmac_%s[] = {\n", $pkg; printf OUT "static const unsigned char nasm_stdmac_%s[] = {\n", $pkg;
print OUT " /* From $fname */\n"; print OUT " /* From $fname */\n";
$lastname = $fname; $lastname = $fname;
push(@pkg_list, $pkg); push(@pkg_list, $pkg);
@@ -127,7 +127,7 @@ foreach $fname ( @ARGV ) {
close(INPUT); close(INPUT);
} }
printf OUT " /* %4d */ 0\n};\n\n", $index++; printf OUT " /* %4d */ 0\n};\n\n", $index++;
print OUT "const char * const nasm_stdmac_after_tasm = ", print OUT "const unsigned char * const nasm_stdmac_after_tasm = ",
"&nasm_stdmac[$tasm_count];\n\n"; "&nasm_stdmac[$tasm_count];\n\n";
my @hashinfo = gen_perfect_hash(\%pkg_number); my @hashinfo = gen_perfect_hash(\%pkg_number);
@@ -139,11 +139,11 @@ verify_hash_table(\%pkg_number, \@hashinfo);
my ($n, $sv, $g) = @hashinfo; my ($n, $sv, $g) = @hashinfo;
die if ($n & ($n-1)); die if ($n & ($n-1));
print OUT "const char *nasm_stdmac_find_package(const char *package)\n"; print OUT "const unsigned char *nasm_stdmac_find_package(const char *package)\n";
print OUT "{\n"; print OUT "{\n";
print OUT " static const struct {\n"; print OUT " static const struct {\n";
print OUT " const char *package;\n"; print OUT " const char *package;\n";
print OUT " const char *macros;\n"; print OUT " const unsigned char *macros;\n";
print OUT " } packages[$npkg] = {\n"; print OUT " } packages[$npkg] = {\n";
foreach $pkg (@pkg_list) { foreach $pkg (@pkg_list) {
printf OUT " { \"%s\", nasm_stdmac_%s },\n", printf OUT " { \"%s\", nasm_stdmac_%s },\n",

View File

@@ -642,7 +642,7 @@ static char *read_line(void)
if (stdmacpos) { if (stdmacpos) {
unsigned char c; unsigned char c;
const char *p = stdmacpos; const unsigned char *p = stdmacpos;
char *ret, *q; char *ret, *q;
size_t len = 0; size_t len = 0;
while ((c = *p++)) { while ((c = *p++)) {
@@ -2153,7 +2153,7 @@ static int do_directive(Token * tline)
case PP_USE: case PP_USE:
{ {
static const char *use_pkg; static const macros_t *use_pkg;
const char *pkg_macro; const char *pkg_macro;
t = tline->next = expand_smacro(tline->next); t = tline->next = expand_smacro(tline->next);
@@ -2175,7 +2175,7 @@ static int do_directive(Token * tline)
if (!use_pkg) if (!use_pkg)
error(ERR_NONFATAL, "unknown `%%use' package: %s", t->text); error(ERR_NONFATAL, "unknown `%%use' package: %s", t->text);
/* The first string will be <%define>__USE_*__ */ /* The first string will be <%define>__USE_*__ */
pkg_macro = use_pkg + 1; pkg_macro = (char *)use_pkg + 1;
if (!smacro_defined(NULL, pkg_macro, 0, NULL, true)) { if (!smacro_defined(NULL, pkg_macro, 0, NULL, true)) {
/* Not already included, go ahead and include it */ /* Not already included, go ahead and include it */
stdmacpos = use_pkg; stdmacpos = use_pkg;

View File

@@ -15,7 +15,7 @@ extern const char * const pp_directives[];
extern const uint8_t pp_directives_len[]; extern const uint8_t pp_directives_len[];
/* Pointer to a macro chain */ /* Pointer to a macro chain */
typedef const char macros_t; typedef const unsigned char macros_t;
enum preproc_token pp_token_hash(const char *token); enum preproc_token pp_token_hash(const char *token);
void pp_include_path(char *); void pp_include_path(char *);

View File

@@ -14,9 +14,9 @@
/* --- From standard.mac via macros.pl: --- */ /* --- From standard.mac via macros.pl: --- */
/* macros.c */ /* macros.c */
extern const char nasm_stdmac[]; extern const unsigned char nasm_stdmac[];
extern const char * const nasm_stdmac_after_tasm; extern const unsigned char * const nasm_stdmac_after_tasm;
const char *nasm_stdmac_find_package(const char *); const unsigned char *nasm_stdmac_find_package(const char *);
/* --- From insns.dat via insns.pl: --- */ /* --- From insns.dat via insns.pl: --- */