Function: gud-perldb-massage-args
gud-perldb-massage-args is a byte-compiled function defined in
gud.el.gz.
Signature
(gud-perldb-massage-args FILE ARGS)
Documentation
Convert a command line as would be typed normally to run perldb
into one that invokes an Emacs-enabled debugging session.
"-emacs" is inserted where it will be $ARGV[0] (see perl5db.pl).
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/gud.el.gz
(defun gud-perldb-massage-args (_file args)
"Convert a command line as would be typed normally to run perldb
into one that invokes an Emacs-enabled debugging session.
\"-emacs\" is inserted where it will be $ARGV[0] (see perl5db.pl)."
;; FIXME: what if the command is `make perldb' and doesn't accept those extra
;; arguments ?
(let* ((new-args nil)
(seen-e nil)
(shift (lambda () (push (pop args) new-args))))
;; Pass all switches and -E/-e scripts through.
(while (and args
(string-match "^-" (car args))
(not (equal "-" (car args)))
(not (equal "--" (car args))))
(when (or (equal "-E" (car args)) (equal "-e" (car args)))
;; -e goes with the next arg, so shift one extra.
(funcall shift)
(or args
;; -E (or -e) as the last arg is an error in Perl.
(error "No code specified for %s" (car new-args)))
(setq seen-e t))
(funcall shift))
(unless seen-e
(if (or (not args)
(string-match "^-" (car args)))
(error "Can't use stdin as the script to debug"))
;; This is the program name.
(funcall shift))
;; If -e specified, make sure there is a -- so -emacs is not taken
;; as -e macs.
(if (and args (equal "--" (car args)))
(funcall shift)
(and seen-e (push "--" new-args)))
(push "-emacs" new-args)
(while args
(funcall shift))
(nreverse new-args)))