Deleted Added
full compact
wall.c (155875) wall.c (175346)
1/*
2 * Copyright (c) 1988, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#include <sys/cdefs.h>
35
1/*
2 * Copyright (c) 1988, 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#include <sys/cdefs.h>
35
36__FBSDID("$FreeBSD: head/usr.bin/wall/wall.c 155875 2006-02-21 13:01:00Z cognet $");
36__FBSDID("$FreeBSD: head/usr.bin/wall/wall.c 175346 2008-01-15 07:40:30Z das $");
37
38#ifndef lint
39static const char copyright[] =
40"@(#) Copyright (c) 1988, 1990, 1993\n\
41 The Regents of the University of California. All rights reserved.\n";
42#endif
43
44#ifndef lint

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

246
247 if (fname) {
248 egid = getegid();
249 setegid(getgid());
250 if (freopen(fname, "r", stdin) == NULL)
251 err(1, "can't read %s", fname);
252 setegid(egid);
253 }
37
38#ifndef lint
39static const char copyright[] =
40"@(#) Copyright (c) 1988, 1990, 1993\n\
41 The Regents of the University of California. All rights reserved.\n";
42#endif
43
44#ifndef lint

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

246
247 if (fname) {
248 egid = getegid();
249 setegid(getgid());
250 if (freopen(fname, "r", stdin) == NULL)
251 err(1, "can't read %s", fname);
252 setegid(egid);
253 }
254 while (fgets(lbuf, sizeof(lbuf), stdin))
254 while (fgets(lbuf, sizeof(lbuf), stdin)) {
255 for (cnt = 0, p = lbuf; (ch = *p) != '\0'; ++p, ++cnt) {
256 if (ch == '\r') {
255 for (cnt = 0, p = lbuf; (ch = *p) != '\0'; ++p, ++cnt) {
256 if (ch == '\r') {
257 putc('\r', fp);
257 cnt = 0;
258 cnt = 0;
258 } else if (cnt == 79 || ch == '\n') {
259 continue;
260 } else if (ch == '\n') {
259 for (; cnt < 79; ++cnt)
260 putc(' ', fp);
261 putc('\r', fp);
262 putc('\n', fp);
261 for (; cnt < 79; ++cnt)
262 putc(' ', fp);
263 putc('\r', fp);
264 putc('\n', fp);
265 break;
266 }
267 if (cnt == 79) {
268 putc('\r', fp);
269 putc('\n', fp);
263 cnt = 0;
270 cnt = 0;
264 } else if (((ch & 0x80) && ch < 0xA0) ||
271 }
272 if (((ch & 0x80) && ch < 0xA0) ||
265 /* disable upper controls */
266 (!isprint(ch) && !isspace(ch) &&
267 ch != '\a' && ch != '\b')
268 ) {
269 if (ch & 0x80) {
270 ch &= 0x7F;
271 putc('M', fp);
272 if (++cnt == 79) {

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

285 ch ^= 040;
286 putc('^', fp);
287 if (++cnt == 79) {
288 putc('\r', fp);
289 putc('\n', fp);
290 cnt = 0;
291 }
292 }
273 /* disable upper controls */
274 (!isprint(ch) && !isspace(ch) &&
275 ch != '\a' && ch != '\b')
276 ) {
277 if (ch & 0x80) {
278 ch &= 0x7F;
279 putc('M', fp);
280 if (++cnt == 79) {

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

293 ch ^= 040;
294 putc('^', fp);
295 if (++cnt == 79) {
296 putc('\r', fp);
297 putc('\n', fp);
298 cnt = 0;
299 }
300 }
293 putc(ch, fp);
294 } else {
295 putc(ch, fp);
296 }
301 }
302 putc(ch, fp);
297 }
303 }
304 }
298 (void)fprintf(fp, "%79s\r\n", " ");
299 rewind(fp);
300
301 if (fstat(fd, &sbuf))
302 err(1, "can't stat temporary file");
303 mbufsize = sbuf.st_size;
304 if (!(mbuf = malloc((u_int)mbufsize)))
305 err(1, "out of memory");
306 if ((int)fread(mbuf, sizeof(*mbuf), mbufsize, fp) != mbufsize)
307 err(1, "can't read temporary file");
308 (void)close(fd);
309}
305 (void)fprintf(fp, "%79s\r\n", " ");
306 rewind(fp);
307
308 if (fstat(fd, &sbuf))
309 err(1, "can't stat temporary file");
310 mbufsize = sbuf.st_size;
311 if (!(mbuf = malloc((u_int)mbufsize)))
312 err(1, "out of memory");
313 if ((int)fread(mbuf, sizeof(*mbuf), mbufsize, fp) != mbufsize)
314 err(1, "can't read temporary file");
315 (void)close(fd);
316}