Replace external dependencies on <ctype.h> with an internal table

Don't rely on the platform <ctype.h>; hopefully this can avoid
problems.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin 2016-03-03 17:11:28 -08:00
parent a9a1b5c318
commit 3a27b17c7f
36 changed files with 228 additions and 97 deletions

View file

@ -72,7 +72,7 @@ endif
#-- Begin File Lists --#
NASM = nasm.$(O) nasmlib.$(O) ver.$(O) \
NASM = nasm.$(O) nasmlib.$(O) ctype.$(O) ver.$(O) \
raa.$(O) saa.$(O) rbtree.$(O) \
realpath.$(O) \
float.$(O) insnsa.$(O) insnsb.$(O) \
@ -95,7 +95,7 @@ NASM = nasm.$(O) nasmlib.$(O) ver.$(O) \
disp8.$(O) \
iflag.$(O)
NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) ver.$(O) \
NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) ctype.$(O) ver.$(O) \
insnsd.$(O) insnsb.$(O) insnsn.$(O) regs.$(O) regdis.$(O) \
disp8.$(O) iflag.$(O)
#-- End File Lists --#
@ -307,6 +307,7 @@ assemble.$(O): assemble.c assemble.h compiler.h config.h directiv.h disp8.h \
iflag.h iflaggen.h insns.h insnsi.h nasm.h nasmlib.h opflags.h pptok.h \
preproc.h regs.h tables.h tokens.h
crc64.$(O): crc64.c compiler.h config.h hashtbl.h nasmlib.h
ctype.$(O): ctype.c compiler.h config.h nasmlib.h
directiv.$(O): directiv.c compiler.h config.h directiv.h hashtbl.h insnsi.h \
nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
disasm.$(O): disasm.c compiler.h config.h directiv.h disasm.h disp8.h \
@ -344,7 +345,7 @@ listing.$(O): listing.c compiler.h config.h directiv.h insnsi.h listing.h \
macros.$(O): macros.c compiler.h config.h directiv.h hashtbl.h insnsi.h \
nasm.h nasmlib.h opflags.h output/outform.h pptok.h preproc.h regs.h \
tables.h
md5c.$(O): md5c.c md5.h
md5c.$(O): md5c.c compiler.h config.h md5.h
nasm.$(O): nasm.c assemble.h compiler.h config.h directiv.h eval.h float.h \
iflag.h iflaggen.h insns.h insnsi.h labels.h listing.h nasm.h nasmlib.h \
opflags.h output/outform.h parser.h pptok.h preproc.h raa.h regs.h saa.h \
@ -405,7 +406,7 @@ output/outlib.$(O): output/outlib.c compiler.h config.h directiv.h insnsi.h \
tables.h
output/outmacho.$(O): output/outmacho.c compiler.h config.h directiv.h \
insnsi.h nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h \
pptok.h preproc.h raa.h regs.h saa.h tables.h
pptok.h preproc.h raa.h rbtree.h regs.h saa.h tables.h
output/outobj.$(O): output/outobj.c compiler.h config.h directiv.h eval.h \
insnsi.h nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h \
pptok.h preproc.h regs.h stdscan.h tables.h

View file

@ -43,7 +43,7 @@ X = .exe
#-- Begin File Lists --#
# Edit in Makefile.in, not here!
NASM = nasm.$(O) nasmlib.$(O) ver.$(O) \
NASM = nasm.$(O) nasmlib.$(O) ctype.$(O) ver.$(O) \
raa.$(O) saa.$(O) rbtree.$(O) \
realpath.$(O) \
float.$(O) insnsa.$(O) insnsb.$(O) \
@ -66,7 +66,7 @@ NASM = nasm.$(O) nasmlib.$(O) ver.$(O) \
disp8.$(O) \
iflag.$(O)
NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) ver.$(O) \
NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) ctype.$(O) ver.$(O) \
insnsd.$(O) insnsb.$(O) insnsn.$(O) regs.$(O) regdis.$(O) \
disp8.$(O) iflag.$(O)
#-- End File Lists --#
@ -229,6 +229,7 @@ assemble.$(O): assemble.c assemble.h compiler.h directiv.h disp8.h iflag.h \
iflaggen.h insns.h insnsi.h nasm.h nasmlib.h opflags.h pptok.h preproc.h \
regs.h tables.h tokens.h
crc64.$(O): crc64.c compiler.h hashtbl.h nasmlib.h
ctype.$(O): ctype.c compiler.h nasmlib.h
directiv.$(O): directiv.c compiler.h directiv.h hashtbl.h insnsi.h nasm.h \
nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
disasm.$(O): disasm.c compiler.h directiv.h disasm.h disp8.h iflag.h \
@ -265,7 +266,7 @@ listing.$(O): listing.c compiler.h directiv.h insnsi.h listing.h nasm.h \
nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
macros.$(O): macros.c compiler.h directiv.h hashtbl.h insnsi.h nasm.h \
nasmlib.h opflags.h output/outform.h pptok.h preproc.h regs.h tables.h
md5c.$(O): md5c.c md5.h
md5c.$(O): md5c.c compiler.h md5.h
nasm.$(O): nasm.c assemble.h compiler.h directiv.h eval.h float.h iflag.h \
iflaggen.h insns.h insnsi.h labels.h listing.h nasm.h nasmlib.h opflags.h \
output/outform.h parser.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h \
@ -321,7 +322,7 @@ output/outlib.$(O): output/outlib.c compiler.h directiv.h insnsi.h nasm.h \
nasmlib.h opflags.h output/outlib.h pptok.h preproc.h regs.h tables.h
output/outmacho.$(O): output/outmacho.c compiler.h directiv.h insnsi.h \
nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h pptok.h \
preproc.h raa.h regs.h saa.h tables.h
preproc.h raa.h rbtree.h regs.h saa.h tables.h
output/outobj.$(O): output/outobj.c compiler.h directiv.h eval.h insnsi.h \
nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h pptok.h \
preproc.h regs.h stdscan.h tables.h

View file

@ -30,7 +30,7 @@ O = o
#-- Begin File Lists --#
# Edit in Makefile.in, not here!
NASM = nasm.o nasmlib.o ver.o \
NASM = nasm.o nasmlib.o ctype.o ver.o \
raa.o saa.o rbtree.o \
realpath.o \
float.o insnsa.o insnsb.o \
@ -53,7 +53,7 @@ NASM = nasm.o nasmlib.o ver.o \
disp8.o \
iflag.o
NDISASM = ndisasm.o disasm.o sync.o nasmlib.o ver.o \
NDISASM = ndisasm.o disasm.o sync.o nasmlib.o ctype.o ver.o \
insnsd.o insnsb.o insnsn.o regs.o regdis.o \
disp8.o iflag.o
#-- End File Lists --#
@ -137,6 +137,7 @@ assemble.o: assemble.c assemble.h compiler.h config.h directiv.h disp8.h \
iflag.h iflaggen.h insns.h insnsi.h nasm.h nasmlib.h opflags.h pptok.h \
preproc.h regs.h tables.h tokens.h
crc64.o: crc64.c compiler.h config.h hashtbl.h nasmlib.h
ctype.o: ctype.c compiler.h config.h nasmlib.h
directiv.o: directiv.c compiler.h config.h directiv.h hashtbl.h insnsi.h \
nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
disasm.o: disasm.c compiler.h config.h directiv.h disasm.h disp8.h iflag.h \
@ -173,7 +174,7 @@ listing.o: listing.c compiler.h config.h directiv.h insnsi.h listing.h \
nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
macros.o: macros.c compiler.h config.h directiv.h hashtbl.h insnsi.h nasm.h \
nasmlib.h opflags.h outform.h pptok.h preproc.h regs.h tables.h
md5c.o: md5c.c md5.h
md5c.o: md5c.c compiler.h config.h md5.h
nasm.o: nasm.c assemble.h compiler.h config.h directiv.h eval.h float.h \
iflag.h iflaggen.h insns.h insnsi.h labels.h listing.h nasm.h nasmlib.h \
opflags.h outform.h parser.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h \
@ -224,8 +225,8 @@ outieee.o: outieee.c compiler.h config.h directiv.h insnsi.h nasm.h \
outlib.o: outlib.c compiler.h config.h directiv.h insnsi.h nasm.h nasmlib.h \
opflags.h outlib.h pptok.h preproc.h regs.h tables.h
outmacho.o: outmacho.c compiler.h config.h directiv.h insnsi.h nasm.h \
nasmlib.h opflags.h outform.h outlib.h pptok.h preproc.h raa.h regs.h saa.h \
tables.h
nasmlib.h opflags.h outform.h outlib.h pptok.h preproc.h raa.h rbtree.h \
regs.h saa.h tables.h
outobj.o: outobj.c compiler.h config.h directiv.h eval.h insnsi.h nasm.h \
nasmlib.h opflags.h outform.h outlib.h pptok.h preproc.h regs.h stdscan.h \
tables.h

View file

@ -46,7 +46,7 @@ X = .exe
#-- Begin File Lists --#
# Edit in Makefile.in, not here!
NASM = nasm.$(O) nasmlib.$(O) ver.$(O) &
NASM = nasm.$(O) nasmlib.$(O) ctype.$(O) ver.$(O) &
raa.$(O) saa.$(O) rbtree.$(O) &
realpath.$(O) &
float.$(O) insnsa.$(O) insnsb.$(O) &
@ -69,7 +69,7 @@ NASM = nasm.$(O) nasmlib.$(O) ver.$(O) &
disp8.$(O) &
iflag.$(O)
NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) ver.$(O) &
NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) ctype.$(O) ver.$(O) &
insnsd.$(O) insnsb.$(O) insnsn.$(O) regs.$(O) regdis.$(O) &
disp8.$(O) iflag.$(O)
#-- End File Lists --#
@ -274,6 +274,7 @@ assemble.$(O): assemble.c assemble.h compiler.h config.h directiv.h disp8.h &
iflag.h iflaggen.h insns.h insnsi.h nasm.h nasmlib.h opflags.h pptok.h &
preproc.h regs.h tables.h tokens.h
crc64.$(O): crc64.c compiler.h config.h hashtbl.h nasmlib.h
ctype.$(O): ctype.c compiler.h config.h nasmlib.h
directiv.$(O): directiv.c compiler.h config.h directiv.h hashtbl.h insnsi.h &
nasm.h nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
disasm.$(O): disasm.c compiler.h config.h directiv.h disasm.h disp8.h &
@ -311,7 +312,7 @@ listing.$(O): listing.c compiler.h config.h directiv.h insnsi.h listing.h &
macros.$(O): macros.c compiler.h config.h directiv.h hashtbl.h insnsi.h &
nasm.h nasmlib.h opflags.h output/outform.h pptok.h preproc.h regs.h &
tables.h
md5c.$(O): md5c.c md5.h
md5c.$(O): md5c.c compiler.h config.h md5.h
nasm.$(O): nasm.c assemble.h compiler.h config.h directiv.h eval.h float.h &
iflag.h iflaggen.h insns.h insnsi.h labels.h listing.h nasm.h nasmlib.h &
opflags.h output/outform.h parser.h pptok.h preproc.h raa.h regs.h saa.h &
@ -372,7 +373,7 @@ output/outlib.$(O): output/outlib.c compiler.h config.h directiv.h insnsi.h &
tables.h
output/outmacho.$(O): output/outmacho.c compiler.h config.h directiv.h &
insnsi.h nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h &
pptok.h preproc.h raa.h regs.h saa.h tables.h
pptok.h preproc.h raa.h rbtree.h regs.h saa.h tables.h
output/outobj.$(O): output/outobj.c compiler.h config.h directiv.h eval.h &
insnsi.h nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h &
pptok.h preproc.h regs.h stdscan.h tables.h

View file

