[Lisppaste-cvs] CVS update: lisppaste2/encode-for-pre.lisp

Brian Mastenbrook bmastenbrook at common-lisp.net
Wed Mar 31 21:25:15 UTC 2004


Update of /project/lisppaste/cvsroot/lisppaste2
In directory common-lisp.net:/home/bmastenbrook/lisppaste2

Modified Files:
	encode-for-pre.lisp 
Log Message:
aaaaargh! the bug from hell is still not fixed!

Date: Wed Mar 31 16:25:14 2004
Author: bmastenbrook

Index: lisppaste2/encode-for-pre.lisp
diff -u lisppaste2/encode-for-pre.lisp:1.11 lisppaste2/encode-for-pre.lisp:1.12
--- lisppaste2/encode-for-pre.lisp:1.11	Sun Mar  7 15:40:20 2004
+++ lisppaste2/encode-for-pre.lisp	Wed Mar 31 16:25:14 2004
@@ -1,4 +1,4 @@
-;;;; $Id: encode-for-pre.lisp,v 1.11 2004/03/07 20:40:20 bmastenbrook Exp $
+;;;; $Id: encode-for-pre.lisp,v 1.12 2004/03/31 21:25:14 bmastenbrook Exp $
 ;;;; $Source: /project/lisppaste/cvsroot/lisppaste2/encode-for-pre.lisp,v $
 
 ;;;; See the LICENSE file for licensing information.
@@ -10,16 +10,17 @@
 			   summing (if (not only-in-dup)
                                        (if (char= (elt str i) char)
                                            (length repstr) 1)
-                                       (if (< i (1- (length str)))
-                                           (if (and (char= (elt str i) char)
-                                                    (char= (elt str (1+ i)) char))
+                                       (if (> i 1)
+                                           (if (and (member (elt str (1- i)) only-in-dup :test #'char=)
+                                                    (char= (elt str i) char))
                                                (length repstr) 1) 1))))
 	 (new-array (make-array `(,new-length) :element-type 'character)))
     (loop for i from 0 to (1- (length str))
 	  with j = 0
 	  do (if (if only-in-dup
-                     (and (< i (1- (length str))) (and (char= (elt str i) char)
-                                                    (char= (elt str (1+ i)) char)))
+                     (and (> i 1) (char= (elt str i) char)
+			  (member (elt str (1- i))
+				  only-in-dup :test #'char=))
                      (char= (elt str i) char))
 		 (progn
 		   (loop for k from 0 to (1- (length repstr))
@@ -40,8 +41,13 @@
 (defun encode-for-pre (str)
   (replace-in-string str '(#\& #\< #\>) '("&" "<" ">")))
 
+(defun replace-first-space (str)
+  (if (char= (elt str 0) #\space)
+      (concatenate 'string " " (subseq str 1))
+    str))
+
 (defun encode-for-tt (str)
-  (replace-in-string-1 (replace-in-string str '(#\& #\< #\> #\newline #\return #\linefeed #\tab) '("&" "<" ">" "<br>" "" "" "    ")) #\space " " t))
+  (replace-in-string-1 (replace-in-string str '(#\& #\< #\> #\newline #\return #\linefeed #\tab) '("&" "<" ">" "<br>" "" "" "    ")) #\space " " '(#\space #\>)))
 
 (defun encode-for-http (str)
   (replace-in-string-1 str #\> (format nil ">~%") nil))





More information about the Lisppaste-cvs mailing list