From 6e9564f09a223f1c3f964e04905ecb3f235fa2f5 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mattias=20Engdeg=C3=A5rd?= Date: Fri, 6 Nov 2020 17:10:55 +0100 Subject: [PATCH] Fix javac message parsing column number off-by-one MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * lisp/progmodes/compile.el (compilation-error-regexp-alist-alist): 'javac': Column numbers are 1-based by default; remove subtraction and η-reduce. Translate regexp to rx (mechanised). * test/lisp/progmodes/compile-tests.el (compile-tests--test-regexps-data): Adapt 'javac' test cases to the change. --- lisp/progmodes/compile.el | 23 +++++++++++++---------- test/lisp/progmodes/compile-tests.el | 4 ++-- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el index de0ea428d5e..e0dabed6a7a 100644 --- a/lisp/progmodes/compile.el +++ b/lisp/progmodes/compile.el @@ -268,17 +268,20 @@ of[ \t]+\"?\\([a-zA-Z]?:?[^\":\n]+\\)\"?:" 3 2 nil (1)) "^\\(?:[ \t]+at \\|==[0-9]+== +\\(?:at\\|b\\(y\\)\\)\\).+(\\([^()\n]+\\):\\([0-9]+\\))$" 2 3 nil (1)) (javac - ,(concat - ;; line1 - "^\\(\\(?:[A-Za-z]:\\)?[^:\n]+\\):" ;file - "\\([0-9]+\\): " ;line - "\\(warning: \\)?.*\n" ;type (optional) and message - ;; line2: source line containing error - ".*\n" - ;; line3: single "^" under error position in line2 - " *\\^$") + ,(rx bol + (group ; file + (? (in "A-Za-z") ":") + (+ (not (in "\n:")))) + ":" + (group (+ (in "0-9"))) ; line number + ": " + (? (group "warning: ")) ; type (optional) + (* nonl) "\n" ; message + (* nonl) "\n" ; source line containing error + (* " ") "^" ; caret line; ^ marks error + eol) 1 2 - ,(lambda () (1- (current-column))) + ,#'current-column (3)) (jikes-file diff --git a/test/lisp/progmodes/compile-tests.el b/test/lisp/progmodes/compile-tests.el index b8ed6e0e76b..0288cba789e 100644 --- a/test/lisp/progmodes/compile-tests.el +++ b/test/lisp/progmodes/compile-tests.el @@ -191,10 +191,10 @@ ;; javac (javac "/src/Test.java:5: ';' expected\n foo foo\n ^\n" - 1 15 5 "/src/Test.java" 2) + 1 16 5 "/src/Test.java" 2) (javac "e:\\src\\Test.java:7: warning: ';' expected\n foo foo\n ^\n" - 1 10 7 "e:\\src\\Test.java" 1) + 1 11 7 "e:\\src\\Test.java" 1) ;; jikes-file jikes-line (jikes-file "Found 2 semantic errors compiling \"../javax/swing/BorderFactory.java\":" -- 2.39.2