Package: bsd-mailx / 8.1.2-0.20141216cvs-2

11-Showname-option.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
From: Tormod Volden <volden@iqe.phys.ethz.ch>
Date: Sun, 6 May 2001 20:23:48 +0200
Subject: 11 Showname option

Debian Bug#96867:

Dear mailx maintainer,

I have written a patch that mimics the SunOS mailx
"showname" option, that is, in the mail header listing the
senders full name is shown instead of the e-mail address.

I had to make the "skin" function aware of the reptype variable,
and thus give a reptype value for each call of skin. Ugly but
it seems to work.
---
 aux.c    |  9 +++++++--
 cmd1.c   |  2 +-
 cmd3.c   | 18 +++++++++---------
 extern.h |  2 +-
 4 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/aux.c b/aux.c
index 3c6e961..bfc9140 100644
--- a/aux.c
+++ b/aux.c
@@ -368,7 +368,7 @@ nameof(struct message *mp, int reptype)
 {
 	char *cp, *cp2;
 
-	cp = skin(name1(mp, reptype));
+	cp = skin(name1(mp, reptype), reptype);
 	if (reptype != 0 || charcount(cp, '!') < 2)
 		return(cp);
 	cp2 = strrchr(cp, '!');
@@ -411,7 +411,7 @@ skip_comment(char *cp)
  * of "host-phrase."
  */
 char *
-skin(char *name)
+skin(char *name, int reptype)
 {
 	char *nbuf, *bufend, *cp, *cp2;
 	int c, gotlt, lastsp;
@@ -465,6 +465,11 @@ skin(char *name)
 			break;
 
 		case '<':
+			/* in case of showname it is time to return */
+			if (reptype == 0 && value("showname") != NULL) {
+				*cp2 = 0;
+				return(savestr(nbuf));
+			}
 			cp2 = bufend;
 			gotlt++;
 			lastsp = 0;
diff --git a/cmd1.c b/cmd1.c
index 84186c5..1c7f748 100644
--- a/cmd1.c
+++ b/cmd1.c
@@ -214,7 +214,7 @@ printhead(int mesg)
 		dispc = 'M';
 	parse(headline, &hl, pbuf);
 	from = nameof(mp, 0);
-	to = skin(hfield("to", mp));
+	to = skin(hfield("to", mp), 0);
 	np = extract(from, GTO);
 	np = delname(np, myname);
 	if (altnames)
diff --git a/cmd3.c b/cmd3.c
index 20a61c4..db16208 100644
--- a/cmd3.c
+++ b/cmd3.c
@@ -203,11 +203,11 @@ _respond(msgvec)
 	mp = &message[msgvec[0] - 1];
 	touch(mp);
 	dot = mp;
-	if ((rcv = skin(hfield("from", mp))) == NULL)
-		rcv = skin(nameof(mp, 1));
-	if ((replyto = skin(hfield("reply-to", mp))) != NULL)
+	if ((rcv = skin(hfield("from", mp), 1)) == NULL)
+		rcv = skin(nameof(mp, 1), 1);
+	if ((replyto = skin(hfield("reply-to", mp), 1)) != NULL)
 		np = extract(replyto, GTO);
-	else if ((cp = skin(hfield("to", mp))) != NULL)
+	else if ((cp = skin(hfield("to", mp), 1)) != NULL)
 		np = extract(cp, GTO);
 	else
 		np = NULL;
@@ -231,7 +231,7 @@ _respond(msgvec)
 	if ((head.h_subject = hfield("subject", mp)) == NULL)
 		head.h_subject = hfield("subj", mp);
 	head.h_subject = reedit(head.h_subject);
-	if (replyto == NULL && (cp = skin(hfield("cc", mp))) != NULL) {
+	if (replyto == NULL && (cp = skin(hfield("cc", mp), 2)) != NULL) {
 		np = elide(extract(cp, GCC));
 		np = delname(np, myname);
 		if (altnames != 0)
@@ -243,7 +243,7 @@ _respond(msgvec)
 	head.h_bcc = NULL;
 	head.h_smopts = NULL;
 	head.h_replyto = getenv("REPLYTO");
-	head.h_inreplyto = skin(hfield("message-id", mp));
+	head.h_inreplyto = skin(hfield("message-id", mp), 1);
 
 	mail1(&head, 1);
 	return(0);
@@ -616,10 +616,10 @@ _Respond(int *msgvec)
 		mp = &message[*ap - 1];
 		touch(mp);
 		dot = mp;
-		if ((cp = skin(hfield("from", mp))) == NULL)
-			cp = skin(nameof(mp, 2));
+		if ((cp = skin(hfield("from", mp), 2)) == NULL)
+			cp = skin(nameof(mp, 2), 2);
 		head.h_to = cat(head.h_to, extract(cp, GTO));
-		mid = skin(hfield("message-id", mp));
+		mid = skin(hfield("message-id", mp), 1);
 	}
 	if (head.h_to == NULL)
 		return(0);
diff --git a/extern.h b/extern.h
index c888a9e..919747d 100644
--- a/extern.h
+++ b/extern.h
@@ -69,7 +69,7 @@ FILE	*run_editor(FILE *, off_t, int, int);
 char	*salloc(int);
 char	*savestr(char *);
 FILE	*setinput(struct message *);
-char	*skin(char *);
+char	*skin(char *, int);
 char	*skip_comment(char *);
 char	*snarf(char *, int *);
 char	*username(void);