diff options
author | Jérémie Courrèges-Anglas <jca@wxcvbn.org> | 2013-11-17 18:33:14 +0100 |
---|---|---|
committer | Jérémie Courrèges-Anglas <jca@wxcvbn.org> | 2013-11-17 18:33:14 +0100 |
commit | 797796e2d9d4c708668ed05359695c53f8448386 (patch) | |
tree | d97c7fbe4742c62ed8e92a710a8cc4b916304d3f | |
parent | 5304bcb44ff71ddfa02af3bff4d05812b4fc4be3 (diff) | |
download | ratpoison-797796e2d9d4c708668ed05359695c53f8448386.zip |
Introduce sbuf_chop()
-rw-r--r-- | src/sbuf.c | 9 | ||||
-rw-r--r-- | src/sbuf.h | 4 |
2 files changed, 11 insertions, 2 deletions
@@ -143,3 +143,12 @@ sbuf_printf_concat (struct sbuf *b, char *fmt, ...) return b->data; } + +void +sbuf_chop (struct sbuf *b) +{ + if (b->len) + { + b->data[--(b->len)] = '\0'; + } +} @@ -24,8 +24,7 @@ #include <stdlib.h> -struct -sbuf +struct sbuf { char *data; size_t len; @@ -45,5 +44,6 @@ char *sbuf_clear (struct sbuf *b); char *sbuf_get (struct sbuf *b); char *sbuf_printf (struct sbuf *b, char *fmt, ...); char *sbuf_printf_concat (struct sbuf *b, char *fmt, ...); +void sbuf_chop (struct sbuf *b); #endif /* ! _RATPOISON_SBUF_H */ |