From a96faee879f2b7a556a2428a8b38b0c081217a24 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Tue, 4 Oct 2011 22:54:35 +0200 Subject: [PATCH] Make xbt_strbuff_chomp() really do its work. --- src/xbt/xbt_strbuff.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/xbt/xbt_strbuff.c b/src/xbt/xbt_strbuff.c index b12ff3c299..a474b3a258 100644 --- a/src/xbt/xbt_strbuff.c +++ b/src/xbt/xbt_strbuff.c @@ -88,10 +88,9 @@ void xbt_strbuff_append(xbt_strbuff_t b, const char *toadd) XBT_INLINE void xbt_strbuff_chomp(xbt_strbuff_t b) { - while (b->data[b->used] == '\n') { + while (b->used && b->data[b->used - 1] == '\n') { + b->used--; b->data[b->used] = '\0'; - if (b->used) - b->used--; } } -- 2.20.1