Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/sh If we are going to keep the MAILPATH % hack, then at ...
details: https://anonhg.NetBSD.org/src/rev/480107915af9
branches: trunk
changeset: 354123:480107915af9
user: kre <kre%NetBSD.org@localhost>
date: Sun Jun 04 20:28:13 2017 +0000
description:
If we are going to keep the MAILPATH % hack, then at least do something
rational. Since it isn't documented, what "rational" is is up for
discussion, but what it did before was not it (it was nonsense...).
diffstat:
bin/sh/mail.c | 37 ++++++++++++++++++++++++++++++-------
1 files changed, 30 insertions(+), 7 deletions(-)
diffs (81 lines):
diff -r 0d7273e53633 -r 480107915af9 bin/sh/mail.c
--- a/bin/sh/mail.c Sun Jun 04 20:27:14 2017 +0000
+++ b/bin/sh/mail.c Sun Jun 04 20:28:13 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mail.c,v 1.17 2017/06/04 20:27:14 kre Exp $ */
+/* $NetBSD: mail.c,v 1.18 2017/06/04 20:28:13 kre Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)mail.c 8.2 (Berkeley) 5/4/95";
#else
-__RCSID("$NetBSD: mail.c,v 1.17 2017/06/04 20:27:14 kre Exp $");
+__RCSID("$NetBSD: mail.c,v 1.18 2017/06/04 20:28:13 kre Exp $");
#endif
#endif /* not lint */
@@ -47,6 +47,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
+#include <string.h>
#include "shell.h"
#include "exec.h" /* defines padvance() */
@@ -61,7 +62,7 @@
STATIC int nmboxes; /* number of mailboxes */
-STATIC time_t mailtime[MAXMBOXES]; /* times of mailboxes */
+STATIC off_t mailsize[MAXMBOXES]; /* sizes of mailboxes */
@@ -94,7 +95,8 @@
stunalloc(p);
if (*p == '\0')
continue;
- for (q = p ; *q ; q++);
+ for (q = p ; *q ; q++)
+ ;
if (q[-1] != '/')
abort();
q[-1] = '\0'; /* delete trailing '/' */
@@ -109,11 +111,32 @@
#else /* this is what it should do */
if (stat(p, &statb) < 0)
statb.st_size = 0;
- if (statb.st_size > mailtime[i] && ! silent) {
- out2str(pathopt ? pathopt : "you have mail");
+ if (statb.st_size > mailsize[i] && ! silent) {
+ const char *pp;
+
+ if ((pp = pathopt) != NULL) {
+ int len = 0;
+
+ while (*pp && *pp != ':')
+ len++, pp++;
+ if (len == 0) {
+ CHECKSTRSPACE(16, p);
+ strcat(p, ": file changed");
+ } else {
+ while (stackblocksize() <= len)
+ growstackblock();
+ p = stackblock();
+ memcpy(p, pathopt, len);
+ p[len] = '\0';
+ }
+ pp = p;
+ } else
+ pp = "you have mail";
+
+ out2str(pp);
out2c('\n');
}
- mailtime[i] = statb.st_size;
+ mailsize[i] = statb.st_size;
#endif
}
nmboxes = i;
Home |
Main Index |
Thread Index |
Old Index