From dc75829616e686c55248f260c5bfccfd82c4350f Mon Sep 17 00:00:00 2001 From: morioka Date: Wed, 28 Aug 1996 18:07:03 +0000 Subject: [PATCH] (std11-check-enclosure): New function; changed from `std11-analyze-enclosure'. (std11-analyze-quoted-string): Use function `std11-check-enclosure'. (std11-analyze-domain-literal): Use function `std11-check-enclosure'. (std11-analyze-comment): New function. --- std11-parse.el | 53 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 37 insertions(+), 16 deletions(-) diff --git a/std11-parse.el b/std11-parse.el index 34d22d3..200008e 100644 --- a/std11-parse.el +++ b/std11-parse.el @@ -4,7 +4,7 @@ ;; Author: MORIOKA Tomohiko ;; Keywords: mail, news, RFC 822, STD 11 -;; Version: $Id: std11-parse.el,v 0.6 1996-08-28 17:35:10 morioka Exp $ +;; Version: $Id: std11-parse.el,v 0.7 1996-08-28 18:07:03 morioka Exp $ ;; This file is part of tl (Tiny Library). @@ -59,11 +59,14 @@ (substring str end) )))) -(defun std11-analyze-enclosure (str type open close) - (let ((len (length str))) - (if (and (> len 0) - (eq (aref str 0) open)) - (let ((i 1) chr dest) +(defun std11-check-enclosure (str open close &optional recursive from) + (let ((len (length str)) + (i (or from 0)) + ) + (if (and (> len i) + (eq (aref str i) open)) + (let (p chr dest) + (setq i (1+ i)) (catch 'tag (while (< i len) (setq chr (aref str i)) @@ -72,26 +75,44 @@ (if (>= i len) (throw 'tag nil) ) - (setq dest (concat dest (char-to-string (aref str i)))) + (setq i (1+ i)) ) ((eq chr close) - (throw 'tag - (cons (cons type dest) (substring str (1+ i))) - ) + (throw 'tag (1+ i)) ) + ((eq chr open) + (if (and recursive + (setq p (std11-check-enclosure + str open close recursive i)) + ) + (setq i p) + (throw 'tag nil) + )) (t - (setq dest (concat dest (char-to-string (aref str i)))) + (setq i (1+ i)) )) - (setq i (1+ i)) )))))) (defun std11-analyze-quoted-string (str) - (std11-analyze-enclosure str 'quoted-string ?\" ?\") - ) + (let ((p (std11-check-enclosure str ?\" ?\"))) + (if p + (cons (cons 'quoted-string (substring str 1 (1- p))) + (substring str p)) + ))) (defun std11-analyze-domain-literal (str) - (std11-analyze-enclosure str 'domain-literal ?\[ ?\]) - ) + (let ((p (std11-check-enclosure str ?\[ ?\]))) + (if p + (cons (cons 'domain-literal (substring str 1 (1- p))) + (substring str p)) + ))) + +(defun std11-analyze-comment (str) + (let ((p (std11-check-enclosure str ?\( ?\) t))) + (if p + (cons (cons 'comment (substring str 1 (1- p))) + (substring str p)) + ))) ;;; @ end -- 1.7.10.4