๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: fj.editor.emacs
Article #664

Re: split string

#664
From: Fujii Hironori
Date: Sat, 02 Aug 2003 06:35
53 lines
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-mail
References: <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