aboutsummaryrefslogtreecommitdiffstats
path: root/anchor.c
diff options
context:
space:
mode:
authorFumitoshi UKAI <ukai@debian.or.jp>2003-01-06 15:36:56 +0000
committerFumitoshi UKAI <ukai@debian.or.jp>2003-01-06 15:36:56 +0000
commitff20968c8c0cbafa349495c791f700775d0e23af (patch)
treeb3610ae72e8d9e30344a0d29bb0cfb0cc8c78611 /anchor.c
parentfix build errors (diff)
downloadw3m-ff20968c8c0cbafa349495c791f700775d0e23af.tar.gz
w3m-ff20968c8c0cbafa349495c791f700775d0e23af.zip
[w3m-dev 03610] Re: news:<newsgroup>
* anchor.c (_put_anchor_news): check '<' (reAnchorNewsheader): added * file.c (loadSomething): Subject: as buffername (checkHeader): check buf->document_header (loadGeneralFile): reAnchorNewsheader * html.h (SCM_NNTP_GROUP): added * main.c (main): delete USE_NNTP in switch (newbuf->real_scheme) (chkNMIDBuffer): lowercase in url_like_pat * news.c (add_news_message): add scheme, group as arg (openNewsStream): check SCM_NNTP_GROUP check current_news.host (readNewsgroup): rewrite to support nntp:,news: extension * proto.h (reAnchorNewsheader): added * url.c (DefaultPort): add 119 for nntp group (parseURL2): rewrite to support nntp:,news: extension (_parsedURL2Str): add for SCM_NNTP_GROUP (openURL): rewrite to support nntp:,news: extension From: Hironori SAKAMOTO <hsaka@mth.biglobe.ne.jp>
Diffstat (limited to 'anchor.c')
-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