mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-14 09:37:34 -05:00
Introduce and use strbuf_chomp.
Those chomp operations in wincons.c and uxcons.c looked ugly, and I'm not totally convinced they couldn't underrun the buffer by 1 byte in weird circumstances. strbuf_chomp is neater.
This commit is contained in:
9
utils.c
9
utils.c
@ -443,6 +443,15 @@ void strbuf_shrink_by(strbuf *buf, size_t amount_to_remove)
|
||||
buf->s[buf->len] = '\0';
|
||||
}
|
||||
|
||||
bool strbuf_chomp(strbuf *buf, char char_to_remove)
|
||||
{
|
||||
if (buf->len > 0 && buf->s[buf->len-1] == char_to_remove) {
|
||||
strbuf_shrink_by(buf, 1);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static void strbuf_BinarySink_write(
|
||||
BinarySink *bs, const void *data, size_t len)
|
||||
{
|
||||
|
Reference in New Issue
Block a user