]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/basic/string-util.c
string-util: tweak cellescape() a bit
authorLennart Poettering <lennart@poettering.net>
Fri, 1 Jun 2018 19:45:23 +0000 (21:45 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 1 Jun 2018 19:49:16 +0000 (21:49 +0200)
commit61f6e276714c0bc5c43f7f0c9daf1863f3958987
tree9922075c13388040331fb539a0e7b4ea65eb1f04
parent76a359736f0f57d8a77b143fe682eceed51d9cda
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