Function: gdb-mi--parse-c-string

gdb-mi--parse-c-string is a byte-compiled function defined in gdb-mi.el.gz.

Signature

(gdb-mi--parse-c-string)

Documentation

Parse a c-string.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/gdb-mi.el.gz
(defun gdb-mi--parse-c-string ()
  "Parse a c-string."
  (let ((start (point))
        (pieces nil)
        (octals-used nil))
    (while (and (re-search-forward (rx (or ?\\ ?\")))
                (not (eq (preceding-char) ?\")))
      (push (buffer-substring start (1- (point))) pieces)
      (cond
       ((looking-at (rx (any "0-7") (? (any "0-7") (? (any "0-7")))))
        (push (unibyte-string (string-to-number (match-string 0) 8)) pieces)
        (setq octals-used t)
        (goto-char (match-end 0)))
       ((looking-at (rx (any "ntrvfab\"\\")))
        (push (cdr (assq (following-char)
                         '((?n . "\n")
                           (?t . "\t")
                           (?r . "\r")
                           (?v . "\v")
                           (?f . "\f")
                           (?a . "\a")
                           (?b . "\b")
                           (?\" . "\"")
                           (?\\ . "\\"))))
              pieces)
        (forward-char))
       (t
        (warn "Unrecognized escape char: %c" (following-char))))
      (setq start (point)))
    (push (buffer-substring start (1- (point))) pieces)
    (let ((s (apply #'concat (nreverse pieces))))
      (if (and octals-used gdb-mi-decode-strings)
          (let ((coding
                 (if (coding-system-p gdb-mi-decode-strings)
                     gdb-mi-decode-strings
                   (buffer-local-value
                    'buffer-file-coding-system
                    ;; FIXME: This is somewhat expensive.
                    (gdb-get-buffer-create 'gdb-partial-output-buffer)))))
            (decode-coding-string s coding))
        s))))