summaryrefslogtreecommitdiff
path: root/pith/reply.c
diff options
context:
space:
mode:
authorEduardo Chappa <chappa@washington.edu>2016-12-18 12:55:31 -0700
committerEduardo Chappa <chappa@washington.edu>2016-12-18 12:55:31 -0700
commit0674c5f2bbeb0402fccc41eb5855d24ed1220ea8 (patch)
tree2780a4b7c3e9442dbbfab1788d21bfff8bb04a0b /pith/reply.c
parentaccf5768851fc5f323e66c41de43061e86d4a9f6 (diff)
downloadalpine-0674c5f2bbeb0402fccc41eb5855d24ed1220ea8.tar.xz
* New token SHORTSUBJECT, SHORTSUBJKEY and SHORTSUBJKEYINIT to shorten
the subject, removing list name information from the subject (text enclosed between "[" and "]".)
Diffstat (limited to 'pith/reply.c')
-rw-r--r--pith/reply.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/pith/reply.c b/pith/reply.c
index 7ceb31f8..b89a8614 100644
--- a/pith/reply.c
+++ b/pith/reply.c
@@ -1704,6 +1704,33 @@ get_news_data(ENVELOPE *env, IndexColType type, char *buf, size_t maxlen)
buf[orig_maxlen] = '\0';
}
+void
+shorten_subject(char *origsubj)
+{
+ char *s, *t, *u;
+ int endlist = 0;
+
+ if(origsubj == NULL || *origsubj == '\0')
+ return;
+
+ for(t=s=origsubj; *s ; s++){
+ switch(*s){
+ /* this transforms "A [B [C] D" into "A D" should this be
+ * "A [B D"?
+ */
+ case '[' : if((u = strchr(s+1,']')) != NULL){
+ s = u;
+ endlist = 1;
+ }
+ else
+ *t++ = *s;
+ break;
+ case ' ' : if(endlist == 0) *t++ = *s; break;
+ default : endlist = 0; *t++ = *s; break;
+ }
+ }
+ *t = '\0';
+}
/*
* Buf is at least size maxlen+1
@@ -1863,6 +1890,7 @@ get_reply_data(ENVELOPE *env, ACTION_S *role, IndexColType type, char *buf, size
break;
case iSubject:
+ case iShortSubject:
if(env && env->subject){
size_t n, len;
unsigned char *p, *tmp = NULL;
@@ -1882,6 +1910,9 @@ get_reply_data(ENVELOPE *env, ACTION_S *role, IndexColType type, char *buf, size
if(tmp)
fs_give((void **)&tmp);
+
+ if(type == iShortSubject)
+ shorten_subject(buf);
}
break;