Subject: bug#45255: [PATCH] cperl-mode: Don't mistreat <<>> as starting a here-doc

From: [email-masked] (Harald Jörg)
Date: Tue, 15 Dec 2020 18:55:07 +0100

The patch includes "<<>>" in the list of checks for stuff which does not
start a here-doc after "<<", and adds a test.
-- 
Cheers,
haj
>From 80c7ba0cb9ffc71b5d3ebd389f668d1c8fd86462 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Harald=20J=C3=B6rg?= <[email-masked]>
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