lib: Improve error reporting from broken config files
* command.h: (config_from_file) Add variable to interface for line
number reporting.
* command.c: (config_from_file) Set & increment 'line_num' while parsing.
* vty.c: (vty_read_file) Report parse errors in the correct order to
stderr, with added line numbers.
diff --git a/lib/command.c b/lib/command.c
index 7249c65..1087ceb 100644
--- a/lib/command.c
+++ b/lib/command.c
@@ -2762,13 +2762,15 @@
/* Configration make from file. */
int
-config_from_file (struct vty *vty, FILE *fp)
+config_from_file (struct vty *vty, FILE *fp, unsigned int *line_num)
{
int ret;
+ *line_num = 0;
vector vline;
while (fgets (vty->buf, VTY_BUFSIZ, fp))
{
+ ++(*line_num);
vline = cmd_make_strvec (vty->buf);
/* In case of comment line */