result = (result << 4) | digit;
s++;
} /* for */
- if (n != NULL)
+ if (n)
*n = s;
if (negate)
result = (~result) + 1; /* take two's complement of the result */
static char *
skipwhitespace(char *str)
{
- while (isspace(*str))
+ while (sc_isspace(*str))
str++;
return str;
}
{
char *ptr = strchr(str, ';');
- if (ptr != NULL)
+ if (ptr)
{
*ptr++ = '\n'; /* terminate the line, but leave the '\n' */
*ptr = '\0';
static cell
parm0(FILE * fbin, char *params __UNUSED__, cell opcode)
{
- if (fbin != NULL)
+ if (fbin)
write_encoded(fbin, (ucell *) & opcode, 1);
return opcodes(1);
}
{
ucell p = hex2long(params, NULL);
- if (fbin != NULL)
+ if (fbin)
{
write_encoded(fbin, (ucell *) & opcode, 1);
write_encoded(fbin, &p, 1);
p[0] = hex2long(params, ¶ms);
p[1] = hex2long(params, NULL);
- if (fbin != NULL)
+ if (fbin)
{
write_encoded(fbin, (ucell *) & opcode, 1);
write_encoded(fbin, p, 2);
while (*params != '\0')
{
p = hex2long(params, ¶ms);
- if (fbin != NULL)
+ if (fbin)
write_encoded(fbin, &p, 1);
num++;
- while (isspace(*params))
+ while (sc_isspace(*params))
params++;
} /* while */
return num * sizeof(cell);
symbol *sym;
ucell p;
- for (i = 0; !isspace(*params); i++, params++)
+ for (i = 0; !sc_isspace(*params); i++, params++)
{
assert(*params != '\0');
assert(i < sNAMEMAX);
assert(sym->vclass == sGLOBAL);
p = sym->addr;
- if (fbin != NULL)
+ if (fbin)
{
write_encoded(fbin, (ucell *) & opcode, 1);
write_encoded(fbin, &p, 1);
i = (int)hex2long(params, NULL);
assert(i >= 0 && i < labnum);
- if (fbin != NULL)
+ if (fbin)
{
assert(lbltab != NULL);
p = lbltab[i];
p = hex2long(params, ¶ms);
/* remove leading and trailing white space from the filename */
- while (isspace(*params))
+ while (sc_isspace(*params))
params++;
len = strlen(params);
- while (len > 0 && isspace(params[len - 1]))
+ while (len > 0 && sc_isspace(params[len - 1]))
len--;
params[len++] = '\0'; /* zero-terminate */
while (len % sizeof(cell) != 0)
assert(len > 0 && len < 256);
clen = len + sizeof(cell); /* add size of file ordinal */
- if (fbin != NULL)
+ if (fbin)
{
write_encoded(fbin, (ucell *) & opcode, 1);
write_encoded(fbin, &clen, 1);
int len;
unsigned char mclass, type;
- for (endptr = params; !isspace(*endptr) && endptr != '\0'; endptr++)
+ for (endptr = params; !sc_isspace(*endptr) && endptr != '\0'; endptr++)
/* nothing */ ;
assert(*endptr == ' ');
params[len++] = '\0'; /* pad with zeros up to full cell */
clen = len + 2 * sizeof(cell); /* add size of symbol address and flags */
- if (fbin != NULL)
+ if (fbin)
{
write_encoded(fbin, (ucell *) & opcode, 1);
write_encoded(fbin, &clen, 1);
#if !defined NDEBUG
/* function should start right after the symbolic information */
- if (fbin == NULL && mclass == 0 && type == iFUNCTN)
+ if (!fbin && mclass == 0 && type == iFUNCTN)
assert(offset == codeindex + opcodes(1) + opargs(1) + clen);
#endif
i = (int)hex2long(params, NULL);
assert(i >= 0 && i < labnum);
- if (fbin != NULL)
+ if (fbin)
{
assert(lbltab != NULL);
p = lbltab[i];
i = (int)hex2long(params, NULL);
assert(i >= 0 && i < labnum);
- if (fbin != NULL)
+ if (fbin)
{
assert(lbltab != NULL);
p = lbltab[i];
#if !defined NDEBUG
/* verify that the opcode list is sorted (skip entry 1; it is reserved
- * for a non-existant opcode)
+ * for a non-existent opcode)
*/
assert(opcodelist[1].name != NULL);
- for (i = 2; i < (sizeof opcodelist / sizeof opcodelist[0]); i++)
+ for (i = 2; i < (int)(sizeof(opcodelist) / sizeof(opcodelist[0])); i++)
{
assert(opcodelist[i].name != NULL);
assert(strcasecmp(opcodelist[i].name, opcodelist[i - 1].name) > 0);
numpubvars = 0;
mainaddr = -1;
/* count number of public and native functions and public variables */
- for (sym = glbtab.next; sym != NULL; sym = sym->next)
+ for (sym = glbtab.next; sym; sym = sym->next)
{
char alias[sNAMEMAX + 1] = "";
int match = 0;
/* count number of libraries */
numlibraries = 0;
- for (constptr = libname_tab.next; constptr != NULL;
+ for (constptr = libname_tab.next; constptr;
constptr = constptr->next)
{
if (constptr->value > 0)
/* count number of public tags */
numtags = 0;
- for (constptr = tagname_tab.next; constptr != NULL;
+ for (constptr = tagname_tab.next; constptr;
constptr = constptr->next)
{
if ((constptr->value & PUBLICTAG) != 0)
/* write the public functions table */
count = 0;
- for (sym = glbtab.next; sym != NULL; sym = sym->next)
+ for (sym = glbtab.next; sym; sym = sym->next)
{
if (sym->ident == iFUNCTN
&& (sym->usage & uPUBLIC) != 0 && (sym->usage & uDEFINE) != 0)
if (numnatives > 0)
{
nativelist = (symbol **) malloc(numnatives * sizeof(symbol *));
- if (nativelist == NULL)
+ if (!nativelist)
error(103); /* insufficient memory */
#if !defined NDEBUG
memset(nativelist, 0, numnatives * sizeof(symbol *)); /* for NULL checking */
#endif
- for (sym = glbtab.next; sym != NULL; sym = sym->next)
+ for (sym = glbtab.next; sym; sym = sym->next)
{
if (sym->ident == iFUNCTN && (sym->usage & uNATIVE) != 0
&& (sym->usage & uREAD) != 0 && sym->addr >= 0)
/* write the libraries table */
count = 0;
- for (constptr = libname_tab.next; constptr != NULL;
+ for (constptr = libname_tab.next; constptr;
constptr = constptr->next)
{
if (constptr->value > 0)
/* write the public variables table */
count = 0;
- for (sym = glbtab.next; sym != NULL; sym = sym->next)
+ for (sym = glbtab.next; sym; sym = sym->next)
{
if (sym->ident == iVARIABLE && (sym->usage & uPUBLIC) != 0)
{
/* write the public tagnames table */
count = 0;
- for (constptr = tagname_tab.next; constptr != NULL;
+ for (constptr = tagname_tab.next; constptr;
constptr = constptr->next)
{
if ((constptr->value & PUBLICTAG) != 0)
/* only very short programs have zero labels; no first pass is needed
* if there are no labels */
lbltab = (cell *) malloc(labnum * sizeof(cell));
- if (lbltab == NULL)
+ if (!lbltab)
error(103); /* insufficient memory */
codeindex = 0;
sc_resetasm(fin);
- while (sc_readasm(fin, line, sizeof line) != NULL)
+ while (sc_readasm(fin, line, sizeof line))
{
stripcomment(line);
instr = skipwhitespace(line);
/* get to the end of the instruction (make use of the '\n' that fgets()
* added at the end of the line; this way we will *always* drop on a
* whitespace character) */
- for (params = instr; *params != '\0' && !isspace(*params);
+ for (params = instr; *params != '\0' && !sc_isspace(*params);
params++)
/* nothing */ ;
assert(params > instr);
i = findopcode(instr, (int)(params - instr));
- if (opcodelist[i].name == NULL)
+ if (!opcodelist[i].name)
{
*params = '\0';
error(104, instr); /* invalid assembler instruction */
for (pass = sIN_CSEG; pass <= sIN_DSEG; pass++)
{
sc_resetasm(fin);
- while (sc_readasm(fin, line, sizeof line) != NULL)
+ while (sc_readasm(fin, line, sizeof line))
{
stripcomment(line);
instr = skipwhitespace(line);
/* get to the end of the instruction (make use of the '\n' that fgets()
* added at the end of the line; this way we will *always* drop on a
* whitespace character) */
- for (params = instr; *params != '\0' && !isspace(*params);
+ for (params = instr; *params != '\0' && !sc_isspace(*params);
params++)
/* nothing */ ;
assert(params > instr);
if (bytes_out - bytes_in > 0)
error(106); /* compression buffer overflow */
- if (lbltab != NULL)
+ if (lbltab)
{
free(lbltab);
#if !defined NDEBUG