Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/indent indent: merge isblank and is_hspace into ch_i...
details: https://anonhg.NetBSD.org/src/rev/ca16cb61baf4
branches: trunk
changeset: 990526:ca16cb61baf4
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Oct 29 20:27:42 2021 +0000
description:
indent: merge isblank and is_hspace into ch_isblank
No functional change.
diffstat:
usr.bin/indent/indent.c | 14 +++++++-------
usr.bin/indent/indent.h | 4 ++--
usr.bin/indent/io.c | 20 ++++++++++----------
usr.bin/indent/lexi.c | 8 ++++----
usr.bin/indent/pr_comment.c | 18 +++++++++---------
5 files changed, 32 insertions(+), 32 deletions(-)
diffs (272 lines):
diff -r 8029eb7bd9c5 -r ca16cb61baf4 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c Fri Oct 29 20:05:58 2021 +0000
+++ b/usr.bin/indent/indent.c Fri Oct 29 20:27:42 2021 +0000
@@ -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 @@
#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 @@
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 @@
* 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 @@
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 @@
}
}
- 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 @@
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;
diff -r 8029eb7bd9c5 -r ca16cb61baf4 usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h Fri Oct 29 20:05:58 2021 +0000
+++ b/usr.bin/indent/indent.h Fri Oct 29 20:27:42 2021 +0000
@@ -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 @@
void buf_expand(struct buffer *, size_t);
static inline bool
-is_hspace(char ch)
+ch_isblank(char ch)
{
return ch == ' ' || ch == '\t';
}
diff -r 8029eb7bd9c5 -r ca16cb61baf4 usr.bin/indent/io.c
--- a/usr.bin/indent/io.c Fri Oct 29 20:05:58 2021 +0000
+++ b/usr.bin/indent/io.c Fri Oct 29 20:27:42 2021 +0000
@@ -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 @@
#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 @@
{
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 @@
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 @@
}
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 @@
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 @@
else
return;
- skip_hspace(&p);
+ skip_blank(&p);
if (!skip_string(&p, "*/\n"))
return;
diff -r 8029eb7bd9c5 -r ca16cb61baf4 usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c Fri Oct 29 20:05:58 2021 +0000
+++ b/usr.bin/indent/lexi.c Fri Oct 29 20:27:42 2021 +0000
@@ -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 @@
#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 @@
(*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 @@
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();
}
diff -r 8029eb7bd9c5 -r ca16cb61baf4 usr.bin/indent/pr_comment.c
--- a/usr.bin/indent/pr_comment.c Fri Oct 29 20:05:58 2021 +0000
+++ b/usr.bin/indent/pr_comment.c Fri Oct 29 20:27:42 2021 +0000
@@ -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 @@
#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 @@
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 @@
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 @@
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 @@
} 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 @@
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 @@
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 @@
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++;
Home |
Main Index |
Thread Index |
Old Index