aboutsummaryrefslogtreecommitdiffstats
path: root/config/columns.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-01-17 14:33:09 +0100
committerRobin Jarry <robin@jarry.cc>2023-01-26 00:20:45 +0100
commit3191ee171c435a43912264b131340af66fea8112 (patch)
tree2a68c5c4a3b9975d102cb379171548e7a8937da5 /config/columns.go
parenta8b6693f7e7bdcc8b73c3fa0baa0ef5f51993dc7 (diff)
downloadaerc-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 'config/columns.go')
0 files changed, 0 insertions, 0 deletions