HomePhabricator

misc: Add a function to encode newlines

Authored by ansasaki on Nov 4 2019, 3:35 PM.

Description

misc: Add a function to encode newlines

Given a string, the added function encodes existing newline characters
('\n') as the string "\\n" and puts into a given output buffer.

The output buffer must have at least 2 times the length of the input
string plus 1 for the terminating '\0'. In the worst case, each
character can be replaced by 2 characters.

Fixes T189

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>

Details

Committed
asnDec 9 2019, 4:08 PM
Parents
rLIBSSH6c79ed980163: gzip: Use SSH_BUFFER_FREE()
Branches
Unknown
Tags
Unknown
Tasks
Restricted Maniphest Task