branch: externals/csv-mode commit f31c9d5657a755991301e3a099a6cde6306883b2 Author: Simen Heggestøyl <simen...@gmail.com> Commit: Simen Heggestøyl <simen...@gmail.com>
Fix bug in `csv-end-of-field' at end of file * csv-mode.el (csv-end-of-field): Avoid error when called on the last field when it's quoted and there's no trailing newline. Unbreaks the test `csv-mode-tests-end-of-field-with-quotes'. * csv-mode-tests.el (csv-mode-tests-align-fields-double-quote-comma): New test for Bug#14053. --- csv-mode-tests.el | 8 ++++++++ csv-mode.el | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/csv-mode-tests.el b/csv-mode-tests.el index b5e0b49..316dc4b 100644 --- a/csv-mode-tests.el +++ b/csv-mode-tests.el @@ -98,5 +98,13 @@ '("aaa, \"b,b\", ccc" "1 , 2 , 3"))) +;; Bug#14053 +(ert-deftest csv-mode-tests-align-fields-double-quote-comma () + (csv-mode-tests--align-fields + '("1,2,3" + "a,\"b\"\"c,\",d") + '("1, 2 , 3" + "a, \"b\"\"c,\", d"))) + (provide 'csv-mode-tests) ;;; csv-mode-tests.el ends here diff --git a/csv-mode.el b/csv-mode.el index 7b9c915..0e7b19d 100644 --- a/csv-mode.el +++ b/csv-mode.el @@ -677,7 +677,8 @@ point or marker arguments, BEG and END, delimiting the region." ;; According to RFC-4180 (sec 2.7), quotes inside quoted strings ;; are quoted by doubling the quote char: a,"b""c,",d ;; FIXME: Maybe we should handle this via syntax-propertize? - ((eq (char-syntax (char-after (1+ (point)))) ?\") + ((let ((c (char-after (1+ (point))))) + (and c (eq (char-syntax c) ?\"))) (forward-char 2)) (t (setq ended t))))))