aboutsummaryrefslogtreecommitdiffstats
path: root/anchor.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--anchor.c65
1 files changed, 61 insertions, 4 deletions
diff --git a/anchor.c b/anchor.c
index 5d2e64d..bcd1ba0 100644
--- a/anchor.c
+++ b/anchor.c
@@ -1,4 +1,4 @@
-/* $Id: anchor.c,v 1.17 2002/12/24 17:24:33 ukai Exp $ */
+/* $Id: anchor.c,v 1.18 2003/01/06 15:36:57 ukai Exp $ */
#include "fm.h"
#include "myctype.h"
#include "regex.h"
@@ -193,9 +193,11 @@ _put_anchor_news(Buffer *buf, char *p1, char *p2, int line, int pos)
{
Str tmp;
- p1++;
- if (*(p2 - 1) == '>')
- p2--;
+ if (*p1 == '<') {
+ p1++;
+ if (*(p2 - 1) == '>')
+ p2--;
+ }
tmp = Strnew_charp_n(p1, p2 - p1);
#ifdef JP_CHARSET
tmp = conv_str(tmp, InnerCode, buf->document_code);
@@ -366,6 +368,61 @@ reAnchorNews(Buffer *buf, char *re)
{
return reAnchorAny(buf, re, _put_anchor_news);
}
+
+char *
+reAnchorNewsheader(Buffer *buf)
+{
+ Line *l;
+ char *p, *p1, *p2;
+ static char *header_mid[] = {
+ "Message-Id:", "References:", "In-Reply-To:", NULL
+ };
+ static char *header_group[] = {
+ "Newsgroups:", NULL
+ };
+ char **header, **q;
+ int i, search = FALSE;
+
+ if (!buf || !buf->firstLine)
+ return NULL;
+ for (i = 0; i <= 1; i++) {
+ if (i == 0) {
+ regexCompile("<[!-;=?-~]+@[a-zA-Z0-9\\.\\-_]+>", 1);
+ header = header_mid;
+ }
+ else {
+ regexCompile("[a-zA-Z0-9\\.\\-_]+", 1);
+ header = header_group;
+ }
+ for (l = buf->firstLine; l != NULL && l->real_linenumber == 0;
+ l = l->next) {
+ p = l->lineBuf;
+ if (!IS_SPACE(*p)) {
+ search = FALSE;
+ for (q = header; *q; q++) {
+ if (!strncasecmp(p, *q, sizeof(*q) - 1)) {
+ search = TRUE;
+ p = strchr(p, ':') + 1;
+ break;
+ }
+ }
+ }
+ if (!search)
+ continue;
+ for (;;) {
+ if (regexMatch(p, &l->lineBuf[l->len] - p, p == l->lineBuf)
+ == 1) {
+ matchedPosition(&p1, &p2);
+ p = reAnchorPos(buf, l, p1, p2, _put_anchor_news);
+ }
+ else
+ break;
+ }
+ }
+ }
+ reseq_anchor(buf);
+ return NULL;
+}
#endif /* USE_NNTP */
#define FIRST_MARKER_SIZE 30