diff options
author | Robin Jarry <robin@jarry.cc> | 2023-01-17 14:33:09 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-01-26 00:20:45 +0100 |
commit | 3191ee171c435a43912264b131340af66fea8112 (patch) | |
tree | 2a68c5c4a3b9975d102cb379171548e7a8937da5 /.builds/alpine-edge.yml | |
parent | a8b6693f7e7bdcc8b73c3fa0baa0ef5f51993dc7 (diff) | |
download | aerc-3191ee171c435a43912264b131340af66fea8112.tar.gz |
filters: rewrite wrap in c
This utility introduced in commit c9524d265793 ("filters: add wrap
utility written in go") allows to reflow text to view emails that have
very long lines without breaking quotes, lists and indentation.
For such a simple task, go produces a binary that is 2.0M bytes on disk.
After stripping debugging symbols, it can be reduced to 1.2M bytes. All
of this for 267 lines of source code. This is a bit ridiculous, provided
people may load this binary into memory multiple times per minute. This
tool is a small side-project that seems not suitable for golang.
Rewrite it in C. It now only depends on a POSIX libc to run. It is safe
to assume that there is one available on all *NIX systems in the world
of 2023. The resulting binary is now 27K bytes (15K after stripping).
To build it, a C compiler and libc headers are required. These should
most likely be available since they are dependencies of the go compiler
toolchain.
I have tested compilation (with clang-analyzer and gcc -fanalyzer) and
basic operation on FreeBSD, Fedora (glibc) and Alpine (musl libc). More
tests would probably be required on MacOSX and older Linux distros.
I also added test vectors to give some confidence that this works as
expected.
Update CI with aggressive gcc hardening flags and to run these tests
with valgrind --leak-check=full.
Command line options are unchanged:
usage: wrap [-h] [-w INT] [-r] [-l INT] [-f FILE]
Wrap text without messing up email quotes.
options:
-h show this help message
-w INT preferred wrap margin (default 80)
-r reflow all paragraphs even if no trailing space
-l INT minimum percentage of letters in a line to be considered
a paragaph
-f FILE read from filename (default stdin)
Signed-off-by: Robin Jarry <robin@jarry.cc>
Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
Tested-by: Maxwell G <gotmax@e.email>
Diffstat (limited to '.builds/alpine-edge.yml')
-rw-r--r-- | .builds/alpine-edge.yml | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/.builds/alpine-edge.yml b/.builds/alpine-edge.yml index 0d795595..8398a9a4 100644 --- a/.builds/alpine-edge.yml +++ b/.builds/alpine-edge.yml @@ -5,11 +5,17 @@ packages: - gnupg - notmuch-dev - scdoc + - valgrind sources: - "https://git.sr.ht/~rjarry/aerc" environment: DESTDIR: ./out GOFLAGS: "-tags=notmuch" + CC: gcc + CFLAGS: > + -O2 -g -Wall -Wextra -Werror -Wformat-security -Wstack-protector + -fstack-protector-strong -fanalyzer + FILTERS_TEST_PREFIX: valgrind --leak-check=full --error-exitcode=1 tasks: - lint: | cd aerc |