Function: gud-perldb-marker-filter
gud-perldb-marker-filter is a byte-compiled function defined in
gud.el.gz.
Signature
(gud-perldb-marker-filter STRING)
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/gud.el.gz
;; There's no guarantee that Emacs will hand the filter the entire
;; marker at once; it could be broken up across several strings. We
;; might even receive a big chunk with several markers in it. If we
;; receive a chunk of text which looks like it might contain the
;; beginning of a marker, we save it here between calls to the
;; filter.
(defun gud-perldb-marker-filter (string)
(setq gud-marker-acc (concat gud-marker-acc string))
(let ((output ""))
;; Process all the complete markers in this chunk.
;;
;; Here I match the string coming out of perldb.
;; The strings can look like any of
;;
;; "\032\032/tmp/tst.pl:6:0\n"
;; "\032\032(eval 5)[/tmp/tst.pl:6]:3:0\n"
;; "\032\032(eval 17)[Basic/Core/Core.pm.PL (i.e. PDL::Core.pm):2931]:1:0\n"
;;
;; From those I want the filename and the line number. First I look for
;; the eval case. If that doesn't match, I look for the "normal" case.
(while
(string-match
(eval-when-compile
(let ((file-re "\\(?:[a-zA-Z]:\\)?[^:\n]*"))
(concat "\032\032\\(?:"
(concat
"(eval [0-9]+)\\["
"\\(" file-re "\\)" ; Filename.
"\\(?: (i\\.e\\. [^)]*)\\)?"
":\\([0-9]*\\)\\]") ; Line number.
"\\|"
(concat
"\\(?1:" file-re "\\)" ; Filename.
":\\(?2:[0-9]*\\)") ; Line number.
"\\):.*\n")))
gud-marker-acc)
(setq
;; Extract the frame position from the marker.
gud-last-frame
(cons (match-string 1 gud-marker-acc)
(string-to-number (match-string 2 gud-marker-acc)))
;; Append any text before the marker to the output we're going
;; to return - we don't include the marker in this text.
output (concat output
(substring gud-marker-acc 0 (match-beginning 0)))
;; Set the accumulator to the remaining text.
gud-marker-acc (substring gud-marker-acc (match-end 0))))
;; Does the remaining text look like it might end with the
;; beginning of another marker? If it does, then keep it in
;; gud-marker-acc until we receive the rest of it. Since we
;; know the full marker regexp above failed, it's pretty simple to
;; test for marker starts.
(if (string-match "\032.*\\'" gud-marker-acc)
(progn
;; Everything before the potential marker start can be output.
(setq output (concat output (substring gud-marker-acc
0 (match-beginning 0))))
;; Everything after, we save, to combine with later input.
(setq gud-marker-acc
(substring gud-marker-acc (match-beginning 0))))
(setq output (concat output gud-marker-acc)
gud-marker-acc ""))
output))