Function: sql-escape-newlines-filter

sql-escape-newlines-filter is a byte-compiled function defined in sql.el.gz.

Signature

(sql-escape-newlines-filter STRING)

Documentation

Escape newlines in STRING.

Every newline in STRING will be preceded with a space and a backslash.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/sql.el.gz
;; Using DB2 interactively, newlines must be escaped with " \".
;; The space before the backslash is relevant.

(defun sql-escape-newlines-filter (string)
  "Escape newlines in STRING.
Every newline in STRING will be preceded with a space and a backslash."
  (if (not sql-db2-escape-newlines)
      string
    (let ((result "") (start 0) mb me)
      (while (string-match "\n" string start)
        (setq mb (match-beginning 0)
              me (match-end 0)
              result (concat result
                             (substring string start mb)
                             (if (and (> mb 1)
                                      (string-equal " \\" (substring string (- mb 2) mb)))
                                 "" " \\\n"))
              start me))
      (concat result (substring string start)))))