Deleted Added
full compact
write.c (11898) write.c (11916)
1/*
2 * Copyright (c) 1989, 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 * Jef Poskanzer and Craig Leres of the Lawrence Berkeley Laboratory.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

298
299/*
300 * wr_fputs - like fputs(), but makes control characters visible and
301 * turns \n into \r\n
302 */
303wr_fputs(s)
304 register char *s;
305{
1/*
2 * Copyright (c) 1989, 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 * Jef Poskanzer and Craig Leres of the Lawrence Berkeley Laboratory.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

298
299/*
300 * wr_fputs - like fputs(), but makes control characters visible and
301 * turns \n into \r\n
302 */
303wr_fputs(s)
304 register char *s;
305{
306 register char c;
307
308#define PUTC(c) if (putchar(c) == EOF) goto err;
309
310 for (; *s != '\0'; ++s) {
306
307#define PUTC(c) if (putchar(c) == EOF) goto err;
308
309 for (; *s != '\0'; ++s) {
311 c = *s;
312 if (c == '\n') {
310 if (*s == '\n') {
313 PUTC('\r');
314 PUTC('\n');
311 PUTC('\r');
312 PUTC('\n');
315 } else if (!isprint(c) && !isspace(c) && c != '\007') {
313 } else if (!isprint(*s) && !isspace(*s) && *s != '\007') {
316 PUTC('^');
314 PUTC('^');
317 PUTC(c^0x40); /* DEL to ?, others to alpha */
315 PUTC((*s^0x40)&~0x80); /* DEL to ?, others to alpha */
318 } else
316 } else
319 PUTC(c);
317 PUTC(*s);
320 }
321 return;
322
323err: (void)fprintf(stderr, "write: %s\n", strerror(errno));
324 exit(1);
325#undef PUTC
326}
318 }
319 return;
320
321err: (void)fprintf(stderr, "write: %s\n", strerror(errno));
322 exit(1);
323#undef PUTC
324}