Module Name: src
Committed By: christos
Date: Wed Feb 20 14:38:13 UTC 2013
Modified Files:
src/usr.bin/mail: fio.c lex.c
Log Message:
PR/47577: Steffen "Daode" Nurpmeso: Refinement to previous to keep always
keep track of the folder when it is updated.
To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/mail/fio.c
cvs rdiff -u -r1.42 -r1.43 src/usr.bin/mail/lex.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/mail/fio.c
diff -u src/usr.bin/mail/fio.c:1.37 src/usr.bin/mail/fio.c:1.38
--- src/usr.bin/mail/fio.c:1.37 Tue Feb 19 12:43:32 2013
+++ src/usr.bin/mail/fio.c Wed Feb 20 09:38:13 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: fio.c,v 1.37 2013/02/19 17:43:32 christos Exp $ */
+/* $NetBSD: fio.c,v 1.38 2013/02/20 14:38:13 christos Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)fio.c 8.2 (Berkeley) 4/20/95";
#else
-__RCSID("$NetBSD: fio.c,v 1.37 2013/02/19 17:43:32 christos Exp $");
+__RCSID("$NetBSD: fio.c,v 1.38 2013/02/20 14:38:13 christos Exp $");
#endif
#endif /* not lint */
@@ -397,15 +397,15 @@ getfold(char *name, size_t namesize)
if ((folder = value(ENAME_FOLDER)) == NULL)
return -1;
- if (*folder == '/')
- (void)strlcpy(unres, folder, sizeof(unres));
- else
+ if (*folder != '/') {
(void)snprintf(unres, sizeof(unres), "%s/%s", homedir, folder);
- if (realpath(unres, res) == NULL) {
- warn("Can't canonicalize folder `%s'", unres);
- (void)strlcpy(name, unres, namesize);
- } else
- (void)strlcpy(name, res, namesize);
+ folder = unres;
+ }
+ if (realpath(folder, res) == NULL)
+ warn("Can't canonicalize folder `%s'", folder);
+ else
+ folder = res;
+ (void)strlcpy(name, folder, namesize);
return 0;
}
Index: src/usr.bin/mail/lex.c
diff -u src/usr.bin/mail/lex.c:1.42 src/usr.bin/mail/lex.c:1.43
--- src/usr.bin/mail/lex.c:1.42 Tue Feb 19 12:43:32 2013
+++ src/usr.bin/mail/lex.c Wed Feb 20 09:38:13 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: lex.c,v 1.42 2013/02/19 17:43:32 christos Exp $ */
+/* $NetBSD: lex.c,v 1.43 2013/02/20 14:38:13 christos Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)lex.c 8.2 (Berkeley) 4/20/95";
#else
-__RCSID("$NetBSD: lex.c,v 1.42 2013/02/19 17:43:32 christos Exp $");
+__RCSID("$NetBSD: lex.c,v 1.43 2013/02/20 14:38:13 christos Exp $");
#endif
#endif /* not lint */
@@ -147,7 +147,8 @@ update_mailname(const char *name)
char tbuf[PATHSIZE];
size_t l;
- if (realpath(name, mailname) == NULL) {
+ /* Don't realpath(3) if it's only an update request */
+ if (name != NULL && realpath(name, mailname) == NULL) {
warn("Can't canonicalize `%s'", name);
return;
}
@@ -272,8 +273,7 @@ setfile(const char *name)
shudclob = 1;
edit = isedit;
(void)strcpy(prevfile, mailname);
- if (name != mailname)
- update_mailname(name);
+ update_mailname(name != mailname ? name : NULL);
mailsize = fsize(ibuf);
(void)snprintf(tempname, sizeof(tempname),
"%s/mail.RxXXXXXXXXXX", tmpdir);
@@ -1057,6 +1057,7 @@ newfileinfo(int omsgCount)
/*
* Display the statistics.
*/
+ update_mailname(NULL);
(void)printf("\"%s\": ", displayname);
{
int cnt = get_abs_msgCount();