Thread (21 messages) 21 messages, 4 authors, 2016-06-15

Re: [PATCH i18n 01/11] Add three convenient format printing functions with \n automatically appended

From: Jonathan Nieder <hidden>
Date: 2016-06-15 22:53:36

Nguyễn Thái Ngọc Duy wrote:
    printf("hello world\n");

can be converted to

    printf_ln(_("hello world"));
Fun.

[...]
quoted hunk ↗ jump to hunk
--- a/strbuf.c
+++ b/strbuf.c
@@ -464,3 +464,36 @@ void strbuf_addstr_urlencode(struct strbuf *sb, const char *s,
[...]
+int printf_ln(const char *fmt, ...)
+{
+	int ret;
+	va_list ap;
+	va_start(ap, fmt);
+	ret = vprintf(fmt, ap);
+	va_end(ap);
+	if (ret >= 0)
+		ret += printf("\n");
What happens if the second printf fails?
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help