emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/csv-mode 8849ff3: Allow quoting quotes in csv fields


From: Lars Ingebrigtsen
Subject: [elpa] externals/csv-mode 8849ff3: Allow quoting quotes in csv fields
Date: Sun, 6 Dec 2020 13:45:59 -0500 (EST)

branch: externals/csv-mode
commit 8849ff33eb3e3c7417ffce37982d890597159240
Author: Lars Ingebrigtsen <larsi@gnus.org>
Commit: Lars Ingebrigtsen <larsi@gnus.org>

    Allow quoting quotes in csv fields
    
    * csv-mode.el (csv-end-of-field): Allow parsing of quoted quotes
    in quoted strings (bug#14053).
---
 csv-mode.el | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/csv-mode.el b/csv-mode.el
index 4e4c4b7..b243c4b 100644
--- a/csv-mode.el
+++ b/csv-mode.el
@@ -662,8 +662,20 @@ point or marker arguments, BEG and END, delimiting the 
region."
 (defun csv-end-of-field ()
   "Skip forward over one field."
   (skip-chars-forward " ")
-  (if (eq (char-syntax (following-char)) ?\")
-      (goto-char (scan-sexps (point) 1)))
+  ;; If the first character is a double quote, then we have a quoted
+  ;; value.
+  (when (eq (char-syntax (following-char)) ?\")
+    (forward-char)
+    (let ((ended nil))
+      (while (not ended)
+       (cond ((not (eq (char-syntax (following-char)) ?\"))
+              (forward-char 1))
+             ;; Quotes inside quoted strings are quoted by doubling
+             ;; the quote char: a,"b""c,",d
+             ((eq (char-syntax (char-after (1+ (point)))) ?\")
+              (forward-char 2))
+             (t
+              (setq ended t))))))
   (skip-chars-forward csv--skip-chars))
 
 (defun csv-beginning-of-field ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]