summaryrefslogtreecommitdiff
path: root/usr.bin/msgc/msg_sys.def
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2019-06-20 00:45:18 +0000
committerchristos <christos@NetBSD.org>2019-06-20 00:45:18 +0000
commit9ecdf1614e59eb187ab58000dcdfdaa7fa794ec4 (patch)
treeaa1812c972be31aee28678162d8827c0d58d9309 /usr.bin/msgc/msg_sys.def
parentf9805030357f8b55fdbda020f97f9bef197297b8 (diff)
Introduce _fmt_ flavors of the menu functions that take a formatting string
so we can use fmtcheck(3) to check the formats of the messages strings.
Diffstat (limited to 'usr.bin/msgc/msg_sys.def')
-rw-r--r--usr.bin/msgc/msg_sys.def109
1 files changed, 81 insertions, 28 deletions
diff --git a/usr.bin/msgc/msg_sys.def b/usr.bin/msgc/msg_sys.def
index e00e5cb6df0..5e46a4380bf 100644
--- a/usr.bin/msgc/msg_sys.def
+++ b/usr.bin/msgc/msg_sys.def
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_sys.def,v 1.44 2019/03/01 17:02:21 martin Exp $ */
+/* $NetBSD: msg_sys.def,v 1.45 2019/06/20 00:45:18 christos Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -158,7 +158,7 @@ msg_standend(void)
wstandend(msg_win);
}
-static int
+static int __printflike(2, 0)
_msg_vprintf(int auto_fill, const char *fmt, va_list ap)
{
const char *wstart, *afterw;
@@ -285,28 +285,42 @@ out:
}
void
-msg_display(msg msg_no, ...)
+msg_display(msg msg_no)
+{
+
+ msg_printf("%s", msg_string(msg_no));
+}
+
+void __printflike(2, 3)
+msg_fmt_display(msg msg_no, const char *fmt, ...)
{
va_list ap;
msg_clear();
- va_start(ap, msg_no);
- (void)_msg_vprintf(1, msg_string(msg_no), ap);
+ va_start(ap, fmt);
+ (void)_msg_vprintf(1, fmtcheck(msg_string(msg_no), fmt), ap);
va_end(ap);
}
void
-msg_display_add(msg msg_no, ...)
+msg_display_add(msg msg_no)
+{
+
+ msg_printf("%s", msg_string(msg_no));
+}
+
+void __printflike(2, 3)
+msg_fmt_display_add(msg msg_no, const char *fmt, ...)
{
va_list ap;
- va_start(ap, msg_no);
- (void)_msg_vprintf(1, msg_string(msg_no), ap);
+ va_start(ap, fmt);
+ (void)_msg_vprintf(1, fmtcheck(msg_string(msg_no), fmt), ap);
va_end(ap);
}
-void
+void __printflike(1, 2)
msg_printf(const char *fmt, ...)
{
va_list ap;
@@ -316,7 +330,7 @@ msg_printf(const char *fmt, ...)
va_end(ap);
}
-static void
+static void __printflike(1, 0)
_msg_vprompt(const char *fmt, int flags, const char *def, char *val,
size_t val_buf_len, va_list ap)
{
@@ -469,21 +483,36 @@ _msg_vprompt(const char *fmt, int flags, const char *def, char *val,
}
void
-msg_prompt(msg msg_no, const char *def, char *val, size_t val_buf_len, ...)
+msg_prompt(msg msg_no, const char *def, char *val, size_t val_buf_len)
+{
+
+ msg_fmt_prompt(msg_no, def, val, val_buf_len, "");
+}
+
+void __printflike(5, 6)
+msg_fmt_prompt(msg msg_no, const char *def, char *val, size_t val_buf_len,
+ const char *fmt, ...)
{
va_list ap;
msg_clear();
- va_start(ap, val_buf_len);
- _msg_vprompt(msg_string(msg_no), MSG_PROMPT_ECHO,
+ va_start(ap, fmt);
+ _msg_vprompt(fmtcheck(msg_string(msg_no), fmt), MSG_PROMPT_ECHO,
def, val, val_buf_len, ap);
va_end(ap);
}
void
msg_prompt_win(msg msg_no, int x, int y, int w, int h,
- const char *def, char *val, size_t val_buf_len, ...)
+ const char *def, char *val, size_t val_buf_len)
+{
+ msg_fmt_prompt_win(msg_no, x, y, w, h, def, val, val_buf_len, "");
+}
+
+void __printflike(9, 10)
+msg_fmt_prompt_win(msg msg_no, int x, int y, int w, int h,
+ const char *def, char *val, size_t val_buf_len, const char *fmt, ...)
{
va_list ap;
WINDOW *win;
@@ -495,10 +524,10 @@ msg_prompt_win(msg msg_no, int x, int y, int w, int h,
maxx = getmaxx(msg_win);
maxy = getmaxy(msg_win);
if (w == 0) {
- va_start(ap, val_buf_len);
- w = vsnprintf(NULL, 0, msg_string(msg_no), ap);
+ va_start(ap, fmt);
+ w = vsnprintf(NULL, 0, fmtcheck(msg_string(msg_no), fmt), ap);
va_end(ap);
- if (def != NULL && *def != 0 && w + (int)val_buf_len * 2 < maxx) {
+ if (def != NULL && *def != 0 && w + (int)val_buf_len * 2 < maxx) {
w += 2 + strlen(def) + 1;
msg_flags &= ~MSG_PROMPT_HIDE_DFLT;
}
@@ -561,7 +590,7 @@ msg_prompt_win(msg msg_no, int x, int y, int w, int h,
msg_clear();
}
- va_start(ap, val_buf_len);
+ va_start(ap, fmt);
_msg_vprompt(msg_string(msg_no), msg_flags, def, val, val_buf_len, ap);
va_end(ap);
@@ -579,35 +608,59 @@ msg_prompt_win(msg msg_no, int x, int y, int w, int h,
}
}
-void
-msg_prompt_add(msg msg_no, const char *def, char *val, size_t val_buf_len, ...)
+void
+msg_prompt_add(msg msg_no, const char *def, char *val, size_t val_buf_len)
+{
+
+ msg_fmt_prompt_add(msg_no, def, val, val_buf_len, "");
+}
+
+void __printflike(5, 6)
+msg_fmt_prompt_add(msg msg_no, const char *def, char *val, size_t val_buf_len,
+ const char *fmt, ...)
{
va_list ap;
- va_start(ap, val_buf_len);
- _msg_vprompt(msg_string(msg_no), MSG_PROMPT_ECHO, def, val, val_buf_len, ap);
+ va_start(ap, fmt);
+ _msg_vprompt(fmtcheck(msg_string(msg_no), fmt), MSG_PROMPT_ECHO, def,
+ val, val_buf_len, ap);
va_end(ap);
}
void
-msg_prompt_noecho(msg msg_no, const char *def, char *val, size_t val_buf_len, ...)
+msg_prompt_noecho(msg msg_no, const char *def, char *val, size_t val_buf_len)
+{
+ msg_fmt_prompt_noecho(msg_no, def, val, val_buf_len, "");
+}
+
+void __printflike(5, 6)
+msg_fmt_prompt_noecho(msg msg_no, const char *def, char *val,
+ size_t val_buf_len, const char *fmt, ...)
{
va_list ap;
msg_clear();
- va_start(ap, val_buf_len);
- _msg_vprompt(msg_string(msg_no), 0, def, val, val_buf_len, ap);
+ va_start(ap, fmt);
+ _msg_vprompt(fmtcheck(msg_string(msg_no), fmt), 0, def, val,
+ val_buf_len, ap);
va_end(ap);
}
void
-msg_table_add(msg msg_no, ...)
+msg_table_add(msg msg_no)
+{
+
+ msg_printf("%s", msg_string(msg_no));
+}
+
+void __printflike(2, 3)
+msg_fmt_table_add(msg msg_no, const char *fmt, ...)
{
va_list ap;
- va_start(ap, msg_no);
- (void)_msg_vprintf(0, msg_string(msg_no), ap);
+ va_start(ap, fmt);
+ (void)_msg_vprintf(0, fmtcheck(msg_string(msg_no), fmt), ap);
va_end(ap);
}