The following commit has been merged in the master branch:
commit dc43d2bb115cf5da809708ce6cfb3d78c9de503a
Author: Guillem Jover <[email protected]>
Date: Fri Sep 4 20:50:04 2009 +0200
libdpkg: On configuration error print file name and line number
diff --git a/debian/changelog b/debian/changelog
index e647dab..5dbaafe 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -41,6 +41,7 @@ dpkg (1.15.4) UNRELEASED; urgency=low
in-tree builds.
* Use po4a “--previous” support when updating the man pages.
Suggested by Christian Perrier <[email protected]>.
+ * On configuration error print file name and line number.
[ Raphael Hertzog ]
* Replace install-info by a wrapper around GNU's install-info. The wrapper
diff --git a/lib/dpkg/myopt.c b/lib/dpkg/myopt.c
index e828da8..7d5abcc 100644
--- a/lib/dpkg/myopt.c
+++ b/lib/dpkg/myopt.c
@@ -49,7 +49,7 @@ badusage(const char *fmt, ...)
}
static void
-config_error(const char *fmt, ...)
+config_error(const char *file_name, int line_num, const char *fmt, ...)
{
char buf[1024];
va_list al;
@@ -58,11 +58,12 @@ config_error(const char *fmt, ...)
vsnprintf(buf, sizeof(buf), fmt, al);
va_end(al);
- ohshit(_("configuration error: %s"), buf);
+ ohshit(_("configuration error: %s:%d: %s"), file_name, line_num, buf);
}
void myfileopt(const char* fn, const struct cmdinfo* cmdinfos) {
FILE* file;
+ int line_num = 0;
char linebuf[MAX_CONFIG_LINE];
file= fopen(fn, "r");
@@ -79,6 +80,8 @@ void myfileopt(const char* fn, const struct cmdinfo*
cmdinfos) {
const struct cmdinfo *cip;
int l;
+ line_num++;
+
if ((linebuf[0] == '#') || (linebuf[0] == '\n') || (linebuf[0] == '\0'))
continue;
l=strlen(linebuf);
@@ -106,17 +109,17 @@ void myfileopt(const char* fn, const struct cmdinfo*
cmdinfos) {
}
if (!cip->olong)
- config_error(_("unknown option '%s'"), linebuf);
+ config_error(fn, line_num, _("unknown option '%s'"), linebuf);
if (cip->takesvalue) {
if (!opt)
- config_error(_("'%s' needs a value"), linebuf);
+ config_error(fn, line_num, _("'%s' needs a value"), linebuf);
if (cip->call) cip->call(cip,opt);
else
*cip->sassignto = m_strdup(opt);
} else {
if (opt)
- config_error(_("'%s' does not take a value"), linebuf);
+ config_error(fn, line_num, _("'%s' does not take a value"), linebuf);
if (cip->call) cip->call(cip,NULL);
else *cip->iassignto= cip->arg;
}
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]