Function: csv--collect-fields

csv--collect-fields is a natively compiled function defined in csv-mode.el.

Signature

(csv--collect-fields ROW-END-POSITION)

Documentation

Collect the fields of a row.

Splits a row into fields, honoring quoted fields, and returns the list of fields. ROW-END-POSITION is the end-of-line position. point is assumed to be at the beginning of the line.

Source Code

;; Defined in /nix/store/3gmjnyw9n226b7k7jamikx980vf8267p-emacs-packages-deps/share/emacs/site-lisp/elpa/csv-mode-1.27/csv-mode.el
(defun csv--collect-fields (row-end-position)
  "Collect the fields of a row.
Splits a row into fields, honoring quoted fields, and returns
the list of fields.  ROW-END-POSITION is the end-of-line position.
point is assumed to be at the beginning of the line."
  (let ((csv-field-quotes-regexp (apply #'concat `("[" ,@csv-field-quotes "]")))
	(row-text (buffer-substring-no-properties (point) row-end-position))
	fields field-start)
    (if (not (string-match csv-field-quotes-regexp row-text))
	(split-string row-text csv-separator-regexp)
      (save-excursion
	(while (< (setq field-start (point)) row-end-position)
          ;; csv-forward-field will skip a separator if point is on
          ;; it, and we'll miss an empty field
          (unless (memq (following-char) csv-separator-chars)
	    (csv-forward-field 1))
	  (push
	   (buffer-substring-no-properties field-start (point))
	   fields)
	  (if (memq (following-char) csv-separator-chars)
	      (forward-char)))
	(nreverse fields)))))