1
0
mirror of https://github.com/openbsd/src.git synced 2024-12-22 16:42:56 -08:00

- use strncmp/strncasecmp instead of comparing by character

- simplify istrlcpy, no need to check for isupper
- line[0] is redundant, because strcasecmp will take care of it
ok millert@
This commit is contained in:
martynas 2008-07-16 14:53:41 +00:00
parent c086f8ec4d
commit 0ab8ef8408
5 changed files with 17 additions and 22 deletions

View File

@ -1,4 +1,4 @@
/* $OpenBSD: aux.c,v 1.23 2008/07/15 19:23:26 martynas Exp $ */
/* $OpenBSD: aux.c,v 1.24 2008/07/16 14:53:41 martynas Exp $ */
/* $NetBSD: aux.c,v 1.5 1997/05/13 06:15:52 mikel Exp $ */
/*
@ -34,7 +34,7 @@
#if 0
static const char sccsid[] = "@(#)aux.c 8.1 (Berkeley) 6/6/93";
#else
static const char rcsid[] = "$OpenBSD: aux.c,v 1.23 2008/07/15 19:23:26 martynas Exp $";
static const char rcsid[] = "$OpenBSD: aux.c,v 1.24 2008/07/16 14:53:41 martynas Exp $";
#endif
#endif /* not lint */
@ -241,9 +241,7 @@ istrlcpy(char *dst, const char *src, size_t dsize)
/* Copy as many bytes as will fit */
if (n != 0 && --n != 0) {
do {
if (isupper(*s))
*d++ = tolower(*s++);
else if ((*d++ = *s++) == 0)
if ((*d++ = tolower(*s++)) == 0)
break;
} while (--n != 0);
}
@ -464,10 +462,10 @@ skin(char *name)
break;
case ' ':
if (cp[0] == 'a' && cp[1] == 't' && cp[2] == ' ')
if (strncmp(cp, "at ", 3) == 0)
cp += 3, *cp2++ = '@';
else
if (cp[0] == '@' && cp[1] == ' ')
if (strncmp(cp, "@ ", 2) == 0)
cp += 2, *cp2++ = '@';
else
lastsp = 1;

View File

@ -1,4 +1,4 @@
/* $OpenBSD: cmd3.c,v 1.20 2003/06/03 02:56:11 millert Exp $ */
/* $OpenBSD: cmd3.c,v 1.21 2008/07/16 14:53:41 martynas Exp $ */
/* $NetBSD: cmd3.c,v 1.8 1997/07/09 05:29:49 mikel Exp $ */
/*
@ -34,7 +34,7 @@
#if 0
static const char sccsid[] = "@(#)cmd3.c 8.2 (Berkeley) 4/20/95";
#else
static const char rcsid[] = "$OpenBSD: cmd3.c,v 1.20 2003/06/03 02:56:11 millert Exp $";
static const char rcsid[] = "$OpenBSD: cmd3.c,v 1.21 2008/07/16 14:53:41 martynas Exp $";
#endif
#endif /* not lint */
@ -265,9 +265,7 @@ reedit(char *subj)
if (subj == NULL)
return(NULL);
if ((subj[0] == 'r' || subj[0] == 'R') &&
(subj[1] == 'e' || subj[1] == 'E') &&
subj[2] == ':')
if (strncasecmp(subj, "re:", 3) == 0)
return(subj);
len = strlen(subj) + 5;
newsubj = salloc(len);

View File

@ -1,4 +1,4 @@
/* $OpenBSD: collect.c,v 1.28 2007/09/10 14:29:53 tobias Exp $ */
/* $OpenBSD: collect.c,v 1.29 2008/07/16 14:53:41 martynas Exp $ */
/* $NetBSD: collect.c,v 1.9 1997/07/09 05:25:45 mikel Exp $ */
/*
@ -34,7 +34,7 @@
#if 0
static const char sccsid[] = "@(#)collect.c 8.2 (Berkeley) 4/19/94";
#else
static const char rcsid[] = "$OpenBSD: collect.c,v 1.28 2007/09/10 14:29:53 tobias Exp $";
static const char rcsid[] = "$OpenBSD: collect.c,v 1.29 2008/07/16 14:53:41 martynas Exp $";
#endif
#endif /* not lint */
@ -533,7 +533,7 @@ forward(char *ms, FILE *fp, char *fn, int f)
}
msgvec[1] = NULL;
}
if (f == 'f' || f == 'F')
if (tolower(f) == 'f')
tabst = NULL;
else if ((tabst = value("indentprefix")) == NULL)
tabst = "\t";

View File

@ -1,4 +1,4 @@
/* $OpenBSD: head.c,v 1.9 2003/06/03 02:56:11 millert Exp $ */
/* $OpenBSD: head.c,v 1.10 2008/07/16 14:53:41 martynas Exp $ */
/* $NetBSD: head.c,v 1.6 1996/12/28 07:11:03 tls Exp $ */
/*
@ -34,7 +34,7 @@
#if 0
static const char sccsid[] = "@(#)head.c 8.2 (Berkeley) 4/20/95";
#else
static const char rcsid[] = "$OpenBSD: head.c,v 1.9 2003/06/03 02:56:11 millert Exp $";
static const char rcsid[] = "$OpenBSD: head.c,v 1.10 2008/07/16 14:53:41 martynas Exp $";
#endif
#endif /* not lint */
@ -114,7 +114,7 @@ parse(char *line, struct headline *hl, char *pbuf)
cp = nextword(cp, word);
if (*word)
hl->l_from = copyin(word, &sp);
if (cp != NULL && cp[0] == 't' && cp[1] == 't' && cp[2] == 'y') {
if (cp != NULL && strncmp(cp, "tty", 3) == 0) {
cp = nextword(cp, word);
hl->l_tty = copyin(word, &sp);
}

View File

@ -1,4 +1,4 @@
/* $OpenBSD: send.c,v 1.18 2007/03/20 21:01:08 millert Exp $ */
/* $OpenBSD: send.c,v 1.19 2008/07/16 14:53:41 martynas Exp $ */
/* $NetBSD: send.c,v 1.6 1996/06/08 19:48:39 christos Exp $ */
/*
@ -34,7 +34,7 @@
#if 0
static const char sccsid[] = "@(#)send.c 8.1 (Berkeley) 6/6/93";
#else
static const char rcsid[] = "$OpenBSD: send.c,v 1.18 2007/03/20 21:01:08 millert Exp $";
static const char rcsid[] = "$OpenBSD: send.c,v 1.19 2008/07/16 14:53:41 martynas Exp $";
#endif
#endif /* not lint */
@ -167,8 +167,7 @@ sendmessage(struct message *mp, FILE *obuf, struct ignoretab *doign,
*cp2 = 0; /* temporarily null terminate */
if (doign && isign(line, doign))
ignoring = 1;
else if ((line[0] == 's' || line[0] == 'S') &&
strcasecmp(line, "status") == 0) {
else if (strcasecmp(line, "status") == 0) {
/*
* If the field is "status," go compute
* and print the real Status: field