[Prime-cvs] CVS update: prime-el/src

Back to archive index

Hiroyuki Komatsu komat****@users*****
2005年 3月 2日 (水) 18:26:17 JST


Index: prime-el/src/prime-server.el
diff -u prime-el/src/prime-server.el:1.6 prime-el/src/prime-server.el:1.7
--- prime-el/src/prime-server.el:1.6	Mon Feb 21 15:23:15 2005
+++ prime-el/src/prime-server.el	Wed Mar  2 18:26:17 2005
@@ -35,6 +35,31 @@
     (append-to-file (point-min) (point-max) (expand-file-name filename))
     ))
 
+;; Overwriting the old function before 2005-03-01.
+(defun mell-string-split (string regexp)
+  "Divide STRING from REGEXP."
+  (let ((start 0)
+	(string-length (length string))
+	match-list
+	splited-list)
+    ;; In CPerl-mode, (string-match "a" "あ" 1) raises an error,
+    ;; even it is expected to return nil.  So we check the position of start.
+    ;; (2005-03-02) <Hiroyuki Komatsu>
+    (while (and (< start string-length)
+		(string-match regexp string start))
+      (setq match-list
+	    (append match-list (list (match-beginning 0) (match-end 0))))
+      (setq start (match-end 0))
+      )
+    (setq match-list (append '(0) match-list (list (length string))))
+    (while match-list
+      (setq splited-list 
+	    (cons (substring string (nth 0 match-list) (nth 1 match-list))
+		  splited-list))
+      (setq match-list (nthcdr 2 match-list))
+      )
+    (reverse splited-list)))
+
 ;;;; -----------------------------------------------------------------
 
 ;;;; ------------------------------------------------------------
@@ -130,7 +155,7 @@
 (defun prime-server-get-env (key)
   (let ((result (prime-server-send-command (format "get_env\t%s\n" key)))
 	value)
-    (setq value (car (cdr (delete "" (split-string result "\n")))))
+    (setq value (car (cdr (delete "" (mell-string-split result "\n")))))
     (if (string-match "^\\([^\t]*\\)\t" value)
 	(let ((type (match-string 1 value))
 	      (data (substring value (match-end 0))))
@@ -202,13 +227,13 @@
 	      (cons (car tmp-list)
 		    (nthcdr 2 tmp-list)))
 	))
-   (cdr (delete "" (split-string cands-string "\n")))
+   (cdr (delete "" (mell-string-split cands-string "\n")))
    ))
 
 (defun prime-server-get-version ()
   (let* ((result (prime-server-send-command "version\n"))
 	 (data (mell-string-split
-		(car (cdr (delete "" (split-string result "\n")))) "\t"))
+		(car (cdr (delete "" (mell-string-split result "\n")))) "\t"))
 	 (version (if (> (length data) 1) (nth 1 data) (nth 0 data))))
     version))
 
@@ -274,10 +299,10 @@
 (defun prime-server-send-command2 (command)
   "This sends the command and returns a list of items splited by tabs"
   (let ((result (prime-server-send-command command)))
-    (mell-string-split (or (car (cdr (delete "" (split-string result "\n"))))
-			   "")
-		       "\t")
-    ))
+    (mell-string-split
+     (or (car (cdr (delete "" (mell-string-split result "\n"))))
+	 "")
+     "\t")))
 
 (defun prime-server-session-start ()
   "This starts a session with PRIME and returns the session id."


Prime-cvs メーリングリストの案内
Back to archive index