Article View: fj.editor.emacs
Article #664Re: split string
From: Fujii Hironori
Date: Sat, 02 Aug 2003 06:35
Date: Sat, 02 Aug 2003 06:35
53 lines
2731 bytes
2731 bytes
> ๆๅญๅใ็ฉบ็ฝใงๅๅฒใใใใฎใงใใใ
> ็ฉบ็ฝใ "" ใ \ ใงใฏใชใผใใใจในใฑใผใใใงใใๆนๆณใๆขใใฆใใพใใ
ไปฅไธใฎใใใซ while ใง1ๆๅญใใคใซใผใใใใใจใซใใพใใใ
ใฉใใใใใใจใใใใใพใใใ
(defun split-string-shell-quote (str)
(let ((pos 0) (len (length str)) (state 'out-word)
char-list str-list char blankp)
(while (< pos len)
(setq char (aref str pos))
(setq blankp (memq char '(? ?\t ?\n)))
(cond
((and (eq state 'out-word) blankp)) ; skip blank
((and (eq state 'in-word) blankp) ; end word
(setq str-list
(cons (concat (nreverse char-list)) str-list))
(setq char-list nil state 'out-word))
((eq state char) ; break out ' or "
(setq state 'in-word))
((and (or (eq state 'in-word) (eq state 'out-word)) ; into ' or "
(or (eq char ?') (eq char ?\")))
(setq state char))
(t ; add char to char-list
(when (eq char ?\\)
(setq pos (1+ pos))
(setq char (aref str pos)))
(when (eq state 'out-word)
(setq state 'in-word))
(setq char-list (cons char char-list))))
(setq pos (1+ pos)))
(cond ((memq state '(?' ?\"))
(error "Missing %c" state))
((eq state 'in-word)
(setq str-list
(cons (concat (nreverse char-list)) str-list))))
(nreverse str-list)))
้ขไฟใชใใใฉใconcat ใฏๅผๆฐ0ๅใงใใใใใฉใ
(concat)
=>""
string ใฏใ ใใชใใงใใญใ
(string)
=>(wrong-number-of-arguments #<subr string> 0)
ใกใใฃใจไธไพฟใ
---
่คไบๅฎๆฒ
Technical Details
Message-ID:
<87adasva69.wl@anago2.mas.chi.its.hiroshima-cu.ac.jp>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!newsfeed.media.kyoto-u.ac.jp!news.media.kyoto-u.ac.jp!not-for-mailReferences:
<87fzmwc610.wl@anago2.mas.chi.its.hiroshima-cu.ac.jp>Show Full Headers
Complete Article Headers
X-Google-Language: Japanese,JIS X-Google-Thread: ff358,9928b267563d584d X-Google-Attributes: gidff358,public X-Google-ArrivalTime: 2003-08-01 23:32:17 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!newsfeed.media.kyoto-u.ac.jp!news.media.kyoto-u.ac.jp!not-for-mail From: Fujii Hironori <fujii@chi.its.hiroshima-cu.ac.jp> Newsgroups: fj.editor.emacs Subject: Re: split string Date: Sat, 02 Aug 2003 15:35:42 +0900 Organization: Hiroshima City University Graduate School Lines: 54 Message-ID: <87adasva69.wl@anago2.mas.chi.its.hiroshima-cu.ac.jp> References: <87fzmwc610.wl@anago2.mas.chi.its.hiroshima-cu.ac.jp> NNTP-Posting-Host: edus4050.edu.ipc.hiroshima-cu.ac.jp Mime-Version: 1.0 (generated by SEMI 1.14.4 - "Hosorogi") Content-Type: text/plain; charset=ISO-2022-JP X-Trace: caraway.media.kyoto-u.ac.jp 1059805937 19983 165.242.18.50 (2 Aug 2003 06:32:17 GMT) X-Complaints-To: news@news.media.kyoto-u.ac.jp NNTP-Posting-Date: Sat, 2 Aug 2003 06:32:17 +0000 (UTC) In-Reply-To: <87fzmwc610.wl@anago2.mas.chi.its.hiroshima-cu.ac.jp> User-Agent: Wanderlust/2.10.0 Emacs/21.3 Mule/5.0