@@ -222,34 +222,32 @@ COMMAND arg
222222COMMAND arg1 arg2
223223COMMAND arg1 arg2 :arg3 still arg3
224224:sender COMMAND arg1 arg2 :arg3 still arg3"
225- (with-temp-buffer
226- (insert line)
227- (goto-char (point-min ))
228- (let ((sender nil )
229- (args nil ))
230- ; ; Optional sender.
231- (when (looking-at " :\\ ([^ ]+\\ ) " )
232- (setq sender (decode-coding-string
233- (match-string 1 )
234- 'undecided ))
235- (goto-char (match-end 0 )))
236-
237- ; ; COMMAND.
238- (unless (looking-at " \\ ([^ ]+\\ )" )
239- (error " Invalid message: %s " line))
240- (push (decode-coding-string (match-string 1 ) 'undecided )
241- args)
242- (goto-char (match-end 0 ))
243-
244- ; ; Arguments.
245- (while (re-search-forward " :\\ (.*\\ )\\ | \\ ([^ ]*\\ )" nil t )
246- (push (decode-coding-string
247- (or (match-string 1 )
248- (match-string 2 ))
249- 'undecided )
250- args))
251-
252- (cons sender (nreverse args)))))
225+ (let ((pos 0 )
226+ (end (length line))
227+ sender
228+ args)
229+ ; ; Optional sender.
230+ (when (equal (string-match " :\\ ([^ ]+\\ ) " line pos) pos)
231+ (setq pos (+ (length (match-string 0 line)) pos))
232+ (setq sender (decode-coding-string (match-string 1 line) 'undecided )))
233+
234+ ; ; COMMAND.
235+ (unless (equal (string-match " [^ ]+" line pos) pos)
236+ (error " Invalid message: %s " line))
237+ (let ((arg (decode-coding-string (match-string 0 line) 'undecided )))
238+ (push arg args)
239+ (setq pos (+ (length arg) pos)))
240+
241+ ; ; Arguments.
242+ (while (and (string-match " :\\ (.*\\ )\\ | \\ ([^ ]*\\ )" line pos)
243+ (< pos end))
244+ (let ((arg-end (length (match-string 0 line)))
245+ (arg (decode-coding-string (or (match-string 1 line)
246+ (match-string 2 line))
247+ 'undecided )))
248+ (push arg args)
249+ (setq pos (+ arg-end pos))))
250+ (cons sender (nreverse args))))
253251
254252(defun irc-userstring-nick (userstring )
255253 " Return the nick in a given USERSTRING.
0 commit comments