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: use character input API from the toke...
details: https://anonhg.NetBSD.org/src/rev/423c0906730e
branches: trunk
changeset: 1026331:423c0906730e
user: rillig <rillig%NetBSD.org@localhost>
date: Fri Nov 19 17:30:10 2021 +0000
description:
indent: use character input API from the tokenizer
No functional change.
diffstat:
usr.bin/indent/indent.h | 4 +++-
usr.bin/indent/io.c | 16 ++++++++++++++--
usr.bin/indent/lexi.c | 16 +++++++---------
3 files changed, 24 insertions(+), 12 deletions(-)
diffs (110 lines):
diff -r d6a8dd7c8862 -r 423c0906730e usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h Fri Nov 19 17:20:57 2021 +0000
+++ b/usr.bin/indent/indent.h Fri Nov 19 17:30:10 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.h,v 1.90 2021/11/19 17:20:57 rillig Exp $ */
+/* $NetBSD: indent.h,v 1.91 2021/11/19 17:30:10 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -377,6 +377,8 @@
int compute_label_indent(void);
int ind_add(int, const char *, const char *);
+const char *inp_p(void);
+const char *inp_line_end(void);
char inp_peek(void);
char inp_lookahead(size_t);
void inp_skip(void);
diff -r d6a8dd7c8862 -r 423c0906730e usr.bin/indent/io.c
--- a/usr.bin/indent/io.c Fri Nov 19 17:20:57 2021 +0000
+++ b/usr.bin/indent/io.c Fri Nov 19 17:30:10 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: io.c,v 1.118 2021/11/19 17:20:57 rillig Exp $ */
+/* $NetBSD: io.c,v 1.119 2021/11/19 17:30:10 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.118 2021/11/19 17:20:57 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.119 2021/11/19 17:30:10 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
#endif
@@ -59,6 +59,18 @@
static bool suppress_blanklines;
+const char *
+inp_p(void)
+{
+ return inbuf.inp.s;
+}
+
+const char *
+inp_line_end(void)
+{
+ return inbuf.inp.e;
+}
+
char
inp_peek(void)
{
diff -r d6a8dd7c8862 -r 423c0906730e usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c Fri Nov 19 17:20:57 2021 +0000
+++ b/usr.bin/indent/lexi.c Fri Nov 19 17:30:10 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lexi.c,v 1.142 2021/11/19 17:20:57 rillig Exp $ */
+/* $NetBSD: lexi.c,v 1.143 2021/11/19 17:30:10 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.142 2021/11/19 17:20:57 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.143 2021/11/19 17:30:10 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
#endif
@@ -504,7 +504,7 @@
if (inp_peek() == '(' && ps.tos <= 1 && ps.ind_level == 0 &&
!ps.in_parameter_declaration && !ps.block_init) {
- for (const char *p = inbuf.inp.s; p < inbuf.inp.e;)
+ for (const char *p = inp_p(), *e = inp_line_end(); p < e;)
if (*p++ == ')' && (*p == ';' || *p == ','))
goto no_function_definition;
@@ -682,14 +682,14 @@
}
if (ps.in_decl) {
- char *tp = inbuf.inp.s;
+ const char *tp = inp_p();
while (isalpha((unsigned char)*tp) ||
isspace((unsigned char)*tp)) {
- if (++tp >= inbuf.inp.e) {
- const char *s_before = inbuf.inp.s;
+ if (++tp >= inp_line_end()) {
+ const char *p_before = inp_p();
inp_read_line();
- if (inbuf.inp.s != s_before)
+ if (inp_p() != p_before)
abort();
}
}
@@ -716,8 +716,6 @@
unary_delim = true;
}
- assert(inbuf.inp.s < inbuf.inp.e);
-
ps.next_unary = unary_delim;
check_size_token(1);
Home |
Main Index |
Thread Index |
Old Index