summaryrefslogtreecommitdiffstats
path: root/lib/libutil/logwtmp.c
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>1999-04-07 14:03:31 +0000
committerbrian <brian@FreeBSD.org>1999-04-07 14:03:31 +0000
commit37c783b7891d1cfb8771028b6893c5d5d88f804e (patch)
tree39863ec31fda087e67c2b1dc1254ae0c6f8dc98e /lib/libutil/logwtmp.c
parentbdfcb84054121852260eb6336ff07e7ca57ee832 (diff)
downloadFreeBSD-src-37c783b7891d1cfb8771028b6893c5d5d88f804e.zip
FreeBSD-src-37c783b7891d1cfb8771028b6893c5d5d88f804e.tar.gz
Tidy up trimdomain() and document it.
Don't truncate one byte short of the passed length.
Diffstat (limited to 'lib/libutil/logwtmp.c')
-rw-r--r--lib/libutil/logwtmp.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/lib/libutil/logwtmp.c b/lib/libutil/logwtmp.c
index 9759578..acbb4c9 100644
--- a/lib/libutil/logwtmp.c
+++ b/lib/libutil/logwtmp.c
@@ -36,7 +36,7 @@
static char sccsid[] = "@(#)logwtmp.c 8.1 (Berkeley) 6/4/93";
#else
static const char rcsid[] =
- "$Id: logwtmp.c,v 1.8 1998/10/09 11:24:19 jkh Exp $";
+ "$Id: logwtmp.c,v 1.9 1999/04/07 08:27:04 brian Exp $";
#endif
#endif /* LIBC_SCCS and not lint */
@@ -55,7 +55,7 @@ static const char rcsid[] =
#include <utmp.h>
void
-trimdomain( char * fullhost, int hostsize )
+trimdomain(char *fullhost, int hostsize)
{
static char domain[MAXHOSTNAMELEN];
static int first = 1;
@@ -67,21 +67,18 @@ trimdomain( char * fullhost, int hostsize )
(s = strchr(domain, '.')))
bcopy(s + 1, domain, strlen(s + 1) + 1);
else
- domain[0] = 0;
+ domain[0] = '\0';
}
- if (domain[0]) {
- s = fullhost;
- while ((fullhost = strchr(fullhost, '.'))) {
+ if (domain[0] != '\0') {
+ s = fullhost;
+ while ((fullhost = strchr(fullhost, '.')) != NULL)
if (!strcasecmp(fullhost + 1, domain)) {
- if ( fullhost - s < hostsize ) {
+ if (fullhost - s <= hostsize)
*fullhost = '\0'; /* hit it and acceptable size*/
- }
break;
- } else {
+ } else
fullhost++;
- }
- }
}
}
OpenPOWER on IntegriCloud