Module Name: src
Committed By: rillig
Date: Fri Oct 29 20:27:42 UTC 2021
Modified Files:
src/usr.bin/indent: indent.c indent.h io.c lexi.c pr_comment.c
Log Message:
indent: merge isblank and is_hspace into ch_isblank
No functional change.
To generate a diff of this commit:
cvs rdiff -u -r1.176 -r1.177 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.61 -r1.62 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.106 -r1.107 src/usr.bin/indent/io.c
cvs rdiff -u -r1.110 -r1.111 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.89 -r1.90 src/usr.bin/indent/pr_comment.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.176 src/usr.bin/indent/indent.c:1.177
--- src/usr.bin/indent/indent.c:1.176 Fri Oct 29 20:05:58 2021
+++ src/usr.bin/indent/indent.c Fri Oct 29 20:27:42 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.176 2021/10/29 20:05:58 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.177 2021/10/29 20:27:42 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c 5.1
#include <sys/cdefs.h>
#if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.176 2021/10/29 20:05:58 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.177 2021/10/29 20:27:42 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
#endif
@@ -266,7 +266,7 @@ search_stmt_other(lexer_symbol lsym, boo
return false;
}
- while (sc_end > save_com && isblank((unsigned char)sc_end[-1]))
+ while (sc_end > save_com && ch_isblank(sc_end[-1]))
sc_end--;
if (opt.swallow_optional_blanklines ||
@@ -332,7 +332,7 @@ search_stmt_lookahead(lexer_symbol *lsym
* into the buffer so that the later lexi() call will read them.
*/
if (sc_end != NULL) {
- while (is_hspace(*inp.s)) {
+ while (ch_isblank(*inp.s)) {
*sc_end++ = *inp.s++;
if (sc_end >= &save_com[sc_size])
errx(1, "input too long");
@@ -1196,7 +1196,7 @@ read_preprocessing_line(void)
state = PLAIN;
int com_start = 0, com_end = 0;
- while (is_hspace(*inp.s))
+ while (ch_isblank(*inp.s))
inbuf_skip();
while (*inp.s != '\n' || (state == COMM && !had_eof)) {
@@ -1236,7 +1236,7 @@ read_preprocessing_line(void)
}
}
- while (lab.e > lab.s && is_hspace(lab.e[-1]))
+ while (lab.e > lab.s && ch_isblank(lab.e[-1]))
lab.e--;
if (lab.e - lab.s == com_end && saved_inp_s == NULL) {
/* comment on preprocessor line */
@@ -1254,7 +1254,7 @@ read_preprocessing_line(void)
memmove(sc_end, lab.s + com_start, (size_t)(com_end - com_start));
sc_end += com_end - com_start;
lab.e = lab.s + com_start;
- while (lab.e > lab.s && is_hspace(lab.e[-1]))
+ while (lab.e > lab.s && ch_isblank(lab.e[-1]))
lab.e--;
saved_inp_s = inp.s; /* save current input buffer */
saved_inp_e = inp.e;
Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.61 src/usr.bin/indent/indent.h:1.62
--- src/usr.bin/indent/indent.h:1.61 Fri Oct 29 18:18:03 2021
+++ src/usr.bin/indent/indent.h Fri Oct 29 20:27:42 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.h,v 1.61 2021/10/29 18:18:03 rillig Exp $ */
+/* $NetBSD: indent.h,v 1.62 2021/10/29 20:27:42 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -407,7 +407,7 @@ char *xstrdup(const char *);
void buf_expand(struct buffer *, size_t);
static inline bool
-is_hspace(char ch)
+ch_isblank(char ch)
{
return ch == ' ' || ch == '\t';
}
Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.106 src/usr.bin/indent/io.c:1.107
--- src/usr.bin/indent/io.c:1.106 Fri Oct 29 19:12:48 2021
+++ src/usr.bin/indent/io.c Fri Oct 29 20:27:42 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: io.c,v 1.106 2021/10/29 19:12:48 rillig Exp $ */
+/* $NetBSD: io.c,v 1.107 2021/10/29 20:27:42 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)io.c 8.1 (Be
#include <sys/cdefs.h>
#if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.106 2021/10/29 19:12:48 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.107 2021/10/29 20:27:42 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
#endif
@@ -106,7 +106,7 @@ dump_line_label(void)
{
int ind;
- while (lab.e > lab.s && is_hspace(lab.e[-1]))
+ while (lab.e > lab.s && ch_isblank(lab.e[-1]))
lab.e--;
*lab.e = '\0';
@@ -121,7 +121,7 @@ dump_line_label(void)
output_char(*s++);
} while (s < lab.e && 'a' <= *s && *s <= 'z');
- while (s < lab.e && is_hspace(*s))
+ while (s < lab.e && ch_isblank(*s))
s++;
if (s < lab.e) {
@@ -344,9 +344,9 @@ compute_label_indent(void)
}
static void
-skip_hspace(const char **pp)
+skip_blank(const char **pp)
{
- while (is_hspace(**pp))
+ while (ch_isblank(**pp))
(*pp)++;
}
@@ -368,13 +368,13 @@ parse_indent_comment(void)
const char *p = inp.buf;
- skip_hspace(&p);
+ skip_blank(&p);
if (!skip_string(&p, "/*"))
return;
- skip_hspace(&p);
+ skip_blank(&p);
if (!skip_string(&p, "INDENT"))
return;
- skip_hspace(&p);
+ skip_blank(&p);
if (*p == '*' || skip_string(&p, "ON"))
on = true;
@@ -383,7 +383,7 @@ parse_indent_comment(void)
else
return;
- skip_hspace(&p);
+ skip_blank(&p);
if (!skip_string(&p, "*/\n"))
return;
Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.110 src/usr.bin/indent/lexi.c:1.111
--- src/usr.bin/indent/lexi.c:1.110 Fri Oct 29 17:50:37 2021
+++ src/usr.bin/indent/lexi.c Fri Oct 29 20:27:42 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lexi.c,v 1.110 2021/10/29 17:50:37 rillig Exp $ */
+/* $NetBSD: lexi.c,v 1.111 2021/10/29 20:27:42 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)lexi.c 8.1 (
#include <sys/cdefs.h>
#if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.110 2021/10/29 17:50:37 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.111 2021/10/29 20:27:42 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
#endif
@@ -453,7 +453,7 @@ lexi_alnum(void)
(*inp.s == '"' || *inp.s == '\''))
return lsym_string_prefix;
- while (is_hspace(inbuf_peek()))
+ while (ch_isblank(inbuf_peek()))
inbuf_skip();
if (ps.prev_token == lsym_tag && ps.p_l_follow == 0) {
@@ -563,7 +563,7 @@ lexi(void)
ps.prev_keyword = ps.curr_keyword;
ps.curr_keyword = kw_0;
- while (is_hspace(*inp.s)) {
+ while (ch_isblank(*inp.s)) {
ps.prev_col_1 = false;
inbuf_skip();
}
Index: src/usr.bin/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.89 src/usr.bin/indent/pr_comment.c:1.90
--- src/usr.bin/indent/pr_comment.c:1.89 Fri Oct 29 19:12:48 2021
+++ src/usr.bin/indent/pr_comment.c Fri Oct 29 20:27:42 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pr_comment.c,v 1.89 2021/10/29 19:12:48 rillig Exp $ */
+/* $NetBSD: pr_comment.c,v 1.90 2021/10/29 20:27:42 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)pr_comment.c
#include <sys/cdefs.h>
#if defined(__NetBSD__)
-__RCSID("$NetBSD: pr_comment.c,v 1.89 2021/10/29 19:12:48 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.90 2021/10/29 20:27:42 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
#endif
@@ -93,7 +93,7 @@ fits_in_one_line(int max_line_length)
continue;
int len = indentation_after_range(ps.com_ind + 3, inp.s, p);
- len += is_hspace(p[-1]) ? 2 : 3;
+ len += ch_isblank(p[-1]) ? 2 : 3;
if (len <= max_line_length)
return true;
}
@@ -199,7 +199,7 @@ process_comment(void)
ps.n_comment_delta = -indentation_after_range(0, start, inp.s - 2);
} else {
ps.n_comment_delta = 0;
- while (is_hspace(*inp.s))
+ while (ch_isblank(*inp.s))
inp.s++;
}
@@ -234,7 +234,7 @@ process_comment(void)
last_blank = -1;
com_add_delim();
inp.s++;
- while (is_hspace(*inp.s))
+ while (ch_isblank(*inp.s))
inp.s++;
} else {
inbuf_skip();
@@ -267,7 +267,7 @@ process_comment(void)
} else {
ps.prev_newline = true;
- if (!is_hspace(com.e[-1]))
+ if (!ch_isblank(com.e[-1]))
com_add_char(' ');
last_blank = com.e - 1 - com.buf;
}
@@ -283,7 +283,7 @@ process_comment(void)
if (*inp.s == '/')
goto end_of_comment;
}
- } while (is_hspace(*inp.s));
+ } while (ch_isblank(*inp.s));
} else
inbuf_skip();
break; /* end of case for newline */
@@ -303,7 +303,7 @@ process_comment(void)
com_add_char(' ');
}
- if (!is_hspace(com.e[-1]) && may_wrap)
+ if (!ch_isblank(com.e[-1]) && may_wrap)
com_add_char(' ');
if (token.e[-1] != '/') {
com_add_char('*');
@@ -323,7 +323,7 @@ process_comment(void)
int now_len = indentation_after_range(ps.com_ind, com.s, com.e);
for (;;) {
char ch = inbuf_next();
- if (is_hspace(ch))
+ if (ch_isblank(ch))
last_blank = com.e - com.buf;
com_add_char(ch);
now_len++;