aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Steven Schubiger <stsc@refcnt.org> 2019-08-30 20:41:16 +0200
committerGravatar Steven Schubiger <stsc@refcnt.org> 2019-08-30 20:41:16 +0200
commit31de42f6348099f80017e1b35abb407db01e6559 (patch)
treea585bc1aa9298c45349f49adfaf0b12764f94ba9
parent946a888c6c7aea8af693089bed73673c193899a7 (diff)
downloadcolorize-31de42f6348099f80017e1b35abb407db01e6559.tar.gz
colorize-31de42f6348099f80017e1b35abb407db01e6559.tar.bz2
Print line number when exceeding chars
-rw-r--r--colorize.c4
-rwxr-xr-xt/conf/parse/fail.t2
2 files changed, 4 insertions, 2 deletions
diff --git a/colorize.c b/colorize.c
index dbeed25..bf7e3d6 100644
--- a/colorize.c
+++ b/colorize.c
@@ -663,6 +663,7 @@ init_opts_vars (void)
static void
parse_conf (const char *conf_file, struct conf *config)
{
+ unsigned int cnt = 0;
char line[256 + 1];
FILE *conf;
@@ -674,8 +675,9 @@ parse_conf (const char *conf_file, struct conf *config)
char *assign, *comment, *opt, *value;
char *p;
+ cnt++;
if (strlen (line) > (sizeof (line) - 2))
- vfprintf_fail ("%s: line exceeds maximum of %u characters", conf_file, (unsigned int)(sizeof (line) - 2));
+ vfprintf_fail ("%s: line %u exceeds maximum of %u characters", conf_file, cnt, (unsigned int)(sizeof (line) - 2));
if ((p = strrchr (line, '\n')))
*p = '\0';
/* NAME PARSING (start) */
diff --git a/t/conf/parse/fail.t b/t/conf/parse/fail.t
index 673153b..ea267f8 100755
--- a/t/conf/parse/fail.t
+++ b/t/conf/parse/fail.t
@@ -48,7 +48,7 @@ SKIP: {
[ 'omit-color-empty1=yes', 'option \'omit-color-empty1\' not recognized' ],
[ 'attr', 'option \'attr\' not followed by =' ],
[ 'attr bold', 'option \'attr\' not followed by =' ],
- [ "color=$chars_exceed", 'line exceeds maximum of' ],
+ [ "color=$chars_exceed", 'line 1 exceeds maximum of' ],
);
foreach my $set (@set) {