Deleted Added
full compact
forward.c (17826) forward.c (17833)
1/*-
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Edward Sze-Tyan Wang.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 191 unchanged lines hidden (view full) ---

200 register char *p;
201 char *start;
202
203 if (!(size = sbp->st_size))
204 return;
205
206 if (size > SIZE_T_MAX) {
207 errno = EFBIG;
1/*-
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * Edward Sze-Tyan Wang.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 191 unchanged lines hidden (view full) ---

200 register char *p;
201 char *start;
202
203 if (!(size = sbp->st_size))
204 return;
205
206 if (size > SIZE_T_MAX) {
207 errno = EFBIG;
208 err(0, "%s", fname);
208 ierr();
209 return;
210 }
211
212 if ((start = mmap(NULL, (size_t)size,
213 PROT_READ, 0, fileno(fp), (off_t)0)) == (caddr_t)-1) {
209 return;
210 }
211
212 if ((start = mmap(NULL, (size_t)size,
213 PROT_READ, 0, fileno(fp), (off_t)0)) == (caddr_t)-1) {
214 err(0, "%s", fname);
214 ierr();
215 return;
216 }
217
218 /* Last char is special, ignore whether newline or not. */
219 for (p = start + size - 1; --size;)
220 if (*--p == '\n' && !--off) {
221 ++p;
222 break;
223 }
224
225 /* Set the file pointer to reflect the length displayed. */
226 size = sbp->st_size - size;
227 WR(p, size);
228 if (fseek(fp, (long)sbp->st_size, SEEK_SET) == -1) {
229 ierr();
230 return;
231 }
232 if (munmap(start, (size_t)sbp->st_size)) {
215 return;
216 }
217
218 /* Last char is special, ignore whether newline or not. */
219 for (p = start + size - 1; --size;)
220 if (*--p == '\n' && !--off) {
221 ++p;
222 break;
223 }
224
225 /* Set the file pointer to reflect the length displayed. */
226 size = sbp->st_size - size;
227 WR(p, size);
228 if (fseek(fp, (long)sbp->st_size, SEEK_SET) == -1) {
229 ierr();
230 return;
231 }
232 if (munmap(start, (size_t)sbp->st_size)) {
233 err(0, "%s", fname);
233 ierr();
234 return;
235 }
236}
234 return;
235 }
236}