CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: rin Date: Thu Jun 15 03:20:59 UTC 2023 Modified Files: src/sys/stand/efiboot: Makefile.efiboot Log Message: Add missing include paths for libz. Not used at the moment although. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/stand/efiboot/Makefile.efiboot Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/Makefile.efiboot diff -u src/sys/stand/efiboot/Makefile.efiboot:1.28 src/sys/stand/efiboot/Makefile.efiboot:1.29 --- src/sys/stand/efiboot/Makefile.efiboot:1.28 Sat Jun 3 21:26:29 2023 +++ src/sys/stand/efiboot/Makefile.efiboot Thu Jun 15 03:20:58 2023 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile.efiboot,v 1.28 2023/06/03 21:26:29 lukem Exp $ +# $NetBSD: Makefile.efiboot,v 1.29 2023/06/15 03:20:58 rin Exp $ S= ${.CURDIR}/../../.. @@ -132,6 +132,7 @@ LIBKERN= ${KERNLIB} ### find out what to use for libz Z_AS= library .include "${S}/lib/libz/Makefile.inc" +CPPFLAGS+= -I${S}/lib/libz -I${S}/../common/dist/zlib LIBZ= ${ZLIB} ### find out what to use for libgnuefi
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: rin Date: Thu Jun 15 03:20:59 UTC 2023 Modified Files: src/sys/stand/efiboot: Makefile.efiboot Log Message: Add missing include paths for libz. Not used at the moment although. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/sys/stand/efiboot/Makefile.efiboot Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/distrib/riscv/ramdisk
Module Name:src Committed By: gutteridge Date: Wed Jun 14 23:03:20 UTC 2023 Modified Files: src/distrib/riscv/ramdisk: Makefile Log Message: Remove redundant variable assignment (Someone may want to define MAKEDEVTARGETS differently than is done at present, but that would be a different change.) To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/distrib/riscv/ramdisk/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/riscv/ramdisk/Makefile diff -u src/distrib/riscv/ramdisk/Makefile:1.2 src/distrib/riscv/ramdisk/Makefile:1.3 --- src/distrib/riscv/ramdisk/Makefile:1.2 Tue Jan 24 18:04:04 2017 +++ src/distrib/riscv/ramdisk/Makefile Wed Jun 14 23:03:19 2023 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.2 2017/01/24 18:04:04 christos Exp $ +# $NetBSD: Makefile,v 1.3 2023/06/14 23:03:19 gutteridge Exp $ .include .include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib" @@ -15,7 +15,7 @@ LISTS= ${.CURDIR}/list #LISTS+= ${DISTRIBDIR}/common/list.sysinst MTREECONF= ${DISTRIBDIR}/common/mtree.common IMAGEENDIAN= le -MAKEDEVTARGETS= ramdisk + IMAGEDEPENDS= ${CRUNCHBIN} \ dot.profile \ ${NETBSDSRCDIR}/etc/group ${NETBSDSRCDIR}/etc/master.passwd \
CVS commit: src/distrib/riscv/ramdisk
Module Name:src Committed By: gutteridge Date: Wed Jun 14 23:03:20 UTC 2023 Modified Files: src/distrib/riscv/ramdisk: Makefile Log Message: Remove redundant variable assignment (Someone may want to define MAKEDEVTARGETS differently than is done at present, but that would be a different change.) To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/distrib/riscv/ramdisk/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Wed Jun 14 21:35:01 UTC 2023 Modified Files: src/usr.bin/indent: args.c Log Message: indent: reduce number of relocations Since all command line options modify a member of struct options, there is no need to encode that relocation 38 times. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.83 -r1.84 src/usr.bin/indent/args.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/args.c diff -u src/usr.bin/indent/args.c:1.83 src/usr.bin/indent/args.c:1.84 --- src/usr.bin/indent/args.c:1.83 Sat Jun 10 16:43:55 2023 +++ src/usr.bin/indent/args.c Wed Jun 14 21:35:01 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: args.c,v 1.83 2023/06/10 16:43:55 rillig Exp $ */ +/* $NetBSD: args.c,v 1.84 2023/06/14 21:35:01 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,12 +38,13 @@ */ #include -__RCSID("$NetBSD: args.c,v 1.83 2023/06/10 16:43:55 rillig Exp $"); +__RCSID("$NetBSD: args.c,v 1.84 2023/06/14 21:35:01 rillig Exp $"); /* Read options from profile files and from the command line. */ #include #include +#include #include #include #include @@ -51,17 +52,18 @@ __RCSID("$NetBSD: args.c,v 1.83 2023/06/ #include "indent.h" #if __STDC_VERSION__ >= 201112L -#define assert_type(expr, type) _Generic((expr), type : (expr)) +#define get_offset(name, type) \ + _Generic((), type *: offsetof(struct options, name)) #else -#define assert_type(expr, type) (expr) +#define get_offset(name, type) (offsetof(struct options, name)) #endif #define bool_option(name, value, var) \ - {name, true, false, value, 0, 0, assert_type(&(opt.var), bool *)} + {name, true, false, value, 0, 0, get_offset(var, bool)} #define bool_options(name, var) \ - {name, true, true, false, 0, 0, assert_type(&(opt.var), bool *)} + {name, true, true, false, 0, 0, get_offset(var, bool)} #define int_option(name, var, min, max) \ - {name, false, false, false, min, max, assert_type(&(opt.var), int *)} + {name, false, false, false, min, max, get_offset(var, int)} /* See set_special_option for special options. */ static const struct pro { @@ -71,7 +73,7 @@ static const struct pro { bool p_bool_value; /* only relevant if !p_may_negate */ short i_min; short i_max; - void *p_var; /* the associated variable */ + unsigned short opt_offset; /* the associated variable */ } pro[] = { bool_options("bacc", blank_line_around_conditional_compilation), bool_options("bad", blank_line_after_decl), @@ -232,7 +234,7 @@ found: errx(1, "%s: unknown option \"-%s\"", option_source, arg); - *(bool *)p->p_var = + *(bool *)((unsigned char *)(void *) + p->opt_offset) = p->p_may_negate ? arg[0] != 'n' : p->p_bool_value; return; } @@ -250,7 +252,7 @@ found: "must be between %d and %d", option_source, arg_arg, p->p_name, p->i_min, p->i_max); - *(int *)p->p_var = (int)num; + *(int *)((unsigned char *)(void *) + p->opt_offset) = (int)num; } static void
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Wed Jun 14 21:35:01 UTC 2023 Modified Files: src/usr.bin/indent: args.c Log Message: indent: reduce number of relocations Since all command line options modify a member of struct options, there is no need to encode that relocation 38 times. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.83 -r1.84 src/usr.bin/indent/args.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: rillig Date: Wed Jun 14 20:46:08 UTC 2023 Modified Files: src/tests/usr.bin/indent: fmt_block.c fmt_decl.c lsym_preprocessing.c opt_bc.c ps_ind_level.c psym_rbrace.c src/usr.bin/indent: debug.c indent.c indent.h parse.c Log Message: indent: clean up the code, add a few tests To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/indent/fmt_block.c \ src/tests/usr.bin/indent/ps_ind_level.c cvs rdiff -u -r1.54 -r1.55 src/tests/usr.bin/indent/fmt_decl.c cvs rdiff -u -r1.13 -r1.14 src/tests/usr.bin/indent/lsym_preprocessing.c cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/indent/opt_bc.c cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/psym_rbrace.c cvs rdiff -u -r1.60 -r1.61 src/usr.bin/indent/debug.c cvs rdiff -u -r1.366 -r1.367 src/usr.bin/indent/indent.c cvs rdiff -u -r1.196 -r1.197 src/usr.bin/indent/indent.h cvs rdiff -u -r1.76 -r1.77 src/usr.bin/indent/parse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: rillig Date: Wed Jun 14 20:46:08 UTC 2023 Modified Files: src/tests/usr.bin/indent: fmt_block.c fmt_decl.c lsym_preprocessing.c opt_bc.c ps_ind_level.c psym_rbrace.c src/usr.bin/indent: debug.c indent.c indent.h parse.c Log Message: indent: clean up the code, add a few tests To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/indent/fmt_block.c \ src/tests/usr.bin/indent/ps_ind_level.c cvs rdiff -u -r1.54 -r1.55 src/tests/usr.bin/indent/fmt_decl.c cvs rdiff -u -r1.13 -r1.14 src/tests/usr.bin/indent/lsym_preprocessing.c cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/indent/opt_bc.c cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/psym_rbrace.c cvs rdiff -u -r1.60 -r1.61 src/usr.bin/indent/debug.c cvs rdiff -u -r1.366 -r1.367 src/usr.bin/indent/indent.c cvs rdiff -u -r1.196 -r1.197 src/usr.bin/indent/indent.h cvs rdiff -u -r1.76 -r1.77 src/usr.bin/indent/parse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/indent/fmt_block.c diff -u src/tests/usr.bin/indent/fmt_block.c:1.7 src/tests/usr.bin/indent/fmt_block.c:1.8 --- src/tests/usr.bin/indent/fmt_block.c:1.7 Mon May 22 23:03:16 2023 +++ src/tests/usr.bin/indent/fmt_block.c Wed Jun 14 20:46:08 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: fmt_block.c,v 1.7 2023/05/22 23:03:16 rillig Exp $ */ +/* $NetBSD: fmt_block.c,v 1.8 2023/06/14 20:46:08 rillig Exp $ */ /* * Tests for formatting blocks of statements and declarations. @@ -6,7 +6,6 @@ * See also: * lsym_lbrace.c * psym_stmt.c - * psym_stmt_list.c */ //indent input Index: src/tests/usr.bin/indent/ps_ind_level.c diff -u src/tests/usr.bin/indent/ps_ind_level.c:1.7 src/tests/usr.bin/indent/ps_ind_level.c:1.8 --- src/tests/usr.bin/indent/ps_ind_level.c:1.7 Mon May 15 14:55:47 2023 +++ src/tests/usr.bin/indent/ps_ind_level.c Wed Jun 14 20:46:08 2023 @@ -1,10 +1,13 @@ -/* $NetBSD: ps_ind_level.c,v 1.7 2023/05/15 14:55:47 rillig Exp $ */ +/* $NetBSD: ps_ind_level.c,v 1.8 2023/06/14 20:46:08 rillig Exp $ */ /* * The indentation of the very first line of a file determines the - * indentation of the remaining code. Even if later code has a smaller - * indentation, it is nevertheless indented to the level given by the first - * line of code. + * indentation of the remaining code. This mode is meant for code snippets from + * function bodies. At this level, function definitions are not recognized + * properly. + * + * Even if later code has a smaller indentation, it is nevertheless indented to + * the level given by the first line of code. * * In this particular test, the indentation is set to 5 and the tabulator * width is set to 8, to demonstrate an off-by-one error in @@ -18,6 +21,9 @@ int indented_by_24; void function_in_column_1(void){} + + #if indented +#endif //indent end /* 5 spaces indentation, 8 spaces per tabulator */ @@ -26,6 +32,9 @@ void function_in_column_1(void){} void function_in_column_1(void) { } + +#if indented +#endif //indent end Index: src/tests/usr.bin/indent/fmt_decl.c diff -u src/tests/usr.bin/indent/fmt_decl.c:1.54 src/tests/usr.bin/indent/fmt_decl.c:1.55 --- src/tests/usr.bin/indent/fmt_decl.c:1.54 Sat Jun 10 17:56:29 2023 +++ src/tests/usr.bin/indent/fmt_decl.c Wed Jun 14 20:46:08 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: fmt_decl.c,v 1.54 2023/06/10 17:56:29 rillig Exp $ */ +/* $NetBSD: fmt_decl.c,v 1.55 2023/06/14 20:46:08 rillig Exp $ */ /* * Tests for declarations of global variables, external functions, and local @@ -1085,3 +1085,104 @@ die(void) { } //indent end + + +/* + * In very rare cases, the type of a declarator might include literal tab + * characters. This tab might affect the indentation of the declarator, but + * only if it occurs before the declarator, and that is hard to achieve. + */ +//indent input +int arr[sizeof " "]; +//indent end + +//indent run-equals-input + + +/* + * The '}' of an initializer is not supposed to end the statement, it only ends + * the brace level of the initializer expression. + */ +//indent input +int multi_line[1][1][1] = { +{ +{ +1 +}, +}, +}; +int single_line[2][1][1] = {{{1},},{{2}}}; +//indent end + +//indent run -di0 +int multi_line[1][1][1] = { + { + { + 1 + }, + }, +}; +int single_line[2][1][1] = {{{1},}, {{2}}}; +//indent end + + +/* + * The '}' of an initializer is not supposed to end the statement, it only ends + * the brace level of the initializer expression. + */ +//indent input +{ +int multi_line = { +{ +{ +b +}, +}, +}; +int single_line = {{{b},},{}}; +} +//indent end + +//indent run -di0 +{ + int multi_line = { + { + { +b + }, + }, + }; + int single_line = {{{b},}, {}}; +} +//indent end + + +/* + * In initializers, multi-line expressions don't have their second line + * indented, even though they should. + */ +//indent input +{ +multi_line = (int[]){
CVS commit: src
Module Name:src Committed By: rillig Date: Wed Jun 14 19:05:40 UTC 2023 Modified Files: src/tests/usr.bin/indent: t_errors.sh src/usr.bin/indent: indent.c indent.h parse.c Log Message: indent: allow more than 128 brace levels To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/tests/usr.bin/indent/t_errors.sh cvs rdiff -u -r1.365 -r1.366 src/usr.bin/indent/indent.c cvs rdiff -u -r1.195 -r1.196 src/usr.bin/indent/indent.h cvs rdiff -u -r1.75 -r1.76 src/usr.bin/indent/parse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/indent/t_errors.sh diff -u src/tests/usr.bin/indent/t_errors.sh:1.36 src/tests/usr.bin/indent/t_errors.sh:1.37 --- src/tests/usr.bin/indent/t_errors.sh:1.36 Wed Jun 14 10:26:00 2023 +++ src/tests/usr.bin/indent/t_errors.sh Wed Jun 14 19:05:40 2023 @@ -1,5 +1,5 @@ #! /bin/sh -# $NetBSD: t_errors.sh,v 1.36 2023/06/14 10:26:00 rillig Exp $ +# $NetBSD: t_errors.sh,v 1.37 2023/06/14 19:05:40 rillig Exp $ # # Copyright (c) 2021 The NetBSD Foundation, Inc. # All rights reserved. @@ -459,7 +459,7 @@ stack_overflow_body() atf_check \ -s 'exit:1' \ - -e 'inline:indent: Parser stack overflow\n' \ + -e 'inline:error: code.c:3: Stuff missing from end of file\n' \ "$indent" code.c } Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.365 src/usr.bin/indent/indent.c:1.366 --- src/usr.bin/indent/indent.c:1.365 Wed Jun 14 16:14:30 2023 +++ src/usr.bin/indent/indent.c Wed Jun 14 19:05:40 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.365 2023/06/14 16:14:30 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.366 2023/06/14 19:05:40 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: indent.c,v 1.365 2023/06/14 16:14:30 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.366 2023/06/14 19:05:40 rillig Exp $"); #include #include @@ -187,7 +187,7 @@ ind_add(int ind, const char *s, size_t l static void init_globals(void) { - ps.psyms.sym[ps.psyms.len++] = psym_stmt; + ps_push(psym_stmt, false); ps.prev_lsym = lsym_semicolon; ps.lbrace_kind = psym_lbrace_block; @@ -454,36 +454,55 @@ paren_stack_push(struct paren_stack *s, s->item[s->len++] = (struct paren_level){indent, cast}; } +static void * +dup_mem(const void *src, size_t size) +{ + return memcpy(nonnull(malloc(size)), src, size); +} + +#define dup_array(src, len) \ +dup_mem((src), sizeof((src)[0]) * (len)) +#define copy_array(dst, src, len) \ +memcpy((dst), (src), sizeof((dst)[0]) * (len)) + static void -parser_state_backup(struct parser_state *dst) +parser_state_back_up(struct parser_state *dst) { *dst = ps; - dst->paren.item = nonnull( - malloc(sizeof(dst->paren.item[0]) * ps.paren.cap)); - dst->paren.len = ps.paren.len; - dst->paren.cap = ps.paren.cap; - memcpy(dst->paren.item, ps.paren.item, - sizeof(dst->paren.item[0]) * ps.paren.len); + dst->paren.item = dup_array(ps.paren.item, ps.paren.len); + dst->psyms.sym = dup_array(ps.psyms.sym, ps.psyms.len); + dst->psyms.ind_level = dup_array(ps.psyms.ind_level, ps.psyms.len); } static void parser_state_restore(const struct parser_state *src) { - struct paren_stack dst_paren = ps.paren; + struct paren_level *ps_paren_item = ps.paren.item; + size_t ps_paren_cap = ps.paren.cap; + enum parser_symbol *ps_psyms_sym = ps.psyms.sym; + int *ps_psyms_ind_level = ps.psyms.ind_level; + size_t ps_psyms_cap = ps.psyms.cap; + ps = *src; - ps.paren = dst_paren; - ps.paren.len = 0; - for (size_t i = 0; i < src->paren.len; i++) - paren_stack_push(, - src->paren.item[i].indent, src->paren.item[i].cast); + ps.paren.item = ps_paren_item; + ps.paren.cap = ps_paren_cap; + ps.psyms.sym = ps_psyms_sym; + ps.psyms.ind_level = ps_psyms_ind_level; + ps.psyms.cap = ps_psyms_cap; + + copy_array(ps.paren.item, src->paren.item, src->paren.len); + copy_array(ps.psyms.sym, src->psyms.sym, src->psyms.len); + copy_array(ps.psyms.ind_level, src->psyms.ind_level, src->psyms.len); } static void parser_state_free(struct parser_state *pst) { free(pst->paren.item); + free(pst->psyms.sym); + free(pst->psyms.ind_level); } static void @@ -507,7 +526,7 @@ process_preprocessing(void) ifdef.item = nonnull(realloc(ifdef.item, sizeof(ifdef.item[0]) * ifdef.cap)); } - parser_state_backup(ifdef.item + ifdef.len++); + parser_state_back_up(ifdef.item + ifdef.len++); out.line_kind = lk_if; } else if (dir_len >= 2 && memcmp(dir, "el", 2) == 0) { Index: src/usr.bin/indent/indent.h diff -u src/usr.bin/indent/indent.h:1.195 src/usr.bin/indent/indent.h:1.196 --- src/usr.bin/indent/indent.h:1.195 Wed Jun 14 16:14:30 2023 +++ src/usr.bin/indent/indent.h Wed Jun 14 19:05:40 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.h,v 1.195 2023/06/14 16:14:30 rillig Exp $ */ +/* $NetBSD: indent.h,v 1.196 2023/06/14 19:05:40 rillig Exp
CVS commit: src
Module Name:src Committed By: rillig Date: Wed Jun 14 19:05:40 UTC 2023 Modified Files: src/tests/usr.bin/indent: t_errors.sh src/usr.bin/indent: indent.c indent.h parse.c Log Message: indent: allow more than 128 brace levels To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/tests/usr.bin/indent/t_errors.sh cvs rdiff -u -r1.365 -r1.366 src/usr.bin/indent/indent.c cvs rdiff -u -r1.195 -r1.196 src/usr.bin/indent/indent.h cvs rdiff -u -r1.75 -r1.76 src/usr.bin/indent/parse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Wed Jun 14 17:52:46 UTC 2023 Modified Files: src/usr.bin/indent: parse.c Log Message: indent: fix out-of-bounds read when reducing a statement Since parse.c 1.73 from today. The parser symbol psym_stmt_list that was removed in that commit acted as a stop symbol, so that psyms_reduce_stmt would save a memory access. To generate a diff of this commit: cvs rdiff -u -r1.74 -r1.75 src/usr.bin/indent/parse.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/parse.c diff -u src/usr.bin/indent/parse.c:1.74 src/usr.bin/indent/parse.c:1.75 --- src/usr.bin/indent/parse.c:1.74 Wed Jun 14 16:14:30 2023 +++ src/usr.bin/indent/parse.c Wed Jun 14 17:52:45 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.74 2023/06/14 16:14:30 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.75 2023/06/14 17:52:45 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: parse.c,v 1.74 2023/06/14 16:14:30 rillig Exp $"); +__RCSID("$NetBSD: parse.c,v 1.75 2023/06/14 17:52:45 rillig Exp $"); #include @@ -116,7 +116,7 @@ static void psyms_reduce(struct psym_stack *psyms) { again: - if (psyms->sym[psyms->len - 1] == psym_stmt + if (psyms->len >= 2 && psyms->sym[psyms->len - 1] == psym_stmt && psyms_reduce_stmt(psyms)) goto again; if (psyms->sym[psyms->len - 1] == psym_while_expr &&
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Wed Jun 14 17:52:46 UTC 2023 Modified Files: src/usr.bin/indent: parse.c Log Message: indent: fix out-of-bounds read when reducing a statement Since parse.c 1.73 from today. The parser symbol psym_stmt_list that was removed in that commit acted as a stop symbol, so that psyms_reduce_stmt would save a memory access. To generate a diff of this commit: cvs rdiff -u -r1.74 -r1.75 src/usr.bin/indent/parse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/usr.bin/indent
Module Name:src Committed By: rillig Date: Wed Jun 14 17:07:33 UTC 2023 Modified Files: src/tests/usr.bin/indent: fmt_expr.c lsym_preprocessing.c psym_else.c t_options.lua Log Message: tests/indent: separate stdout from stderr Due to buffering, there was no guarantee that the output would be exactly in the same order as written in the tests. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/indent/fmt_expr.c cvs rdiff -u -r1.12 -r1.13 src/tests/usr.bin/indent/lsym_preprocessing.c cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/psym_else.c cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/t_options.lua Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/indent/fmt_expr.c diff -u src/tests/usr.bin/indent/fmt_expr.c:1.7 src/tests/usr.bin/indent/fmt_expr.c:1.8 --- src/tests/usr.bin/indent/fmt_expr.c:1.7 Sat Jun 10 08:17:04 2023 +++ src/tests/usr.bin/indent/fmt_expr.c Wed Jun 14 17:07:32 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: fmt_expr.c,v 1.7 2023/06/10 08:17:04 rillig Exp $ */ +/* $NetBSD: fmt_expr.c,v 1.8 2023/06/14 17:07:32 rillig Exp $ */ /* * Tests for all kinds of expressions that are not directly related to unary @@ -44,8 +44,6 @@ //indent end //indent run -di0 -error: Standard Input:7: Unbalanced parentheses -warning: Standard Input:9: Extra ')' { int var = ({1}); int var = ({ @@ -57,4 +55,6 @@ warning: Standard Input:9: Extra ')' }); } exit 1 +error: Standard Input:7: Unbalanced parentheses +warning: Standard Input:9: Extra ')' //indent end Index: src/tests/usr.bin/indent/lsym_preprocessing.c diff -u src/tests/usr.bin/indent/lsym_preprocessing.c:1.12 src/tests/usr.bin/indent/lsym_preprocessing.c:1.13 --- src/tests/usr.bin/indent/lsym_preprocessing.c:1.12 Wed Jun 14 10:29:52 2023 +++ src/tests/usr.bin/indent/lsym_preprocessing.c Wed Jun 14 17:07:32 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lsym_preprocessing.c,v 1.12 2023/06/14 10:29:52 rillig Exp $ */ +/* $NetBSD: lsym_preprocessing.c,v 1.13 2023/06/14 17:07:32 rillig Exp $ */ /* * Tests for the token lsym_preprocessing, which represents a '#' that starts @@ -294,10 +294,6 @@ int before; //indent end //indent run -error: Standard Input:1: Unmatched #else -error: Standard Input:2: Unmatched #elif -error: Standard Input:3: Unmatched #elifdef -error: Standard Input:4: Unmatched #endif #else #elif 0 #elifdef var @@ -306,4 +302,8 @@ error: Standard Input:4: Unmatched #endi #unknown # 3 "file.c" exit 1 +error: Standard Input:1: Unmatched #else +error: Standard Input:2: Unmatched #elif +error: Standard Input:3: Unmatched #elifdef +error: Standard Input:4: Unmatched #endif //indent end Index: src/tests/usr.bin/indent/psym_else.c diff -u src/tests/usr.bin/indent/psym_else.c:1.5 src/tests/usr.bin/indent/psym_else.c:1.6 --- src/tests/usr.bin/indent/psym_else.c:1.5 Sat Jun 10 17:35:41 2023 +++ src/tests/usr.bin/indent/psym_else.c Wed Jun 14 17:07:32 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: psym_else.c,v 1.5 2023/06/10 17:35:41 rillig Exp $ */ +/* $NetBSD: psym_else.c,v 1.6 2023/06/14 17:07:32 rillig Exp $ */ /* * Tests for the parser symbol psym_else, which represents the keyword 'else' @@ -80,9 +80,9 @@ function(void) //indent end //indent run -error: Standard Input:2: Unmatched 'else' { else } exit 1 +error: Standard Input:2: Unmatched 'else' //indent end Index: src/tests/usr.bin/indent/t_options.lua diff -u src/tests/usr.bin/indent/t_options.lua:1.4 src/tests/usr.bin/indent/t_options.lua:1.5 --- src/tests/usr.bin/indent/t_options.lua:1.4 Mon May 22 06:35:56 2023 +++ src/tests/usr.bin/indent/t_options.lua Wed Jun 14 17:07:32 2023 @@ -1,4 +1,4 @@ --- $NetBSD: t_options.lua,v 1.4 2023/05/22 06:35:56 rillig Exp $ +-- $NetBSD: t_options.lua,v 1.5 2023/06/14 17:07:32 rillig Exp $ -- -- Copyright (c) 2023 The NetBSD Foundation, Inc. -- All rights reserved. @@ -126,7 +126,7 @@ end local function run_indent(inp, args) local indent = os.getenv("INDENT") or "indent" - local cmd = indent .. " " .. args .. " 2>&1" + local cmd = indent .. " " .. args .. " 2>t_options.err" local indent_in = assert(io.popen(cmd, "w")) indent_in:write(inp) @@ -134,6 +134,9 @@ local function run_indent(inp, args) if not ok then print(kind .. " " .. info) end + for line in io.lines("t_options.err") do + print(line) + end end local function handle_empty_section(line)
CVS commit: src/tests/usr.bin/indent
Module Name:src Committed By: rillig Date: Wed Jun 14 17:07:33 UTC 2023 Modified Files: src/tests/usr.bin/indent: fmt_expr.c lsym_preprocessing.c psym_else.c t_options.lua Log Message: tests/indent: separate stdout from stderr Due to buffering, there was no guarantee that the output would be exactly in the same order as written in the tests. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/indent/fmt_expr.c cvs rdiff -u -r1.12 -r1.13 src/tests/usr.bin/indent/lsym_preprocessing.c cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/psym_else.c cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/t_options.lua Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Wed Jun 14 16:14:30 UTC 2023 Modified Files: src/usr.bin/indent: debug.c indent.c indent.h io.c lexi.c parse.c Log Message: indent: clean up array indexing for parser symbols With 'top' pointing to the actual top element, the array was indexed in the closed range from 0 to top. All other arrays are indexed by the usual half-open interval from 0 to len. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/usr.bin/indent/debug.c cvs rdiff -u -r1.364 -r1.365 src/usr.bin/indent/indent.c cvs rdiff -u -r1.194 -r1.195 src/usr.bin/indent/indent.h cvs rdiff -u -r1.220 -r1.221 src/usr.bin/indent/io.c cvs rdiff -u -r1.228 -r1.229 src/usr.bin/indent/lexi.c cvs rdiff -u -r1.73 -r1.74 src/usr.bin/indent/parse.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/debug.c diff -u src/usr.bin/indent/debug.c:1.59 src/usr.bin/indent/debug.c:1.60 --- src/usr.bin/indent/debug.c:1.59 Wed Jun 14 14:11:28 2023 +++ src/usr.bin/indent/debug.c Wed Jun 14 16:14:30 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.59 2023/06/14 14:11:28 rillig Exp $ */ +/* $NetBSD: debug.c,v 1.60 2023/06/14 16:14:30 rillig Exp $ */ /*- * Copyright (c) 2023 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: debug.c,v 1.59 2023/06/14 14:11:28 rillig Exp $"); +__RCSID("$NetBSD: debug.c,v 1.60 2023/06/14 16:14:30 rillig Exp $"); #include #include @@ -383,7 +383,7 @@ debug_psyms_stack(const char *situation) { debug_printf("parse stack %s:", situation); const struct psym_stack *psyms = - for (int i = 0; i <= psyms->top; ++i) + for (size_t i = 0; i < psyms->len; ++i) debug_printf(" %d %s", psyms->ind_level[i], psym_name[psyms->sym[i]]); debug_println(""); Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.364 src/usr.bin/indent/indent.c:1.365 --- src/usr.bin/indent/indent.c:1.364 Wed Jun 14 14:11:28 2023 +++ src/usr.bin/indent/indent.c Wed Jun 14 16:14:30 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.364 2023/06/14 14:11:28 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.365 2023/06/14 16:14:30 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: indent.c,v 1.364 2023/06/14 14:11:28 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.365 2023/06/14 16:14:30 rillig Exp $"); #include #include @@ -187,7 +187,7 @@ ind_add(int ind, const char *s, size_t l static void init_globals(void) { - ps.psyms.sym[0] = psym_stmt; + ps.psyms.sym[ps.psyms.len++] = psym_stmt; ps.prev_lsym = lsym_semicolon; ps.lbrace_kind = psym_lbrace_block; @@ -388,7 +388,7 @@ process_eof(void) { finish_output(); - if (ps.psyms.top > 1) /* check for balanced braces */ + if (ps.psyms.len > 2) /* check for balanced braces */ diag(1, "Stuff missing from end of file"); return found_err ? EXIT_FAILURE : EXIT_SUCCESS; @@ -534,7 +534,7 @@ process_newline(void) && lab.len == 0 /* for preprocessing lines */ && com.len == 0) goto stay_in_line; - if (ps.psyms.sym[ps.psyms.top] == psym_switch_expr + if (ps.psyms.sym[ps.psyms.len - 1] == psym_switch_expr && opt.brace_same_line && com.len == 0) { ps.force_nl = true; @@ -577,7 +577,7 @@ process_lparen(void) if (opt.extra_expr_indent && ps.spaced_expr_psym != psym_0) ps.extra_expr_indent = eei_maybe; - if (ps.in_var_decl && ps.psyms.top <= 2 && !ps.in_init) { + if (ps.in_var_decl && ps.psyms.len <= 3 && !ps.in_init) { parse(psym_stmt); /* prepare for function definition */ ps.in_var_decl = false; } @@ -762,14 +762,14 @@ process_rbrace(void) ps.in_decl = true; } - if (ps.psyms.top == 2) + if (ps.psyms.len == 3) out.line_kind = lk_func_end; parse(psym_rbrace); if (!ps.in_var_decl - && ps.psyms.sym[ps.psyms.top] != psym_do_stmt - && ps.psyms.sym[ps.psyms.top] != psym_if_expr_stmt) + && ps.psyms.sym[ps.psyms.len - 1] != psym_do_stmt + && ps.psyms.sym[ps.psyms.len - 1] != psym_if_expr_stmt) ps.force_nl = true; } @@ -905,7 +905,7 @@ process_type_outside_parentheses(void) { parse(psym_decl); /* let the parser worry about indentation */ - if (ps.prev_lsym == lsym_rparen && ps.psyms.top <= 1 && code.len > 0) + if (ps.prev_lsym == lsym_rparen && ps.psyms.len <= 2 && code.len > 0) output_line(); if (ps.in_func_def_params && opt.indent_parameters && Index: src/usr.bin/indent/indent.h diff -u src/usr.bin/indent/indent.h:1.194 src/usr.bin/indent/indent.h:1.195 --- src/usr.bin/indent/indent.h:1.194 Wed Jun 14 14:11:28 2023 +++ src/usr.bin/indent/indent.h Wed Jun 14 16:14:30 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.h,v 1.194 2023/06/14 14:11:28 rillig Exp $ */ +/* $NetBSD: indent.h,v 1.195 2023/06/14 16:14:30 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -272,7 +272,10 @@ struct
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Wed Jun 14 16:14:30 UTC 2023 Modified Files: src/usr.bin/indent: debug.c indent.c indent.h io.c lexi.c parse.c Log Message: indent: clean up array indexing for parser symbols With 'top' pointing to the actual top element, the array was indexed in the closed range from 0 to top. All other arrays are indexed by the usual half-open interval from 0 to len. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/usr.bin/indent/debug.c cvs rdiff -u -r1.364 -r1.365 src/usr.bin/indent/indent.c cvs rdiff -u -r1.194 -r1.195 src/usr.bin/indent/indent.h cvs rdiff -u -r1.220 -r1.221 src/usr.bin/indent/io.c cvs rdiff -u -r1.228 -r1.229 src/usr.bin/indent/lexi.c cvs rdiff -u -r1.73 -r1.74 src/usr.bin/indent/parse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: rillig Date: Wed Jun 14 14:11:28 UTC 2023 Modified Files: src/tests/usr.bin/indent: lsym_lparen_or_lbracket.c opt_bc.c opt_pcs.c src/usr.bin/indent: debug.c indent.c indent.h io.c lexi.c pr_comment.c Log Message: indent: allow more than 20 nested parentheses or brackets To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c \ src/tests/usr.bin/indent/opt_pcs.c cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/indent/opt_bc.c cvs rdiff -u -r1.58 -r1.59 src/usr.bin/indent/debug.c cvs rdiff -u -r1.363 -r1.364 src/usr.bin/indent/indent.c cvs rdiff -u -r1.193 -r1.194 src/usr.bin/indent/indent.h cvs rdiff -u -r1.219 -r1.220 src/usr.bin/indent/io.c cvs rdiff -u -r1.227 -r1.228 src/usr.bin/indent/lexi.c cvs rdiff -u -r1.164 -r1.165 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/tests/usr.bin/indent/lsym_lparen_or_lbracket.c diff -u src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c:1.16 src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c:1.17 --- src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c:1.16 Sat Jun 10 08:17:04 2023 +++ src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c Wed Jun 14 14:11:28 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lsym_lparen_or_lbracket.c,v 1.16 2023/06/10 08:17:04 rillig Exp $ */ +/* $NetBSD: lsym_lparen_or_lbracket.c,v 1.17 2023/06/14 14:11:28 rillig Exp $ */ /* * Tests for the token lsym_lparen_or_lbracket, which represents a '(' or '[' @@ -144,9 +144,9 @@ function(void) //indent run-equals-input -/* This is the maximum supported number of parentheses. */ //indent input int zero = (((0))); +int many = 0; //indent end //indent run-equals-input -di0 Index: src/tests/usr.bin/indent/opt_pcs.c diff -u src/tests/usr.bin/indent/opt_pcs.c:1.16 src/tests/usr.bin/indent/opt_pcs.c:1.17 --- src/tests/usr.bin/indent/opt_pcs.c:1.16 Thu May 18 08:09:28 2023 +++ src/tests/usr.bin/indent/opt_pcs.c Wed Jun 14 14:11:28 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: opt_pcs.c,v 1.16 2023/05/18 08:09:28 rillig Exp $ */ +/* $NetBSD: opt_pcs.c,v 1.17 2023/06/14 14:11:28 rillig Exp $ */ /* * Tests for the options '-pcs' and '-npcs'. @@ -114,6 +114,8 @@ int offset = offsetof(struct s, member); //indent input int unary = +call(); +// $ FIXME: Unusual, but there should be no space. +int postfix = step++ (); int binary = 1 + call(); //indent end @@ -121,5 +123,6 @@ int binary = 1 + call(); //indent run -pcs -di0 int unary = +call (); +int postfix = step++ (); int binary = 1 + call (); //indent end Index: src/tests/usr.bin/indent/opt_bc.c diff -u src/tests/usr.bin/indent/opt_bc.c:1.10 src/tests/usr.bin/indent/opt_bc.c:1.11 --- src/tests/usr.bin/indent/opt_bc.c:1.10 Sat Jun 10 06:52:35 2023 +++ src/tests/usr.bin/indent/opt_bc.c Wed Jun 14 14:11:28 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: opt_bc.c,v 1.10 2023/06/10 06:52:35 rillig Exp $ */ +/* $NetBSD: opt_bc.c,v 1.11 2023/06/14 14:11:28 rillig Exp $ */ /* * Tests for the options '-bc' and '-nbc'. @@ -119,3 +119,22 @@ int a = 1, int a = (1), b = 2; //indent end + + +/* + * When declarations are too long to fit in a single line, they should not be + * joined. + */ +//indent input +{ + const struct paren_level *prev = state.prev_ps.paren.item, + *curr = ps.paren.item; +} +//indent end + +//indent run +// $ FIXME: The line becomes too long. +{ + const struct paren_level *prev = state.prev_ps.paren.item, *curr = ps.paren.item; +} +//indent end Index: src/usr.bin/indent/debug.c diff -u src/usr.bin/indent/debug.c:1.58 src/usr.bin/indent/debug.c:1.59 --- src/usr.bin/indent/debug.c:1.58 Wed Jun 14 09:57:02 2023 +++ src/usr.bin/indent/debug.c Wed Jun 14 14:11:28 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.58 2023/06/14 09:57:02 rillig Exp $ */ +/* $NetBSD: debug.c,v 1.59 2023/06/14 14:11:28 rillig Exp $ */ /*- * Copyright (c) 2023 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: debug.c,v 1.58 2023/06/14 09:57:02 rillig Exp $"); +__RCSID("$NetBSD: debug.c,v 1.59 2023/06/14 14:11:28 rillig Exp $"); #include #include @@ -255,15 +255,14 @@ debug_ps_enum_member(const char *name, c } static bool -ps_paren_has_changed(void) +paren_stack_equal(const struct paren_stack *a, const struct paren_stack *b) { - if (state.prev_ps.nparen != ps.nparen) - return true; + if (a->len != b->len) + return false; - const struct paren_level *prev = state.prev_ps.paren, *curr = ps.paren; - for (int i = 0; i < ps.nparen; i++) - if (curr[i].indent != prev[i].indent - || curr[i].cast != prev[i].cast) + for (size_t i = 0, n = a->len; i < n; i++) + if (a->item[i].indent != b->item[i].indent + || a->item[i].cast != b->item[i].cast) return true; return false; } @@
CVS commit: src
Module Name:src Committed By: rillig Date: Wed Jun 14 14:11:28 UTC 2023 Modified Files: src/tests/usr.bin/indent: lsym_lparen_or_lbracket.c opt_bc.c opt_pcs.c src/usr.bin/indent: debug.c indent.c indent.h io.c lexi.c pr_comment.c Log Message: indent: allow more than 20 nested parentheses or brackets To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/tests/usr.bin/indent/lsym_lparen_or_lbracket.c \ src/tests/usr.bin/indent/opt_pcs.c cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/indent/opt_bc.c cvs rdiff -u -r1.58 -r1.59 src/usr.bin/indent/debug.c cvs rdiff -u -r1.363 -r1.364 src/usr.bin/indent/indent.c cvs rdiff -u -r1.193 -r1.194 src/usr.bin/indent/indent.h cvs rdiff -u -r1.219 -r1.220 src/usr.bin/indent/io.c cvs rdiff -u -r1.227 -r1.228 src/usr.bin/indent/lexi.c cvs rdiff -u -r1.164 -r1.165 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.
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Wed Jun 14 13:15:30 UTC 2023 Modified Files: src/usr.bin/indent: indent.c Log Message: indent: merge duplicate code To generate a diff of this commit: cvs rdiff -u -r1.362 -r1.363 src/usr.bin/indent/indent.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Wed Jun 14 13:15:30 UTC 2023 Modified Files: src/usr.bin/indent: indent.c Log Message: indent: merge duplicate code To generate a diff of this commit: cvs rdiff -u -r1.362 -r1.363 src/usr.bin/indent/indent.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.362 src/usr.bin/indent/indent.c:1.363 --- src/usr.bin/indent/indent.c:1.362 Wed Jun 14 11:18:09 2023 +++ src/usr.bin/indent/indent.c Wed Jun 14 13:15:30 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.362 2023/06/14 11:18:09 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.363 2023/06/14 13:15:30 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: indent.c,v 1.362 2023/06/14 11:18:09 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.363 2023/06/14 13:15:30 rillig Exp $"); #include #include @@ -523,13 +523,20 @@ want_blank_before_lparen(void) } static void -process_lparen(void) +ps_paren_push(int indent, enum paren_level_cast cast) { if (++ps.nparen == array_length(ps.paren)) { diag(0, "Reached internal limit of %zu unclosed parentheses", - array_length(ps.paren)); + array_length(ps.paren)); ps.nparen--; } + ps.paren[ps.nparen - 1].indent = indent; + ps.paren[ps.nparen - 1].cast = cast; +} + +static void +process_lparen(void) +{ if (is_function_pointer_declaration()) indent_declarator(ps.decl_ind, ps.tabs_to_var); @@ -558,8 +565,7 @@ process_lparen(void) || ps.line_has_func_def) cast = cast_no; - ps.paren[ps.nparen - 1].indent = indent; - ps.paren[ps.nparen - 1].cast = cast; + ps_paren_push(indent, cast); debug_println("paren_indents[%d] is now %s%d", ps.nparen - 1, paren_level_cast_name[cast], indent); } @@ -605,12 +611,6 @@ unbalanced: static void process_lbracket(void) { - if (++ps.nparen == array_length(ps.paren)) { - diag(0, "Reached internal limit of %zu unclosed parentheses", - array_length(ps.paren)); - ps.nparen--; - } - if (code.len > 0 && (ps.prev_lsym == lsym_comma || ps.prev_lsym == lsym_binary_op)) buf_add_char(, ' '); @@ -618,9 +618,7 @@ process_lbracket(void) buf_add_char(, token.s[0]); int indent = ind_add(0, code.s, code.len); - - ps.paren[ps.nparen - 1].indent = indent; - ps.paren[ps.nparen - 1].cast = cast_no; + ps_paren_push(indent, cast_no); debug_println("paren_indents[%d] is now %d", ps.nparen - 1, indent); }
CVS commit: src
Module Name:src Committed By: rillig Date: Wed Jun 14 11:18:09 UTC 2023 Modified Files: src/tests/usr.bin/indent: lsym_switch.c src/usr.bin/indent: indent.c Log Message: indent: fix formatting of comment after 'switch (expr)' To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/lsym_switch.c cvs rdiff -u -r1.361 -r1.362 src/usr.bin/indent/indent.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/indent/lsym_switch.c diff -u src/tests/usr.bin/indent/lsym_switch.c:1.4 src/tests/usr.bin/indent/lsym_switch.c:1.5 --- src/tests/usr.bin/indent/lsym_switch.c:1.4 Sat Jun 10 16:43:56 2023 +++ src/tests/usr.bin/indent/lsym_switch.c Wed Jun 14 11:18:09 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lsym_switch.c,v 1.4 2023/06/10 16:43:56 rillig Exp $ */ +/* $NetBSD: lsym_switch.c,v 1.5 2023/06/14 11:18:09 rillig Exp $ */ /* * Tests for the token lsym_switch, which represents the keyword 'switch' that @@ -16,16 +16,10 @@ */ //indent input { - switch (expr) // comment + switch (expr) // comment { } } //indent end -//indent run -{ -// $ FIXME: The '{' has moved to the comment. - switch (expr) // comment { - } -} -//indent end +//indent run-equals-input Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.361 src/usr.bin/indent/indent.c:1.362 --- src/usr.bin/indent/indent.c:1.361 Wed Jun 14 10:29:52 2023 +++ src/usr.bin/indent/indent.c Wed Jun 14 11:18:09 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.361 2023/06/14 10:29:52 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.362 2023/06/14 11:18:09 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: indent.c,v 1.361 2023/06/14 10:29:52 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.362 2023/06/14 11:18:09 rillig Exp $"); #include #include @@ -492,7 +492,8 @@ process_newline(void) && com.len == 0) goto stay_in_line; if (ps.psyms.sym[ps.psyms.top] == psym_switch_expr - && opt.brace_same_line) { + && opt.brace_same_line + && com.len == 0) { ps.force_nl = true; goto stay_in_line; }
CVS commit: src
Module Name:src Committed By: rillig Date: Wed Jun 14 11:18:09 UTC 2023 Modified Files: src/tests/usr.bin/indent: lsym_switch.c src/usr.bin/indent: indent.c Log Message: indent: fix formatting of comment after 'switch (expr)' To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/lsym_switch.c cvs rdiff -u -r1.361 -r1.362 src/usr.bin/indent/indent.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/arch/evbarm/nslu2
Module Name:src Committed By: rin Date: Wed Jun 14 10:30:35 UTC 2023 Modified Files: src/sys/arch/evbarm/nslu2: nslu2_machdep.c Log Message: Make this compile again with VERBOSE_INIT_ARM. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/arch/evbarm/nslu2/nslu2_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/evbarm/nslu2/nslu2_machdep.c diff -u src/sys/arch/evbarm/nslu2/nslu2_machdep.c:1.36 src/sys/arch/evbarm/nslu2/nslu2_machdep.c:1.37 --- src/sys/arch/evbarm/nslu2/nslu2_machdep.c:1.36 Thu Apr 20 08:28:05 2023 +++ src/sys/arch/evbarm/nslu2/nslu2_machdep.c Wed Jun 14 10:30:34 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: nslu2_machdep.c,v 1.36 2023/04/20 08:28:05 skrll Exp $ */ +/* $NetBSD: nslu2_machdep.c,v 1.37 2023/06/14 10:30:34 rin Exp $ */ /*- * Copyright (c) 2006 The NetBSD Foundation, Inc. @@ -94,7 +94,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: nslu2_machdep.c,v 1.36 2023/04/20 08:28:05 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nslu2_machdep.c,v 1.37 2023/06/14 10:30:34 rin Exp $"); #include "opt_arm_debug.h" #include "opt_console.h" @@ -482,8 +482,9 @@ initarm(void *arg) /* Tell the user about the memory */ #ifdef VERBOSE_INIT_ARM - printf("physmemory: %d pages at 0x%08lx -> 0x%08lx\n", physmem, - physical_start, physical_end - 1); + printf("physmemory: %" PRIuPSIZE " pages at " + "0x%08" PRIxPADDR " -> 0x%08" PRIxPADDR "\n", + physmem, physical_start, physical_end - 1); printf("Allocating page tables\n"); #endif
CVS commit: src/sys/arch/evbarm/nslu2
Module Name:src Committed By: rin Date: Wed Jun 14 10:30:35 UTC 2023 Modified Files: src/sys/arch/evbarm/nslu2: nslu2_machdep.c Log Message: Make this compile again with VERBOSE_INIT_ARM. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/sys/arch/evbarm/nslu2/nslu2_machdep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: rillig Date: Wed Jun 14 10:29:52 UTC 2023 Modified Files: src/tests/usr.bin/indent: lsym_preprocessing.c src/usr.bin/indent: indent.c Log Message: indent: use correct preprocessing directive in error message To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/indent/lsym_preprocessing.c cvs rdiff -u -r1.360 -r1.361 src/usr.bin/indent/indent.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/indent/lsym_preprocessing.c diff -u src/tests/usr.bin/indent/lsym_preprocessing.c:1.11 src/tests/usr.bin/indent/lsym_preprocessing.c:1.12 --- src/tests/usr.bin/indent/lsym_preprocessing.c:1.11 Wed Jun 14 10:26:00 2023 +++ src/tests/usr.bin/indent/lsym_preprocessing.c Wed Jun 14 10:29:52 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lsym_preprocessing.c,v 1.11 2023/06/14 10:26:00 rillig Exp $ */ +/* $NetBSD: lsym_preprocessing.c,v 1.12 2023/06/14 10:29:52 rillig Exp $ */ /* * Tests for the token lsym_preprocessing, which represents a '#' that starts @@ -296,8 +296,7 @@ int before; //indent run error: Standard Input:1: Unmatched #else error: Standard Input:2: Unmatched #elif -// $ TODO: '#elifdef' instead of '#elif' -error: Standard Input:3: Unmatched #elif +error: Standard Input:3: Unmatched #elifdef error: Standard Input:4: Unmatched #endif #else #elif 0 Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.360 src/usr.bin/indent/indent.c:1.361 --- src/usr.bin/indent/indent.c:1.360 Wed Jun 14 10:26:00 2023 +++ src/usr.bin/indent/indent.c Wed Jun 14 10:29:52 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.360 2023/06/14 10:26:00 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.361 2023/06/14 10:29:52 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: indent.c,v 1.360 2023/06/14 10:26:00 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.361 2023/06/14 10:29:52 rillig Exp $"); #include #include @@ -469,8 +469,7 @@ process_preprocessing(void) } else if (dir_len >= 2 && memcmp(dir, "el", 2) == 0) { if (ifdef.len == 0) - diag(1, dir[2] == 'i' - ? "Unmatched #elif" : "Unmatched #else"); + diag(1, "Unmatched #%.*s", (int)dir_len, dir); else ps = ifdef.item[ifdef.len - 1];
CVS commit: src
Module Name:src Committed By: rillig Date: Wed Jun 14 10:29:52 UTC 2023 Modified Files: src/tests/usr.bin/indent: lsym_preprocessing.c src/usr.bin/indent: indent.c Log Message: indent: use correct preprocessing directive in error message To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/indent/lsym_preprocessing.c cvs rdiff -u -r1.360 -r1.361 src/usr.bin/indent/indent.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: rin Date: Wed Jun 14 10:26:46 UTC 2023 Modified Files: src/sys/stand/efiboot: exec.c Log Message: Use %zd instead of %ld for ssize_t. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/stand/efiboot/exec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/sys/stand/efiboot
Module Name:src Committed By: rin Date: Wed Jun 14 10:26:46 UTC 2023 Modified Files: src/sys/stand/efiboot: exec.c Log Message: Use %zd instead of %ld for ssize_t. To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/sys/stand/efiboot/exec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/stand/efiboot/exec.c diff -u src/sys/stand/efiboot/exec.c:1.23 src/sys/stand/efiboot/exec.c:1.24 --- src/sys/stand/efiboot/exec.c:1.23 Wed Oct 6 10:13:19 2021 +++ src/sys/stand/efiboot/exec.c Wed Jun 14 10:26:45 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: exec.c,v 1.23 2021/10/06 10:13:19 jmcneill Exp $ */ +/* $NetBSD: exec.c,v 1.24 2023/06/14 10:26:45 rin Exp $ */ /*- * Copyright (c) 2019 Jason R. Thorpe @@ -109,7 +109,7 @@ load_file(const char *path, u_long extra if (len < 0) { printf(": %s\n", strerror(errno)); } else { - printf(": returned %ld (expected %ld)\n", len, + printf(": returned %zd (expected %zd)\n", len, expectedlen); } return EIO;
CVS commit: src
Module Name:src Committed By: rillig Date: Wed Jun 14 10:26:00 UTC 2023 Modified Files: src/tests/usr.bin/indent: lsym_preprocessing.c t_errors.sh src/usr.bin/indent: indent.c Log Message: indent: allow more than 5 levels of #if/#endif To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/indent/lsym_preprocessing.c cvs rdiff -u -r1.35 -r1.36 src/tests/usr.bin/indent/t_errors.sh cvs rdiff -u -r1.359 -r1.360 src/usr.bin/indent/indent.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/indent/lsym_preprocessing.c diff -u src/tests/usr.bin/indent/lsym_preprocessing.c:1.10 src/tests/usr.bin/indent/lsym_preprocessing.c:1.11 --- src/tests/usr.bin/indent/lsym_preprocessing.c:1.10 Sat May 13 08:33:39 2023 +++ src/tests/usr.bin/indent/lsym_preprocessing.c Wed Jun 14 10:26:00 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lsym_preprocessing.c,v 1.10 2023/05/13 08:33:39 rillig Exp $ */ +/* $NetBSD: lsym_preprocessing.c,v 1.11 2023/06/14 10:26:00 rillig Exp $ */ /* * Tests for the token lsym_preprocessing, which represents a '#' that starts @@ -256,3 +256,55 @@ int before; #endif int after; //indent end + + +/* + * Before 2023-06-14, indent was limited to 5 levels of conditional compilation + * directives. + */ +//indent input +#if 1 +#if 2 +#if 3 +#if 4 +#if 5 +#if 6 +#endif 6 +#endif 5 +#endif 4 +#endif 3 +#endif 2 +#endif 1 +//indent end + +//indent run-equals-input + + +/* + * Unrecognized and unmatched preprocessing directives are preserved. + */ +//indent input +#else +#elif 0 +#elifdef var +#endif + +#unknown +# 3 "file.c" +//indent end + +//indent run +error: Standard Input:1: Unmatched #else +error: Standard Input:2: Unmatched #elif +// $ TODO: '#elifdef' instead of '#elif' +error: Standard Input:3: Unmatched #elif +error: Standard Input:4: Unmatched #endif +#else +#elif 0 +#elifdef var +#endif + +#unknown +# 3 "file.c" +exit 1 +//indent end Index: src/tests/usr.bin/indent/t_errors.sh diff -u src/tests/usr.bin/indent/t_errors.sh:1.35 src/tests/usr.bin/indent/t_errors.sh:1.36 --- src/tests/usr.bin/indent/t_errors.sh:1.35 Sat Jun 10 17:35:41 2023 +++ src/tests/usr.bin/indent/t_errors.sh Wed Jun 14 10:26:00 2023 @@ -1,5 +1,5 @@ #! /bin/sh -# $NetBSD: t_errors.sh,v 1.35 2023/06/10 17:35:41 rillig Exp $ +# $NetBSD: t_errors.sh,v 1.36 2023/06/14 10:26:00 rillig Exp $ # # Copyright (c) 2021 The NetBSD Foundation, Inc. # All rights reserved. @@ -348,54 +348,6 @@ unexpected_closing_brace_decl_body() cat code.c } -atf_test_case 'preprocessing_overflow' -preprocessing_overflow_body() -{ - cat <<-\EOF > code.c - #if 1 - #if 2 - #if 3 - #if 4 - #if 5 - #if 6 - #endif 6 - #endif 5 - #endif 4 - #endif 3 - #endif 2 - #endif 1 - #endif too much - EOF - cat <<-\EOF > stderr.exp - error: code.c:6: #if stack overflow - error: code.c:12: Unmatched #endif - error: code.c:13: Unmatched #endif - EOF - - atf_check -s 'exit:1' \ - -e 'file:stderr.exp' \ - "$indent" code.c -} - -atf_test_case 'preprocessing_unrecognized' -preprocessing_unrecognized_body() -{ - cat <<-\EOF > code.c - #unknown - # 3 "file.c" - #elif 3 - #else - EOF - cat <<-\EOF > stderr.exp - error: code.c:3: Unmatched #elif - error: code.c:4: Unmatched #else - EOF - - atf_check -s 'exit:1' \ - -e 'file:stderr.exp' \ - "$indent" code.c -} - atf_test_case 'unbalanced_parentheses' unbalanced_parentheses_body() { @@ -544,8 +496,6 @@ atf_init_test_cases() atf_add_test_case 'unexpected_end_of_file' atf_add_test_case 'unexpected_closing_brace_top_level' atf_add_test_case 'unexpected_closing_brace_decl' - atf_add_test_case 'preprocessing_overflow' - atf_add_test_case 'preprocessing_unrecognized' atf_add_test_case 'unbalanced_parentheses' atf_add_test_case 'gcc_statement_expression' atf_add_test_case 'crash_comment_after_controlling_expression' Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.359 src/usr.bin/indent/indent.c:1.360 --- src/usr.bin/indent/indent.c:1.359 Wed Jun 14 08:36:51 2023 +++ src/usr.bin/indent/indent.c Wed Jun 14 10:26:00 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.359 2023/06/14 08:36:51 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.360 2023/06/14 10:26:00 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: indent.c,v 1.359 2023/06/14 08:36:51 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.360 2023/06/14 10:26:00 rillig Exp $"); #include #include @@ -82,8 +82,11 @@ bool found_err; bool had_eof; int line_no = 1; -static int ifdef_level; -static struct parser_state state_stack[5]; +static struct { + struct parser_state *item; + size_t len; + size_t cap; +} ifdef; FILE *input; FILE *output; @@ -456,24 +459,26 @@ process_preprocessing(void) dir_len++; if (dir_len >= 2 && memcmp(dir, "if", 2) == 0) { - if
CVS commit: src
Module Name:src Committed By: rillig Date: Wed Jun 14 10:26:00 UTC 2023 Modified Files: src/tests/usr.bin/indent: lsym_preprocessing.c t_errors.sh src/usr.bin/indent: indent.c Log Message: indent: allow more than 5 levels of #if/#endif To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/indent/lsym_preprocessing.c cvs rdiff -u -r1.35 -r1.36 src/tests/usr.bin/indent/t_errors.sh cvs rdiff -u -r1.359 -r1.360 src/usr.bin/indent/indent.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Wed Jun 14 09:57:02 UTC 2023 Modified Files: src/usr.bin/indent: debug.c indent.h io.c Log Message: indent: clean up debugging code To generate a diff of this commit: cvs rdiff -u -r1.57 -r1.58 src/usr.bin/indent/debug.c cvs rdiff -u -r1.192 -r1.193 src/usr.bin/indent/indent.h cvs rdiff -u -r1.218 -r1.219 src/usr.bin/indent/io.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Wed Jun 14 09:57:02 UTC 2023 Modified Files: src/usr.bin/indent: debug.c indent.h io.c Log Message: indent: clean up debugging code To generate a diff of this commit: cvs rdiff -u -r1.57 -r1.58 src/usr.bin/indent/debug.c cvs rdiff -u -r1.192 -r1.193 src/usr.bin/indent/indent.h cvs rdiff -u -r1.218 -r1.219 src/usr.bin/indent/io.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/debug.c diff -u src/usr.bin/indent/debug.c:1.57 src/usr.bin/indent/debug.c:1.58 --- src/usr.bin/indent/debug.c:1.57 Wed Jun 14 09:31:05 2023 +++ src/usr.bin/indent/debug.c Wed Jun 14 09:57:02 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.57 2023/06/14 09:31:05 rillig Exp $ */ +/* $NetBSD: debug.c,v 1.58 2023/06/14 09:57:02 rillig Exp $ */ /*- * Copyright (c) 2023 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: debug.c,v 1.57 2023/06/14 09:31:05 rillig Exp $"); +__RCSID("$NetBSD: debug.c,v 1.58 2023/06/14 09:57:02 rillig Exp $"); #include #include @@ -40,10 +40,8 @@ __RCSID("$NetBSD: debug.c,v 1.57 2023/06 #ifdef debug static struct { - /*- - * false show only the changes to the parser state - * true show unchanged parts of the parser state as well - */ + // false show only the changes to the parser state + // true show unchanged parts of the parser state as well bool full_parser_state; } config = { .full_parser_state = false, @@ -191,10 +189,9 @@ debug_blank_line(void) } void -debug_vis_range(const char *prefix, const char *s, size_t len, -const char *suffix) +debug_vis_range(const char *s, size_t len) { - debug_printf("%s", prefix); + debug_printf("\""); for (size_t i = 0; i < len; i++) { const char *p = s + i; if (*p == '\\' || *p == '"') @@ -208,7 +205,7 @@ debug_vis_range(const char *prefix, cons else debug_printf("\\x%02x", (unsigned char)*p); } - debug_printf("%s", suffix); + debug_printf("\""); } void @@ -216,7 +213,7 @@ debug_print_buf(const char *name, const { if (buf->len > 0) { debug_printf(" %s ", name); - debug_vis_range("\"", buf->s, buf->len, "\""); + debug_vis_range(buf->s, buf->len); } } @@ -230,7 +227,7 @@ debug_buffers(void) } static void -write_ps_bool(const char *name, bool prev, bool curr) +debug_ps_bool_member(const char *name, bool prev, bool curr) { if (!state.ps_first && curr != prev) { char diff = " -+x"[(prev ? 1 : 0) + (curr ? 2 : 0)]; @@ -240,7 +237,7 @@ write_ps_bool(const char *name, bool pre } static void -write_ps_int(const char *name, int prev, int curr) +debug_ps_int_member(const char *name, int prev, int curr) { if (!state.ps_first && curr != prev) debug_println(" %3d -> %3d ps.%s", prev, curr, name); @@ -249,7 +246,7 @@ write_ps_int(const char *name, int prev, } static void -write_ps_enum(const char *name, const char *prev, const char *curr) +debug_ps_enum_member(const char *name, const char *prev, const char *curr) { if (!state.ps_first && strcmp(prev, curr) != 0) debug_println(" %3s -> %3s ps.%s", prev, curr, name); @@ -316,11 +313,12 @@ debug_ps_di_stack(void) } #define debug_ps_bool(name) \ - write_ps_bool(#name, state.prev_ps.name, ps.name) + debug_ps_bool_member(#name, state.prev_ps.name, ps.name) #define debug_ps_int(name) \ - write_ps_int(#name, state.prev_ps.name, ps.name) + debug_ps_int_member(#name, state.prev_ps.name, ps.name) #define debug_ps_enum(name, names) \ -write_ps_enum(#name, (names)[state.prev_ps.name], (names)[ps.name]) +debug_ps_enum_member(#name, (names)[state.prev_ps.name], \ + (names)[ps.name]) void debug_parser_state(void) Index: src/usr.bin/indent/indent.h diff -u src/usr.bin/indent/indent.h:1.192 src/usr.bin/indent/indent.h:1.193 --- src/usr.bin/indent/indent.h:1.192 Wed Jun 14 09:31:05 2023 +++ src/usr.bin/indent/indent.h Wed Jun 14 09:57:02 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.h,v 1.192 2023/06/14 09:31:05 rillig Exp $ */ +/* $NetBSD: indent.h,v 1.193 2023/06/14 09:57:02 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -431,7 +431,7 @@ extern struct output_state { void debug_printf(const char *, ...) __printflike(1, 2); void debug_println(const char *, ...) __printflike(1, 2); void debug_blank_line(void); -void debug_vis_range(const char *, const char *, size_t, const char *); +void debug_vis_range(const char *, size_t); void debug_parser_state(void); void debug_psyms_stack(const char *); void debug_print_buf(const char *, const struct buffer *); @@ -445,7 +445,7 @@ extern const char *const line_kind_name[ #define debug_printf(fmt, ...) debug_noop() #define debug_println(fmt, ...) debug_noop() #define debug_blank_line() debug_noop() -#define debug_vis_range(prefix, s, e, suffix) debug_noop() +#define debug_vis_range(s, len) debug_noop() #define debug_parser_state() debug_noop()
CVS commit: src
Module Name:src Committed By: rillig Date: Wed Jun 14 09:31:05 UTC 2023 Modified Files: src/tests/usr.bin/indent: lsym_comment.c psym_decl.c src/usr.bin/indent: debug.c indent.h io.c pr_comment.c Log Message: indent: clean up handling of comments One less moving part in the parser state. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/tests/usr.bin/indent/lsym_comment.c cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/psym_decl.c cvs rdiff -u -r1.56 -r1.57 src/usr.bin/indent/debug.c cvs rdiff -u -r1.191 -r1.192 src/usr.bin/indent/indent.h cvs rdiff -u -r1.217 -r1.218 src/usr.bin/indent/io.c cvs rdiff -u -r1.163 -r1.164 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/tests/usr.bin/indent/lsym_comment.c diff -u src/tests/usr.bin/indent/lsym_comment.c:1.20 src/tests/usr.bin/indent/lsym_comment.c:1.21 --- src/tests/usr.bin/indent/lsym_comment.c:1.20 Sat Jun 10 16:43:56 2023 +++ src/tests/usr.bin/indent/lsym_comment.c Wed Jun 14 09:31:05 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lsym_comment.c,v 1.20 2023/06/10 16:43:56 rillig Exp $ */ +/* $NetBSD: lsym_comment.c,v 1.21 2023/06/14 09:31:05 rillig Exp $ */ /* * Tests for the token lsym_comment, which starts a comment. @@ -43,7 +43,6 @@ * - with varying opt.comment_column (-c0, -c1, -c33, -c80) * - with varying opt.decl_comment_column (-cd0, -cd1, -cd20, -cd33, -cd80) * - with/without ps.line_has_decl - * - with/without ps.next_col_1 * * - very long comments that overflow the buffer 'com' * - comments that come from save_com @@ -1020,8 +1019,8 @@ f(void) /* - * Test two completely empty lines in a wrap comment. The second empty line - * covers the condition ps.next_col_1 in copy_comment_wrap. + * In a comment that is wrapped, one or more empty lines separate paragraphs. + * All of these empty lines are preserved. */ //indent input /* line 1 @@ -1131,3 +1130,17 @@ int line; // comment line 1 // comment line 2 int block; /* comment line 1 comment line 2 */ //indent end + + +//indent input +/*/ comment? or:not; /* */ +//indent end + +//indent run +/* / comment? or:not; /* */ +//indent end + +//indent run -nfc1 +// $ FIXME: It's a comment, not code. +/*/ comment ? or : not; /* */ +//indent end Index: src/tests/usr.bin/indent/psym_decl.c diff -u src/tests/usr.bin/indent/psym_decl.c:1.4 src/tests/usr.bin/indent/psym_decl.c:1.5 --- src/tests/usr.bin/indent/psym_decl.c:1.4 Sun Apr 24 10:36:37 2022 +++ src/tests/usr.bin/indent/psym_decl.c Wed Jun 14 09:31:05 2023 @@ -1,20 +1,17 @@ -/* $NetBSD: psym_decl.c,v 1.4 2022/04/24 10:36:37 rillig Exp $ */ +/* $NetBSD: psym_decl.c,v 1.5 2023/06/14 09:31:05 rillig Exp $ */ /* * Tests for the parser symbol psym_decl, which represents a declaration. * * Since C99, declarations and statements can be mixed in blocks. * - * A label can be followed by a statement but not by a declaration. + * In C, a label can be followed by a statement but not by a declaration. * * Indent distinguishes global and local declarations. * * Declarations can be for functions or for variables. */ -// TODO: prove that psym_decl can only ever occur at the top of the stack. -// TODO: delete decl_level if the above is proven. - //indent input int global_var; int global_array = [1,2,3,4]; @@ -36,3 +33,23 @@ int global_array = [ 4, ]; //indent end + + +// Declarations can be nested. +//indent input +struct level_1 { + union level_2 { + enum level_3 { + level_3_c_1, + level_3_c_2, + } level_3; + } level_2; +} level_1; +//indent end + +// The outermost declarator 'level_1' is indented as a global variable. +// The inner declarators 'level_2' and 'level_3' are indented as local +// variables. +// XXX: This is inconsistent, as in practice, struct members are usually +// aligned, while local variables aren't. +//indent run-equals-input -ldi0 Index: src/usr.bin/indent/debug.c diff -u src/usr.bin/indent/debug.c:1.56 src/usr.bin/indent/debug.c:1.57 --- src/usr.bin/indent/debug.c:1.56 Wed Jun 14 08:36:51 2023 +++ src/usr.bin/indent/debug.c Wed Jun 14 09:31:05 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.56 2023/06/14 08:36:51 rillig Exp $ */ +/* $NetBSD: debug.c,v 1.57 2023/06/14 09:31:05 rillig Exp $ */ /*- * Copyright (c) 2023 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: debug.c,v 1.56 2023/06/14 08:36:51 rillig Exp $"); +__RCSID("$NetBSD: debug.c,v 1.57 2023/06/14 09:31:05 rillig Exp $"); #include #include @@ -363,10 +363,10 @@ debug_parser_state(void) debug_ps_int(nparen); debug_ps_paren(); - state.heading = "horizontal spacing for comments"; - debug_ps_int(comment_delta); - debug_ps_int(n_comment_delta); - debug_ps_int(com_ind); + state.heading = "indentation of comments"; + debug_ps_int(comment_ind); + debug_ps_int(comment_shift); +
CVS commit: src
Module Name:src Committed By: rillig Date: Wed Jun 14 09:31:05 UTC 2023 Modified Files: src/tests/usr.bin/indent: lsym_comment.c psym_decl.c src/usr.bin/indent: debug.c indent.h io.c pr_comment.c Log Message: indent: clean up handling of comments One less moving part in the parser state. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/tests/usr.bin/indent/lsym_comment.c cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/psym_decl.c cvs rdiff -u -r1.56 -r1.57 src/usr.bin/indent/debug.c cvs rdiff -u -r1.191 -r1.192 src/usr.bin/indent/indent.h cvs rdiff -u -r1.217 -r1.218 src/usr.bin/indent/io.c cvs rdiff -u -r1.163 -r1.164 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.
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Wed Jun 14 08:36:51 UTC 2023 Modified Files: src/usr.bin/indent: debug.c indent.c indent.h lexi.c pr_comment.c Log Message: indent: remove another flag from parser state When processing a comment, the flag ps.next_col_1 was not used for the next token, but for a line within a comment. As its scope was limited to a single comment, there is no need to store it any longer than that No functional change. To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/usr.bin/indent/debug.c cvs rdiff -u -r1.358 -r1.359 src/usr.bin/indent/indent.c cvs rdiff -u -r1.190 -r1.191 src/usr.bin/indent/indent.h cvs rdiff -u -r1.226 -r1.227 src/usr.bin/indent/lexi.c cvs rdiff -u -r1.162 -r1.163 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/debug.c diff -u src/usr.bin/indent/debug.c:1.55 src/usr.bin/indent/debug.c:1.56 --- src/usr.bin/indent/debug.c:1.55 Wed Jun 14 08:25:15 2023 +++ src/usr.bin/indent/debug.c Wed Jun 14 08:36:51 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.55 2023/06/14 08:25:15 rillig Exp $ */ +/* $NetBSD: debug.c,v 1.56 2023/06/14 08:36:51 rillig Exp $ */ /*- * Copyright (c) 2023 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: debug.c,v 1.55 2023/06/14 08:25:15 rillig Exp $"); +__RCSID("$NetBSD: debug.c,v 1.56 2023/06/14 08:36:51 rillig Exp $"); #include #include @@ -374,9 +374,6 @@ debug_parser_state(void) debug_ps_enum(declaration, declaration_name); debug_ps_bool(blank_line_after_decl); - state.heading = "comments"; - debug_ps_bool(next_col_1); - state.heading = NULL; debug_blank_line(); Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.358 src/usr.bin/indent/indent.c:1.359 --- src/usr.bin/indent/indent.c:1.358 Wed Jun 14 07:20:55 2023 +++ src/usr.bin/indent/indent.c Wed Jun 14 08:36:51 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.358 2023/06/14 07:20:55 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.359 2023/06/14 08:36:51 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: indent.c,v 1.358 2023/06/14 07:20:55 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.359 2023/06/14 08:36:51 rillig Exp $"); #include #include @@ -186,7 +186,6 @@ init_globals(void) { ps.psyms.sym[0] = psym_stmt; ps.prev_lsym = lsym_semicolon; - ps.next_col_1 = true; ps.lbrace_kind = psym_lbrace_block; const char *suffix = getenv("SIMPLE_BACKUP_SUFFIX"); Index: src/usr.bin/indent/indent.h diff -u src/usr.bin/indent/indent.h:1.190 src/usr.bin/indent/indent.h:1.191 --- src/usr.bin/indent/indent.h:1.190 Wed Jun 14 08:25:15 2023 +++ src/usr.bin/indent/indent.h Wed Jun 14 08:36:51 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.h,v 1.190 2023/06/14 08:25:15 rillig Exp $ */ +/* $NetBSD: indent.h,v 1.191 2023/06/14 08:36:51 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -402,11 +402,6 @@ extern struct parser_state { decl_end, /* finished a declaration */ } declaration; bool blank_line_after_decl; - - /* Comments */ - - bool next_col_1; /* whether the next token starts in column 1 of - * the original input */ } ps; extern struct output_state { Index: src/usr.bin/indent/lexi.c diff -u src/usr.bin/indent/lexi.c:1.226 src/usr.bin/indent/lexi.c:1.227 --- src/usr.bin/indent/lexi.c:1.226 Wed Jun 14 08:25:15 2023 +++ src/usr.bin/indent/lexi.c Wed Jun 14 08:36:51 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lexi.c,v 1.226 2023/06/14 08:25:15 rillig Exp $ */ +/* $NetBSD: lexi.c,v 1.227 2023/06/14 08:36:51 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: lexi.c,v 1.226 2023/06/14 08:25:15 rillig Exp $"); +__RCSID("$NetBSD: lexi.c,v 1.227 2023/06/14 08:36:51 rillig Exp $"); #include #include @@ -532,7 +532,6 @@ lexer_symbol lexi(void) { buf_clear(); - ps.next_col_1 = false; for (;;) { if (ch_isblank(inp_p[0])) @@ -567,7 +566,6 @@ lexi(void) /* if data has been exhausted, the '\n' is a dummy. */ lsym = had_eof ? lsym_eof : lsym_newline; next_unary = ps.next_unary; - ps.next_col_1 = true; break; /* INDENT OFF */ Index: src/usr.bin/indent/pr_comment.c diff -u src/usr.bin/indent/pr_comment.c:1.162 src/usr.bin/indent/pr_comment.c:1.163 --- src/usr.bin/indent/pr_comment.c:1.162 Wed Jun 14 08:25:15 2023 +++ src/usr.bin/indent/pr_comment.c Wed Jun 14 08:36:51 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: pr_comment.c,v 1.162 2023/06/14 08:25:15 rillig Exp $ */ +/* $NetBSD: pr_comment.c,v 1.163 2023/06/14 08:36:51 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: pr_comment.c,v 1.162 2023/06/14 08:25:15 rillig Exp $"); +__RCSID("$NetBSD: pr_comment.c,v 1.163 2023/06/14 08:36:51 rillig Exp
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Wed Jun 14 08:36:51 UTC 2023 Modified Files: src/usr.bin/indent: debug.c indent.c indent.h lexi.c pr_comment.c Log Message: indent: remove another flag from parser state When processing a comment, the flag ps.next_col_1 was not used for the next token, but for a line within a comment. As its scope was limited to a single comment, there is no need to store it any longer than that No functional change. To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/usr.bin/indent/debug.c cvs rdiff -u -r1.358 -r1.359 src/usr.bin/indent/indent.c cvs rdiff -u -r1.190 -r1.191 src/usr.bin/indent/indent.h cvs rdiff -u -r1.226 -r1.227 src/usr.bin/indent/lexi.c cvs rdiff -u -r1.162 -r1.163 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.
CVS commit: src
Module Name:src Committed By: rillig Date: Wed Jun 14 08:25:15 UTC 2023 Modified Files: src/tests/usr.bin/indent: lsym_binary_op.c src/usr.bin/indent: debug.c indent.h lexi.c pr_comment.c Log Message: indent: remove a redundant flag from the parser state No functional change. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/indent/lsym_binary_op.c cvs rdiff -u -r1.54 -r1.55 src/usr.bin/indent/debug.c cvs rdiff -u -r1.189 -r1.190 src/usr.bin/indent/indent.h cvs rdiff -u -r1.225 -r1.226 src/usr.bin/indent/lexi.c cvs rdiff -u -r1.161 -r1.162 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/tests/usr.bin/indent/lsym_binary_op.c diff -u src/tests/usr.bin/indent/lsym_binary_op.c:1.11 src/tests/usr.bin/indent/lsym_binary_op.c:1.12 --- src/tests/usr.bin/indent/lsym_binary_op.c:1.11 Sun Jun 4 22:57:18 2023 +++ src/tests/usr.bin/indent/lsym_binary_op.c Wed Jun 14 08:25:15 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lsym_binary_op.c,v 1.11 2023/06/04 22:57:18 rillig Exp $ */ +/* $NetBSD: lsym_binary_op.c,v 1.12 2023/06/14 08:25:15 rillig Exp $ */ /* * Tests for the token lsym_binary_op, which represents a binary operator in @@ -147,7 +147,7 @@ joined_unary_and_binary_operators(void) * Ensure that the result of the indentation does not depend on whether a * token from the input starts in column 1 or 9. * - * See process_binary_op, ps.curr_col_1. + * See process_binary_op. */ //indent input int col_1 // Index: src/usr.bin/indent/debug.c diff -u src/usr.bin/indent/debug.c:1.54 src/usr.bin/indent/debug.c:1.55 --- src/usr.bin/indent/debug.c:1.54 Wed Jun 14 07:20:55 2023 +++ src/usr.bin/indent/debug.c Wed Jun 14 08:25:15 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.54 2023/06/14 07:20:55 rillig Exp $ */ +/* $NetBSD: debug.c,v 1.55 2023/06/14 08:25:15 rillig Exp $ */ /*- * Copyright (c) 2023 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: debug.c,v 1.54 2023/06/14 07:20:55 rillig Exp $"); +__RCSID("$NetBSD: debug.c,v 1.55 2023/06/14 08:25:15 rillig Exp $"); #include #include @@ -375,7 +375,6 @@ debug_parser_state(void) debug_ps_bool(blank_line_after_decl); state.heading = "comments"; - debug_ps_bool(curr_col_1); debug_ps_bool(next_col_1); state.heading = NULL; Index: src/usr.bin/indent/indent.h diff -u src/usr.bin/indent/indent.h:1.189 src/usr.bin/indent/indent.h:1.190 --- src/usr.bin/indent/indent.h:1.189 Wed Jun 14 07:20:55 2023 +++ src/usr.bin/indent/indent.h Wed Jun 14 08:25:15 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.h,v 1.189 2023/06/14 07:20:55 rillig Exp $ */ +/* $NetBSD: indent.h,v 1.190 2023/06/14 08:25:15 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -405,9 +405,8 @@ extern struct parser_state { /* Comments */ - bool curr_col_1; /* whether the current token started in column - * 1 of the original input */ - bool next_col_1; + bool next_col_1; /* whether the next token starts in column 1 of + * the original input */ } ps; extern struct output_state { Index: src/usr.bin/indent/lexi.c diff -u src/usr.bin/indent/lexi.c:1.225 src/usr.bin/indent/lexi.c:1.226 --- src/usr.bin/indent/lexi.c:1.225 Sat Jun 10 16:43:56 2023 +++ src/usr.bin/indent/lexi.c Wed Jun 14 08:25:15 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lexi.c,v 1.225 2023/06/10 16:43:56 rillig Exp $ */ +/* $NetBSD: lexi.c,v 1.226 2023/06/14 08:25:15 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: lexi.c,v 1.225 2023/06/10 16:43:56 rillig Exp $"); +__RCSID("$NetBSD: lexi.c,v 1.226 2023/06/14 08:25:15 rillig Exp $"); #include #include @@ -532,14 +532,12 @@ lexer_symbol lexi(void) { buf_clear(); - ps.curr_col_1 = ps.next_col_1; ps.next_col_1 = false; for (;;) { - if (ch_isblank(inp_p[0])) { - ps.curr_col_1 = false; + if (ch_isblank(inp_p[0])) inp_p++; - } else if (inp_p[0] == '\\' && inp_p[1] == '\n') { + else if (inp_p[0] == '\\' && inp_p[1] == '\n') { inp_p++; inp_skip(); line_no++; Index: src/usr.bin/indent/pr_comment.c diff -u src/usr.bin/indent/pr_comment.c:1.161 src/usr.bin/indent/pr_comment.c:1.162 --- src/usr.bin/indent/pr_comment.c:1.161 Sat Jun 10 16:43:56 2023 +++ src/usr.bin/indent/pr_comment.c Wed Jun 14 08:25:15 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: pr_comment.c,v 1.161 2023/06/10 16:43:56 rillig Exp $ */ +/* $NetBSD: pr_comment.c,v 1.162 2023/06/14 08:25:15 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: pr_comment.c,v 1.161 2023/06/10 16:43:56 rillig Exp $"); +__RCSID("$NetBSD: pr_comment.c,v 1.162 2023/06/14 08:25:15 rillig Exp $"); #include @@ -84,7 +84,7 @@ analyze_comment(bool *p_may_wrap, bool * int ind; int line_length = opt.max_line_length; - if (ps.curr_col_1
CVS commit: src
Module Name:src Committed By: rillig Date: Wed Jun 14 08:25:15 UTC 2023 Modified Files: src/tests/usr.bin/indent: lsym_binary_op.c src/usr.bin/indent: debug.c indent.h lexi.c pr_comment.c Log Message: indent: remove a redundant flag from the parser state No functional change. To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/indent/lsym_binary_op.c cvs rdiff -u -r1.54 -r1.55 src/usr.bin/indent/debug.c cvs rdiff -u -r1.189 -r1.190 src/usr.bin/indent/indent.h cvs rdiff -u -r1.225 -r1.226 src/usr.bin/indent/lexi.c cvs rdiff -u -r1.161 -r1.162 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.
CVS commit: src
Module Name:src Committed By: rillig Date: Wed Jun 14 07:20:55 UTC 2023 Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin/indent: Makefile psym_stmt.c src/usr.bin/indent: debug.c indent.c indent.h parse.c Removed Files: src/tests/usr.bin/indent: psym_stmt_list.c Log Message: indent: merge parser symbols for stmt and stmt_list They were handled in exactly the same way. To generate a diff of this commit: cvs rdiff -u -r1.1266 -r1.1267 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.47 -r1.48 src/tests/usr.bin/indent/Makefile cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/psym_stmt.c cvs rdiff -u -r1.5 -r0 src/tests/usr.bin/indent/psym_stmt_list.c cvs rdiff -u -r1.53 -r1.54 src/usr.bin/indent/debug.c cvs rdiff -u -r1.357 -r1.358 src/usr.bin/indent/indent.c cvs rdiff -u -r1.188 -r1.189 src/usr.bin/indent/indent.h cvs rdiff -u -r1.72 -r1.73 src/usr.bin/indent/parse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: rillig Date: Wed Jun 14 07:20:55 UTC 2023 Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin/indent: Makefile psym_stmt.c src/usr.bin/indent: debug.c indent.c indent.h parse.c Removed Files: src/tests/usr.bin/indent: psym_stmt_list.c Log Message: indent: merge parser symbols for stmt and stmt_list They were handled in exactly the same way. To generate a diff of this commit: cvs rdiff -u -r1.1266 -r1.1267 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.47 -r1.48 src/tests/usr.bin/indent/Makefile cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/psym_stmt.c cvs rdiff -u -r1.5 -r0 src/tests/usr.bin/indent/psym_stmt_list.c cvs rdiff -u -r1.53 -r1.54 src/usr.bin/indent/debug.c cvs rdiff -u -r1.357 -r1.358 src/usr.bin/indent/indent.c cvs rdiff -u -r1.188 -r1.189 src/usr.bin/indent/indent.h cvs rdiff -u -r1.72 -r1.73 src/usr.bin/indent/parse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1266 src/distrib/sets/lists/tests/mi:1.1267 --- src/distrib/sets/lists/tests/mi:1.1266 Thu Jun 1 07:27:30 2023 +++ src/distrib/sets/lists/tests/mi Wed Jun 14 07:20:54 2023 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1266 2023/06/01 07:27:30 rillig Exp $ +# $NetBSD: mi,v 1.1267 2023/06/14 07:20:54 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -5252,7 +5252,7 @@ ./usr/tests/usr.bin/indent/psym_rbrace.ctests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/indent/psym_semicolon.ctests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/indent/psym_stmt.c tests-usr.bin-tests compattestfile,atf -./usr/tests/usr.bin/indent/psym_stmt_list.ctests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/indent/psym_stmt_list.ctests-obsolete obsolete,atf ./usr/tests/usr.bin/indent/psym_switch_expr.ctests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/indent/psym_while_expr.ctests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/indent/struct.0 tests-obsolete obsolete,atf Index: src/tests/usr.bin/indent/Makefile diff -u src/tests/usr.bin/indent/Makefile:1.47 src/tests/usr.bin/indent/Makefile:1.48 --- src/tests/usr.bin/indent/Makefile:1.47 Sat May 20 21:32:05 2023 +++ src/tests/usr.bin/indent/Makefile Wed Jun 14 07:20:55 2023 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.47 2023/05/20 21:32:05 rillig Exp $ +# $NetBSD: Makefile,v 1.48 2023/06/14 07:20:55 rillig Exp $ .include @@ -109,7 +109,6 @@ FILES+= psym_lbrace.c FILES+= psym_rbrace.c FILES+= psym_semicolon.c FILES+= psym_stmt.c -FILES+= psym_stmt_list.c FILES+= psym_switch_expr.c FILES+= psym_while_expr.c FILES+= t_options.lua Index: src/tests/usr.bin/indent/psym_stmt.c diff -u src/tests/usr.bin/indent/psym_stmt.c:1.6 src/tests/usr.bin/indent/psym_stmt.c:1.7 --- src/tests/usr.bin/indent/psym_stmt.c:1.6 Fri Jun 9 10:24:55 2023 +++ src/tests/usr.bin/indent/psym_stmt.c Wed Jun 14 07:20:55 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: psym_stmt.c,v 1.6 2023/06/09 10:24:55 rillig Exp $ */ +/* $NetBSD: psym_stmt.c,v 1.7 2023/06/14 07:20:55 rillig Exp $ */ /* * Tests for the parser symbol psym_stmt, which represents a statement on the @@ -39,3 +39,40 @@ function(void) //indent end //indent run-equals-input -di0 -nlp -ci4 + + +//indent input +void +function(void) +{ + stmt(); + int var; + stmt(); + { + stmt(); + int var; + stmt(); + } +} +//indent end + +//indent run-equals-input -ldi0 + + +//indent input +void +return_after_rbrace(void) +{ + {}return; +} +//indent end + +//indent run +void +return_after_rbrace(void) +{ + { + } + return; +} +//indent end Index: src/usr.bin/indent/debug.c diff -u src/usr.bin/indent/debug.c:1.53 src/usr.bin/indent/debug.c:1.54 --- src/usr.bin/indent/debug.c:1.53 Sat Jun 10 21:36:38 2023 +++ src/usr.bin/indent/debug.c Wed Jun 14 07:20:55 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.53 2023/06/10 21:36:38 rillig Exp $ */ +/* $NetBSD: debug.c,v 1.54 2023/06/14 07:20:55 rillig Exp $ */ /*- * Copyright (c) 2023 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: debug.c,v 1.53 2023/06/10 21:36:38 rillig Exp $"); +__RCSID("$NetBSD: debug.c,v 1.54 2023/06/14 07:20:55 rillig Exp $"); #include #include @@ -99,7 +99,6 @@ const char *const psym_name[] = { "}", "decl", "stmt", - "stmt_list", "for_exprs", "if_expr", "if_expr_stmt", Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.357 src/usr.bin/indent/indent.c:1.358 --- src/usr.bin/indent/indent.c:1.357 Sat Jun 10 21:36:38 2023 +++ src/usr.bin/indent/indent.c Wed Jun 14 07:20:55 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.357 2023/06/10 21:36:38 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.358 2023/06/14 07:20:55 rillig Exp $ */ /*- * SPDX-License-Identifier: