Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/msgc const-ify strings as appropriate, and convert m...
details: https://anonhg.NetBSD.org/src/rev/970ea071039a
branches: trunk
changeset: 474379:970ea071039a
user: cgd <cgd%NetBSD.org@localhost>
date: Sun Jul 04 21:30:14 1999 +0000
description:
const-ify strings as appropriate, and convert message 'numbers' from
ints to 'msg's. 'msg' is currently typedef'd as 'const char *', but it'll
become more complex eventually.
diffstat:
usr.bin/msgc/msg_sys.def | 46 +++++++++++++++++++++++-----------------------
usr.bin/msgc/msgc.1 | 22 +++++++++++-----------
usr.bin/msgc/msgdb.c | 27 +++++++++++++++------------
3 files changed, 49 insertions(+), 46 deletions(-)
diffs (260 lines):
diff -r 3e086a8dcfc0 -r 970ea071039a usr.bin/msgc/msg_sys.def
--- a/usr.bin/msgc/msg_sys.def Sun Jul 04 20:16:57 1999 +0000
+++ b/usr.bin/msgc/msg_sys.def Sun Jul 04 21:30:14 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msg_sys.def,v 1.15 1999/07/04 10:39:40 cgd Exp $ */
+/* $NetBSD: msg_sys.def,v 1.16 1999/07/04 21:30:14 cgd Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -44,9 +44,9 @@
static int last_o_was_punct, last_o_was_space;
static void _msg_beep(void);
-static int _msg_vprintf(int auto_fill, char *fmt, va_list ap);
-static void _msg_vprompt(char *msg, int do_echo, char *def, char *val,
- int max_chars, va_list ap);
+static int _msg_vprintf(int auto_fill, const char *fmt, va_list ap);
+static void _msg_vprompt(const char *msg, int do_echo, const char *def,
+ char *val, int max_chars, va_list ap);
/* Routines */
@@ -76,9 +76,9 @@
return 0;
}
-char *msg_string (int msg_no)
+const char *msg_string (msg msg_no)
{
- return msg_list[msg_no];
+ return msg_list[(long)msg_no];
}
void msg_clear(void)
@@ -100,7 +100,7 @@
}
static int
-_msg_vprintf(int auto_fill, char *fmt, va_list ap)
+_msg_vprintf(int auto_fill, const char *fmt, va_list ap)
{
const char *wstart, *afterw;
int wordlen, nspaces;
@@ -225,27 +225,27 @@
return ret;
}
-void msg_display(int msg_no, ...)
+void msg_display(msg msg_no, ...)
{
va_list ap;
msg_clear();
va_start(ap, msg_no);
- (void)_msg_vprintf(1, msg_list[msg_no], ap);
+ (void)_msg_vprintf(1, msg_string(msg_no), ap);
va_end(ap);
}
-void msg_display_add(int msg_no, ...)
+void msg_display_add(msg msg_no, ...)
{
va_list ap;
va_start (ap, msg_no);
- (void)_msg_vprintf(1, msg_list[msg_no], ap);
+ (void)_msg_vprintf(1, msg_string(msg_no), ap);
va_end (ap);
}
-int msg_printf (char *fmt, ...)
+int msg_printf (const char *fmt, ...)
{
va_list ap;
int res;
@@ -258,7 +258,7 @@
return res;
}
-int msg_printf_add (char *fmt, ...)
+int msg_printf_add (const char *fmt, ...)
{
va_list ap;
int res;
@@ -271,8 +271,8 @@
static void
-_msg_vprompt(char *msg, int do_echo, char *def, char *val, int max_chars,
- va_list ap)
+_msg_vprompt(const char *msg, int do_echo, const char *def, char *val,
+ int max_chars, va_list ap)
{
int ch;
int count = 0;
@@ -360,45 +360,45 @@
}
void
-msg_prompt(int msg_no, char *def, char *val, int max_chars, ...)
+msg_prompt(msg msg_no, const char *def, char *val, int max_chars, ...)
{
va_list ap;
msg_clear();
va_start (ap, max_chars);
- _msg_vprompt(msg_list[msg_no], 1, def, val, max_chars, ap);
+ _msg_vprompt(msg_string(msg_no), 1, def, val, max_chars, ap);
va_end (ap);
}
void
-msg_prompt_add(int msg_no, char *def, char *val, int max_chars, ...)
+msg_prompt_add(msg msg_no, const char *def, char *val, int max_chars, ...)
{
va_list ap;
va_start (ap, max_chars);
- _msg_vprompt(msg_list[msg_no], 1, def, val, max_chars, ap);
+ _msg_vprompt(msg_string(msg_no), 1, def, val, max_chars, ap);
va_end(ap);
}
void
-msg_prompt_noecho(int msg_no, char *def, char *val, int max_chars, ...)
+msg_prompt_noecho(msg msg_no, const char *def, char *val, int max_chars, ...)
{
va_list ap;
msg_clear();
va_start (ap, max_chars);
- _msg_vprompt(msg_list[msg_no], 0, def, val, max_chars, ap);
+ _msg_vprompt(msg_string(msg_no), 0, def, val, max_chars, ap);
va_end (ap);
}
-void msg_table_add(int msg_no, ...)
+void msg_table_add(msg msg_no, ...)
{
va_list ap;
va_start (ap, msg_no);
- (void)_msg_vprintf(0, msg_list[msg_no], ap);
+ (void)_msg_vprintf(0, msg_string(msg_no), ap);
va_end (ap);
}
diff -r 3e086a8dcfc0 -r 970ea071039a usr.bin/msgc/msgc.1
--- a/usr.bin/msgc/msgc.1 Sun Jul 04 20:16:57 1999 +0000
+++ b/usr.bin/msgc/msgc.1 Sun Jul 04 21:30:14 1999 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: msgc.1,v 1.8 1999/07/04 10:35:19 cgd Exp $
+.\" $NetBSD: msgc.1,v 1.9 1999/07/04 21:30:14 cgd Exp $
.\"
.\" Copyright 1997 Piermont Information Systems Inc.
.\" All rights reserved.
@@ -47,8 +47,8 @@
.Fd #include \b'"'msg_defs.h\b'"'
.Ft void
.Fn msg_window "WINDOW *window"
-.Ft char *
-.Fn msg_string "int msg_no"
+.Ft const char *
+.Fn msg_string "msg msg_no"
.Ft void
.Fn msg_clear "void"
.Ft void
@@ -56,21 +56,21 @@
.Ft void
.Fn msg_standend "void"
.Ft void
-.Fn msg_display "int msg_no" ...
+.Fn msg_display "msg msg_no" ...
.Ft void
-.Fn msg_display_add "int msg_no" ...
+.Fn msg_display_add "msg msg_no" ...
.Ft int
-.Fn msg_printf "char *fmt" ...
+.Fn msg_printf "const char *fmt" ...
.Ft int
-.Fn msg_printf_add "char *fmt" ...
+.Fn msg_printf_add "const char *fmt" ...
.Ft void
-.Fn msg_prompt "int msg_no" "char *def" "char *val" "int max_chars" ...
+.Fn msg_prompt "msg msg_no" "const char *def" "char *val" "int max_chars" ...
.Ft void
-.Fn msg_prompt_add "int msg_no" "char *def" "char *val" "int max_chars" ...
+.Fn msg_prompt_add "msg msg_no" "const char *def" "char *val" "int max_chars" ...
.Ft void
-.Fn msg_prompt_noecho "int msg_no" "char *def" "char *val" "int max_chars" ...
+.Fn msg_prompt_noecho "msg msg_no" "const char *def" "char *val" "int max_chars" ...
.Ft void
-.Fn msg_table_add "int msg_no" ...
+.Fn msg_table_add "msg msg_no" ...
.Sh DESCRIPTION
This implements a curses based message display system. A source file that
lists messages with associated names is given to
diff -r 3e086a8dcfc0 -r 970ea071039a usr.bin/msgc/msgdb.c
--- a/usr.bin/msgc/msgdb.c Sun Jul 04 20:16:57 1999 +0000
+++ b/usr.bin/msgc/msgdb.c Sun Jul 04 21:30:14 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: msgdb.c,v 1.9 1999/07/04 10:35:19 cgd Exp $ */
+/* $NetBSD: msgdb.c,v 1.10 1999/07/04 21:30:15 cgd Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -141,28 +141,31 @@
"#include <stdarg.h>\n"
"#include <curses.h>\n"
"\n"
+ "typedef const char *msg;\n"
+ "\n"
"/* Prototypes */\n"
"int msg_window(WINDOW *window);\n"
- "char *msg_string (int msg_no);\n"
+ "const char *msg_string (msg msg_no);\n"
"void msg_clear(void);\n"
"void msg_standout(void);\n"
"void msg_standend(void);\n"
- "void msg_display(int msg_no,...);\n"
- "void msg_display_add(int msg_no,...);\n"
- "int msg_printf (char *fmt, ...);\n"
- "int msg_printf_add (char *fmt, ...);\n"
- "void msg_prompt (int msg_no, char *def,"
+ "void msg_display(msg msg_no,...);\n"
+ "void msg_display_add(msg msg_no,...);\n"
+ "int msg_printf (const char *fmt, ...);\n"
+ "int msg_printf_add (const char *fmt, ...);\n"
+ "void msg_prompt (msg msg_no, const char *def,"
" char *val, int max_chars, ...);\n"
- "void msg_prompt_add (int msg_no, char *def,"
+ "void msg_prompt_add (msg msg_no, const char *def,"
" char *val, int max_chars, ...);\n"
- "void msg_prompt_noecho (int msg_no, char *def,"
+ "void msg_prompt_noecho (msg msg_no, const char *def,"
" char *val, int max_chars, ...);\n"
- "void msg_table_add(int msg_no,...);\n"
+ "void msg_table_add(msg msg_no,...);\n"
"\n"
"/* Message names */\n"
);
+ (void) fprintf (out_file, "#define MSG_NONE\tNULL\n");
for (t=head; t != NULL; t = t->next) {
- (void) fprintf (out_file, "#define MSG_%s\t%d\n",
+ (void) fprintf (out_file, "#define MSG_%s\t((msg)(long)%d)\n",
t->id, t->msg_no);
}
(void) fprintf (out_file, "\n#endif\n");
@@ -181,7 +184,7 @@
(void)fprintf (out_file, "#include \"%s\"\n", hname);
/* msg_list */
- (void)fprintf (out_file, "char *msg_list[] = {\n");
+ (void)fprintf (out_file, "const char *msg_list[] = {\n");
for (t=head ; t != NULL; t = t->next)
write_str (out_file, t->msg);
(void)fprintf (out_file, "NULL};\n");
Home |
Main Index |
Thread Index |
Old Index