Module Name: src Committed By: rillig Date: Fri Nov 19 17:30:10 UTC 2021
Modified Files: src/usr.bin/indent: indent.h io.c lexi.c Log Message: indent: use character input API from the tokenizer No functional change. To generate a diff of this commit: cvs rdiff -u -r1.90 -r1.91 src/usr.bin/indent/indent.h cvs rdiff -u -r1.118 -r1.119 src/usr.bin/indent/io.c cvs rdiff -u -r1.142 -r1.143 src/usr.bin/indent/lexi.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.h diff -u src/usr.bin/indent/indent.h:1.90 src/usr.bin/indent/indent.h:1.91 --- src/usr.bin/indent/indent.h:1.90 Fri Nov 19 17:20:57 2021 +++ src/usr.bin/indent/indent.h Fri Nov 19 17:30:10 2021 @@ -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_code_indent(void); 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); Index: src/usr.bin/indent/io.c diff -u src/usr.bin/indent/io.c:1.118 src/usr.bin/indent/io.c:1.119 --- src/usr.bin/indent/io.c:1.118 Fri Nov 19 17:20:57 2021 +++ src/usr.bin/indent/io.c Fri Nov 19 17:30:10 2021 @@ -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 @@ static char sccsid[] = "@(#)io.c 8.1 (Be #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 int paren_indent; 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) { Index: src/usr.bin/indent/lexi.c diff -u src/usr.bin/indent/lexi.c:1.142 src/usr.bin/indent/lexi.c:1.143 --- src/usr.bin/indent/lexi.c:1.142 Fri Nov 19 17:20:57 2021 +++ src/usr.bin/indent/lexi.c Fri Nov 19 17:30:10 2021 @@ -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 @@ static char sccsid[] = "@(#)lexi.c 8.1 ( #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 @@ found_typename: 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 @@ lexi(void) } 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 @@ lexi(void) unary_delim = true; } - assert(inbuf.inp.s < inbuf.inp.e); - ps.next_unary = unary_delim; check_size_token(1);