Changeset 71 for lang/elisp/pdicv-mode/trunk/nt-string.el
- Timestamp:
- 01/30/09 23:52:02 (16 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/elisp/pdicv-mode/trunk/nt-string.el
r67 r71 1 1 ;;; nt-string.el --- NT's string utilities 2 3 2 ;; 4 ;; Copyright (C) 2005 Naoya TOZUKA. All Rights Reserved.3 ;; Copyright (C) 2005-2009 naoya_t. All Rights Reserved. 5 4 ;; 6 ;; Author: Naoya TOZUKA <pdicviewer@gmail.com> 7 ;; Maintainer: Naoya TOZUKA <pdicviewer@gmail.com> 8 ;; Primary distribution site: http://pdicviewer.naochan.com/el/ 5 ;; Author: naoya_t <naoya.t@aqua.plala.or.jp> 6 ;; Maintainer: naoya_t <naoya.t@aqua.plala.or.jp> 7 ;; Primary distribution site: 8 ;; http://lambdarepos.svnrepository.com/svn/share/lang/elisp/pdicv-mode/trunk 9 9 ;; 10 10 ;; Created: 16 Feb 2005 … … 44 44 (i 0)) 45 45 46 ( ifn47 (if(or (> n s1-length) (> n s2-length))48 49 ( if(null n)50 46 (when n 47 (when (or (> n s1-length) (> n s2-length)) 48 (setq n nil strncmp-p nil))) 49 (when (null n) 50 (setq n (min s1-length s2-length))) 51 51 52 (if (zerop n) (throw 'strcmp 0)) 53 52 (when (zerop n) (throw 'strcmp 0)) 54 53 55 54 (while (< i n) 56 55 (let ((s1-i (aref s1 i)) 57 56 (s2-i (aref s2 i))) 58 (if (/= s1-i s2-i) (throw 'strcmp (- s1-i s2-i))) 59 );let 60 (setq i (1+ i)) 61 );wend 57 (when (/= s1-i s2-i) (throw 'strcmp (- s1-i s2-i)))) 58 (setq i (1+ i))) 62 59 63 60 ;nʸ����1=s2 … … 82 79 (while (<= i till) 83 80 (setq at (string-match r str i)) 84 ( if(null at) (throw 'replace-in-string (concat result (substring str i))))81 (when (null at) (throw 'replace-in-string (concat result (substring str i)))) 85 82 86 83 (setq result (concat result (substring str i at) n)) 87 (setq i (+ at r-len)) 88 ); wend 89 result 90 ); let 91 ); caught 92 ) 84 (setq i (+ at r-len))) 85 result))) 93 86 94 87 (defun nt:replace-all (str regex subst) … … 103 96 (progn 104 97 (setq result (concat result (substring str ofs found-at) subst)) 105 (setq ofs (match-end 0)) 106 ) 98 (setq ofs (match-end 0))) 107 99 (progn 108 100 (setq result (concat result (substring str ofs last))) 109 (throw 'while nil) 110 )) 111 );let 112 );wend 113 );caught 114 result 115 );let 116 ) 101 (throw 'while nil)))))) 102 result)) 117 103 118 104 (defun nt:rtrim (str) … … 121 107 (let ((i (1- (length str)))) 122 108 (while (> i 0) 123 (if (> (aref str i) #x20) (throw 'rtrim (substring str 0 (1+ i)))) 124 (-- i) 125 );wend 126 );let 127 );caught 128 ) 109 (when (> (aref str i) #x20) (throw 'rtrim (substring str 0 (1+ i)))) 110 (-- i))))) 129 111 130 112 (defun nt:ltrim (str) … … 133 115 (let ((len (length str)) (i 0)) 134 116 (while (< i len) 135 (if (> (aref str i) #x20) (throw 'ltrim (substring str i len))) 136 (++ i) 137 );wend 138 );let 139 );caught 140 ) 117 (when (> (aref str i) #x20) (throw 'ltrim (substring str i len))) 118 (++ i))))) 141 119 142 120 ;(defun nt:trim (str) 143 121 ; "trim" 144 ; (nt:ltrim (nt:rtrim str)) 145 ; ) 122 ; (nt:ltrim (nt:rtrim str))) 146 123 (defmacro nt:trim (str) 147 124 "trim" 148 `(nt:ltrim (nt:rtrim ,str)) 149 ) 125 `(nt:ltrim (nt:rtrim ,str))) 150 126 151 127 ;;; nt-string.el ends here