chiark / gitweb /
string-util: tweak cellescape() a bit
authorLennart Poettering <lennart@poettering.net>
Fri, 1 Jun 2018 19:45:23 +0000 (21:45 +0200)
committerSven Eden <yamakuzure@gmx.net>
Fri, 24 Aug 2018 14:47:08 +0000 (16:47 +0200)
commitae22dea58699350462ac7100283bec6919a60765
tree7d0b7aa2912b02c823a147f8291a9b4186e80f74
parent5acc15fbb0ce306d4a2f4e0d47f4c5d5ac433b08
string-util: tweak cellescape() a bit

For short buffer sizes cellescape() was a bit wasteful, as it might
suffice to to drop a single character to find enough place for the full
four byte ellipsis, if that one character was a four character escape.
With this rework we'll guarantee to drop the minimum number of
characters from the end to fit in the ellipsis.

If the buffers we write to are large this doesn't matter much. However,
if they are short (as they are when talking about the process comm
field) then it starts to matter that we put as much information as we
can in the space we get.
src/basic/string-util.c
src/test/test-string-util.c