@ -57,7 +57,7 @@ X = .exe
#-- Begin File Lists --#
# Edit in Makefile.in, not here!
NASM = nasm.$(O) nasmlib.$(O) ver.$(O) \
NASM = nasm.$(O) nasmlib.$(O) ctype.$(O) ver.$(O) \
raa.$(O) saa.$(O) rbtree.$(O) \
realpath.$(O) \
float.$(O) insnsa.$(O) insnsb.$(O) \
@ -80,7 +80,7 @@ NASM = nasm.$(O) nasmlib.$(O) ver.$(O) \
disp8.$(O) \
iflag.$(O)
NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) ver.$(O) \
NDISASM = ndisasm.$(O) disasm.$(O) sync.$(O) nasmlib.$(O) ctype.$(O) ver.$(O) \
insnsd.$(O) insnsb.$(O) insnsn.$(O) regs.$(O) regdis.$(O) \
disp8.$(O) iflag.$(O)
#-- End File Lists --#
@ -243,6 +243,7 @@ assemble.$(O): assemble.c assemble.h compiler.h directiv.h disp8.h iflag.h \
iflaggen.h insns.h insnsi.h nasm.h nasmlib.h opflags.h pptok.h preproc.h \
regs.h tables.h tokens.h
crc64.$(O): crc64.c compiler.h hashtbl.h nasmlib.h
ctype.$(O): ctype.c compiler.h nasmlib.h
directiv.$(O): directiv.c compiler.h directiv.h hashtbl.h insnsi.h nasm.h \
nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
disasm.$(O): disasm.c compiler.h directiv.h disasm.h disp8.h iflag.h \
@ -279,7 +280,7 @@ listing.$(O): listing.c compiler.h directiv.h insnsi.h listing.h nasm.h \
nasmlib.h opflags.h pptok.h preproc.h regs.h tables.h
macros.$(O): macros.c compiler.h directiv.h hashtbl.h insnsi.h nasm.h \
nasmlib.h opflags.h output/outform.h pptok.h preproc.h regs.h tables.h
md5c.$(O): md5c.c md5.h
md5c.$(O): md5c.c compiler.h md5.h
nasm.$(O): nasm.c assemble.h compiler.h directiv.h eval.h float.h iflag.h \
iflaggen.h insns.h insnsi.h labels.h listing.h nasm.h nasmlib.h opflags.h \
output/outform.h parser.h pptok.h preproc.h raa.h regs.h saa.h stdscan.h \
@ -335,7 +336,7 @@ output/outlib.$(O): output/outlib.c compiler.h directiv.h insnsi.h nasm.h \
nasmlib.h opflags.h output/outlib.h pptok.h preproc.h regs.h tables.h
output/outmacho.$(O): output/outmacho.c compiler.h directiv.h insnsi.h \
nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h pptok.h \
preproc.h raa.h regs.h saa.h tables.h
preproc.h raa.h rbtree.h regs.h saa.h tables.h
output/outobj.$(O): output/outobj.c compiler.h directiv.h eval.h insnsi.h \
nasm.h nasmlib.h opflags.h output/outform.h output/outlib.h pptok.h \
preproc.h regs.h stdscan.h tables.h

181
ctype.c Normal file
View file

@ -0,0 +1,181 @@
/* ----------------------------------------------------------------------- *
*
* Copyright 2016 The NASM Authors - All Rights Reserved
* See the file AUTHORS included with the NASM distribution for
* the specific copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following
* conditions are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ----------------------------------------------------------------------- */
/*
* ctype.c
*
* Replacement for <ctype.h>
*
* We require that the input format is a superset of ASCII, so we
* might as well hard-code these rather than rely on the platform.
* This also avoids potential strangeness related to locale.
*
* We treat all bytes >= 0x80 as alphabetic. This is a hack but
* allows us to handle symbol names in Unicode or other extended
* character sets, although it will not support case conversion for
* those. It is as good as we can do without actually being
* multibyte-character aware.
*/
#include "compiler.h"
#include "nasmlib.h"
const unsigned char nasm_tolower_tab[256] =
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
};
const unsigned char nasm_toupper_tab[256] =
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
0x60, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47,
0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f,
0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57,
0x58, 0x59, 0x5a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
};
#define S 0x01 /* Space */
#define A 0x62 /* Upper case alphabetic non-hex digit */
#define X 0x6a /* Upper case alphabetic hex digit */
#define a 0x62 /* Lower case alphabetic non-hex digit */
#define x 0x6a /* Lower case alphabetic hex digit */
#define T 0x62 /* Other character valid in all alpha tokens */
#define D 0xcc /* Decimal digit */
#define C 0x10 /* Control */
#define Z 0x11 /* Control whitespace */
#define P 0x00 /* Other printable symbol */
#define F 0x60 /* Other char allowed to start ID */
#define M 0x40 /* Other char allowed in ID */
#define B 0x20 /* Character allowed inside {} */
#define N (0x80|M) /* Other char allowed to start number (+M) */
const unsigned char nasm_ctype_tab[256] =
{
C,C,C,C,C,C,C,C, Z,Z,Z,Z,Z,Z,C,C, C,C,C,C,C,C,C,C, C,C,C,C,C,C,C,C,
S,P,P,M,N,P,P,P, P,P,P,P,P,B,F,P, D,D,D,D,D,D,D,D, D,D,P,P,P,P,P,F,
F,X,X,X,X,X,X,A, A,A,A,A,A,A,A,A, A,A,A,A,A,A,A,A, A,A,A,P,P,P,P,T,
P,x,x,x,x,x,x,a, a,a,a,a,a,a,a,a, a,a,a,a,a,a,a,a, a,a,a,P,P,P,M,C,
T,T,T,T,T,T,T,T, T,T,T,T,T,T,T,T, T,T,T,T,T,T,T,T, T,T,T,T,T,T,T,T,
T,T,T,T,T,T,T,T, T,T,T,T,T,T,T,T, T,T,T,T,T,T,T,T, T,T,T,T,T,T,T,T,
T,T,T,T,T,T,T,T, T,T,T,T,T,T,T,T, T,T,T,T,T,T,T,T, T,T,T,T,T,T,T,T,
T,T,T,T,T,T,T,T, T,T,T,T,T,T,T,T, T,T,T,T,T,T,T,T, T,T,T,T,T,T,T,T
};

