From 911daed647eeb8617bf3b21e1f6e987e5e7e97f2 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 17 Dec 2003 12:25:09 +0000 Subject: [PATCH] (initialize): Replaced use of non-literal forma args. Suggested by Florian Weimer. --- jnlib/ChangeLog | 5 +++++ jnlib/argparse.c | 32 +++++++++++++++++--------------- 2 files changed, 22 insertions(+), 15 deletions(-) diff --git a/jnlib/ChangeLog b/jnlib/ChangeLog index a6ff01d71..89a3ccca4 100644 --- a/jnlib/ChangeLog +++ b/jnlib/ChangeLog @@ -1,3 +1,8 @@ +2003-12-17 Werner Koch + + * argparse.c (initialize): Replaced use of non-literal forma + args. Suggested by Florian Weimer. + 2003-12-16 Werner Koch * logging.c (writen, fun_writer, fun_closer): New. diff --git a/jnlib/argparse.c b/jnlib/argparse.c index 0eb99d452..148934637 100644 --- a/jnlib/argparse.c +++ b/jnlib/argparse.c @@ -165,35 +165,37 @@ initialize( ARGPARSE_ARGS *arg, const char *filename, unsigned *lineno ) if( filename ) { if( arg->r_opt == -6 ) - s = "%s:%u: argument not expected\n"; + s = "argument not expected\n"; else if( arg->r_opt == -5 ) - s = "%s:%u: read error\n"; + s = "read error\n"; else if( arg->r_opt == -4 ) - s = "%s:%u: keyword too long\n"; + s = "keyword too long\n"; else if( arg->r_opt == -3 ) - s = "%s:%u: missing argument\n"; + s = "missing argument\n"; else if( arg->r_opt == -7 ) - s = "%s:%u: invalid command\n"; + s = "invalid command\n"; else if( arg->r_opt == -10 ) - s = "%s:%u: invalid alias definition\n"; + s = "invalid alias definition\n"; else - s = "%s:%u: invalid option\n"; - jnlib_log_error(s, filename, *lineno ); + s = "invalid option\n"; + jnlib_log_error("%s:%u: %s\n", filename, *lineno, s); } else { + s = arg->internal.last? arg->internal.last:"[??]"; + if( arg->r_opt == -3 ) - s = "Missing argument for option \"%.50s\"\n"; + jnlib_log_error ("Missing argument for option \"%.50s\"\n", s); else if( arg->r_opt == -6 ) - s = "Option \"%.50s\" does not expect an argument\n"; + jnlib_log_error ("Option \"%.50s\" does not expect an argument\n", + s ); else if( arg->r_opt == -7 ) - s = "Invalid command \"%.50s\"\n"; + jnlib_log_error ("Invalid command \"%.50s\"\n", s); else if( arg->r_opt == -8 ) - s = "Option \"%.50s\" is ambiguous\n"; + jnlib_log_error ("Option \"%.50s\" is ambiguous\n", s); else if( arg->r_opt == -9 ) - s = "Command \"%.50s\" is ambiguous\n"; + jnlib_log_error ("Command \"%.50s\" is ambiguous\n",s ); else - s = "Invalid option \"%.50s\"\n"; - jnlib_log_error(s, arg->internal.last? arg->internal.last:"[??]" ); + jnlib_log_error ("Invalid option \"%.50s\"\n", s); } if( arg->err != 1 ) exit(2);