SCCS-vsn: usr.bin/tail/forward.c 5.4
-static char sccsid[] = "@(#)forward.c 5.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)forward.c 5.4 (Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#endif /* not lint */
#include <sys/types.h>
if ((p = mmap(NULL,
size, PROT_READ, MAP_FILE, fileno(fp), (off_t)0)) == (caddr_t)-1)
err("%s", strerror(errno));
if ((p = mmap(NULL,
size, PROT_READ, MAP_FILE, fileno(fp), (off_t)0)) == (caddr_t)-1)
err("%s", strerror(errno));
/* Last char is special, ignore whether newline or not. */
/* Last char is special, ignore whether newline or not. */
- while (--size)
- if (*--p == '\n' && !--off)
+ for (p += size - 1; --size;)
+ if (*--p == '\n' && !--off) {
+ ++p;
/* Set the file pointer to reflect the length displayed. */
size = sbp->st_size - size;
/* Set the file pointer to reflect the length displayed. */
size = sbp->st_size - size;
if (fseek(fp, sbp->st_size, SEEK_SET) == -1)
ierr();
}
if (fseek(fp, sbp->st_size, SEEK_SET) == -1)
ierr();
}