[Dctrl-tools-devel] [PATCH] msg.[ch] (and others): allow the message functions to handle format strings

Antti-Juhani Kaijanaho ajk at debian.org
Sat Jul 5 10:40:06 UTC 2008


There are some places in the code where it would simplify both the code
and the translations to have message strings be printf-formatted.  This
change changes the message function interfaces so that they can take
a variable number of arguments.  This required changes at all call sites.

At the same time, the key logic of the message functions is moved out of
the headers, leaving only the "shall we output this" test for inlining.

Signed-off-by: Antti-Juhani Kaijanaho <ajk at debian.org>
---

(The previous version was broken in that message did not actually do
anything with its ellipsis arguments.)

debian/changelog        |    3 +-
 grep-dctrl/grep-dctrl.c |   58 ++++++++++++++++++++++------------------------
 grep-dctrl/rc.c         |   27 ++++++++++++---------
 join-dctrl/join-dctrl.c |   34 +++++++++++++-------------
 lib/misc.c              |    6 ++--
 lib/msg.c               |   16 ++++++++++++-
 lib/msg.h               |   41 ++++++++++++++++++++-------------
 lib/paragraph.c         |   16 +++++-------
 lib/predicate.c         |    8 +++---
 lib/sorter.c            |    6 ++--
 sort-dctrl/sort-dctrl.c |   10 ++++----
 tbl-dctrl/tbl-dctrl.c   |   12 +++++-----
 12 files changed, 130 insertions(+), 107 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 432bfe4..ece8e25 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,6 +1,7 @@
 dctrl-tools (2.14) UNRELEASED; urgency=low
 
-  * 
+  [ Antti-Juhani Kaijanaho ]
+  * msg.[ch] (and others): allow the message functions to handle format strings
 
  -- Antti-Juhani Kaijanaho <ajk at debian.org>  Fri, 04 Jul 2008 19:35:16 +0300
 