1
eval.c
View file

@ -41,7 +41,6 @@
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <ctype.h>
#include <inttypes.h>
#include "nasm.h"

View file

@ -37,7 +37,6 @@
#include "compiler.h"
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

View file

@ -41,7 +41,6 @@
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <ctype.h>
#include <inttypes.h>
#include "nasm.h"

View file

@ -10,7 +10,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/mman.h>

3
nasm.c
View file

@ -41,7 +41,6 @@
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <inttypes.h>
#include <limits.h>
#include <time.h>
@ -336,8 +335,6 @@ int main(int argc, char **argv)
error_file = stderr;
tolower_init();
offsets = raa_init();
forwrefs = saa_init((int32_t)sizeof(struct forwrefinfo));

21
nasm.h
View file

@ -428,25 +428,14 @@ extern struct preproc_ops preproc_nop;
* decorator. E.g. {rn-sae}, {1to8}, {k1}{z}
*/
#define isidstart(c) (nasm_isalpha(c) || \
(c) == '_' || \
(c) == '.' || \
(c) == '?' || \
(c) == '@')
#define isidchar(c) (isidstart(c) || \
nasm_isdigit(c) || \
(c) == '$' || \
(c) == '#' || \
(c) == '~')
#define isbrcchar(c) (isidchar(c) || \
(c) == '-')
#define isidstart(c) ((nasm_ctype_tab[(unsigned char)c] & 0x60) >= 0x60)
#define isidchar(c) ((nasm_ctype_tab[(unsigned char)c] & 0x60) >= 0x40)
#define isbrcchar(c) ((nasm_ctype_tab[(unsigned char)c] & 0x60) >= 0x20)
/* Ditto for numeric constants. */
#define isnumstart(c) (nasm_isdigit(c) || (c) == '$')
#define isnumchar(c) (nasm_isalnum(c) || (c) == '_')
#define isnumstart(c) (!!(nasm_ctype_tab[(unsigned char)c] & 0x80))
#define isnumchar(c) nasm_isalnum(c)
/*
* Data-type flags that get passed to listing-file routines.

View file

@ -40,7 +40,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
@ -54,21 +53,6 @@ vefunc nasm_verror; /* Global error handling function */
/* Uninitialized -> all zero by C spec */
const uint8_t zero_buffer[ZERO_BUF_SIZE];
/*
* Prepare a table of tolower() results. This avoids function calls
* on some platforms.
*/
unsigned char nasm_tolower_tab[256];
void tolower_init(void)
{
int i;
for (i = 0; i < 256; i++)
nasm_tolower_tab[i] = tolower(i);
}
void nasm_error(int severity, const char *fmt, ...)
{
va_list ap;

View file

@ -48,21 +48,22 @@
#endif
/*
* tolower table -- avoids a function call on some platforms.
* NOTE: unlike the tolower() function in ctype, EOF is *NOT*
* tolower/toupper tables -- avoids a function call on some platforms.
* NOTE: unlike the to*() and is*() functions in ctype.h, EOF is *NOT*
* a permitted value, for obvious reasons.
*/
void tolower_init(void);
extern unsigned char nasm_tolower_tab[256];
extern const unsigned char nasm_tolower_tab[256];
#define nasm_tolower(x) nasm_tolower_tab[(unsigned char)(x)]
/* Wrappers around <ctype.h> functions */
/* These are only valid for values that cannot include EOF */
#define nasm_isspace(x) isspace((unsigned char)(x))
#define nasm_isalpha(x) isalpha((unsigned char)(x))
#define nasm_isdigit(x) isdigit((unsigned char)(x))
#define nasm_isalnum(x) isalnum((unsigned char)(x))
#define nasm_isxdigit(x) isxdigit((unsigned char)(x))
extern const unsigned char nasm_toupper_tab[256];
#define nasm_toupper(x) nasm_toupper_tab[(unsigned char)(x)]
extern const unsigned char nasm_ctype_tab[256];
#define nasm_isspace(x) (!!(nasm_ctype_tab[(unsigned char)(x)] & 0x01))
#define nasm_isalpha(x) (!!(nasm_ctype_tab[(unsigned char)(x)] & 0x02))
#define nasm_isdigit(x) (!!(nasm_ctype_tab[(unsigned char)(x)] & 0x04))
#define nasm_isalnum(x) (!!(nasm_ctype_tab[(unsigned char)(x)] & 0x06))
#define nasm_isxdigit(x) (!!(nasm_ctype_tab[(unsigned char)(x)] & 0x08))
/*
* -------------------------

View file

@ -41,7 +41,6 @@
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <inttypes.h>
@ -93,7 +92,6 @@ int main(int argc, char **argv)
int32_t offset;
FILE *fp;
tolower_init();
nasm_set_verror(ndisasm_verror);
iflag_clear_all(&prefer);

View file

@ -41,7 +41,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <inttypes.h>
#include "nasm.h"

View file

@ -41,7 +41,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <inttypes.h>
#include "nasm.h"

View file

@ -78,7 +78,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <inttypes.h>
#include "nasm.h"

View file

@ -41,7 +41,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <inttypes.h>

View file

@ -41,7 +41,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <inttypes.h>
#include "nasm.h"

View file

@ -41,7 +41,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <inttypes.h>
#include <limits.h>

View file

@ -41,7 +41,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <inttypes.h>
#include "nasm.h"

View file

@ -41,7 +41,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <inttypes.h>
#include "nasm.h"

View file

@ -72,7 +72,6 @@
#include <string.h>
#include <time.h>
#include <stdarg.h> /* Note: we need the ANSI version of stdarg.h */
#include <ctype.h>
#include <inttypes.h>
#include "nasm.h"
@ -1294,7 +1293,7 @@ static void ieee_unqualified_name(char *dest, char *source)
{
if (ieee_uppercase) {
while (*source)
*dest++ = toupper(*source++);
*dest++ = nasm_toupper(*source++);
*dest = 0;
} else
strcpy(dest, source);

View file

@ -41,7 +41,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <inttypes.h>
#include "nasm.h"

View file

@ -41,7 +41,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <inttypes.h>
#include <limits.h>
@ -428,7 +427,7 @@ static ObjRecord *obj_name(ObjRecord * orp, const char *name)
orp->used += len + 1;
if (obj_uppercase)
while (--len >= 0) {
*ptr++ = toupper(*name);
*ptr++ = nasm_toupper(*name);
name++;
} else
memcpy(ptr, name, len);

View file

@ -42,7 +42,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
#include <inttypes.h>

View file

@ -34,7 +34,6 @@
#ifndef STABS_H_
#define STABS_H_
#include <ctype.h>
#include <inttypes.h>
#include "compiler.h"

View file

@ -41,7 +41,6 @@
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <ctype.h>
#include <inttypes.h>
#include "nasm.h"

View file

@ -180,7 +180,6 @@ if ($what eq 'c') {
print OUT "#include \"compiler.h\"\n";
print OUT "#include <inttypes.h>\n";
print OUT "#include <ctype.h>\n";
print OUT "#include \"nasmlib.h\"\n";
print OUT "#include \"hashtbl.h\"\n";
print OUT "#include \"preproc.h\"\n";

View file

@ -43,7 +43,6 @@
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <inttypes.h>
#include <limits.h>
#include <time.h>

View file

@ -67,7 +67,6 @@
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include <inttypes.h>

View file

@ -32,7 +32,7 @@ MKDIR = mkdir
LDRDFLIBS = rdoff.$(O) symtab.$(O) collectn.$(O) \
rdlib.$(O) segtab.$(O) hash.$(O)
RDXLIBS = rdoff.$(O) rdfload.$(O) symtab.$(O) collectn.$(O) hash.$(O)
NASMLIB = ../nasmlib.$(O)
NASMLIB = ../nasmlib.$(O) ../ctype.$(O)
# Binary suffixes
O = @OBJEXT@

View file

@ -40,7 +40,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include "rdfload.h"
@ -263,7 +262,7 @@ static const char *getformat(const char *pathname)
if (!nasm_stricmp(p, "rdf2")) {
const char *q = p+4;
char *r = fmt_buf;
while (isalnum(*q) && r < fmt_buf+sizeof fmt_buf-1)
while (nasm_isalnum(*q) && r < fmt_buf+sizeof fmt_buf-1)
*r++ = *q++;
*r = '\0';
if (fmt_buf[0])

View file

@ -39,7 +39,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <stdarg.h>
#include <string.h>
#include <errno.h>

View file

@ -36,7 +36,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <inttypes.h>
#include "nasm.h"