X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Fmipsstrops.lisp;h=6f98979f02c059f3b2342d5766954db3419847a5;hb=860543cc7ba0266e41e1d41ac9b6a208f3795f1a;hp=5acc918552a5cd1fd567d9a565c7a731247e853d;hpb=9f926721993baa5711eaf00d7c314924f269f3d2;p=sbcl.git diff --git a/src/code/mipsstrops.lisp b/src/code/mipsstrops.lisp index 5acc918..6f98979 100644 --- a/src/code/mipsstrops.lisp +++ b/src/code/mipsstrops.lisp @@ -77,92 +77,3 @@ (declare (fixnum index1 index2)) (if (char/= (schar string1 index1) (schar string2 index2)) (return index1))))))) - -(defmacro maybe-sap-maybe-string ((var) &body body) - `(etypecase ,var - (system-area-pointer - (macrolet ((byte-ref (index) - `(sap-ref-8 ,',var ,index)) - (char-ref (index) - `(code-char (byte-ref ,index)))) - ,@body)) - (simple-string - (macrolet ((char-ref (index) - `(schar ,',var ,index)) - (byte-ref (index) - `(char-code (char-ref ,index)))) - ,@body)))) - -;;; Search STRING for the CHARACTER from START to END. If the -;;; character is found, the corresponding index into STRING is -;;; returned, otherwise NIL is returned. -(defun %sp-find-character (string start end character) - (declare (fixnum start end) - (type (or simple-string system-area-pointer) string) - (base-char character)) - (maybe-sap-maybe-string (string) - (do ((index start (1+ index))) - ((>= index end) nil) - (declare (fixnum index)) - (when (char= (char-ref index) character) - (return index))))) - -;;; Search STRING for CHARACTER from END to START. If the character is -;;; found, the corresponding index into STRING is returned, otherwise -;;; NIL is returned. -(defun %sp-reverse-find-character (string start end character) - (declare (type (or simple-string system-area-pointer) string) - (fixnum start end) - (base-char character)) - (maybe-sap-maybe-string (string) - (do ((index (1- end) (1- index)) - (terminus (1- start))) - ((= index terminus) nil) - (declare (fixnum terminus index)) - (if (char= (char-ref index) character) - (return index))))) - -;;; Return the index of the first character between START and END -;;; which is not CHAR= to CHARACTER, or NIL if there is no such -;;; character. -(defun %sp-skip-character (string start end character) - (declare (type (or simple-string system-area-pointer) string) - (fixnum start end) - (base-char character)) - (maybe-sap-maybe-string (string) - (do ((index start (1+ index))) - ((= index end) nil) - (declare (fixnum index)) - (if (char/= (char-ref index) character) - (return index))))) - -;;; Return the index of the last character between START and END which -;;; is not CHAR= to CHARACTER, or NIL if there is no such character. -(defun %sp-reverse-skip-character (string start end character) - (declare (type (or simple-string system-area-pointer) string) - (fixnum start end) - (base-char character)) - (maybe-sap-maybe-string (string) - (do ((index (1- end) (1- index)) - (terminus (1- start))) - ((= index terminus) nil) - (declare (fixnum terminus index)) - (if (char/= (char-ref index) character) - (return index))))) - -;;; Search for the substring of STRING1 specified in STRING2. Return -;;; an index into STRING2, or NIL if the substring wasn't found. -(defun %sp-string-search (string1 start1 end1 string2 start2 end2) - (declare (simple-string string1 string2)) - (do ((index2 start2 (1+ index2))) - ((= index2 end2) nil) - (declare (fixnum index2)) - (when (do ((index1 start1 (1+ index1)) - (index2 index2 (1+ index2))) - ((= index1 end1) t) - (declare (fixnum index1 index2)) - (when (= index2 end2) - (return-from %sp-string-search nil)) - (when (char/= (char string1 index1) (char string2 index2)) - (return nil))) - (return index2))))