diff --git a/grep-dctrl/grep-dctrl.c b/grep-dctrl/grep-dctrl.c
index 3f6a81f..63936be 100644
--- a/grep-dctrl/grep-dctrl.c
+++ b/grep-dctrl/grep-dctrl.c
@@ -1,5 +1,5 @@
 /*  dctrl-tools - Debian control file inspection tools
-    Copyright © 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007
+    Copyright © 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
                 Antti-Juhani Kaijanaho
 
     This program is free software; you can redistribute it and/or modify
@@ -224,7 +224,7 @@ struct arguments {
 struct atom * clone_atom(struct arguments * args)
 {
 	if (args->p.num_atoms >= MAX_ATOMS) {
-		message(L_FATAL, _("predicate is too complex"), 0);
+		message(L_FATAL, 0, _("predicate is too complex"));
 		fail();
 	}
 	int oa = args->p.num_atoms-1;
@@ -301,7 +301,7 @@ static void apptok(struct arguments * args, const int tok)
 		finish_atom(args);
 	}
 	if (args->toks_np >= MAX_TOKS) {
-		message(L_FATAL, _("predicate is too long"), 0);
+		message(L_FATAL, 0, _("predicate is too long"));
 		fail();
 	}
 	args->toks[args->toks_np++] = tok;
@@ -333,7 +333,7 @@ static struct atom * enter_atom(struct arguments * args)
 	}
 	args->in_atom = true;
 	if (args->p.num_atoms >= MAX_ATOMS) {
-		message(L_FATAL, _("predicate is too complex"), 0);
+		message(L_FATAL, 0, _("predicate is too complex"));
 		fail();
 	}
 	APPTOK(args->p.num_atoms + TOK_ATOM_BASE);
@@ -360,7 +360,7 @@ static struct atom * enter_atom(struct arguments * args)
 #define set_mode(nmode) do { \
 	atom = ENTER_ATOM; \
 	if (atom->mode != M_SUBSTR) { \
-		message(L_FATAL, _("inconsistent atom modifiers"), 0); \
+		message(L_FATAL, 0, _("inconsistent atom modifiers")); \
 		fail(); \
 	} \
 	atom->mode = (nmode); \
@@ -419,7 +419,7 @@ static error_t parse_opt (int key, char * arg, struct argp_state * state)
                         }
                         struct field_attr *fa = fieldtrie_insert(s);
                         if (args->num_show_fields >= MAX_FIELDS) {
-                                message(L_FATAL, _("too many output fields"), 0);
+                                message(L_FATAL, 0, _("too many output fields"));
                                 fail();
                         }
                         args->show_fields[args->num_show_fields] = fa->inx;
@@ -443,7 +443,7 @@ static error_t parse_opt (int key, char * arg, struct argp_state * state)
 		int ll = str2loglevel(arg);
 		if (ll < 0)
 		{
-			message(L_FATAL, _("no such log level"), arg);
+			message(L_FATAL, 0, _("no such log level '%s'"), arg);
 			fail();
 		}
 		set_loglevel(ll);
@@ -537,8 +537,8 @@ static error_t parse_opt (int key, char * arg, struct argp_state * state)
                 debug_message("parse_opt: pattern", 0);
 		atom = ENTER_ATOM;
 		if (atom->pat != 0) {
-                        message(L_FATAL, _("Multiple patterns for the same "
-                                           "atom are not allowed"), 0);
+                        message(L_FATAL, 0, _("Multiple patterns for the same "
+                                              "atom are not allowed"));
                         fail();
                 }
 		atom->patlen = strlen(arg);
@@ -569,7 +569,7 @@ static error_t parse_opt (int key, char * arg, struct argp_state * state)
 		if (args->finished) {
 			char const * s;
 			if (args->num_fnames >= MAX_FNAMES) {
-				message(L_FATAL, _("too many file names"), 0);
+				message(L_FATAL, 0, _("too many file names"));
 				fail();
 			}
 			s = strdup(arg);
@@ -658,26 +658,26 @@ static void unexpected(int tok)
 {
 	switch (tok) {
 	case TOK_EOD:
-		message(L_FATAL, _("unexpected end of predicate"), 0);
+		message(L_FATAL, 0, _("unexpected end of predicate"));
 		fail();
 	case TOK_NOT: 
-		message(L_FATAL, _("unexpected '!' in command line"), 0);
+		message(L_FATAL, 0, _("unexpected '!' in command line"));
 		fail();
 	case TOK_AND:
-		message(L_FATAL, _("unexpected '-a' in command line"), 0);
+		message(L_FATAL, 0, _("unexpected '-a' in command line"));
 		fail();
 	case TOK_OR : 
-		message(L_FATAL, _("unexpected '-o' in command line"), 0);
+		message(L_FATAL, 0, _("unexpected '-o' in command line"));
 		fail();
 	case TOK_LP :
-		message(L_FATAL, _("unexpected '(' in command line"), 0);
+		message(L_FATAL, 0, _("unexpected '(' in command line"));
 		fail();
 	case TOK_RP :
-		message(L_FATAL, _("unexpected ')' in command line"), 0);
+		message(L_FATAL, 0, _("unexpected ')' in command line"));
 		fail();
 	default:
 		assert(tok >=TOK_ATOM_BASE);
-		message(L_FATAL, _("unexpected atom in command line"), 0);
+		message(L_FATAL, 0, _("unexpected atom in command line"));
 		fail();
 	}
 }
@@ -690,7 +690,7 @@ static void parse_prim(struct arguments * args)
 		get_token(args);
 		parse_conj(args);
 		if (get_token(args) != TOK_RP) {
-			message(L_FATAL, _("missing ')' in command line"), 0);
+			message(L_FATAL, 0, _("missing ')' in command line"));
 			fail();
 		}
 		return;
@@ -799,45 +799,43 @@ int main (int argc, char * argv[])
 #endif
 	parse_predicate(&args);
 	if (args.pattern_error) {
-		message(L_FATAL, _("A pattern is mandatory"), 0);
+		message(L_FATAL, 0, _("A pattern is mandatory"));
 		fail();
 	}
 
 	if (debug_optparse) { dump_args(&args); return 0; }
 
 	if (args.p.num_atoms == 0) {
-		message(L_FATAL, _("a predicate is required"), 0);
+		message(L_FATAL, 0, _("a predicate is required"));
 		fail();
 	}
 
 	if (!check_predicate(&args.p)) {
-		message(L_FATAL, _("malformed predicate"), 0);
+		message(L_FATAL, 0, _("malformed predicate"));
 		fail();
 	}
 
 	if (args.short_descr && !args.description_selected) {
 		if (args.num_show_fields >= MAX_FIELDS) {
-			message(L_FATAL, _("too many output fields"), 0);
+			message(L_FATAL, 0, _("too many output fields"));
 			fail();
 		}
-		message(L_INFORMATIONAL,
-			_("Adding \"Description\" to selected output fields because of -d"),
-			0);
+		message(L_INFORMATIONAL, 0,
+			_("Adding \"Description\" to selected output fields because of -d"));
                 SET_SHOW_FIELD(description_attr->application_data, 1);
                 args.show_fields[args.num_show_fields] = description_attr->inx;
 		++args.num_show_fields;
 	}
 
         if (args.invert_show && args.num_show_fields == 0) {
-                message(L_FATAL,
-                        _("-I requires at least one instance of -s"), 0);
+                message(L_FATAL, 0,
+                        _("-I requires at least one instance of -s"));
                 fail();
         }
 
 	if (!args.show_field_name && args.num_show_fields == 0) {
-		message(L_FATAL,
-			_("cannot suppress field names when showing whole paragraphs"),
-			0);
+		message(L_FATAL, 0,
+			_("cannot suppress field names when showing whole paragraphs"));
 		fail();
 	}
 
diff --git a/grep-dctrl/rc.c b/grep-dctrl/rc.c
index cbe8634..4606877 100644
--- a/grep-dctrl/rc.c
+++ b/grep-dctrl/rc.c
@@ -1,5 +1,5 @@
 /*   grep-dctrl - grep Debian control files
-     Copyright © 1999, 2003, 2004  Antti-Juhani Kaijanaho
+     Copyright © 1999, 2003, 2004, 2008  Antti-Juhani Kaijanaho
 
      This program is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published by
@@ -158,25 +158,27 @@ struct ifile find_ifile_by_exename(const char * exename, const char * rcfname)
 
 		line_exe = strtok(line, " \t");
 		if (line_exe == 0) {
-			line_message(L_IMPORTANT,
-				     _("syntax error: need a executable name"),
-				     fname, lineno);
+			line_message(L_IMPORTANT, fname, lineno,
+				     _("syntax error: need a executable name")
+                                );
 			continue;
 		}
 
 		line_ifile = strtok(0, "\n\t");
 		if (line_ifile == 0) {
-			line_message(L_IMPORTANT,
-				     _("syntax error: need an input file name"),
-				     fname, lineno);
+			line_message(L_IMPORTANT, fname, lineno,
+				     _("syntax error: need an input file name")
+                                );
 			continue;
 		}
 
-		message(L_INFORMATIONAL, _("considering executable name"), line_exe);
+		message(L_INFORMATIONAL, line_exe, 
+                        _("considering executable name"));
 		if (strcmp (exename, line_exe) == 0) {
-			message(L_INFORMATIONAL, _("yes, will use executable name"), line_exe);
+			message(L_INFORMATIONAL, line_exe,
+                                _("yes, will use executable name"));
 			rv = line_ifile;
-			message(L_INFORMATIONAL, _("default input file"), rv);
+			message(L_INFORMATIONAL, rv, _("default input file"));
 			break;
 		}
 	}
@@ -187,8 +189,9 @@ struct ifile find_ifile_by_exename(const char * exename, const char * rcfname)
 	if (rv != 0) {
 		return parse(rv);
 	} else {
-		message(L_IMPORTANT, _("executable name not found; "
-				       "reading from standard input"), 0);
+		message(L_IMPORTANT, 0,
+                        _("executable name not found; "
+                          "reading from standard input"));
 		return (struct ifile) { .mode = m_read, .s = "-" };
 	}
 }
diff --git a/join-dctrl/join-dctrl.c b/join-dctrl/join-dctrl.c
index d6975cf..64d93b8 100644
--- a/join-dctrl/join-dctrl.c
+++ b/join-dctrl/join-dctrl.c
@@ -1,5 +1,5 @@
 /*  dctrl-tools - Debian control file inspection tools
-    Copyright © 2007 Antti-Juhani Kaijanaho
+    Copyright © 2007, 2008 Antti-Juhani Kaijanaho
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -78,7 +78,7 @@ static error_t parse_opt (int key, char * arg, struct argp_state * state)
                 } else if (arg[1] == '2' && arg[1] == '\0') {
                         args->unpairables = 2;
                 } else {
-                        message(L_FATAL, _("malformed argument to '-a'"), 0);
+                        message(L_FATAL, 0, _("malformed argument to '-a'"));
                         fail();
                 }
                 break;
@@ -91,7 +91,7 @@ static error_t parse_opt (int key, char * arg, struct argp_state * state)
                 for (size_t i = 0; i < 2; i++) {
                         if (key == the_other_key[i]) continue;
                         if (args->join_field[0] != NULL) {
-                                message(L_FATAL, gettext(errmsg[i]), 0);
+                                message(L_FATAL, 0, gettext(errmsg[i]));
                                 fail();
                         }
                 }
@@ -109,8 +109,8 @@ static error_t parse_opt (int key, char * arg, struct argp_state * state)
                 if (carg == 0) fatal_enomem(0);
                 for (char * s = strtok(carg, ","); s != 0; s = strtok(0, ",")){
                         if (args->num_show_fields >= MAX_FIELDS) {
-                                message(L_FATAL, _("too many output fields"), 
-                                        0);
+                                message(L_FATAL, 0, 
+                                        _("too many output fields"));
                                 fail();
                         }
                         struct show_field *of =
@@ -124,8 +124,9 @@ static error_t parse_opt (int key, char * arg, struct argp_state * state)
                         }
                         char * fld = strchr(s, '.');
                         if (fld == NULL) {
-                                message(L_FATAL, _("missing '.' in output "
-                                                   "field specification"), 0);
+                                message(L_FATAL, 0, 
+                                        _("missing '.' in output "
+                                          "field specification"));
                                 fail();
                         }
                         *fld = '\0';
@@ -141,10 +142,10 @@ static error_t parse_opt (int key, char * arg, struct argp_state * state)
                         } else if (s[0] == '2' && s[1] == '\0') {
                                 file_inx = 1;
                         } else {
-                                message(L_FATAL, _("expected either '1.' or "
-                                                   "'2.' at the start of the "
-                                                   "field specification"), 
-                                        0);
+                                message(L_FATAL, 0, 
+                                        _("expected either '1.' or "
+                                          "'2.' at the start of the "
+                                          "field specification"));
                                         fail();
                         }
                         of->file_inx = file_inx;
@@ -164,7 +165,7 @@ static error_t parse_opt (int key, char * arg, struct argp_state * state)
 		int ll = str2loglevel(arg);
 		if (ll < 0)
 		{
-			message(L_FATAL, _("no such log level"), arg);
+			message(L_FATAL, 0, _("no such log level '%s'"), arg);
 			fail();
 		}
 		set_loglevel(ll);
@@ -176,7 +177,7 @@ static error_t parse_opt (int key, char * arg, struct argp_state * state)
 		{
 			char const * s;
 			if (args->num_fnames >= MAX_FNAMES) {
-				message(L_FATAL, _("too many file names"), 0);
+				message(L_FATAL, 0, _("too many file names"));
 				fail();
 			}
 			s = strdup(arg);
@@ -266,7 +267,7 @@ int main(int argc, char * argv[])
 	argp_parse (&argp, argc, argv, ARGP_IN_ORDER, 0, &args);
 
         if (args.num_fnames != 2) {
-                message(L_FATAL, _("need exactly two input files"), 0);
+                message(L_FATAL, 0, _("need exactly two input files"));
                 fail();
         }
 
@@ -290,9 +291,8 @@ int main(int argc, char * argv[])
         for (size_t i = 0; i < args.num_fnames; i++) {
                 for (size_t j = i+1; j < args.num_fnames; j++) {
                         if (fd[i] == fd[j]) {
-                                message(L_FATAL, 
-                                        _("cannot join a stream with itself"),
-                                        0);
+                                message(L_FATAL,  0,
+                                        _("cannot join a stream with itself"));
                                 fail();
                         }
                 } 
diff --git a/lib/misc.c b/lib/misc.c
index 1b299b6..924bfac 100644
--- a/lib/misc.c
+++ b/lib/misc.c
@@ -1,5 +1,5 @@
 /*  dctrl-tools - Debian control file inspection tools
-    Copyright (C) 2004 Antti-Juhani Kaijanaho
+    Copyright (C) 2004, 2008 Antti-Juhani Kaijanaho
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -51,14 +51,14 @@ int to_stdout (const char * fname)
 
 	f = fopen (fname, "r");
 	if (f == 0) {
-		message (L_FATAL, strerror (errno), COPYING);
+		message(L_FATAL, COPYING, "%s", strerror (errno));
 		return 0;
 	}
 
 	while ( ( c = getc (f)) != EOF) putc(c, t);
 
 	if (ferror (f)) {
-		message (L_FATAL, strerror (errno), COPYING);
+		message(L_FATAL, COPYING, "%s", strerror(errno));
 		rv = 0;
 	}
 
diff --git a/lib/msg.c b/lib/msg.c
index 85e8382..42534df 100644
--- a/lib/msg.c
+++ b/lib/msg.c
@@ -1,5 +1,5 @@
 /*   grep-dctrl - grep Debian control files
-     Copyright (C) 1999, 2004  Antti-Juhani Kaijanaho
+     Copyright (C) 1999, 2004, 2008  Antti-Juhani Kaijanaho
   
      This program is free software; you can redistribute it and/or modify
      it under the terms of the GNU General Public License as published by
@@ -100,3 +100,17 @@ str2loglevel (const char * s)
       return avec[i].integer;
   return -1;
 }
+
+void
+msg_primitive(const char *fname, int line, const char *fmt, va_list ap)
+{
+        if (fname == 0) {
+                fprintf(stderr,  "%s: ", get_progname());
+        } else if (line > 0) {
+                fprintf(stderr, "%s: %s:%i: ", get_progname(), fname, line);
+        } else {
+                fprintf(stderr, "%s: %s: ", get_progname(), fname);
+        }
+        vfprintf(stderr, fmt, ap);
+        fputs("\n.", stderr);
+}
diff --git a/lib/msg.h b/lib/msg.h
index bda8531..cc89198 100644
--- a/lib/msg.h
+++ b/lib/msg.h
@@ -1,5 +1,5 @@
 /*  dctrl-tools - Debian control file inspection tools
-    Copyright (C) 1999 Antti-Juhani Kaijanaho
+    Copyright (C) 1999, 2008 Antti-Juhani Kaijanaho
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -69,30 +69,39 @@ void record_error(void)
 	errors = 1;
 }
 
+void
+msg_primitive(const char *fname, int line, const char *fmt, va_list ap);
+
+static void
+line_message(int severity, const char *fname, int line, const char *fmt, ...)
+        __attribute__((format(printf,4,5)));
+
 inline static void
-line_message (int severity, const char * s, const char * fname, int line)
+line_message(int severity, const char *fname, int line, const char *fmt, ...)
 {
 	if (do_msg(severity)) {
-      
-		if (fname == 0) {
-			fprintf (stderr,  "%s: %s.\n", get_progname(), s);
-		} else {
-			if (line > 0) {
-				fprintf (stderr, "%s: %s:%i: %s.\n",
-					 get_progname(), fname, line, s);
-			} else {
-				fprintf (stderr, "%s: %s: %s.\n", 
-					 get_progname(), fname, s);
-			}
-		}
+                va_list ap;
+                va_start(ap, fmt);
+                msg_primitive(fname, line, fmt, ap);
+                va_end(ap);
 		if (severity >= L_IMPORTANT) record_error();
 	}
 }
 
+static void
+message (int severity, const char * fname, const char * s, ...)
+        __attribute__((format(printf,3,4)));
+
 inline static void
-message (int severity, const char * s, const char * fname)
+message (int severity, const char * fname, const char * fmt, ...)
 {
-  line_message (severity, s, fname, 0);
+	if (do_msg(severity)) {
+                va_list ap;
+                va_start(ap, fmt);
+                msg_primitive(fname, 0, fmt, ap);
+                va_end(ap);
+		if (severity >= L_IMPORTANT) record_error();
+	}
 }
 
 #ifndef MSG_C__
diff --git a/lib/paragraph.c b/lib/paragraph.c
index b5f5903..62df573 100644
--- a/lib/paragraph.c
+++ b/lib/paragraph.c
@@ -1,5 +1,5 @@
 /*  dctrl-tools - Debian control file inspection tools
-    Copyright (C) 2003, 2004 Antti-Juhani Kaijanaho
+    Copyright (C) 2003, 2004, 2008 Antti-Juhani Kaijanaho
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -118,16 +118,14 @@ FIELD_NAME:
         switch (c) {
         case '\n': case -1:
                 if (pp->ignore_broken_paras) {
-                        line_message(L_IMPORTANT,
-                                     _("warning: expected a colon"),
-                                     fp->fname,
-                                     c == '\n' ?line-1:line);
+                        line_message(L_IMPORTANT, fp->fname, 
+                                     c == '\n' ?line-1:line,
+                                     _("warning: expected a colon"));
                         goto FAIL;
                 } else {
-                        line_message(L_FATAL,
-                                     _("expected a colon"),
-                                     fp->fname,
-                                     c == '\n' ?line-1:line);
+                        line_message(L_FATAL, fp->fname,
+                                     c == '\n' ?line-1:line,
+                                     _("expected a colon"));
                         fail();
                 }
                 break;
diff --git a/lib/predicate.c b/lib/predicate.c
index e75aa82..9b8ada1 100644
--- a/lib/predicate.c
+++ b/lib/predicate.c
@@ -1,5 +1,5 @@
 /*  dctrl-tools - Debian control file inspection tools
-    Copyright (C) 2003, 2004 Antti-Juhani Kaijanaho
+    Copyright (C) 2003, 2004, 2008 Antti-Juhani Kaijanaho
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -37,7 +37,7 @@ void addinsn(struct predicate * p, int insn)
 {
 	if (insn == I_NOP) return;
 	if (p->proglen >= MAX_OPS) {
-		message(L_FATAL, _("predicate is too complex"), 0);
+		message(L_FATAL, 0, _("predicate is too complex"));
 		fail();
 	}
 	p->program[p->proglen++] = insn;
@@ -69,7 +69,7 @@ void predicate_finish_atom(struct predicate * p)
 			char * s;
 			s = get_regerror(rerr, &atom->regex);
 			if (s == 0) fatal_enomem(0);
-			message(L_FATAL, s, 0);
+			message(L_FATAL, 0, "%s", s);
 			free(s);
 			fail();
 		}
@@ -136,7 +136,7 @@ static bool verify_atom(struct atom * atom, para_t * para)
 		assert(regex_errcode != 0 && regex_errcode != REG_NOMATCH);
 		s = get_regerror (regex_errcode, &atom->regex);
 		if (s == 0) { enomem (0); return false; }
-		message(L_IMPORTANT, s, 0);
+		message(L_IMPORTANT, 0, "%s", s);
 		free(s);
 		return false;
 	}
diff --git a/lib/sorter.c b/lib/sorter.c
index dbd2591..da7c43f 100644
--- a/lib/sorter.c
+++ b/lib/sorter.c
@@ -1,5 +1,5 @@
 /*  dctrl-tools - Debian control file inspection tools
-    Copyright (C) 2004, 2005 Antti-Juhani Kaijanaho
+    Copyright (C) 2004, 2005, 2008 Antti-Juhani Kaijanaho
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -45,8 +45,8 @@ int para_compare(keys_t *keys, const para_t *a, const para_t *b)
 			bool aok = parse_version(&ar, af, strlen(af));
 			bool bok = parse_version(&br, bf, strlen(bf));
 			if (!aok || !bok) {
-				message(L_IMPORTANT,
-					_("Parse error in field."), 0);
+				message(L_IMPORTANT, 0,
+					_("Parse error in field."));
 				free(af);
 				free(bf);
 				return aok ? (bok ? 0 : 1) : (bok ? -1 : 0);
diff --git a/sort-dctrl/sort-dctrl.c b/sort-dctrl/sort-dctrl.c
index 95876e4..279d593 100644
--- a/sort-dctrl/sort-dctrl.c
+++ b/sort-dctrl/sort-dctrl.c
@@ -1,5 +1,5 @@
 /*  dctrl-tools - Debian control file inspection tools
-    Copyright © 2004, 2005, 2006, 2007 Antti-Juhani Kaijanaho
+    Copyright © 2004, 2005, 2006, 2007, 2008 Antti-Juhani Kaijanaho
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -84,8 +84,8 @@ static error_t parse_opt (int key, char * arg, struct argp_state * state)
 					key.type = FT_VERSION;
 					break;
 				default:
-					message(L_FATAL, _("invalid key flag"),
-						0);
+					message(L_FATAL, 0, 
+                                                _("invalid key flag"));
 					fail();
 				}
 			}
@@ -98,7 +98,7 @@ static error_t parse_opt (int key, char * arg, struct argp_state * state)
 		int ll = str2loglevel(arg);
 		if (ll < 0)
 		{
-			message(L_FATAL, _("no such log level"), arg);
+			message(L_FATAL, 0, _("no such log level '%s'"), arg);
 			fail();
 		}
 		set_loglevel(ll);
@@ -114,7 +114,7 @@ static error_t parse_opt (int key, char * arg, struct argp_state * state)
 		{
 			char const * s;
 			if (args->num_fnames >= MAX_FNAMES) {
-				message(L_FATAL, _("too many file names"), 0);
+				message(L_FATAL, 0, _("too many file names"));
 				fail();
 			}
 			s = strdup(arg);
diff --git a/tbl-dctrl/tbl-dctrl.c b/tbl-dctrl/tbl-dctrl.c
index bf439e2..d6f3fd6 100644
--- a/tbl-dctrl/tbl-dctrl.c
+++ b/tbl-dctrl/tbl-dctrl.c
@@ -1,5 +1,5 @@
 /*  dctrl-tools - Debian control file inspection tools
-    Copyright © 2005, 2006, 2007 Antti-Juhani Kaijanaho
+    Copyright © 2005, 2006, 2007, 2008 Antti-Juhani Kaijanaho
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -269,7 +269,7 @@ static error_t parse_opt (int key, char * arg, struct argp_state * state)
 			}
 			n = n * 10 + (*p - '0');
 		}
-		if (err) message(L_IMPORTANT, _("invalid column length"), NULL);
+		if (err) message(L_IMPORTANT, 0, _("invalid column length"));
 		col->column_width = n > 0 ? n : -1;
 		if (n == 0) args->need_preprocessing = 1;
 		args->num_columns++;
@@ -286,7 +286,7 @@ static error_t parse_opt (int key, char * arg, struct argp_state * state)
 		int ll = str2loglevel(arg);
 		if (ll < 0)
 		{
-			message(L_FATAL, _("no such log level"), arg);
+			message(L_FATAL, 0, _("no such log level '%s'"), arg);
 			fail();
 		}
 		set_loglevel(ll);
@@ -298,7 +298,7 @@ static error_t parse_opt (int key, char * arg, struct argp_state * state)
 		{
 			char const * s;
 			if (args->num_fnames >= MAX_FNAMES) {
-				message(L_FATAL, _("too many file names"), 0);
+				message(L_FATAL, 0, _("too many file names"));
 				fail();
 			}
 			s = strdup(arg);
@@ -337,8 +337,8 @@ static size_t mbs_len(char const *mbs, size_t n, char const *fname)
 		len++;
 		int delta = mblen(mbs + k, n - k);
 		if (delta <= 0) {
-			message(L_IMPORTANT, _("bad multibyte character"),
-				fname);
+			message(L_IMPORTANT, fname, 
+                                _("bad multibyte character"));
 			k++;
 		} else {
 			k += delta;
-- 
1.5.6

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://lists.alioth.debian.org/pipermail/dctrl-tools-devel/attachments/20080705/de2b4ec2/attachment.pgp 


More information about the Dctrl-tools-devel mailing list