From: haj@posteo.de (Harald Jörg)
To: 45255@debbugs.gnu.org
Subject: bug#45255: [PATCH] cperl-mode: Don't mistreat <<>> as starting a here-doc
Date: Tue, 15 Dec 2020 18:55:07 +0100 [thread overview]
Message-ID: <87wnxjar9g.fsf@hajtower> (raw)
In-Reply-To: <alpine.LSU.2.21.2012151503070.5258@triangle>
[-- Attachment #1: Type: text/plain, Size: 135 bytes --]
The patch includes "<<>>" in the list of checks for stuff which does not
start a here-doc after "<<", and adds a test.
--
Cheers,
haj
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Don't treat <<>> as here-doc --]
[-- Type: text/x-diff, Size: 2174 bytes --]
From 80c7ba0cb9ffc71b5d3ebd389f668d1c8fd86462 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Harald=20J=C3=B6rg?= <haj@posteo.de>
Date: Tue, 15 Dec 2020 18:53:03 +0100
Subject: [PATCH] ; CPerl-mode: don't treat <<>> as starting a here-doc
* lisp/progmodes/cperl-mode.el (cperl-find-pods-heres): Detect
the "<<>>" operator (Bug#42455).
* test/lisp/progmodes/cperl-mode-tests.el
(cperl-test-bug-45255): Verify that <<>> does not start a
HERE-doc.
---
lisp/progmodes/cperl-mode.el | 3 ++-
test/lisp/progmodes/cperl-mode-tests.el | 8 ++++++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/lisp/progmodes/cperl-mode.el b/lisp/progmodes/cperl-mode.el
index ae839a6622..a9edb42b15 100644
--- a/lisp/progmodes/cperl-mode.el
+++ b/lisp/progmodes/cperl-mode.el
@@ -3694,13 +3694,14 @@ cperl-find-pods-heres
;; ;; "\\([^= \t0-9$@%&]\\|[ \t]+[^ \t\n0-9$@%&]\\)" ; 6 + 1
;; "\\(\\)" ; To preserve count of pars :-( 6 + 1
;; "\\)"
- ((match-beginning 3) ; 2 + 1
+ ((match-beginning 3) ; 2 + 1: found "<<", detect its type
(setq b (point)
tb (match-beginning 0)
c (and ; not HERE-DOC
(match-beginning 6)
(save-match-data
(or (looking-at "[ \t]*(") ; << function_call()
+ (looking-at ">>") ; <<>> operator
(save-excursion ; 1 << func_name, or $foo << 10
(condition-case nil
(progn
diff --git a/test/lisp/progmodes/cperl-mode-tests.el b/test/lisp/progmodes/cperl-mode-tests.el
index 896160bb88..cb2d067a61 100644
--- a/test/lisp/progmodes/cperl-mode-tests.el
+++ b/test/lisp/progmodes/cperl-mode-tests.el
@@ -312,4 +312,12 @@ cperl-test-bug-42168
(let ((code "{ $a- / $b } # /"))
(should (equal (nth 8 (cperl-test-ppss code "/")) 7))))
+(ert-deftest cperl-test-bug-45255 ()
+ "Verify that \"<<>>\" is recognized as not starting a HERE-doc."
+ (let ((code (concat "while (<<>>) {\n"
+ " ...;\n"
+ "}\n")))
+ ;; The yadda-yadda operator should not be in a string.
+ (should (equal (nth 8 (cperl-test-ppss code "\\.")) nil))))
+
;;; cperl-mode-tests.el ends here
--
2.20.1
next prev parent reply other threads:[~2020-12-15 17:55 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-15 14:20 bug#45255: cperl-mode doesn't recognise the double diamond operator E. Choroba
2020-12-15 17:55 ` Harald Jörg [this message]
2020-12-16 15:39 ` bug#45255: [PATCH] cperl-mode: Don't mistreat <<>> as starting a here-doc Stefan Kangas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87wnxjar9g.fsf@hajtower \
--to=haj@posteo.de \
--cc=45255@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.