From d13097b0815c3e576073090a1a53b2de736d1f34 Mon Sep 17 00:00:00 2001 From: morioka Date: Thu, 5 Oct 1995 11:26:43 +0000 Subject: [PATCH] =?utf8?q?=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=20rfc822/fiel?= =?utf8?q?d-name-regexp,=20=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=20rfc822/fie?= =?utf8?q?ld-end,=20rfc822/get-field-body,=20=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF?= =?utf8?q?=BD=20rfc822/strip-quoted-pair,=20rfc822/strip-quoted-string,=20=EF?= =?utf8?q?=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=20rfc822/unfolding-string=20=EF=BF?= =?utf8?q?=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD?= =?utf8?q?=EF=BF=BD=EF=BF=BD=EF=BF=BD=EF=BF=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- tl-822.el | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 83 insertions(+), 1 deletion(-) diff --git a/tl-822.el b/tl-822.el index b0902d7..2283b4c 100644 --- a/tl-822.el +++ b/tl-822.el @@ -6,7 +6,7 @@ ;;; ;;; Author: MORIOKA Tomohiko ;;; Version: -;;; $Id: tl-822.el,v 1.1 1995-10-03 05:17:31 morioka Exp $ +;;; $Id: tl-822.el,v 2.0 1995-10-05 11:26:43 morioka Exp $ ;;; Keywords: mail, news, RFC 822 ;;; ;;; This file is part of tm (Tools for MIME). @@ -15,6 +15,88 @@ (require 'tl-seq) +;;; @ field +;;; + +(defconst rfc822/field-name-regexp "[!-9;-~]+") + +(defconst rfc822::next-field-top-regexp + (concat "\n" rfc822/field-name-regexp ":")) + +(defun rfc822/field-end () + (if (re-search-forward rfc822::next-field-top-regexp nil t) + (goto-char (match-beginning 0)) + (if (re-search-forward "^$" nil t) + (goto-char (1- (match-beginning 0))) + (end-of-line) + )) + (point) + ) + +(defun rfc822/get-field-body (name) + (let ((case-fold-search t)) + (save-excursion + (save-restriction + (narrow-to-region + (goto-char (point-min)) + (or (and (re-search-forward "^$" nil t) (match-end 0)) + (point-max) + )) + (goto-char (point-min)) + (if (re-search-forward (concat "^" name ":[ \t]*") nil t) + (buffer-substring-no-properties + (match-end 0) + (rfc822/field-end) + )) + )))) + + +;;; @ quoted-string +;;; + +(defun rfc822/strip-quoted-pair (str) + (let ((dest "") + (i 0) + (len (length str)) + chr flag) + (while (< i len) + (setq chr (elt str i)) + (if (or flag (not (eq chr ?\\))) + (progn + (setq dest (concat dest (char-to-string chr))) + (setq flag nil) + ) + (setq flag t) + ) + (setq i (+ i 1)) + ) + dest)) + +(defun rfc822/strip-quoted-string (str) + (rfc822/strip-quoted-pair + (let ((max (- (length str) 1)) + ) + (if (and (eq (elt str 0) ?\") + (eq (elt str max) ?\") + ) + (substring str 1 max) + str) + ))) + + +;;; @ unfolding +;;; + +(defun rfc822/unfolding-string (str) + (let ((dest "")) + (while (string-match "\n\\s +" str) + (setq dest (concat dest (substring str 0 (match-beginning 0)) " ")) + (setq str (substring str (match-end 0))) + ) + (concat dest str) + )) + + ;;; @ lexical analyze ;;; -- 1.7.10.4