summaryrefslogtreecommitdiffstats
path: root/text.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@kth.se>2022-01-01 23:54:20 +0100
committerMattias Andrée <maandree@kth.se>2022-01-01 23:54:20 +0100
commit76a8994bd5d58138542e7bb0ce8dd0ceef778891 (patch)
tree99a6cd09ac8c1ec5dffb64bb510d205560f0cdc3 /text.c
parentMove some functions into makefile.c (diff)
downloadmakel-76a8994bd5d58138542e7bb0ce8dd0ceef778891.tar.gz
makel-76a8994bd5d58138542e7bb0ce8dd0ceef778891.tar.bz2
makel-76a8994bd5d58138542e7bb0ce8dd0ceef778891.tar.xz
Lint line continuation and whitespace issues
Signed-off-by: Mattias Andrée <maandree@kth.se>
Diffstat (limited to 'text.c')
-rw-r--r--text.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/text.c b/text.c
index 0cb69e6..440ed7d 100644
--- a/text.c
+++ b/text.c
@@ -2,6 +2,15 @@
#include "common.h"
+static void
+print_long_line_tip(enum warning_class class)
+{
+ printtipf(class, "you can put a <backslash> at the end of the line to continue "
+ "it on the next line, except in or immediately proceeding an "
+ "include line");
+}
+
+
struct line *
load_text_file(int fd, const char *fname, int nest_level, size_t *nlinesp)
{
@@ -81,6 +90,8 @@ load_text_file(int fd, const char *fname, int nest_level, size_t *nlinesp)
"text files and POSIX only guarantees support for lines up to 2048 "
"bytes long including the <newline> character in text files",
fname, *nlinesp + 1);
+ printinfof(WC_TEXT, "this implementation supports arbitrarily long lines");
+ print_long_line_tip(WC_TEXT);
}
p += lines[i].len + 1;
}
@@ -140,5 +151,17 @@ check_column_count(struct line *line)
if (columns > style.max_line_length) {
warnf_style(WC_LONG_LINE, "%s:%zu: line is longer than %zu columns",
line->path, line->lineno, columns);
+ if (line->len + 1 <= 2048)
+ print_long_line_tip(WC_LONG_LINE);
}
}
+
+
+int
+is_line_blank(struct line *line)
+{
+ char *s = line->data;
+ while (isspace(*s))
+ s++;
+ return !!*s;
+}