path: root/utf8.c
diff options
authorJeff King <>2011-02-23 09:50:19 (GMT)
committerJunio C Hamano <>2011-02-23 21:44:36 (GMT)
commit98acc837a14c2ab1975b38b93cb028e87e47ad4a (patch)
tree81d7357236e35497abebc42a95448d70df20a2fb /utf8.c
parent7ed863a85a6ce2c4ac4476848310b8f917ab41f9 (diff)
strbuf: add fixed-length version of add_wrapped_text
The function strbuf_add_wrapped_text takes a NUL-terminated string. This makes it annoying to wrap strings we have as a pointer and a length. Refactoring strbuf_add_wrapped_text and all of its sub-functions to handle fixed-length strings turned out to be really ugly. So this implementation is lame; it just strdups the text and operates on the NUL-terminated version. This should be fine as the strings we are wrapping are generally pretty short. If it becomes a problem, we can optimize later. Signed-off-by: Jeff King <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'utf8.c')
1 files changed, 9 insertions, 0 deletions
diff --git a/utf8.c b/utf8.c
index 84cfc72..8acbc66 100644
--- a/utf8.c
+++ b/utf8.c
@@ -405,6 +405,15 @@ new_line:
+int strbuf_add_wrapped_bytes(struct strbuf *buf, const char *data, int len,
+ int indent, int indent2, int width)
+ char *tmp = xstrndup(data, len);
+ int r = strbuf_add_wrapped_text(buf, tmp, indent, indent2, width);
+ free(tmp);
+ return r;
int is_encoding_utf8(const char *name)
if (!name)