aboutsummaryrefslogtreecommitdiff
path: root/filters
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-11-13 19:39:12 +0100
committerRobin Jarry <robin@jarry.cc>2023-12-04 17:03:34 +0100
commit0d98bb7f2418e3b73d8405c7674200778d3fbe0f (patch)
tree9c3a207c28a4c4d128660c92960636e6742ff7fc /filters
parent66b9d36b9231239542e21a4a130959ebf9d40819 (diff)
downloadaerc-0d98bb7f2418e3b73d8405c7674200778d3fbe0f.tar.gz
aerc-0d98bb7f2418e3b73d8405c7674200778d3fbe0f.zip
colorize: better detect diffs
Be more tolerant with diffs that were produced by other version control systems than git. OpenBSD for instance, uses CVS. Add more test cases from the OpenBSD mailing lists. Link: https://marc.info/?l=openbsd-ports&m=169989204001628&w=2 Link: https://marc.info/?l=openbsd-ports&m=169987607521242&w=2 Reported-by: Johannes Thyssen Tishman <johannes@thyssentishman.com> Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Johannes Thyssen Tishman <johannes@thyssentishman.com>
Diffstat (limited to 'filters')
-rw-r--r--filters/colorize.c25
-rw-r--r--filters/vectors/colorize-diff-cvs-bsd.expected31
-rw-r--r--filters/vectors/colorize-diff-cvs-bsd.in31
-rw-r--r--filters/vectors/colorize-diff-cvs-bsd2.expected74
-rw-r--r--filters/vectors/colorize-diff-cvs-bsd2.in74
5 files changed, 217 insertions, 18 deletions
diff --git a/filters/colorize.c b/filters/colorize.c
index d447dcb1..cf6b8402 100644
--- a/filters/colorize.c
+++ b/filters/colorize.c
@@ -585,8 +585,11 @@ static void header(const char *in)
urls(in, NULL);
}
+#define DIFF_START_RE "^(diff (--git|-up|-u)|---) [[:graph:]]"
+static regex_t diff_start_re;
+
#define DIFF_META_RE \
- "^(diff --git|(new|deleted) file|similarity" \
+ "^(diff (--git|-up|-u)|(new|deleted) file|similarity" \
" index|(rename|copy) (to|from)|index|---|\\+\\+\\+) "
static regex_t diff_meta_re;
@@ -679,23 +682,8 @@ static void colorize_line(const char *in)
case SIGNATURE:
signature(in);
break;
- case BODY:
- if (startswith(in, ">")) {
- quote(in);
- } else if (startswith(in, "diff --git ")) {
- state = DIFF;
- print_style(in, &styles.diff_meta);
- } else if (!strcmp(in, "--") || !strcmp(in, "-- ")) {
- state = SIGNATURE;
- signature(in);
- } else if (!regexec(&header_re, in, 8, groups, 0)) {
- header(in);
- } else {
- urls(in, NULL);
- }
- break;
- default: /* INIT */
- if (startswith(in, "diff --git ")) {
+ default: /* BODY, INIT */
+ if (!regexec(&diff_start_re, in, 8, groups, 0)) {
state = DIFF;
print_style(in, &styles.diff_meta);
} else if (!strcmp(in, "--") || !strcmp(in, "-- ")) {
@@ -765,6 +753,7 @@ int main(int argc, char **argv)
int err;
regcomp(&header_re, HEADER_RE, REG_EXTENDED);
+ regcomp(&diff_start_re, DIFF_START_RE, REG_EXTENDED);
regcomp(&diff_meta_re, DIFF_META_RE, REG_EXTENDED);
regcomp(&url_re, URL_RE, REG_EXTENDED);
diff --git a/filters/vectors/colorize-diff-cvs-bsd.expected b/filters/vectors/colorize-diff-cvs-bsd.expected
new file mode 100644
index 00000000..6aa14dab
--- /dev/null
+++ b/filters/vectors/colorize-diff-cvs-bsd.expected
@@ -0,0 +1,31 @@
+Simple diff updating optipng to 0.7.8
+
+Previous versions suffered from a buffer overflow in the GIF
+decoder.
+
+
+diff /usr/ports
+commit - 4757bf975713417bec00c44757c02a21c3b6b956
+path + /usr/ports
+blob - 0d3b98856492b3535664e4900d1b5582f41e6b7b
+file + graphics/optipng/Makefile
+--- graphics/optipng/Makefile
++++ graphics/optipng/Makefile
+@@ -1,7 +1,6 @@
+ COMMENT = lossless PNG optimizer
+-DISTNAME = optipng-0.7.7
++DISTNAME = optipng-0.7.8
+ CATEGORIES = graphics
+-REVISION = 1
+
+ HOMEPAGE = https://optipng.sourceforge.net/
+
+blob - 34f525b3d1ea7b210ee34d1b94c98bd76c30d01f
+file + graphics/optipng/distinfo
+--- graphics/optipng/distinfo
++++ graphics/optipng/distinfo
+@@ -1,2 +1,2 @@
+-SHA256 (optipng-0.7.7.tar.gz) = TzLyM874cLP5XTrWQov+QiTvNJCPG0Kwut+FghZlRFI=
+-SIZE (optipng-0.7.7.tar.gz) = 2329555
++SHA256 (optipng-0.7.8.tar.gz) = JaO9aEgfIVAsyqD0wT+E3PayAzjkxOjFHyzvvYUTOYw=
++SIZE (optipng-0.7.8.tar.gz) = 3294014
diff --git a/filters/vectors/colorize-diff-cvs-bsd.in b/filters/vectors/colorize-diff-cvs-bsd.in
new file mode 100644
index 00000000..0c0a5897
--- /dev/null
+++ b/filters/vectors/colorize-diff-cvs-bsd.in
@@ -0,0 +1,31 @@
+Simple diff updating optipng to 0.7.8
+
+Previous versions suffered from a buffer overflow in the GIF
+decoder.
+
+
+diff /usr/ports
+commit - 4757bf975713417bec00c44757c02a21c3b6b956
+path + /usr/ports
+blob - 0d3b98856492b3535664e4900d1b5582f41e6b7b
+file + graphics/optipng/Makefile
+--- graphics/optipng/Makefile
++++ graphics/optipng/Makefile
+@@ -1,7 +1,6 @@
+ COMMENT = lossless PNG optimizer
+-DISTNAME = optipng-0.7.7
++DISTNAME = optipng-0.7.8
+ CATEGORIES = graphics
+-REVISION = 1
+
+ HOMEPAGE = https://optipng.sourceforge.net/
+
+blob - 34f525b3d1ea7b210ee34d1b94c98bd76c30d01f
+file + graphics/optipng/distinfo
+--- graphics/optipng/distinfo
++++ graphics/optipng/distinfo
+@@ -1,2 +1,2 @@
+-SHA256 (optipng-0.7.7.tar.gz) = TzLyM874cLP5XTrWQov+QiTvNJCPG0Kwut+FghZlRFI=
+-SIZE (optipng-0.7.7.tar.gz) = 2329555
++SHA256 (optipng-0.7.8.tar.gz) = JaO9aEgfIVAsyqD0wT+E3PayAzjkxOjFHyzvvYUTOYw=
++SIZE (optipng-0.7.8.tar.gz) = 3294014
diff --git a/filters/vectors/colorize-diff-cvs-bsd2.expected b/filters/vectors/colorize-diff-cvs-bsd2.expected
new file mode 100644
index 00000000..560208bb
--- /dev/null
+++ b/filters/vectors/colorize-diff-cvs-bsd2.expected
@@ -0,0 +1,74 @@
+On Mon, Nov 13 2023, Jeremie Courreges-Anglas <]8;id=colorize-0;mailto://jca@wxcvbn.org\jca@wxcvbn.org]8;;\> wrote:
+> We need to disable optimization for python3 ports. Even with a fixed
+> path to libclang_rt.profile.etc, I get:
+>
+> ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol '__profd_isdigit'; recompile with -fPIC
+>
+> ok?
+
+The previous diff had an obvious issue spotted by ajacoutot@, thanks!
+
+
+Index: Makefile.inc
+===================================================================
+RCS file: /home/cvs/ports/lang/python/Makefile.inc,v
+diff -u -p -r1.159 Makefile.inc
+--- Makefile.inc 26 Sep 2023 12:02:03 -0000 1.159
++++ Makefile.inc 13 Nov 2023 16:11:40 -0000
+@@ -130,7 +130,9 @@ CONFIGURE_ARGS += --with-lto
+ . if ${MACHINE_ARCH} != "arm" && ${MACHINE_ARCH} != "powerpc"
+ # On armv7, clang errors out due to lack of memory.
+ # On powerpc, the python binary would crash by "Segmentation fault".
+-CONFIGURE_ARGS += --enable-optimizations
++# XXX lld from llvm-16 errors out with:
++# ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol '__profd_isdigit'; recompile with -fPIC
++#CONFIGURE_ARGS += --enable-optimizations
+ . endif
+ . endif
+ TEST_IS_INTERACTIVE = Yes
+Index: 3.10/Makefile
+===================================================================
+RCS file: /home/cvs/ports/lang/python/3.10/Makefile,v
+diff -u -p -r1.36 Makefile
+--- 3.10/Makefile 1 Sep 2023 18:48:06 -0000 1.36
++++ 3.10/Makefile 13 Nov 2023 15:53:49 -0000
+@@ -4,6 +4,7 @@
+ # Python itself.
+
+ FULL_VERSION = 3.10.13
++REVISION = 0
+ SHARED_LIBS = python3.10 0.0
+ VERSION_SPEC = >=3.10,<3.11
+ PORTROACH = limit:^3\.10
+Index: 3.11/Makefile
+===================================================================
+RCS file: /home/cvs/ports/lang/python/3.11/Makefile,v
+diff -u -p -r1.12 Makefile
+--- 3.11/Makefile 20 Oct 2023 09:18:48 -0000 1.12
++++ 3.11/Makefile 13 Nov 2023 15:54:05 -0000
+@@ -4,6 +4,7 @@
+ # Python itself.
+
+ FULL_VERSION = 3.11.6
++REVISION = 0
+ SHARED_LIBS = python3.11 0.0
+ VERSION_SPEC = >=3.11,<3.12
+ PORTROACH = limit:^3\.11
+Index: 3.9/Makefile
+===================================================================
+RCS file: /home/cvs/ports/lang/python/3.9/Makefile,v
+diff -u -p -r1.42 Makefile
+--- 3.9/Makefile 1 Sep 2023 18:50:44 -0000 1.42
++++ 3.9/Makefile 13 Nov 2023 15:53:58 -0000
+@@ -4,6 +4,7 @@
+ # Python itself.
+
+ FULL_VERSION = 3.9.18
++REVISION = 0
+ SHARED_LIBS = python3.9 0.0
+ VERSION_SPEC = >=3.9,<3.10
+ PORTROACH = limit:^3\.9
+
+
+-- 
+jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE
diff --git a/filters/vectors/colorize-diff-cvs-bsd2.in b/filters/vectors/colorize-diff-cvs-bsd2.in
new file mode 100644
index 00000000..681b6a9d
--- /dev/null
+++ b/filters/vectors/colorize-diff-cvs-bsd2.in
@@ -0,0 +1,74 @@
+On Mon, Nov 13 2023, Jeremie Courreges-Anglas <jca@wxcvbn.org> wrote:
+> We need to disable optimization for python3 ports. Even with a fixed
+> path to libclang_rt.profile.etc, I get:
+>
+> ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol '__profd_isdigit'; recompile with -fPIC
+>
+> ok?
+
+The previous diff had an obvious issue spotted by ajacoutot@, thanks!
+
+
+Index: Makefile.inc
+===================================================================
+RCS file: /home/cvs/ports/lang/python/Makefile.inc,v
+diff -u -p -r1.159 Makefile.inc
+--- Makefile.inc 26 Sep 2023 12:02:03 -0000 1.159
++++ Makefile.inc 13 Nov 2023 16:11:40 -0000
+@@ -130,7 +130,9 @@ CONFIGURE_ARGS += --with-lto
+ . if ${MACHINE_ARCH} != "arm" && ${MACHINE_ARCH} != "powerpc"
+ # On armv7, clang errors out due to lack of memory.
+ # On powerpc, the python binary would crash by "Segmentation fault".
+-CONFIGURE_ARGS += --enable-optimizations
++# XXX lld from llvm-16 errors out with:
++# ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol '__profd_isdigit'; recompile with -fPIC
++#CONFIGURE_ARGS += --enable-optimizations
+ . endif
+ . endif
+ TEST_IS_INTERACTIVE = Yes
+Index: 3.10/Makefile
+===================================================================
+RCS file: /home/cvs/ports/lang/python/3.10/Makefile,v
+diff -u -p -r1.36 Makefile
+--- 3.10/Makefile 1 Sep 2023 18:48:06 -0000 1.36
++++ 3.10/Makefile 13 Nov 2023 15:53:49 -0000
+@@ -4,6 +4,7 @@
+ # Python itself.
+
+ FULL_VERSION = 3.10.13
++REVISION = 0
+ SHARED_LIBS = python3.10 0.0
+ VERSION_SPEC = >=3.10,<3.11
+ PORTROACH = limit:^3\.10
+Index: 3.11/Makefile
+===================================================================
+RCS file: /home/cvs/ports/lang/python/3.11/Makefile,v
+diff -u -p -r1.12 Makefile
+--- 3.11/Makefile 20 Oct 2023 09:18:48 -0000 1.12
++++ 3.11/Makefile 13 Nov 2023 15:54:05 -0000
+@@ -4,6 +4,7 @@
+ # Python itself.
+
+ FULL_VERSION = 3.11.6
++REVISION = 0
+ SHARED_LIBS = python3.11 0.0
+ VERSION_SPEC = >=3.11,<3.12
+ PORTROACH = limit:^3\.11
+Index: 3.9/Makefile
+===================================================================
+RCS file: /home/cvs/ports/lang/python/3.9/Makefile,v
+diff -u -p -r1.42 Makefile
+--- 3.9/Makefile 1 Sep 2023 18:50:44 -0000 1.42
++++ 3.9/Makefile 13 Nov 2023 15:53:58 -0000
+@@ -4,6 +4,7 @@
+ # Python itself.
+
+ FULL_VERSION = 3.9.18
++REVISION = 0
+ SHARED_LIBS = python3.9 0.0
+ VERSION_SPEC = >=3.9,<3.10
+ PORTROACH = limit:^3\.9
+
+
+--
+jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE