- /*
- * build path of user's mail box and get stats; if missing
- * or empty, no mail.
- */
- (void)sprintf(tbuf, "%s/%s", _PATH_MAILDIR, pn->name);
- if (stat(tbuf, &sb) < 0 || !sb.st_size) {
- (void)printf("No unread mail.\n");
- return;
- }
-
- /*
- * if access time matches the modification time then we know
- * that new mail was received but we haven't a clue as to when
- * it was last read.
- */
- date = ctime(&sb.st_ctime);
- if (sb.st_atime == sb.st_ctime)
- (void)printf("New mail received %16.16s.\n", date);
- else if (sb.st_atime > sb.st_ctime) {
- date = ctime(&sb.st_atime);
- (void)printf("No new mail, last read %16.16s.\n", date);
- } else {
- (void)printf("Mail received %16.16s; ", date);
- date = ctime(&sb.st_atime);
- (void)printf("last read %16.16s.\n", date);
+ if (!isascii(ch)) {
+ (void)putchar('M');
+ (void)putchar('-');
+ ch = toascii(ch);
+ meta = 1;
+ } else
+ meta = 0;
+ if (isprint(ch) || !meta && (ch == ' ' || ch == '\t' || ch == '\n'))
+ (void)putchar(ch);
+ else {
+ (void)putchar('^');
+ (void)putchar(ch == '\177' ? '?' : ch | 0100);