The return value of strcmp() is unintuitive for string equality tests.
I prefer explicit comparisions against 0. I changed this everywhere.
*/
#define FINDCOMP(comp,name) \
for (comp = wantcomp[CHASH(name)]; \
- comp && strcmp(comp->c_name,name); \
+ comp && strcmp(comp->c_name,name)!=0; \
comp = comp->c_next) ;
/*
*/
for (np = m_defs;; np = np->n_next) {
if (!mh_strcasecmp(np->n_name, key)) {
- if (strcmp(value, np->n_field)) {
+ if (strcmp(value, np->n_field)!=0) {
if (!np->n_context)
admonish(NULL, "bug: context_replace(key=\"%s\",value=\"%s\")", key, value);
if (np->n_field)
continue;
}
#endif
- if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, "..")) {
+ if (strcmp(dp->d_name, ".")==0 ||
+ strcmp(dp->d_name, "..")==0) {
continue;
}
child = concat(prefix, dp->d_name, (void *)NULL);
** skip any files beginning with
** backup prefix
*/
- if (!strncmp(dp->d_name, backup_prefix,
- prefix_len))
+ if (strncmp(dp->d_name, backup_prefix,
+ prefix_len)==0)
continue;
/* skip the altmsg link file */
- if (!strcmp(dp->d_name, altmsglink))
+ if (strcmp(dp->d_name, altmsglink)==0)
continue;
/*
** ALLOW_BEYOND is set, and can appear only on its own.
** Also, it is available in any folder.
*/
- if ((mp->msgflags & ALLOW_BEYOND) && !strcmp(cp, seq_beyond)) {
+ if ((mp->msgflags & ALLOW_BEYOND) && strcmp(cp, seq_beyond)==0) {
addtosel(mp, getbeyond(mp));
return 1;
}
/*
** Handle the special all sequence: replace `a' with `f-l'
*/
- if (!strcmp(cp, seq_all)) {
+ if (strcmp(cp, seq_all)==0) {
cp = concat(seq_first, "-", seq_last, NULL);
}
*/
if (first > mp->hghmsg || first < mp->lowmsg ||
!does_exist(mp, first)) {
- if (!strcmp(name, seq_cur))
+ if (strcmp(name, seq_cur)==0)
advise(NULL, "no current message");
else
/* this case seems to never be reached */
int first = 0;
/* hack for "c-..." */
- if (!strcmp(cp, seq_cur))
+ if (strcmp(cp, seq_cur)==0)
return 0;
/* "c:..." -- this code need to be rewritten... */
if (strncmp(seq_cur, cp, strlen(seq_cur))==0 &&
** seq:l
*/
if (isalpha(*dp)) {
- if (!strcmp(dp, seq_prev)) {
+ if (strcmp(dp, seq_prev)==0) {
convdir = -1;
first = (mp->curmsg > 0) && (mp->curmsg <= mp->hghmsg)
? mp->curmsg - 1 : mp->hghmsg;
- } else if (!strcmp(dp, seq_next)) {
+ } else if (strcmp(dp, seq_next)==0) {
convdir = 1;
first = (mp->curmsg >= mp->lowmsg)
? mp->curmsg + 1 : mp->lowmsg;
- } else if (!strcmp(dp, seq_first)) {
+ } else if (strcmp(dp, seq_first)==0) {
convdir = 1;
- } else if (!strcmp(dp, seq_last)) {
+ } else if (strcmp(dp, seq_last)==0) {
convdir = -1;
} else
return BADLST;
pos = ftell(iob);
if ((i = fread(text, sizeof *text, edelimlen, iob)) != edelimlen
- || strncmp(text, (char *)edelim, edelimlen)) {
+ || (strncmp(text, (char *)edelim, edelimlen)!=0)) {
if (i == 0 && msg_style == MS_MBOX)
/*
** the final newline in the (brain damaged) unix-format
static int
isat(char *p)
{
- return (strncmp(p, " AT ", 4)
- && strncmp(p, " At ", 4)
- && strncmp(p, " aT ", 4)
- && strncmp(p, " at ", 4) ? FALSE : TRUE);
+ return (strncmp(p, " AT ", 4)!=0 && strncmp(p, " At ", 4)!=0 &&
+ strncmp(p, " aT ", 4)!=0 && strncmp(p, " at ", 4)!=0 ?
+ FALSE : TRUE);
}
*bp++ = 0;
for (b = binds; b->keyword; b++)
- if (!strcmp(buffer, b->keyword))
+ if (strcmp(buffer, b->keyword)==0)
break;
if (b->keyword && (cp = tailor_value(bp)))
*b->value = cp;
** can see what output to expect, and modify for your needs
** as necessary.
*/
- if (!strcmp(name, "UTF-8"))
+ if (strcmp(name, "UTF-8")==0)
return "UTF-8";
- if (!strcmp(name, "EUC-JP"))
+ if (strcmp(name, "EUC-JP")==0)
return "EUC-JP";
- if (!strcmp(name, "EUC-KR"))
+ if (strcmp(name, "EUC-KR")==0)
return "EUC-KR";
- if (!strcmp(name, "EUC-TW"))
+ if (strcmp(name, "EUC-TW")==0)
return "EUC-TW";
- if (!strcmp(name, "KOI8-R"))
+ if (strcmp(name, "KOI8-R")==0)
return "KOI8-R";
- if (!strcmp(name, "KOI8-U"))
+ if (strcmp(name, "KOI8-U")==0)
return "KOI8-U";
- if (!strcmp(name, "GBK"))
+ if (strcmp(name, "GBK")==0)
return "GBK";
- if (!strcmp(name, "GB2312"))
+ if (strcmp(name, "GB2312")==0)
return "GB2312";
- if (!strcmp(name, "GB18030"))
+ if (strcmp(name, "GB18030")==0)
return "GB18030";
- if (!strcmp(name, "VSCII"))
+ if (strcmp(name, "VSCII")==0)
return "VSCII";
/* ASCII comes in many names */
- if (!strcmp(name, "ASCII") ||
- !strcmp(name, "US-ASCII") ||
- !strcmp(name, "ANSI_X3.4-1968") ||
- !strcmp(name, "646") ||
- !strcmp(name, "ISO646") ||
- !strcmp(name, "ISO_646.IRV"))
+ if (strcmp(name, "ASCII")==0 ||
+ strcmp(name, "US-ASCII")==0 ||
+ strcmp(name, "ANSI_X3.4-1968")==0 ||
+ strcmp(name, "646")==0 ||
+ strcmp(name, "ISO646")==0 ||
+ strcmp(name, "ISO_646.IRV")==0)
return "US-ASCII";
/* ISO 8859 will be converted to "ISO-8859-x" */
}
/* TIS-620 comes in at least the following two forms */
- if (!strcmp(name, "TIS-620") ||
- !strcmp(name, "TIS620.2533"))
+ if (strcmp(name, "TIS-620")==0 ||
+ strcmp(name, "TIS620.2533")==0)
return "ISO-8859-11";
/* For some, uppercase/lowercase might differ */
- if (!strcmp(name, "Big5") || !strcmp(name, "BIG5"))
+ if (strcmp(name, "Big5")==0 || strcmp(name, "BIG5")==0)
return "Big5";
- if (!strcmp(name, "Big5HKSCS") || !strcmp(name, "BIG5HKSCS"))
+ if (strcmp(name, "Big5HKSCS")==0 || strcmp(name, "BIG5HKSCS")==0)
return "Big5HKSCS";
/*
if (tokval[0] == 0)
return (0);
for (t = toktabs; t->tokstr; t++)
- if (!strcmp(t->tokstr, tokval))
+ if (strcmp(t->tokstr, tokval)==0)
return (t->tval);
return (ID);
}
** We keep mp->curmsg and cur sequence in sync.
** See seq_list() and seq_init().
*/
- if (!strcmp(seq_cur, cp))
+ if (strcmp(seq_cur, cp)==0)
mp->curmsg = mp->hghsel;
/*
** Get the number for this sequence
*/
for (i = 0; mp->msgattrs[i]; i++) {
- if (!strcmp(mp->msgattrs[i], cp)) {
+ if (strcmp(mp->msgattrs[i], cp)==0) {
new_seq = 0;
break;
}
/*
** keep mp->curmsg and msgattrs[] of seq_cur in sync - see seq_list()
*/
- if (!strcmp(seq_cur, cp))
+ if (strcmp(seq_cur, cp)==0)
mp->curmsg = msgnum;
/*
** Get the number for this sequence
*/
for (i = 0; mp->msgattrs[i]; i++) {
- if (!strcmp(mp->msgattrs[i], cp)) {
+ if (strcmp(mp->msgattrs[i], cp)==0) {
new_seq = 0;
break;
}
** Get the number for this sequence
*/
for (i = 0; mp->msgattrs[i]; i++) {
- if (!strcmp(mp->msgattrs[i], cp)) {
+ if (strcmp(mp->msgattrs[i], cp)==0) {
new_seq = 0;
break;
}
return 0;
for (i = 0; mp->msgattrs[i]; i++) {
- if (!strcmp(mp->msgattrs[i], cp)) {
+ if (strcmp(mp->msgattrs[i], cp)==0) {
clear_sequence(mp, i, msgnum);
mp->msgflags |= SEQMOD;
return 1;
int i;
for (i = 0; mp->msgattrs[i]; i++)
- if (!strcmp(mp->msgattrs[i], seqname))
+ if (strcmp(mp->msgattrs[i], seqname)==0)
return i;
return -1;
** This is returned, even if message doesn't exist or the
** folder is empty.
*/
- if (!strcmp(seq_cur, seqname)) {
+ if (strcmp(seq_cur, seqname)==0) {
if (mp->curmsg) {
sprintf(buffer, "%s", m_name(mp->curmsg));
return (buffer);
plen = strlen(mp->foldpath) + 1;
for (np = m_defs; np; np = np->n_next) {
- if (strncmp(np->n_name, "atr-", alen)==0
- && (j = strlen(np->n_name) - plen) > alen
- && *(np->n_name + j) == '-'
- && strcmp(mp->foldpath, np->n_name + j + 1)
- == 0) {
+ if (strncmp(np->n_name, "atr-", alen)==0 &&
+ (j = strlen(np->n_name) - plen) > alen &&
+ *(np->n_name + j) == '-' &&
+ strcmp(mp->foldpath, np->n_name + j + 1)==0) {
cp = getcpy(np->n_name + alen);
*(cp + j - alen) = '\0';
if ((i = seq_init(mp, cp, getcpy(np->n_field))) != -1)
** Check if this is the cur sequence,
** so we can do some special things.
*/
- is_current = !strcmp(seq_cur, name);
+ is_current = (strcmp(seq_cur, name)==0);
/*
** Search for this sequence name to see if we've seen
** mesages in this folder.
*/
for (i = 0; mp->msgattrs[i]; i++) {
- if (!strcmp(mp->msgattrs[i], name)) {
+ if (strcmp(mp->msgattrs[i], name)==0) {
for (j = mp->lowmsg; j <= mp->hghmsg; j++)
clear_sequence(mp, i, j);
break;
** then really invoked the mhlproc instead
** (which is usually mhl anyway).
*/
- if (!strcmp(mhbasename(lproc), "mhl"))
+ if (strcmp(mhbasename(lproc), "mhl")==0)
lproc = mhlproc;
switch (pid = fork()) {
}
}
if (isdraft) {
- if (!strcmp(vec[0], "show"))
+ if (strcmp(vec[0], "show")==0)
vec[vecp++] = "-file";
vec[vecp++] = file;
}
register struct aka *ak = NULL;
register FILE *fp;
- if (*file!='/' && (strncmp(file, "./", 2) && strncmp(file, "../", 3)))
+ if (*file!='/' && (strncmp(file, "./", 2)!=0 &&
+ strncmp(file, "../", 3)!=0))
file = etcpath(file);
if ((fp = fopen(file, "r")) == NULL) {
akerrst = file;
struct passwd *pw;
#endif /* DBMPWD */
for (hm = homehead; hm; hm = hm->h_next)
- if (!strcmp(hm->h_name, gp)) {
+ if (strcmp(hm->h_name, gp)==0) {
add_aka(ak, hm->h_name);
break;
}
Everyone = EVERYONE;
for (hm = homehead; hm; hm = hm->h_next)
- if (hm->h_uid > Everyone
- && (noshell || strcmp(hm->h_shell, NoShell)))
+ if (hm->h_uid > Everyone && (noshell ||
+ strcmp(hm->h_shell, NoShell)!=0))
add_aka(ak, hm->h_name);
return homehead != NULL;
register struct adr *ad, *ld;
for (ad = ak->ak_addr, ld = NULL; ad; ld = ad, ad = ad->ad_next)
- if (!strcmp(pp, ad->ad_text))
+ if (strcmp(pp, ad->ad_text)==0)
return;
ad = (struct adr *) mh_xmalloc(sizeof(*ad));
setgrent();
while ((gr = getgrent())) {
for (i = 0; i < numgroups; i++)
- if (!strcmp(grps[i], gr->gr_name)) {
+ if (strcmp(grps[i], gr->gr_name)==0) {
setup();
fprintf(out, "duplicate group %s(gid=%d)\n",
gr->gr_name, (int) gr->gr_gid);
while ((gr = getgrent())) {
for (cp = gr->gr_mem; *cp; cp++) {
for (hm = homehead; hm; hm = hm->h_next)
- if (!strcmp(*cp, hm->h_name))
+ if (strcmp(*cp, hm->h_name)==0)
break;
if (hm == NULL) {
setup();
register struct home *hm;
for (hm = homehead; hm; hm = hm->h_next)
- if (!strcmp(s, hm->h_name))
+ if (strcmp(s, hm->h_name)==0)
return 1;
return 0;
}
ldelim[count] = 0;
- if (strcmp(ldelim, mmdlm2) && write(fd, "\n", 1) != 1
+ if (strcmp(ldelim, mmdlm2)!=0 && write(fd, "\n", 1) != 1
&& write(fd, mmdlm2, count) != count)
return NOTOK;
** Change the "Return-Path:" field
** (if in first line) back to "From ".
*/
- if (!strncmp(buffer, "Return-Path:", 12)) {
+ if (strncmp(buffer, "Return-Path:", 12)==0) {
char tmpbuffer[BUFSIZ];
char *tp, *ep, *fp;
fp = strchr(ep + 1, '\n');
tp = dctime(dlocaltimenow());
snprintf(buffer, sizeof(buffer), "From %.*s %s", (int)(fp - ep), ep, tp);
- } else if (!strncmp(buffer, "X-Envelope-From:",
- 16)) {
+ } else if (strncmp(buffer, "X-Envelope-From:",
+ 16)==0) {
/*
** Change the "X-Envelope-From:"
** field (if first line) back
ep = tmpbuffer + 17;
snprintf(buffer, sizeof(buffer),
"From %s", ep);
- } else if (strncmp(buffer, "From ", 5)) {
+ } else if (strncmp(buffer, "From ", 5)!=0) {
/*
** If there is already a "From "
** line, then leave it alone.
** If base directory, don't add it to the
** folder list. We just recurse into it.
*/
- if (!strcmp(dirName, ".")) {
+ if (strcmp(dirName, ".")==0) {
BuildFolderListRecurse(".", &st, 0);
return;
}
** A hack so that we don't see a
** leading "./" in folder names.
*/
- base = strcmp(dirName, ".") ? dirName : dirName + 1;
+ base = (strcmp(dirName, ".")==0) ? dirName + 1 : dirName;
while (nlinks && (dp = readdir(dir))) {
- if (!strcmp(dp->d_name, ".") || !strcmp(dp->d_name, "..")) {
+ if (strcmp(dp->d_name, ".")==0 ||
+ strcmp(dp->d_name, "..")==0) {
nlinks--;
continue;
}
for (j = 0; j < numsequences; j++) {
if (folders[i].nSeq[j] > 0 || showzero) {
/* Add `+' to end of name of current folder */
- if (strcmp(curfol, folders[i].name))
+ if (strcmp(curfol, folders[i].name)!=0)
snprintf(tmpname, sizeof(tmpname),
"%s", folders[i].name);
else
nl = strlen(name);
for (i = 0; i < nOrders; ++i) {
o = &orders[i];
- if (!strcmp(name, o->name))
+ if (strcmp(name, o->name)==0)
return o->priority;
ol = strlen(o->name);
if (nl < ol - 1)
continue;
if (ol < bestLen)
continue;
- if (o->name[0] == '*' && !strcmp(o->name + 1,
- name + (nl - ol + 1))) {
+ if (o->name[0] == '*' &&
+ strcmp(o->name + 1, name + (nl - ol + 1))==0) {
best = o->priority;
bestLen = ol;
} else if (o->name[ol - 1] == '*' &&
}
/* Add `+' to end of name, if folder is current */
- if (strcmp(folder, fi[i].name))
+ if (strcmp(folder, fi[i].name)!=0)
snprintf(tmpname, sizeof(tmpname), "%s",
fi[i].name);
else
return NOTOK;
}
- istore = !strcmp(cmd, "STOR");
+ istore = (strcmp(cmd, "STOR")==0);
- if ((istdio = !strcmp(local, "-")))
+ if ((istdio = strcmp(local, "-")==0))
fp = istore ? stdin : stdout;
else
if ((fp = fopen(local, istore ? "r" : "w")) == NULL) {
return NOTOK;
}
- return(getreply(complete, !strcmp(buffer, "QUIT")));
+ return(getreply(complete, strcmp(buffer, "QUIT")==0));
}
set_endian();
- if ((cp = getenv("MM_NOASK")) && !strcmp(cp, "1"))
+ if ((cp = getenv("MM_NOASK")) && strcmp(cp, "1")==0)
listsw = 0;
/*
if (!isspace(*cp))
break;
*++cp = '\0';
- if (!strncmp(buffer + 2, prefix, len) &&
+ if (strncmp(buffer + 2, prefix, len)==0 &&
isdigit(buffer[2 + len])) {
boundaryclash = 1;
/* no need to keep checking */
for (ap = parts; *ap; ap++) {
len = strlen(*ap);
- if (!strncmp(*ap, ct->c_partno, len) &&
+ if (strncmp(*ap, ct->c_partno, len)==0 &&
(!ct->c_partno[len] ||
ct->c_partno[len] == '.' ))
return 1;
/*
** Check if file is actually standard input
*/
- if ((is_stdin = !(strcmp(file, "-")))) {
+ if ((is_stdin = (strcmp(file, "-")==0))) {
char *tfile = m_mktemp2(NULL, invo_name, NULL, &fp);
if (tfile == NULL) {
advise("mhparse", "unable to create temporary file");
if (buffer[0] != '-' || buffer[1] != '-')
continue;
if (inout) {
- if (strcmp(buffer + 2, m->mp_start))
+ if (strcmp(buffer + 2, m->mp_start)!=0)
continue;
next_part:
if ((part = (struct part *) calloc(1, sizeof(*part)))
set_endian();
- if ((cp = getenv("MM_NOASK")) && !strcmp(cp, "1")) {
+ if ((cp = getenv("MM_NOASK")) && strcmp(cp, "1")==0) {
nolist = 1;
pausesw = 0;
}
/*
** If form is "mhl.null", suppress display of header.
*/
- if (!strcmp(formsw, "mhl.null"))
+ if (strcmp(formsw, "mhl.null")==0)
formsw = NULL;
for (ctp = cts; *ctp; ctp++) {
file = NULL;
if ((fd = (*ct->c_ceopenfnx) (ct, &file)) == NOTOK)
return NOTOK;
- if (ct->c_showproc && !strcmp(ct->c_showproc, "true"))
+ if (ct->c_showproc && strcmp(ct->c_showproc, "true")==0)
return (alternate ? DONE : OK);
xlist = 0;
/* I'm not sure if this is necessary? */
p->c_storage = getcpy(file);
- if (p->c_showproc && !strcmp(p->c_showproc, "true"))
+ if (p->c_showproc && strcmp(p->c_showproc, "true")==0)
return (alternate ? DONE : OK);
(*p->c_ceclosefnx) (p);
}
if (ct->c_folder) {
fprintf(stderr, " to folder %s as message %d\n",
ct->c_folder, msgnum);
- } else if (!strcmp(ct->c_storage, "-")) {
+ } else if (strcmp(ct->c_storage, "-")==0) {
fprintf(stderr, " to stdout\n");
} else {
int cwdlen;
cwdlen = strlen(cwd);
fprintf(stderr, " as file %s\n",
- strncmp(ct->c_storage, cwd, cwdlen) ||
+ strncmp(ct->c_storage, cwd,
+ cwdlen)!=0 ||
ct->c_storage[cwdlen] != '/' ?
ct->c_storage :
ct->c_storage + cwdlen + 1);
return NOTOK;
}
- file = appending || !strcmp(ct->c_storage, "-") ?
+ file = appending || strcmp(ct->c_storage, "-")==0 ?
NULL : ct->c_storage;
if ((fd = (*ct->c_ceopenfnx) (ct, &file)) == NOTOK)
return NOTOK;
- if (!strcmp(file, ct->c_storage)) {
+ if (strcmp(file, ct->c_storage)==0) {
(*ct->c_ceclosefnx) (ct);
return OK;
}
/*
** Send to standard output
*/
- if (!strcmp(ct->c_storage, "-")) {
+ if (strcmp(ct->c_storage, "-")==0) {
int gd;
if ((gd = dup(fileno(stdout))) == NOTOK) {
last = ct->c_end;
fseek(ct->c_fp, pos, SEEK_SET);
- if (!strcmp(ct->c_storage, "-")) {
+ if (strcmp(ct->c_storage, "-")==0) {
int gd;
if ((gd = dup(fileno(stdout))) == NOTOK) {
if (rmf(folder) == OK) {
char *cfolder = context_find(curfolder);
- if (cfolder && strcmp(cfolder, newfolder)) {
+ if (cfolder && strcmp(cfolder, newfolder)!=0) {
printf("[+%s now current]\n", newfolder);
/* update current folder */
context_replace(curfolder, newfolder);
** add the path to the message names. Currently, we are just
** checking for mhn here, since we've already taken care of mhl.
*/
- if (!strcmp(mhbasename(proc), "mhl")
+ if (strcmp(mhbasename(proc), "mhl")==0
&& !file
&& chdir(maildir =
concat(toabsdir("+"), "/", NULL)) != NOTOK) {
while (fgets(buffer, sizeof(buffer), qfp)) {
if (first) {
first = 0;
- if (!strncmp(buffer, "From ", i)) {
+ if (strncmp(buffer, "From ", i)==0) {
#ifdef RPATHS
char *fp, *cp, *hp, *ep;
#endif
char *cp, *sp, *vec[MAXARGS];
/* Translate MIME composition file, if necessary */
- if ((cp = context_find("automimeproc")) && (!strcmp(cp, "1")) &&
+ if ((cp = context_find("automimeproc")) && (strcmp(cp, "1")==0) &&
!getenv("NOMHNPROC") && check_draft(file) &&
(buildfile(NULL, file) == NOTOK))
return 0;