Don't use strlen to check if a string is empty.

SVN revision: 18270
This commit is contained in:
sebastid 2005-11-04 08:16:24 +00:00 committed by sebastid
parent 0cad0c7b33
commit 95b180caa0
4 changed files with 23 additions and 26 deletions

View File

@ -342,7 +342,7 @@ sc_compile(int argc, char *argv[])
sc_status = statFIRST; sc_status = statFIRST;
/* do the first pass through the file */ /* do the first pass through the file */
inpfmark = sc_getpossrc(inpf); inpfmark = sc_getpossrc(inpf);
if (strlen(incfname) > 0) if (incfname[0] != '\0')
{ {
if (strcmp(incfname, sDEF_PREFIX) == 0) if (strcmp(incfname, sDEF_PREFIX) == 0)
{ {
@ -390,7 +390,7 @@ sc_compile(int argc, char *argv[])
* by resetglobals() */ * by resetglobals() */
writeleader(); writeleader();
setfile(inpfname, fnumber); setfile(inpfname, fnumber);
if (strlen(incfname) > 0) if (incfname[0] != '\0')
{ {
if (strcmp(incfname, sDEF_PREFIX) == 0) if (strcmp(incfname, sDEF_PREFIX) == 0)
plungefile(incfname, FALSE, TRUE); /* parse "default.inc" (again) */ plungefile(incfname, FALSE, TRUE); /* parse "default.inc" (again) */
@ -601,19 +601,16 @@ parseoptions(int argc, char **argv, char *iname, char *oname,
{ {
/* include directory */ /* include directory */
i++; i++;
snprintf(str, sizeof(str), "%s", argv[i]); strncpy(str, argv[i], sizeof(str));
len = strlen(str); len = strlen(str);
if (len > 0) if (str[len - 1] != DIRSEP_CHAR)
{ {
if (str[len - 1] != DIRSEP_CHAR) str[len] = DIRSEP_CHAR;
{ str[len + 1] = '\0';
str[len] = DIRSEP_CHAR;
str[len + 1] = '\0';
}
insert_path(str);
} }
insert_path(str);
} }
else if (!strcmp (argv[i], "-o") && *argv[i + 1]) else if (!strcmp (argv[i], "-o") && *argv[i + 1])
{ {
@ -640,7 +637,7 @@ parseoptions(int argc, char **argv, char *iname, char *oname,
else else
{ {
/* only allow one input filename */ /* only allow one input filename */
about (); about();
} }
} }
} }
@ -656,7 +653,7 @@ setopt(int argc, char **argv, char *iname, char *oname,
strcpy(pname, sDEF_PREFIX); strcpy(pname, sDEF_PREFIX);
parseoptions(argc, argv, iname, oname, pname, rname); parseoptions(argc, argv, iname, oname, pname, rname);
if (strlen(iname) == 0) if (iname[0] == '\0')
about(); about();
} }
@ -1668,7 +1665,7 @@ decl_enum(int vclass)
matchtoken(';'); /* eat an optional ; */ matchtoken(';'); /* eat an optional ; */
/* set the enum name to the last value plus one */ /* set the enum name to the last value plus one */
if (strlen(enumname) > 0) if (enumname[0] != '\0')
add_constant(enumname, value, vclass, tag); add_constant(enumname, value, vclass, tag);
} }
@ -1884,7 +1881,7 @@ operatoradjust(int opertok, symbol * sym, char *opername, int resulttag)
error(64); /* cannot change predefined operators */ error(64); /* cannot change predefined operators */
/* change the operator name */ /* change the operator name */
assert(strlen(opername) > 0); assert(opername[0] != '\0');
operator_symname(tmpname, opername, tags[0], tags[1], count, resulttag); operator_symname(tmpname, opername, tags[0], tags[1], count, resulttag);
if ((oldsym = findglb(tmpname)) != NULL) if ((oldsym = findglb(tmpname)) != NULL)
{ {
@ -1919,7 +1916,7 @@ operatoradjust(int opertok, symbol * sym, char *opername, int resulttag)
static int static int
check_operatortag(int opertok, int resulttag, char *opername) check_operatortag(int opertok, int resulttag, char *opername)
{ {
assert(opername != NULL && strlen(opername) > 0); assert(opername != NULL && opername[0] != '\0');
switch (opertok) switch (opertok)
{ {
case '!': case '!':
@ -2891,7 +2888,7 @@ testsymbols(symbol * root, int level, int testlabs, int testconst)
if ((sym->usage & (uDEFINE | uREAD | uNATIVE | uSTOCK)) == uDEFINE) if ((sym->usage & (uDEFINE | uREAD | uNATIVE | uSTOCK)) == uDEFINE)
{ {
funcdisplayname(symname, sym->name); funcdisplayname(symname, sym->name);
if (strlen(symname) > 0) if (symname[0] != '\0')
error(203, symname); /* symbol isn't used ... error(203, symname); /* symbol isn't used ...
* (and not native/stock) */ * (and not native/stock) */
} /* if */ } /* if */

View File

@ -931,7 +931,7 @@ command(void)
char pathname[_MAX_PATH]; char pathname[_MAX_PATH];
lptr = getstring(pathname, sizeof pathname, lptr); lptr = getstring(pathname, sizeof pathname, lptr);
if (strlen(pathname) > 0) if (pathname[0] != '\0')
{ {
free(inpfname); free(inpfname);
inpfname = strdup(pathname); inpfname = strdup(pathname);
@ -1000,7 +1000,7 @@ command(void)
name[i] = *lptr; name[i] = *lptr;
name[i] = '\0'; name[i] = '\0';
} /* if */ } /* if */
if (strlen(name) == 0) if (name[0] == '\0')
{ {
curlibrary = NULL; curlibrary = NULL;
} }
@ -1308,7 +1308,7 @@ command(void)
delete_subst(pattern, prefixlen); delete_subst(pattern, prefixlen);
} /* if */ } /* if */
/* add the pattern/substitution pair to the list */ /* add the pattern/substitution pair to the list */
assert(strlen(pattern) > 0); assert(pattern[0] != '\0');
insert_subst(pattern, substitution, prefixlen); insert_subst(pattern, substitution, prefixlen);
free(pattern); free(pattern);
free(substitution); free(substitution);

View File

@ -710,7 +710,7 @@ assemble(FILE * fout, FILE * fin)
} /* if */ } /* if */
if (match) if (match)
{ {
assert(strlen(alias) > 0); assert(alias[0] != '\0');
nametablesize += strlen(alias) + 1; nametablesize += strlen(alias) + 1;
} /* if */ } /* if */
} /* for */ } /* for */
@ -723,7 +723,7 @@ assemble(FILE * fout, FILE * fin)
{ {
if (constptr->value > 0) if (constptr->value > 0)
{ {
assert(strlen(constptr->name) > 0); assert(constptr->name[0] != '\0');
numlibraries++; numlibraries++;
nametablesize += strlen(constptr->name) + 1; nametablesize += strlen(constptr->name) + 1;
} /* if */ } /* if */
@ -736,7 +736,7 @@ assemble(FILE * fout, FILE * fin)
{ {
if ((constptr->value & PUBLICTAG) != 0) if ((constptr->value & PUBLICTAG) != 0)
{ {
assert(strlen(constptr->name) > 0); assert(constptr->name[0] != '\0');
numtags++; numtags++;
nametablesize += strlen(constptr->name) + 1; nametablesize += strlen(constptr->name) + 1;
} /* if */ } /* if */
@ -892,7 +892,7 @@ assemble(FILE * fout, FILE * fin)
{ {
if (constptr->value > 0) if (constptr->value > 0)
{ {
assert(strlen(constptr->name) > 0); assert(constptr->name[0] != '\0');
func.address = 0; func.address = 0;
func.nameofs = nameofs; func.nameofs = nameofs;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
@ -938,7 +938,7 @@ assemble(FILE * fout, FILE * fin)
{ {
if ((constptr->value & PUBLICTAG) != 0) if ((constptr->value & PUBLICTAG) != 0)
{ {
assert(strlen(constptr->name) > 0); assert(constptr->name[0] != '\0');
func.address = constptr->value & TAGMASK; func.address = constptr->value & TAGMASK;
func.nameofs = nameofs; func.nameofs = nameofs;
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN

View File

@ -360,7 +360,7 @@ stgset(int onoff)
/* write any contents that may be put in the buffer by stgwrite() /* write any contents that may be put in the buffer by stgwrite()
* when "staging" was 0 * when "staging" was 0
*/ */
if (strlen(stgbuf) > 0) if (stgbuf[0] != '\0')
filewrite(stgbuf); filewrite(stgbuf);
} /* if */ } /* if */
stgbuf[0] = '\0'; stgbuf[0] = '\0';