NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: PR/47577 CVS commit: src/usr.bin/mail
The following reply was made to PR bin/47577; it has been noted by GNATS.
From: Steffen "Daode" Nurpmeso <sdaoden%gmail.com@localhost>
To: gnats-bugs%NetBSD.org@localhost
Cc: gnats-admin%netbsd.org@localhost, netbsd-bugs%netbsd.org@localhost
Subject: Re: PR/47577 CVS commit: src/usr.bin/mail
Date: Wed, 20 Feb 2013 13:44:50 +0100
Hello,
| Committed By: christos
| Date: Tue Feb 19 17:43:33 UTC 2013
|=20
| Modified Files:
| src/usr.bin/mail: fio.c glob.h lex.c
|=20
| Log Message:
| PR/47577: Steffen "Daode" Nurpmeso: Keep a resolved folder name together
| with a display name in order to keep track of current state when the \
|directory
| is changed.
I'm not happy with the code after all -- it doesn't recognize
concurrent changes of the *folder* option (and assign() and
unset() do not check for special variables to perform necessary
updates).
So here is a refinement which is of smaller code size and prints
correct results even if *folder* is modified on the fly.
Thanks
--steffen
--- fio.c.orig 2013-02-19 06:58:25.000000000 +0100
+++ fio.c 2013-02-19 07:09:47.000000000 +0100
@@ -397,15 +397,15 @@ getfold(char *name, size_t namesize)
=20
if ((folder =3D value(ENAME_FOLDER)) =3D=3D NULL)
return -1;
- if (*folder =3D=3D '/')
- (void)strlcpy(unres, folder, sizeof(unres));
- else
+ if (*folder !=3D '/') {
(void)snprintf(unres, sizeof(unres), "%s/%s", homedir, folder);
- if (realpath(unres, res) =3D=3D NULL) {
- warn("Can't canonicalize folder `%s'", unres);
- (void)strlcpy(name, unres, namesize);
- } else
- (void)strlcpy(name, res, namesize);
+ folder =3D unres;
+ }
+ if (realpath(folder, res) =3D=3D NULL)
+ warn("Can't canonicalize folder `%s'", folder);
+ else
+ folder =3D res;
+ (void)strlcpy(name, folder, namesize);
return 0;
}
=20
--- lex.c.orig 2013-02-19 06:58:25.000000000 +0100
+++ lex.c 2013-02-19 07:09:47.000000000 +0100
@@ -147,7 +147,8 @@ update_mailname(const char *name)
char tbuf[PATHSIZE];
size_t l;
=20
- if (realpath(name, mailname) =3D=3D NULL) {
+ /* Don't realpath(3) if it's only an update request */
+ if (name !=3D NULL && realpath(name, mailname) =3D=3D NULL) {
warn("Can't canonicalize `%s'", name);
return;
}
@@ -272,8 +273,7 @@ setfile(const char *name)
shudclob =3D 1;
edit =3D isedit;
(void)strcpy(prevfile, mailname);
- if (name !=3D mailname)
- update_mailname(name);
+ update_mailname(name !=3D mailname ? name : NULL);
mailsize =3D 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 =3D get_abs_msgCount();
Home |
Main Index |
Thread Index |
Old Index