diff options
Diffstat (limited to 'libbcachefs/printbuf.c')
-rw-r--r-- | libbcachefs/printbuf.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libbcachefs/printbuf.c b/libbcachefs/printbuf.c index 9f529e4c..4cf5a2af 100644 --- a/libbcachefs/printbuf.c +++ b/libbcachefs/printbuf.c @@ -316,6 +316,20 @@ void bch2_prt_newline(struct printbuf *buf) buf->cur_tabstop = 0; } +void bch2_printbuf_strip_trailing_newline(struct printbuf *out) +{ + for (int p = out->pos - 1; p >= 0; --p) { + if (out->buf[p] == '\n') { + out->pos = p; + break; + } + if (out->buf[p] != ' ') + break; + } + + printbuf_nul_terminate_reserved(out); +} + static void __prt_tab(struct printbuf *out) { int spaces = max_t(int, 0, cur_tabstop(out) - printbuf_linelen(out)); |