CVS commit: src
Module Name:src Committed By: rillig Date: Sat Jun 10 06:52:36 UTC 2023 Modified Files: src/tests/usr.bin/indent: lsym_case_label.c opt_bc.c src/usr.bin/indent: indent.c Log Message: indent: fix token classification in declarations As a side effect, indent handles _Generic from C11 properly now, at least in -nlp mode. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/indent/lsym_case_label.c cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/indent/opt_bc.c cvs rdiff -u -r1.349 -r1.350 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_case_label.c diff -u src/tests/usr.bin/indent/lsym_case_label.c:1.8 src/tests/usr.bin/indent/lsym_case_label.c:1.9 --- src/tests/usr.bin/indent/lsym_case_label.c:1.8 Sun Jun 4 18:58:30 2023 +++ src/tests/usr.bin/indent/lsym_case_label.c Sat Jun 10 06:52:35 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lsym_case_label.c,v 1.8 2023/06/04 18:58:30 rillig Exp $ */ +/* $NetBSD: lsym_case_label.c,v 1.9 2023/06/10 06:52:35 rillig Exp $ */ /* * Tests for the tokens lsym_case and lsym_default, which represent the @@ -92,22 +92,12 @@ const char *type_name = _Generic( // $ XXX: It's strange to align the arguments at the parenthesis even though // $ XXX: the first argument is already on a separate line. ' ', -// $ TODO: indent the type names -int: "character constants have type 'int'", -char: "character constants have type 'char'", -default: -// $ TODO: remove the newline after 'default:' - "character constants have some other type" + int: "character constants have type 'int'", +// $ FIXME: The indentation is not sensible in any way. + char: "character constants have type 'char'", +// $ FIXME: The indentation is not sensible in any way. + default: "character constants have some other type" ); //indent end -//indent run -di0 -nlp -const char *type_name = _Generic( - ' ', -// $ TODO: indent the type names -int: "character constants have type 'int'", -char: "character constants have type 'char'", -default: - "character constants have some other type" -); -//indent end +//indent run-equals-input -di0 -nlp Index: src/tests/usr.bin/indent/opt_bc.c diff -u src/tests/usr.bin/indent/opt_bc.c:1.9 src/tests/usr.bin/indent/opt_bc.c:1.10 --- src/tests/usr.bin/indent/opt_bc.c:1.9 Sat Jun 10 06:38:21 2023 +++ src/tests/usr.bin/indent/opt_bc.c Sat Jun 10 06:52:35 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: opt_bc.c,v 1.9 2023/06/10 06:38:21 rillig Exp $ */ +/* $NetBSD: opt_bc.c,v 1.10 2023/06/10 06:52:35 rillig Exp $ */ /* * Tests for the options '-bc' and '-nbc'. @@ -105,8 +105,8 @@ int d; /* - * A '(' at the top level is taken to start a function definition, leaving - * variable declaration mode. + * Before 2023-06-10, a '(' at the top level started a function definition, + * leaving variable declaration mode. */ //indent input int a = 1, b = 2; @@ -116,6 +116,6 @@ int a = (1), b = 2; //indent run -bc int a = 1, b = 2; -// $ FIXME: Missing line break. -int a = (1), b = 2; +int a = (1), + b = 2; //indent end Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.349 src/usr.bin/indent/indent.c:1.350 --- src/usr.bin/indent/indent.c:1.349 Sat Jun 10 06:38:21 2023 +++ src/usr.bin/indent/indent.c Sat Jun 10 06:52:35 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.349 2023/06/10 06:38:21 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.350 2023/06/10 06:52:35 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: indent.c,v 1.349 2023/06/10 06:38:21 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.350 2023/06/10 06:52:35 rillig Exp $"); #include #include @@ -531,9 +531,8 @@ 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) { - /* A kludge to correctly align function definitions. */ - parse(psym_stmt); + if (ps.in_var_decl && ps.psyms.top <= 2 && !ps.in_init) { + parse(psym_stmt); /* prepare for function definition */ ps.in_var_decl = false; } @@ -841,7 +840,7 @@ static void process_colon_other(void) { buf_add_char(&code, ':'); - ps.want_blank = false; + ps.want_blank = ps.decl_level == 0; } static void
CVS commit: src
Module Name:src Committed By: rillig Date: Sat Jun 10 06:52:36 UTC 2023 Modified Files: src/tests/usr.bin/indent: lsym_case_label.c opt_bc.c src/usr.bin/indent: indent.c Log Message: indent: fix token classification in declarations As a side effect, indent handles _Generic from C11 properly now, at least in -nlp mode. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/indent/lsym_case_label.c cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/indent/opt_bc.c cvs rdiff -u -r1.349 -r1.350 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
Module Name:src Committed By: rillig Date: Sat Jun 10 06:38:21 UTC 2023 Modified Files: src/tests/usr.bin/indent: fmt_decl.c lsym_comment.c opt_bc.c src/usr.bin/indent: debug.c indent.c indent.h io.c lexi.c pr_comment.c Log Message: indent: rename and sort variables in parser state No functional change. To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/tests/usr.bin/indent/fmt_decl.c cvs rdiff -u -r1.18 -r1.19 src/tests/usr.bin/indent/lsym_comment.c cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/indent/opt_bc.c cvs rdiff -u -r1.43 -r1.44 src/usr.bin/indent/debug.c cvs rdiff -u -r1.348 -r1.349 src/usr.bin/indent/indent.c cvs rdiff -u -r1.183 -r1.184 src/usr.bin/indent/indent.h cvs rdiff -u -r1.208 -r1.209 src/usr.bin/indent/io.c cvs rdiff -u -r1.220 -r1.221 src/usr.bin/indent/lexi.c cvs rdiff -u -r1.158 -r1.159 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/fmt_decl.c diff -u src/tests/usr.bin/indent/fmt_decl.c:1.52 src/tests/usr.bin/indent/fmt_decl.c:1.53 --- src/tests/usr.bin/indent/fmt_decl.c:1.52 Fri Jun 9 09:49:07 2023 +++ src/tests/usr.bin/indent/fmt_decl.c Sat Jun 10 06:38:21 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: fmt_decl.c,v 1.52 2023/06/09 09:49:07 rillig Exp $ */ +/* $NetBSD: fmt_decl.c,v 1.53 2023/06/10 06:38:21 rillig Exp $ */ /* * Tests for declarations of global variables, external functions, and local @@ -1048,3 +1048,24 @@ typedef struct { // $ FIXME: Remove this line break. mod_t; //indent end + + +//indent input +int a[] = {1, 2}, +b[] = {1, 2}; +{ +int a[] = {1, 2}, +b[] = {1, 2}; +} +//indent end + +//indent run -di0 +int a[] = {1, 2}, +// $ FIXME: Missing indentation. +b[] = {1, 2}; +{ + int a[] = {1, 2}, + // $ FIXME: Missing indentation. + b[] = {1, 2}; +} +//indent end Index: src/tests/usr.bin/indent/lsym_comment.c diff -u src/tests/usr.bin/indent/lsym_comment.c:1.18 src/tests/usr.bin/indent/lsym_comment.c:1.19 --- src/tests/usr.bin/indent/lsym_comment.c:1.18 Tue Jun 6 07:51:35 2023 +++ src/tests/usr.bin/indent/lsym_comment.c Sat Jun 10 06:38:21 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lsym_comment.c,v 1.18 2023/06/06 07:51:35 rillig Exp $ */ +/* $NetBSD: lsym_comment.c,v 1.19 2023/06/10 06:38:21 rillig Exp $ */ /* * Tests for the token lsym_comment, which starts a comment. @@ -42,7 +42,7 @@ * - with varying opt.block_comment_max_line_length (-lc60, -lc78, -lc90) * - with varying opt.comment_column (-c0, -c1, -c33, -c80) * - with varying opt.decl_comment_column (-cd0, -cd1, -cd20, -cd33, -cd80) - * - with/without ps.decl_on_line + * - with/without ps.line_has_decl * - with/without ps.next_col_1 * * - very long comments that overflow the buffer 'com' Index: src/tests/usr.bin/indent/opt_bc.c diff -u src/tests/usr.bin/indent/opt_bc.c:1.8 src/tests/usr.bin/indent/opt_bc.c:1.9 --- src/tests/usr.bin/indent/opt_bc.c:1.8 Fri Jun 2 11:43:07 2023 +++ src/tests/usr.bin/indent/opt_bc.c Sat Jun 10 06:38:21 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: opt_bc.c,v 1.8 2023/06/02 11:43:07 rillig Exp $ */ +/* $NetBSD: opt_bc.c,v 1.9 2023/06/10 06:38:21 rillig Exp $ */ /* * Tests for the options '-bc' and '-nbc'. @@ -102,3 +102,20 @@ int d; int d; #endif //indent end + + +/* + * A '(' at the top level is taken to start a function definition, leaving + * variable declaration mode. + */ +//indent input +int a = 1, b = 2; +int a = (1), b = 2; +//indent end + +//indent run -bc +int a = 1, + b = 2; +// $ FIXME: Missing line break. +int a = (1), b = 2; +//indent end Index: src/usr.bin/indent/debug.c diff -u src/usr.bin/indent/debug.c:1.43 src/usr.bin/indent/debug.c:1.44 --- src/usr.bin/indent/debug.c:1.43 Fri Jun 9 18:09:30 2023 +++ src/usr.bin/indent/debug.c Sat Jun 10 06:38:20 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.43 2023/06/09 18:09:30 rillig Exp $ */ +/* $NetBSD: debug.c,v 1.44 2023/06/10 06:38:20 rillig Exp $ */ /*- * Copyright (c) 2023 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: debug.c,v 1.43 2023/06/09 18:09:30 rillig Exp $"); +__RCSID("$NetBSD: debug.c,v 1.44 2023/06/10 06:38:20 rillig Exp $"); #include @@ -294,19 +294,19 @@ debug_parser_state(void) lsym_name[ps.prev_lsym]); debug_println("token classification"); - debug_ps_int(quest_level); - debug_ps_bool(is_function_definition); - debug_ps_bool(block_init); - debug_ps_int(block_init_level); - debug_ps_bool(init_or_struct); - debug_ps_bool(decl_on_line); debug_ps_bool(in_stmt_or_decl); debug_ps_bool(in_decl); + debug_ps_bool(in_var_decl); + debug_ps_bool(in_init); + debug_ps_int(init_level); + debug_ps_bool(in_func_def_line); debug_ps_bool(in_func_def_params); - debug_ps_bool(seen_case); - debug_ps_enum(spaced_expr_psym, psym_name); + debug_ps_bool(line_has_decl); debug_ps_enum(lbrace_kind, psym_name); + debug_ps_enum(spaced_expr_psym, psym_name); + debug_ps
CVS commit: src
Module Name:src Committed By: rillig Date: Sat Jun 10 06:38:21 UTC 2023 Modified Files: src/tests/usr.bin/indent: fmt_decl.c lsym_comment.c opt_bc.c src/usr.bin/indent: debug.c indent.c indent.h io.c lexi.c pr_comment.c Log Message: indent: rename and sort variables in parser state No functional change. To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/tests/usr.bin/indent/fmt_decl.c cvs rdiff -u -r1.18 -r1.19 src/tests/usr.bin/indent/lsym_comment.c cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/indent/opt_bc.c cvs rdiff -u -r1.43 -r1.44 src/usr.bin/indent/debug.c cvs rdiff -u -r1.348 -r1.349 src/usr.bin/indent/indent.c cvs rdiff -u -r1.183 -r1.184 src/usr.bin/indent/indent.h cvs rdiff -u -r1.208 -r1.209 src/usr.bin/indent/io.c cvs rdiff -u -r1.220 -r1.221 src/usr.bin/indent/lexi.c cvs rdiff -u -r1.158 -r1.159 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/gzip
Module Name:src Committed By: simonb Date: Sat Jun 10 04:45:25 UTC 2023 Modified Files: src/usr.bin/gzip: gzip.c unlz.c unpack.c Log Message: Pull git commit way-etc-20140221.tar.bz2 by Xin Li from FreeBSD: Remove unneeded checks for prelen. In order to determine the type of a compressed file, we have to read in the first four bytes which may also be important for decompression purposes, to do that we would pass the buffer that we have already read in, along with the size of it. Rename header1 to fourbytes to make that explicit, and remove all checks for prelen. To generate a diff of this commit: cvs rdiff -u -r1.118 -r1.119 src/usr.bin/gzip/gzip.c cvs rdiff -u -r1.7 -r1.8 src/usr.bin/gzip/unlz.c cvs rdiff -u -r1.3 -r1.4 src/usr.bin/gzip/unpack.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/gzip
Module Name:src Committed By: simonb Date: Sat Jun 10 04:45:25 UTC 2023 Modified Files: src/usr.bin/gzip: gzip.c unlz.c unpack.c Log Message: Pull git commit way-etc-20140221.tar.bz2 by Xin Li from FreeBSD: Remove unneeded checks for prelen. In order to determine the type of a compressed file, we have to read in the first four bytes which may also be important for decompression purposes, to do that we would pass the buffer that we have already read in, along with the size of it. Rename header1 to fourbytes to make that explicit, and remove all checks for prelen. To generate a diff of this commit: cvs rdiff -u -r1.118 -r1.119 src/usr.bin/gzip/gzip.c cvs rdiff -u -r1.7 -r1.8 src/usr.bin/gzip/unlz.c cvs rdiff -u -r1.3 -r1.4 src/usr.bin/gzip/unpack.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/gzip/gzip.c diff -u src/usr.bin/gzip/gzip.c:1.118 src/usr.bin/gzip/gzip.c:1.119 --- src/usr.bin/gzip/gzip.c:1.118 Sat Jan 22 14:00:45 2022 +++ src/usr.bin/gzip/gzip.c Sat Jun 10 04:45:25 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: gzip.c,v 1.118 2022/01/22 14:00:45 christos Exp $ */ +/* $NetBSD: gzip.c,v 1.119 2023/06/10 04:45:25 simonb Exp $ */ /* * Copyright (c) 1997, 1998, 2003, 2004, 2006, 2008, 2009, 2010, 2011, 2015, 2017 @@ -31,7 +31,7 @@ #ifndef lint __COPYRIGHT("@(#) Copyright (c) 1997, 1998, 2003, 2004, 2006, 2008,\ 2009, 2010, 2011, 2015, 2017 Matthew R. Green. All rights reserved."); -__RCSID("$NetBSD: gzip.c,v 1.118 2022/01/22 14:00:45 christos Exp $"); +__RCSID("$NetBSD: gzip.c,v 1.119 2023/06/10 04:45:25 simonb Exp $"); #endif /* not lint */ /* @@ -1400,7 +1400,7 @@ file_uncompress(char *file, char *outfil struct stat isb, osb; off_t size; ssize_t rbytes; - unsigned char header1[4]; + unsigned char fourbytes[4]; enum filetype method; int fd, ofd, zfd = -1; size_t in_size; @@ -1434,8 +1434,8 @@ file_uncompress(char *file, char *outfil goto lose; } - rbytes = read(fd, header1, sizeof header1); - if (rbytes != sizeof header1) { + rbytes = read(fd, fourbytes, sizeof fourbytes); + if (rbytes != sizeof fourbytes) { /* we don't want to fail here. */ #ifndef SMALL if (fflag) @@ -1449,7 +1449,7 @@ file_uncompress(char *file, char *outfil } infile_newdata(rbytes); - method = file_gettype(header1); + method = file_gettype(fourbytes); #ifndef SMALL if (fflag == 0 && method == FT_UNKNOWN) { maybe_warnx("%s: not in gzip format", file); @@ -1473,7 +1473,7 @@ file_uncompress(char *file, char *outfil infile_newdata(rv); timestamp = ts[3] << 24 | ts[2] << 16 | ts[1] << 8 | ts[0]; - if (header1[3] & ORIG_NAME) { + if (fourbytes[3] & ORIG_NAME) { rbytes = pread(fd, name, sizeof(name) - 1, GZIP_ORIGNAME); if (rbytes < 0) { maybe_warn("can't read %s", file); @@ -1787,7 +1787,7 @@ static void handle_stdin(void) { struct stat isb; - unsigned char header1[4]; + unsigned char fourbytes[4]; size_t in_size; off_t usize, gsize; enum filetype method; @@ -1818,16 +1818,16 @@ handle_stdin(void) goto out; } - bytes_read = read_retry(STDIN_FILENO, header1, sizeof header1); + bytes_read = read_retry(STDIN_FILENO, fourbytes, sizeof fourbytes); if (bytes_read == -1) { maybe_warn("can't read stdin"); goto out; - } else if (bytes_read != sizeof(header1)) { + } else if (bytes_read != sizeof(fourbytes)) { maybe_warnx("(stdin): unexpected end of file"); goto out; } - method = file_gettype(header1); + method = file_gettype(fourbytes); switch (method) { default: #ifndef SMALL @@ -1835,17 +1835,17 @@ handle_stdin(void) maybe_warnx("unknown compression format"); goto out; } - usize = cat_fd(header1, sizeof header1, &gsize, STDIN_FILENO); + usize = cat_fd(fourbytes, sizeof fourbytes, &gsize, STDIN_FILENO); break; #endif case FT_GZIP: usize = gz_uncompress(STDIN_FILENO, STDOUT_FILENO, - (char *)header1, sizeof header1, &gsize, "(stdin)"); + (char *)fourbytes, sizeof fourbytes, &gsize, "(stdin)"); break; #ifndef NO_BZIP2_SUPPORT case FT_BZIP2: usize = unbzip2(STDIN_FILENO, STDOUT_FILENO, -(char *)header1, sizeof header1, &gsize); +(char *)fourbytes, sizeof fourbytes, &gsize); break; #endif #ifndef NO_COMPRESS_SUPPORT @@ -1855,27 +1855,27 @@ handle_stdin(void) goto out; } - usize = zuncompress(in, stdout, (char *)header1, - sizeof header1, &gsize); + usize = zuncompress(in, stdout, (char *)fourbytes, + sizeof fourbytes, &gsize); fclose(in); break; #endif #ifndef NO_PACK_SUPPORT case FT_PACK: usize = unpack(STDIN_FILENO, STDOUT_FILENO, - (char *)header1, sizeof header1, &gsize); + (char *)fourbytes, sizeof fourbytes, &gsize); break; #endif #ifndef NO_XZ_SUPPORT case FT_XZ: usize = unxz(STDIN_FILENO, STDOUT_FILENO, - (char *)header1, sizeof header1, &gsize); +
CVS commit: src/etc/rc.d
Module Name:src Committed By: kim Date: Sat Jun 10 04:02:39 UTC 2023 Modified Files: src/etc/rc.d: sshd Log Message: Add some backwards compat. Adjust grammar. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/etc/rc.d/sshd Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/etc/rc.d/sshd diff -u src/etc/rc.d/sshd:1.35 src/etc/rc.d/sshd:1.36 --- src/etc/rc.d/sshd:1.35 Mon Jun 5 11:59:12 2023 +++ src/etc/rc.d/sshd Sat Jun 10 04:02:39 2023 @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: sshd,v 1.35 2023/06/05 11:59:12 riastradh Exp $ +# $NetBSD: sshd,v 1.36 2023/06/10 04:02:39 kim Exp $ # # PROVIDE: sshd @@ -26,13 +26,13 @@ sshd_motd_unsafe_keys_warning() -- UNSAFE KEYS WARNING: The ssh host keys on this machine have been generated with - not enough entropy configured, so may be predictable. + not enough entropy configured, so they may be predictable. To fix, follow the "Adding entropy" section in the entropy(7) - man page and after this machine has enough entropy, re-generate + man page. After this machine has enough entropy, re-generate the ssh host keys by running: - sh /etc/rc.d/sshd keyregen + /etc/rc.d/sshd keyregen _EOF fi cmp -s $T /etc/motd || cp $T /etc/motd @@ -66,7 +66,7 @@ ed25519 -1 ssh_host_ed25519_key rsa 0 ssh_host_rsa_key _EOF if "${new_key_created}"; then - sshd_motd_unsafe_keys_warning + sysctl -q kern.entropy.needed && sshd_motd_unsafe_keys_warning fi ) }
CVS commit: src/etc/rc.d
Module Name:src Committed By: kim Date: Sat Jun 10 04:02:39 UTC 2023 Modified Files: src/etc/rc.d: sshd Log Message: Add some backwards compat. Adjust grammar. To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/etc/rc.d/sshd 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: Fri Jun 9 22:01:26 UTC 2023 Modified Files: src/tests/usr.bin/indent: lsym_newline.c src/usr.bin/indent: indent.c indent.h io.c Log Message: indent: trim trailing blank lines To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/lsym_newline.c cvs rdiff -u -r1.347 -r1.348 src/usr.bin/indent/indent.c cvs rdiff -u -r1.182 -r1.183 src/usr.bin/indent/indent.h cvs rdiff -u -r1.207 -r1.208 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/tests/usr.bin/indent/lsym_newline.c diff -u src/tests/usr.bin/indent/lsym_newline.c:1.4 src/tests/usr.bin/indent/lsym_newline.c:1.5 --- src/tests/usr.bin/indent/lsym_newline.c:1.4 Sun Apr 24 10:36:37 2022 +++ src/tests/usr.bin/indent/lsym_newline.c Fri Jun 9 22:01:26 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lsym_newline.c,v 1.4 2022/04/24 10:36:37 rillig Exp $ */ +/* $NetBSD: lsym_newline.c,v 1.5 2023/06/09 22:01:26 rillig Exp $ */ /* * Tests for the token lsym_newline, which represents a forced line break in @@ -32,3 +32,15 @@ int var = + 3 + 4; //indent end + + +// Trim trailing blank lines. +//indent input +int x; + + +//indent end + +//indent run -di0 +int x; +//indent end Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.347 src/usr.bin/indent/indent.c:1.348 --- src/usr.bin/indent/indent.c:1.347 Fri Jun 9 16:23:43 2023 +++ src/usr.bin/indent/indent.c Fri Jun 9 22:01:26 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.347 2023/06/09 16:23:43 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.348 2023/06/09 22:01:26 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: indent.c,v 1.347 2023/06/09 16:23:43 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.348 2023/06/09 22:01:26 rillig Exp $"); #include #include @@ -83,7 +83,6 @@ struct buffer com; bool found_err; bool had_eof; int line_no = 1; -enum indent_enabled indent_enabled; static int ifdef_level; static struct parser_state state_stack[5]; @@ -380,17 +379,11 @@ is_function_pointer_declaration(void) static int process_eof(void) { - if (lab.len > 0 || code.len > 0 || com.len > 0) - output_line(); - if (indent_enabled != indent_on) { - indent_enabled = indent_last_off_line; - output_line(); - } + output_finish(); if (ps.psyms.top > 1) /* check for balanced braces */ diag(1, "Stuff missing from end of file"); - fflush(output); return found_err ? EXIT_FAILURE : EXIT_SUCCESS; } Index: src/usr.bin/indent/indent.h diff -u src/usr.bin/indent/indent.h:1.182 src/usr.bin/indent/indent.h:1.183 --- src/usr.bin/indent/indent.h:1.182 Fri Jun 9 16:23:43 2023 +++ src/usr.bin/indent/indent.h Fri Jun 9 22:01:26 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.h,v 1.182 2023/06/09 16:23:43 rillig Exp $ */ +/* $NetBSD: indent.h,v 1.183 2023/06/09 22:01:26 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -472,6 +472,7 @@ int ind_add(int, const char *, size_t); void inp_skip(void); char inp_next(void); +void output_finish(void); lexer_symbol lexi(void); void diag(int, const char *, ...) __printflike(2, 3); Index: src/usr.bin/indent/io.c diff -u src/usr.bin/indent/io.c:1.207 src/usr.bin/indent/io.c:1.208 --- src/usr.bin/indent/io.c:1.207 Fri Jun 9 08:10:58 2023 +++ src/usr.bin/indent/io.c Fri Jun 9 22:01:26 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: io.c,v 1.207 2023/06/09 08:10:58 rillig Exp $ */ +/* $NetBSD: io.c,v 1.208 2023/06/09 22:01:26 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: io.c,v 1.207 2023/06/09 08:10:58 rillig Exp $"); +__RCSID("$NetBSD: io.c,v 1.208 2023/06/09 22:01:26 rillig Exp $"); #include @@ -48,10 +48,12 @@ struct buffer inp; const char *inp_p; struct output_state out; +enum indent_enabled indent_enabled; static int out_ind; /* width of the line that is being written */ static unsigned wrote_newlines = 2; /* 0 in the middle of a line, 1 after a * single '\n', > 1 means there were (n * - 1) blank lines above */ +static unsigned buffered_blank_lines; static int paren_indent; @@ -108,15 +110,24 @@ inp_next(void) static void output_newline(void) { - fputc('\n', output); - debug_println("output_newline"); + buffered_blank_lines++; wrote_newlines++; out_ind = 0; } static void +write_buffered_blank_lines(void) +{ + for (; buffered_blank_lines > 0; buffered_blank_lines--) { + fputc('\n', output); + debug_println("output_newline"); + } +} + +static void output_range(const char *s, size_t len) { + write_buffered_blank_lines(); fwrite(s, 1, len, output); debug_vis_range("output_range \"", s, len, "\"\n"); for (size_t i = 0; i < len; i++) @@ -127,6 +138,8 @@ output_range(const char *s, size_t len) static void output_indent(int new_ind) { + write_
CVS commit: src
Module Name:src Committed By: rillig Date: Fri Jun 9 22:01:26 UTC 2023 Modified Files: src/tests/usr.bin/indent: lsym_newline.c src/usr.bin/indent: indent.c indent.h io.c Log Message: indent: trim trailing blank lines To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/lsym_newline.c cvs rdiff -u -r1.347 -r1.348 src/usr.bin/indent/indent.c cvs rdiff -u -r1.182 -r1.183 src/usr.bin/indent/indent.h cvs rdiff -u -r1.207 -r1.208 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/distrib/evbmips/instkernel/ramdisk
Module Name:src Committed By: gutteridge Date: Fri Jun 9 21:41:52 UTC 2023 Modified Files: src/distrib/evbmips/instkernel/ramdisk: Makefile Log Message: Add bpf to the device nodes provided in the evbmips ramdisk Intended to address an issue noted by Denis Ovsienko on port-mips, where dhcpcd doesn't work with the netbsd-INSTALL_OCTEON kernel. (I am not able to test this directly, but verified by mounting the ramdisk images generated before and after this change.) To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/distrib/evbmips/instkernel/ramdisk/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/distrib/evbmips/instkernel/ramdisk
Module Name:src Committed By: gutteridge Date: Fri Jun 9 21:41:52 UTC 2023 Modified Files: src/distrib/evbmips/instkernel/ramdisk: Makefile Log Message: Add bpf to the device nodes provided in the evbmips ramdisk Intended to address an issue noted by Denis Ovsienko on port-mips, where dhcpcd doesn't work with the netbsd-INSTALL_OCTEON kernel. (I am not able to test this directly, but verified by mounting the ramdisk images generated before and after this change.) To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/distrib/evbmips/instkernel/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/evbmips/instkernel/ramdisk/Makefile diff -u src/distrib/evbmips/instkernel/ramdisk/Makefile:1.15 src/distrib/evbmips/instkernel/ramdisk/Makefile:1.16 --- src/distrib/evbmips/instkernel/ramdisk/Makefile:1.15 Sun Apr 25 23:40:05 2021 +++ src/distrib/evbmips/instkernel/ramdisk/Makefile Fri Jun 9 21:41:52 2023 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.15 2021/04/25 23:40:05 christos Exp $ +# $NetBSD: Makefile,v 1.16 2023/06/09 21:41:52 gutteridge Exp $ .include .include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib" @@ -25,7 +25,7 @@ IMAGEDEPENDS= ${CRUNCHBIN} \ ${NETBSDSRCDIR}/etc/netconfig ${DISTRIBDIR}/common/protocols \ ${DISTRIBDIR}/common/services -MAKEDEVTARGETS= std md0 wd0 wd1 wd2 wd3 cd0 cd1 sd0 sd1 sd2 sd3 st0 ipty +MAKEDEVTARGETS= std md0 wd0 wd1 wd2 wd3 cd0 cd1 sd0 sd1 sd2 sd3 st0 ipty bpf # Use stubs to eliminate some large stuff from libc HACKSRC= ${DISTRIBDIR}/utils/libhack
CVS commit: src/sys/arch/evbmips/conf
Module Name:src Committed By: gutteridge Date: Fri Jun 9 21:33:16 UTC 2023 Modified Files: src/sys/arch/evbmips/conf: INSTALL_CI20 INSTALL_CPMBR1400 INSTALL_LOONGSON INSTALL_MALTA INSTALL_MALTA32 INSTALL_MALTA64 INSTALL_OCTEON INSTALL_OMSAL400 INSTALL_XLSATX32 INSTALL_XLSATX64 INSTALL_ZYXELKX Log Message: INSTALL_*: correct a path in a comment To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbmips/conf/INSTALL_CI20 \ src/sys/arch/evbmips/conf/INSTALL_LOONGSON \ src/sys/arch/evbmips/conf/INSTALL_ZYXELKX cvs rdiff -u -r1.2 -r1.3 src/sys/arch/evbmips/conf/INSTALL_CPMBR1400 \ src/sys/arch/evbmips/conf/INSTALL_MALTA \ src/sys/arch/evbmips/conf/INSTALL_MALTA64 \ src/sys/arch/evbmips/conf/INSTALL_OCTEON \ src/sys/arch/evbmips/conf/INSTALL_OMSAL400 cvs rdiff -u -r1.3 -r1.4 src/sys/arch/evbmips/conf/INSTALL_MALTA32 \ src/sys/arch/evbmips/conf/INSTALL_XLSATX32 \ src/sys/arch/evbmips/conf/INSTALL_XLSATX64 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/evbmips/conf/INSTALL_CI20 diff -u src/sys/arch/evbmips/conf/INSTALL_CI20:1.1 src/sys/arch/evbmips/conf/INSTALL_CI20:1.2 --- src/sys/arch/evbmips/conf/INSTALL_CI20:1.1 Mon Apr 6 14:18:09 2015 +++ src/sys/arch/evbmips/conf/INSTALL_CI20 Fri Jun 9 21:33:16 2023 @@ -1,12 +1,12 @@ -# $NetBSD: INSTALL_CI20,v 1.1 2015/04/06 14:18:09 joerg Exp $ +# $NetBSD: INSTALL_CI20,v 1.2 2023/06/09 21:33:16 gutteridge Exp $ include "arch/evbmips/conf/CI20" -#ident "INSTALL_CI20-$Revision: 1.1 $" +#ident "INSTALL_CI20-$Revision: 1.2 $" # Enable the hooks used for initializing the root memory-disk. # The ramdisk size must be kept in sync manually with the size of -# the `ramdisk' image (which is built in distrib/evbmips/ramdisk/ramdisk). +# the `ramdisk' image (which is built in distrib/evbmips/instkernel/ramdisk). pseudo-device md# memory disk device options MEMORY_DISK_HOOKS options MEMORY_DISK_IS_ROOT # force root on memory disk Index: src/sys/arch/evbmips/conf/INSTALL_LOONGSON diff -u src/sys/arch/evbmips/conf/INSTALL_LOONGSON:1.1 src/sys/arch/evbmips/conf/INSTALL_LOONGSON:1.2 --- src/sys/arch/evbmips/conf/INSTALL_LOONGSON:1.1 Mon Aug 29 18:32:18 2011 +++ src/sys/arch/evbmips/conf/INSTALL_LOONGSON Fri Jun 9 21:33:16 2023 @@ -1,12 +1,12 @@ -# $NetBSD: INSTALL_LOONGSON,v 1.1 2011/08/29 18:32:18 bouyer Exp $ +# $NetBSD: INSTALL_LOONGSON,v 1.2 2023/06/09 21:33:16 gutteridge Exp $ include "arch/evbmips/conf/LOONGSON" -#ident "INSTALL_LOONGSON-$Revision: 1.1 $" +#ident "INSTALL_LOONGSON-$Revision: 1.2 $" # Enable the hooks used for initializing the root memory-disk. # The ramdisk size must be kept in sync manually with the size of -# the `ramdisk' image (which is built in distrib/evbmips/ramdisk/ramdisk). +# the `ramdisk' image (which is built in distrib/evbmips/instkernel/ramdisk). pseudo-device md# memory disk device options MEMORY_DISK_HOOKS options MEMORY_DISK_IS_ROOT # force root on memory disk Index: src/sys/arch/evbmips/conf/INSTALL_ZYXELKX diff -u src/sys/arch/evbmips/conf/INSTALL_ZYXELKX:1.1 src/sys/arch/evbmips/conf/INSTALL_ZYXELKX:1.2 --- src/sys/arch/evbmips/conf/INSTALL_ZYXELKX:1.1 Wed Apr 30 01:01:04 2014 +++ src/sys/arch/evbmips/conf/INSTALL_ZYXELKX Fri Jun 9 21:33:16 2023 @@ -1,12 +1,12 @@ -# $NetBSD: INSTALL_ZYXELKX,v 1.1 2014/04/30 01:01:04 matt Exp $ +# $NetBSD: INSTALL_ZYXELKX,v 1.2 2023/06/09 21:33:16 gutteridge Exp $ include "arch/evbmips/conf/ZYXELKX" -#ident "INSTALL_ZYXELKX-$Revision: 1.1 $" +#ident "INSTALL_ZYXELKX-$Revision: 1.2 $" # Enable the hooks used for initializing the root memory-disk. # The ramdisk size must be kept in sync manually with the size of -# the `ramdisk' image (which is built in distrib/evbmips/ramdisk/ramdisk). +# the `ramdisk' image (which is built in distrib/evbmips/instkernel/ramdisk). pseudo-device md# memory disk device options MEMORY_DISK_HOOKS options MEMORY_DISK_IS_ROOT # force root on memory disk Index: src/sys/arch/evbmips/conf/INSTALL_CPMBR1400 diff -u src/sys/arch/evbmips/conf/INSTALL_CPMBR1400:1.2 src/sys/arch/evbmips/conf/INSTALL_CPMBR1400:1.3 --- src/sys/arch/evbmips/conf/INSTALL_CPMBR1400:1.2 Thu Jul 28 15:50:13 2011 +++ src/sys/arch/evbmips/conf/INSTALL_CPMBR1400 Fri Jun 9 21:33:16 2023 @@ -1,12 +1,12 @@ -# $NetBSD: INSTALL_CPMBR1400,v 1.2 2011/07/28 15:50:13 matt Exp $ +# $NetBSD: INSTALL_CPMBR1400,v 1.3 2023/06/09 21:33:16 gutteridge Exp $ include "arch/evbmips/conf/CPMBR1400" -#ident "INSTALL_MALTA-$Revision: 1.2 $" +#ident "INSTALL_MALTA-$Revision: 1.3 $" # Enable the hooks used for initializing the root memory-disk. # The ramdisk size must be kept in sync manually with the size of -# the `ramdisk' image (which is built in distrib/evbmips/ramdisk/ramd
CVS commit: src/sys/arch/evbmips/conf
Module Name:src Committed By: gutteridge Date: Fri Jun 9 21:33:16 UTC 2023 Modified Files: src/sys/arch/evbmips/conf: INSTALL_CI20 INSTALL_CPMBR1400 INSTALL_LOONGSON INSTALL_MALTA INSTALL_MALTA32 INSTALL_MALTA64 INSTALL_OCTEON INSTALL_OMSAL400 INSTALL_XLSATX32 INSTALL_XLSATX64 INSTALL_ZYXELKX Log Message: INSTALL_*: correct a path in a comment To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbmips/conf/INSTALL_CI20 \ src/sys/arch/evbmips/conf/INSTALL_LOONGSON \ src/sys/arch/evbmips/conf/INSTALL_ZYXELKX cvs rdiff -u -r1.2 -r1.3 src/sys/arch/evbmips/conf/INSTALL_CPMBR1400 \ src/sys/arch/evbmips/conf/INSTALL_MALTA \ src/sys/arch/evbmips/conf/INSTALL_MALTA64 \ src/sys/arch/evbmips/conf/INSTALL_OCTEON \ src/sys/arch/evbmips/conf/INSTALL_OMSAL400 cvs rdiff -u -r1.3 -r1.4 src/sys/arch/evbmips/conf/INSTALL_MALTA32 \ src/sys/arch/evbmips/conf/INSTALL_XLSATX32 \ src/sys/arch/evbmips/conf/INSTALL_XLSATX64 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/calendar/calendars
Module Name:src Committed By: hgutch Date: Fri Jun 9 20:27:29 UTC 2023 Modified Files: src/usr.bin/calendar/calendars: calendar.netbsd Log Message: Add riscv port Took the date of the first public announcement on port-riscv of something usable (qemu). To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/usr.bin/calendar/calendars/calendar.netbsd 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/calendar/calendars/calendar.netbsd diff -u src/usr.bin/calendar/calendars/calendar.netbsd:1.48 src/usr.bin/calendar/calendars/calendar.netbsd:1.49 --- src/usr.bin/calendar/calendars/calendar.netbsd:1.48 Sun Aug 7 19:37:15 2022 +++ src/usr.bin/calendar/calendars/calendar.netbsd Fri Jun 9 20:27:28 2023 @@ -45,6 +45,7 @@ 05/12 NetBSD 1.4 released, 1999 05/12 NetBSD/hp300 port started, 1993 05/12 NetBSD 9.2 released, 2021 +05/13 NetBSD/riscv port started, 2023 05/14 NetBSD/cesfic port started, 2001 05/15 NetBSD/macppc port started, 1998 05/20 NetBSD 1.2.1 released, 1997
CVS commit: src/usr.bin/calendar/calendars
Module Name:src Committed By: hgutch Date: Fri Jun 9 20:27:29 UTC 2023 Modified Files: src/usr.bin/calendar/calendars: calendar.netbsd Log Message: Add riscv port Took the date of the first public announcement on port-riscv of something usable (qemu). To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/usr.bin/calendar/calendars/calendar.netbsd 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: Fri Jun 9 19:50:51 UTC 2023 Modified Files: src/usr.bin/indent: lexi.c Log Message: indent: clean up lexer No functional change. To generate a diff of this commit: cvs rdiff -u -r1.219 -r1.220 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/lexi.c diff -u src/usr.bin/indent/lexi.c:1.219 src/usr.bin/indent/lexi.c:1.220 --- src/usr.bin/indent/lexi.c:1.219 Fri Jun 9 09:49:07 2023 +++ src/usr.bin/indent/lexi.c Fri Jun 9 19:50:51 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lexi.c,v 1.219 2023/06/09 09:49:07 rillig Exp $ */ +/* $NetBSD: lexi.c,v 1.220 2023/06/09 19:50:51 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: lexi.c,v 1.219 2023/06/09 09:49:07 rillig Exp $"); +__RCSID("$NetBSD: lexi.c,v 1.220 2023/06/09 19:50:51 rillig Exp $"); #include #include @@ -260,16 +260,16 @@ probably_typename(void) return false; if (ps.in_stmt_or_decl) /* XXX: this condition looks incorrect */ return false; - if (inp_p[0] == '*' && inp_p[1] != '=') - goto maybe; - /* XXX: is_identifier_start */ - if (ch_isalpha(inp_p[0])) - goto maybe; + if (ps.prev_lsym == lsym_semicolon + || ps.prev_lsym == lsym_lbrace + || ps.prev_lsym == lsym_rbrace) { + if (inp_p[0] == '*' && inp_p[1] != '=') + return true; + /* XXX: is_identifier_start */ + if (ch_isalpha(inp_p[0])) + return true; + } return false; -maybe: - return ps.prev_lsym == lsym_semicolon || - ps.prev_lsym == lsym_lbrace || - ps.prev_lsym == lsym_rbrace; } static int @@ -558,26 +558,9 @@ lexi(void) switch (token.s[token.len - 1]) { - /* INDENT OFF */ - case '(': lsym = lsym_lparen; next_unary = true; break; - case '[': lsym = lsym_lbracket; next_unary = true; break; - case ')': lsym = lsym_rparen; next_unary = false; break; - case ']': lsym = lsym_rbracket; next_unary = false; break; - case '?': lsym = lsym_question; next_unary = true; break; - case ';': lsym = lsym_semicolon; next_unary = true; break; - case '{': lsym = lsym_lbrace; next_unary = true; break; - case '}': lsym = lsym_rbrace; next_unary = true; break; - case ',': lsym = lsym_comma; next_unary = true; break; - case '.': lsym = lsym_period; next_unary = false; break; - /* INDENT ON */ - - case ':': - lsym = ps.quest_level > 0 - ? (ps.quest_level--, lsym_colon_question) - : ps.init_or_struct - ? lsym_colon_other - : lsym_colon_label; - next_unary = true; + case '#': + lsym = lsym_preprocessing; + next_unary = ps.next_unary; break; case '\n': @@ -587,17 +570,18 @@ lexi(void) ps.next_col_1 = true; break; - case '#': - lsym = lsym_preprocessing; - next_unary = ps.next_unary; - break; - - case '\'': - case '"': - lex_char_or_string(); - lsym = lsym_word; - next_unary = false; - break; + /* INDENT OFF */ + case '(': lsym = lsym_lparen; next_unary = true; break; + case ')': lsym = lsym_rparen; next_unary = false; break; + case '[': lsym = lsym_lbracket; next_unary = true; break; + case ']': lsym = lsym_rbracket; next_unary = false; break; + case '{': lsym = lsym_lbrace; next_unary = true; break; + case '}': lsym = lsym_rbrace; next_unary = true; break; + case '.': lsym = lsym_period; next_unary = false; break; + case '?': lsym = lsym_question; next_unary = true; break; + case ',': lsym = lsym_comma; next_unary = true; break; + case ';': lsym = lsym_semicolon; next_unary = true; break; + /* INDENT ON */ case '-': case '+': @@ -626,6 +610,27 @@ lexi(void) } break; + case ':': + lsym = ps.quest_level > 0 + ? (ps.quest_level--, lsym_colon_question) + : ps.init_or_struct + ? lsym_colon_other + : lsym_colon_label; + next_unary = true; + break; + + case '*': + if (inp_p[0] == '=') { + token_add_char(*inp_p++); + lsym = lsym_binary_op; + } else if (is_asterisk_unary()) { + lex_asterisk_unary(); + lsym = lsym_unary_op; + } else + lsym = lsym_binary_op; + next_unary = true; + break; + case '=': if (ps.init_or_struct) ps.block_init = true; @@ -646,16 +651,11 @@ lexi(void) next_unary = true; break; - case '*': - if (inp_p[0] == '=') { - token_add_char(*inp_p++); - lsym = lsym_binary_op; - } else if (is_asterisk_unary()) { - lex_asterisk_unary(); - lsym = lsym_unary_op; - } else - lsym = lsym_binary_op; - next_unary = true; + case '\'': + case '"': + lex_char_or_string(); + lsym = lsym_word; + next_unary = false; break; default:
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Fri Jun 9 19:50:51 UTC 2023 Modified Files: src/usr.bin/indent: lexi.c Log Message: indent: clean up lexer No functional change. To generate a diff of this commit: cvs rdiff -u -r1.219 -r1.220 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.
CVS commit: src/usr.sbin/sysinst
Module Name:src Committed By: martin Date: Fri Jun 9 18:44:17 UTC 2023 Modified Files: src/usr.sbin/sysinst: main.c Log Message: If the install medium does not come with any openssl trusted root certs, tell ftp(1) not to verify trust chains when doing https downloads. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/usr.sbin/sysinst/main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.sbin/sysinst
Module Name:src Committed By: martin Date: Fri Jun 9 18:44:17 UTC 2023 Modified Files: src/usr.sbin/sysinst: main.c Log Message: If the install medium does not come with any openssl trusted root certs, tell ftp(1) not to verify trust chains when doing https downloads. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/usr.sbin/sysinst/main.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.sbin/sysinst/main.c diff -u src/usr.sbin/sysinst/main.c:1.30 src/usr.sbin/sysinst/main.c:1.31 --- src/usr.sbin/sysinst/main.c:1.30 Sun Jul 10 10:52:40 2022 +++ src/usr.sbin/sysinst/main.c Fri Jun 9 18:44:16 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.30 2022/07/10 10:52:40 martin Exp $ */ +/* $NetBSD: main.c,v 1.31 2023/06/09 18:44:16 martin Exp $ */ /* * Copyright 1997 Piermont Information Systems Inc. @@ -97,6 +97,7 @@ __dead static void miscsighandler(int); static void ttysighandler(int); static void cleanup(void); static void process_f_flag(char *); +static bool no_openssl_trust_anchors_available(void); static int exit_cleanly = 0; /* Did we finish nicely? */ FILE *logfp; /* log file */ @@ -264,6 +265,10 @@ main(int argc, char **argv) /* Initialize the partitioning subsystem */ partitions_init(); + /* do we need to tell ftp(1) to avoid checking certificate chains? */ + if (no_openssl_trust_anchors_available()) + setenv("FTPSSLNOVERIFY", "1", 1); + /* initialize message window */ if (menu_init()) { __menu_initerror(); @@ -635,3 +640,46 @@ process_f_flag(char *f_name) fclose(fp); } + +/* + * return true if we do not have any root certificates installed, + * so can not verify any trust chain. + * We rely on /etc/openssl being the OPENSSLDIR and test the + * "all in one" /etc/openssl/cert.pem first, if that is not found + * check if there are multiple regular files or symlinks in + * /etc/openssl/certs/. + */ +static bool +no_openssl_trust_anchors_available(void) +{ + struct stat sb; + DIR *dir; + struct dirent *ent; + size_t cnt; + + /* check the omnibus single file variant first */ + if (stat("/etc/openssl/cert.pem", &sb) == 0 && + S_ISREG(sb.st_mode) && sb.st_size > 0) + return false; /* exists and is a non-empty file */ + + /* look for files/symlinks in the certs subdirectory */ + dir = opendir("/etc/openssl/certs"); + if (dir == NULL) + return true; + for (cnt = 0; cnt < 2; ) { + ent = readdir(dir); + if (ent == NULL) + break; + switch (ent->d_type) { + case DT_REG: + case DT_LNK: + cnt++; + break; + default: + break; + } + } + closedir(dir); + + return cnt < 2; +}
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Fri Jun 9 18:09:30 UTC 2023 Modified Files: src/usr.bin/indent: debug.c Log Message: indent: sync debug information for lexer symbols To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/usr.bin/indent/debug.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.42 src/usr.bin/indent/debug.c:1.43 --- src/usr.bin/indent/debug.c:1.42 Fri Jun 9 10:24:55 2023 +++ src/usr.bin/indent/debug.c Fri Jun 9 18:09:30 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.42 2023/06/09 10:24:55 rillig Exp $ */ +/* $NetBSD: debug.c,v 1.43 2023/06/09 18:09:30 rillig Exp $ */ /*- * Copyright (c) 2023 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: debug.c,v 1.42 2023/06/09 10:24:55 rillig Exp $"); +__RCSID("$NetBSD: debug.c,v 1.43 2023/06/09 18:09:30 rillig Exp $"); #include @@ -50,32 +50,32 @@ const char *const lsym_name[] = { "newline", "comment", "lparen", - "lbracket", "rparen", + "lbracket", "rbracket", "lbrace", "rbrace", "period", "unary_op", - "binary_op", + "sizeof", + "offsetof", "postfix_op", + "binary_op", "question", "'?:' colon", - "label colon", - "other colon", "comma", - "semicolon", "typedef", "modifier", + "tag", "type_outside_parentheses", "type_in_parentheses", - "tag", - "case", - "default", - "sizeof", - "offsetof", "word", "funcname", + "label colon", + "other colon", + "semicolon", + "case", + "default", "do", "else", "for",
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Fri Jun 9 18:09:30 UTC 2023 Modified Files: src/usr.bin/indent: debug.c Log Message: indent: sync debug information for lexer symbols To generate a diff of this commit: cvs rdiff -u -r1.42 -r1.43 src/usr.bin/indent/debug.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: Fri Jun 9 16:23:43 UTC 2023 Modified Files: src/usr.bin/indent: indent.c indent.h Log Message: indent: group lexer symbols by topic, sort processing functions No functional change. To generate a diff of this commit: cvs rdiff -u -r1.346 -r1.347 src/usr.bin/indent/indent.c cvs rdiff -u -r1.181 -r1.182 src/usr.bin/indent/indent.h 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.346 src/usr.bin/indent/indent.c:1.347 --- src/usr.bin/indent/indent.c:1.346 Fri Jun 9 11:22:31 2023 +++ src/usr.bin/indent/indent.c Fri Jun 9 16:23:43 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.346 2023/06/09 11:22:31 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.347 2023/06/09 16:23:43 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: indent.c,v 1.346 2023/06/09 11:22:31 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.347 2023/06/09 16:23:43 rillig Exp $"); #include #include @@ -185,6 +185,23 @@ init_globals(void) backup_suffix = suffix; } +static void +load_profiles(int argc, char **argv) +{ + const char *profile_name = NULL; + + for (int i = 1; i < argc; ++i) { + const char *arg = argv[i]; + + if (strcmp(arg, "-npro") == 0) + return; + if (arg[0] == '-' && arg[1] == 'P' && arg[2] != '\0') + profile_name = arg + 2; + } + + load_profile_files(profile_name); +} + /* * Copy the input file to the backup file, then make the backup file the input * and the original input file the output. @@ -227,23 +244,6 @@ bakcopy(void) } static void -load_profiles(int argc, char **argv) -{ - const char *profile_name = NULL; - - for (int i = 1; i < argc; ++i) { - const char *arg = argv[i]; - - if (strcmp(arg, "-npro") == 0) - return; - if (arg[0] == '-' && arg[1] == 'P' && arg[2] != '\0') - profile_name = arg + 2; - } - - load_profile_files(profile_name); -} - -static void parse_command_line(int argc, char **argv) { for (int i = 1; i < argc; ++i) { @@ -308,6 +308,44 @@ set_initial_indentation(void) } static void +maybe_break_line(lexer_symbol lsym) +{ + if (!ps.force_nl) + return; + if (lsym == lsym_semicolon) + return; + if (lsym == lsym_lbrace && opt.brace_same_line + && ps.prev_lsym != lsym_lbrace) + return; + + output_line(); + ps.force_nl = false; +} + +static void +move_com_to_code(lexer_symbol lsym) +{ + if (ps.want_blank) + buf_add_char(&code, ' '); + buf_add_buf(&code, &com); + com.len = 0; + ps.want_blank = lsym != lsym_rparen && lsym != lsym_rbracket; +} + +static void +update_ps_lbrace_kind(lexer_symbol lsym) +{ + if (lsym == lsym_tag) { + ps.lbrace_kind = token.s[0] == 's' ? psym_lbrace_struct : + token.s[0] == 'u' ? psym_lbrace_union : + psym_lbrace_enum; + } else if (lsym != lsym_type_outside_parentheses + && lsym != lsym_word + && lsym != lsym_lbrace) + ps.lbrace_kind = psym_lbrace_block; +} + +static void indent_declarator(int decl_ind, bool tabs_to_var) { int base = ps.ind_level * opt.indent_size; @@ -329,17 +367,14 @@ indent_declarator(int decl_ind, bool tab ps.decl_indent_done = true; } -static void -update_ps_lbrace_kind(lexer_symbol lsym) +static bool +is_function_pointer_declaration(void) { - if (lsym == lsym_tag) { - ps.lbrace_kind = token.s[0] == 's' ? psym_lbrace_struct : - token.s[0] == 'u' ? psym_lbrace_union : - psym_lbrace_enum; - } else if (lsym != lsym_type_outside_parentheses - && lsym != lsym_word - && lsym != lsym_lbrace) - ps.lbrace_kind = psym_lbrace_block; + return ps.in_decl + && !ps.block_init + && !ps.decl_indent_done + && !ps.is_function_definition + && ps.line_start_nparen == 0; } static int @@ -359,29 +394,90 @@ process_eof(void) return found_err ? EXIT_FAILURE : EXIT_SUCCESS; } +/* move the whole line to the 'label' buffer */ static void -maybe_break_line(lexer_symbol lsym) +read_preprocessing_line(void) { - if (!ps.force_nl) - return; - if (lsym == lsym_semicolon) - return; - if (lsym == lsym_lbrace && opt.brace_same_line - && ps.prev_lsym != lsym_lbrace) - return; + enum { + PLAIN, STR, CHR, COMM + } state = PLAIN; - output_line(); - ps.force_nl = false; + buf_add_char(&lab, '#'); + + while (inp_p[0] != '\n' || (state == COMM && !had_eof)) { + buf_add_char(&lab, inp_next()); + switch (lab.s[lab.len - 1]) { + case '\\': + if (state != COMM) +buf_add_char(&lab, inp_next()); + break; + case '/': + if (inp_p[0] == '*' && state == PLAIN) { +state = COMM; +buf_add_char(&lab, *inp_p++); + } + break; + case '"': + if (state == STR) +state = PLAIN; + else if (state == PLAIN) +state = STR; + break; + case '\'': + if (state == CHR) +state = PLAIN; + else if (state == PLAIN) +state = CHR; + break; + case '*': + if (inp_p[0] == '/' &
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Fri Jun 9 16:23:43 UTC 2023 Modified Files: src/usr.bin/indent: indent.c indent.h Log Message: indent: group lexer symbols by topic, sort processing functions No functional change. To generate a diff of this commit: cvs rdiff -u -r1.346 -r1.347 src/usr.bin/indent/indent.c cvs rdiff -u -r1.181 -r1.182 src/usr.bin/indent/indent.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xlint
Module Name:src Committed By: rillig Date: Fri Jun 9 15:36:31 UTC 2023 Modified Files: src/usr.bin/xlint/common: param.h src/usr.bin/xlint/lint1: decl.c emit1.c err.c func.c lex.c lint1.h tree.c Log Message: lint: miscellaneous clean-ups No binary change, except for line numbers in assertions. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/usr.bin/xlint/common/param.h cvs rdiff -u -r1.316 -r1.317 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.67 -r1.68 src/usr.bin/xlint/lint1/emit1.c cvs rdiff -u -r1.198 -r1.199 src/usr.bin/xlint/lint1/err.c cvs rdiff -u -r1.155 -r1.156 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.159 -r1.160 src/usr.bin/xlint/lint1/lex.c cvs rdiff -u -r1.164 -r1.165 src/usr.bin/xlint/lint1/lint1.h cvs rdiff -u -r1.526 -r1.527 src/usr.bin/xlint/lint1/tree.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/xlint
Module Name:src Committed By: rillig Date: Fri Jun 9 15:36:31 UTC 2023 Modified Files: src/usr.bin/xlint/common: param.h src/usr.bin/xlint/lint1: decl.c emit1.c err.c func.c lex.c lint1.h tree.c Log Message: lint: miscellaneous clean-ups No binary change, except for line numbers in assertions. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/usr.bin/xlint/common/param.h cvs rdiff -u -r1.316 -r1.317 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.67 -r1.68 src/usr.bin/xlint/lint1/emit1.c cvs rdiff -u -r1.198 -r1.199 src/usr.bin/xlint/lint1/err.c cvs rdiff -u -r1.155 -r1.156 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.159 -r1.160 src/usr.bin/xlint/lint1/lex.c cvs rdiff -u -r1.164 -r1.165 src/usr.bin/xlint/lint1/lint1.h cvs rdiff -u -r1.526 -r1.527 src/usr.bin/xlint/lint1/tree.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/xlint/common/param.h diff -u src/usr.bin/xlint/common/param.h:1.10 src/usr.bin/xlint/common/param.h:1.11 --- src/usr.bin/xlint/common/param.h:1.10 Sat Jan 14 09:21:58 2023 +++ src/usr.bin/xlint/common/param.h Fri Jun 9 15:36:31 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.10 2023/01/14 09:21:58 rillig Exp $ */ +/* $NetBSD: param.h,v 1.11 2023/06/09 15:36:31 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -53,12 +53,3 @@ * Make sure this matches wchar_t. */ #define WCHAR INT - -/* - * The sparc64 long double code generation is broken in old gcc. - */ -#if !(defined(__sparc64__) && defined(__GNUC__) && __GNUC__ <= 2) -typedef long double ldbl_t; -#else -typedef double ldbl_t; -#endif Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.316 src/usr.bin/xlint/lint1/decl.c:1.317 --- src/usr.bin/xlint/lint1/decl.c:1.316 Fri Jun 9 13:03:49 2023 +++ src/usr.bin/xlint/lint1/decl.c Fri Jun 9 15:36:31 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.316 2023/06/09 13:03:49 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.317 2023/06/09 15:36:31 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: decl.c,v 1.316 2023/06/09 13:03:49 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.317 2023/06/09 15:36:31 rillig Exp $"); #endif #include @@ -1601,7 +1601,7 @@ declarator_name(sym_t *sym) case DK_AUTO: if ((sc = dcs->d_scl) == NOSCL) { /* - * XXX somewhat ugly because we dont know whether + * XXX somewhat ugly because we don't know whether * this is AUTO or EXTERN (functions). If we are * wrong it must be corrected in declare_local(), * where we have the necessary type information. @@ -1893,7 +1893,7 @@ enumeration_constant(sym_t *sym, int val /* redeclaration of '%s' */ error(27, sym->s_name); /* - * inside blocks it should not be too + * Inside blocks, it should not be too * complicated to find the position of the * previous declaration */ @@ -2845,7 +2845,7 @@ declare_external_in_block(sym_t *dsym) if (compatible) { /* - * Remember the external symbol so we can update usage + * Remember the external symbol, so we can update usage * information at the end of the block. */ dsym->s_ext_sym = esym; Index: src/usr.bin/xlint/lint1/emit1.c diff -u src/usr.bin/xlint/lint1/emit1.c:1.67 src/usr.bin/xlint/lint1/emit1.c:1.68 --- src/usr.bin/xlint/lint1/emit1.c:1.67 Fri Jun 9 13:03:49 2023 +++ src/usr.bin/xlint/lint1/emit1.c Fri Jun 9 15:36:31 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: emit1.c,v 1.67 2023/06/09 13:03:49 rillig Exp $ */ +/* $NetBSD: emit1.c,v 1.68 2023/06/09 15:36:31 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: emit1.c,v 1.67 2023/06/09 13:03:49 rillig Exp $"); +__RCSID("$NetBSD: emit1.c,v 1.68 2023/06/09 15:36:31 rillig Exp $"); #endif #include "lint1.h" @@ -193,12 +193,8 @@ outsym(const sym_t *sym, scl_t sc, def_t /* reset buffer */ outclr(); - /* - * line number of .c source, 'd' for declaration, Id of current - * source (.c or .h), and line in current source. - */ outint(csrc_pos.p_line); - outchar('d'); + outchar('d'); /* declaration */ outint(get_filename_id(sym->s_def_pos.p_file)); outchar('.'); outint(sym->s_def_pos.p_line); @@ -239,10 +235,8 @@ outsym(const sym_t *sym, scl_t sc, def_t } /* - * write information about function definition - * - * this is also done for static functions so we are able to check if - * they are called with proper argument types + * Write information about a function definition. This is also done for static + * functions, to later check if they are called with proper argument types. */ void outfdef(const sym_t *fsym, const pos_t *posp, bool rval, bool osdef, @@ -254,20 +248,12 @@ outfdef(const sym_t *fsym, con
CVS commit: src/usr.bin/xlint/xlint
Module Name:src Committed By: rillig Date: Fri Jun 9 13:31:11 UTC 2023 Modified Files: src/usr.bin/xlint/xlint: xlint.c Log Message: lint: sort functions in calling order No functional change. To generate a diff of this commit: cvs rdiff -u -r1.110 -r1.111 src/usr.bin/xlint/xlint/xlint.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/xlint/xlint/xlint.c diff -u src/usr.bin/xlint/xlint/xlint.c:1.110 src/usr.bin/xlint/xlint/xlint.c:1.111 --- src/usr.bin/xlint/xlint/xlint.c:1.110 Fri Jun 9 13:03:49 2023 +++ src/usr.bin/xlint/xlint/xlint.c Fri Jun 9 13:31:11 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: xlint.c,v 1.110 2023/06/09 13:03:49 rillig Exp $ */ +/* $NetBSD: xlint.c,v 1.111 2023/06/09 13:31:11 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: xlint.c,v 1.110 2023/06/09 13:03:49 rillig Exp $"); +__RCSID("$NetBSD: xlint.c,v 1.111 2023/06/09 13:31:11 rillig Exp $"); #endif #include @@ -127,11 +127,6 @@ static const char *currfn; #endif static const char target_prefix[] = TARGET_PREFIX; -static void handle_filename(const char *); -static void run_child(const char *, list *, const char *, int); -static void find_libs(const list *); -static bool file_is_readable(const char *); -static void cat(const list *, const char *); static void list_add_ref(list *l, char *s) @@ -197,6 +192,17 @@ concat2(const char *s1, const char *s2) return s; } +static void +set_tmpdir(void) +{ + const char *tmp; + size_t len; + + tmpdir = (tmp = getenv("TMPDIR")) != NULL && (len = strlen(tmp)) != 0 + ? concat2(tmp, tmp[len - 1] == '/' ? "" : "/") + : xstrdup(_PATH_TMP); +} + /* Clean up after a signal or at the regular end. */ static void __attribute__((__noreturn__)) terminate(int signo) @@ -226,32 +232,6 @@ terminate(int signo) exit(signo != 0 ? 1 : 0); } -/* - * Returns a pointer to the last component of path after delim. - * Returns path if the string does not contain delim. - */ -static const char * -lbasename(const char *path, int delim) -{ - - const char *base = path; - for (const char *p = path; *p != '\0'; p++) - if (*p == delim) - base = p + 1; - return base; -} - -static void -set_tmpdir(void) -{ - const char *tmp; - size_t len; - - tmpdir = (tmp = getenv("TMPDIR")) != NULL && (len = strlen(tmp)) != 0 - ? concat2(tmp, tmp[len - 1] == '/' ? "" : "/") - : xstrdup(_PATH_TMP); -} - static void __attribute__((__noreturn__, __format__(__printf__, 1, 2))) usage(const char *fmt, ...) { @@ -282,6 +262,113 @@ usage(const char *fmt, ...) terminate(-1); } +/* + * Returns a pointer to the last component of path after delim. + * Returns path if the string does not contain delim. + */ +static const char * +lbasename(const char *path, int delim) +{ + + const char *base = path; + for (const char *p = path; *p != '\0'; p++) + if (*p == delim) + base = p + 1; + return base; +} + +static bool +is_safe_shell(char ch) +{ + + return ch_isalnum(ch) || ch == '%' || ch == '+' || ch == ',' || + ch == '-' || ch == '.' || ch == '/' || ch == ':' || + ch == '=' || ch == '@' || ch == '_'; +} + +static void +print_sh_quoted(const char *s) +{ + + if (s[0] == '\0') + goto needs_quoting; + for (const char *p = s; *p != '\0'; p++) + if (!is_safe_shell(*p)) + goto needs_quoting; + + (void)printf("%s", s); + return; + +needs_quoting: + (void)putchar('\''); + for (const char *p = s; *p != '\0'; p++) { + if (*p == '\'') + (void)printf("'\\''"); + else + (void)putchar(*p); + } + (void)putchar('\''); +} + +static void +run_child(const char *path, list *args, const char *crfn, int fdout) +{ + int status, rv, signo; + + if (Vflag) { + print_sh_quoted(args->items[0]); + for (size_t i = 1; i < args->len - 1; i++) { + (void)printf(" "); + print_sh_quoted(args->items[i]); + } + (void)printf("\n"); + } + + currfn = crfn; + + (void)fflush(stdout); + + switch (vfork()) { + case -1: + warn("cannot fork"); + terminate(-1); + /* NOTREACHED */ + default: + /* parent */ + break; + case 0: + /* child */ + + /* set up the standard output if necessary */ + if (fdout != -1) { + (void)dup2(fdout, STDOUT_FILENO); + (void)close(fdout); + } + (void)execvp(path, args->items); + warn("cannot exec %s", path); + _exit(1); + /* NOTREACHED */ + } + + while ((rv = wait(&status)) == -1 && errno == EINTR) ; + if (rv == -1) { + warn("wait"); + terminate(-1); + } + if (WIFSIGNALED(status)) { + signo = WTERMSIG(status); +#if HAVE_DECL_SYS_SIGNAME + warnx("%s got SIG%s", path, sys_signame[signo]); +#else + warnx("%s got signal %d", path, signo); +#endif + terminate(-1); + } + if (WEXITSTATUS(status) != 0) + terminate(-1); + currfn = NULL; +} + static void run_cpp(const char *name) { @@ -338,6 +425,112 @@ run_lint1(const char *out_fname) list_clear(&a
CVS commit: src/usr.bin/xlint/xlint
Module Name:src Committed By: rillig Date: Fri Jun 9 13:31:11 UTC 2023 Modified Files: src/usr.bin/xlint/xlint: xlint.c Log Message: lint: sort functions in calling order No functional change. To generate a diff of this commit: cvs rdiff -u -r1.110 -r1.111 src/usr.bin/xlint/xlint/xlint.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/xlint
Module Name:src Committed By: rillig Date: Fri Jun 9 13:03:49 UTC 2023 Modified Files: src/usr.bin/xlint/common: emit.c inittyp.c src/usr.bin/xlint/lint1: decl.c emit1.c err.c func.c lex.c tree.c src/usr.bin/xlint/lint2: chk.c emit2.c hash.c main2.c msg.c read.c src/usr.bin/xlint/xlint: xlint.c Log Message: lint: indent local variables consistently No binary change. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/usr.bin/xlint/common/emit.c cvs rdiff -u -r1.34 -r1.35 src/usr.bin/xlint/common/inittyp.c cvs rdiff -u -r1.315 -r1.316 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.66 -r1.67 src/usr.bin/xlint/lint1/emit1.c cvs rdiff -u -r1.197 -r1.198 src/usr.bin/xlint/lint1/err.c cvs rdiff -u -r1.154 -r1.155 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.158 -r1.159 src/usr.bin/xlint/lint1/lex.c cvs rdiff -u -r1.525 -r1.526 src/usr.bin/xlint/lint1/tree.c cvs rdiff -u -r1.54 -r1.55 src/usr.bin/xlint/lint2/chk.c cvs rdiff -u -r1.30 -r1.31 src/usr.bin/xlint/lint2/emit2.c cvs rdiff -u -r1.24 -r1.25 src/usr.bin/xlint/lint2/hash.c cvs rdiff -u -r1.28 -r1.29 src/usr.bin/xlint/lint2/main2.c cvs rdiff -u -r1.19 -r1.20 src/usr.bin/xlint/lint2/msg.c cvs rdiff -u -r1.80 -r1.81 src/usr.bin/xlint/lint2/read.c cvs rdiff -u -r1.109 -r1.110 src/usr.bin/xlint/xlint/xlint.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/xlint/common/emit.c diff -u src/usr.bin/xlint/common/emit.c:1.18 src/usr.bin/xlint/common/emit.c:1.19 --- src/usr.bin/xlint/common/emit.c:1.18 Sat Jan 14 09:30:07 2023 +++ src/usr.bin/xlint/common/emit.c Fri Jun 9 13:03:49 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: emit.c,v 1.18 2023/01/14 09:30:07 rillig Exp $ */ +/* $NetBSD: emit.c,v 1.19 2023/06/09 13:03:49 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: emit.c,v 1.18 2023/01/14 09:30:07 rillig Exp $"); +__RCSID("$NetBSD: emit.c,v 1.19 2023/06/09 13:03:49 rillig Exp $"); #endif #include @@ -106,7 +106,7 @@ outxbuf(void) void outclr(void) { - size_t sz; + size_t sz; if (ob.o_buf != ob.o_next) { outchar('\n'); Index: src/usr.bin/xlint/common/inittyp.c diff -u src/usr.bin/xlint/common/inittyp.c:1.34 src/usr.bin/xlint/common/inittyp.c:1.35 --- src/usr.bin/xlint/common/inittyp.c:1.34 Mon May 22 12:55:04 2023 +++ src/usr.bin/xlint/common/inittyp.c Fri Jun 9 13:03:49 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: inittyp.c,v 1.34 2023/05/22 12:55:04 rillig Exp $ */ +/* $NetBSD: inittyp.c,v 1.35 2023/06/09 13:03:49 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: inittyp.c,v 1.34 2023/05/22 12:55:04 rillig Exp $"); +__RCSID("$NetBSD: inittyp.c,v 1.35 2023/06/09 13:03:49 rillig Exp $"); #endif #if defined(IS_LINT1) @@ -128,7 +128,7 @@ ttab_t ttab[NTSPEC] = { void inittyp(void) { - size_t i; + size_t i; if (!pflag) { for (i = 0; i < NTSPEC; i++) Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.315 src/usr.bin/xlint/lint1/decl.c:1.316 --- src/usr.bin/xlint/lint1/decl.c:1.315 Sat Jun 3 21:08:06 2023 +++ src/usr.bin/xlint/lint1/decl.c Fri Jun 9 13:03:49 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.315 2023/06/03 21:08:06 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.316 2023/06/09 13:03:49 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: decl.c,v 1.315 2023/06/03 21:08:06 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.316 2023/06/09 13:03:49 rillig Exp $"); #endif #include @@ -152,7 +152,7 @@ gettyp(tspec_t t) type_t * block_dup_type(const type_t *tp) { - type_t *ntp; + type_t *ntp; ntp = block_zero_alloc(sizeof(*ntp)); *ntp = *tp; @@ -163,7 +163,7 @@ block_dup_type(const type_t *tp) type_t * expr_dup_type(const type_t *tp) { - type_t *ntp; + type_t *ntp; ntp = expr_zero_alloc(sizeof(*ntp)); *ntp = *tp; @@ -204,7 +204,7 @@ expr_unqualified_type(const type_t *tp) bool is_incomplete(const type_t *tp) { - tspec_t t; + tspec_t t; if ((t = tp->t_tspec) == VOID) return true; @@ -259,7 +259,7 @@ dcs_add_storage_class(scl_t sc) void dcs_add_type(type_t *tp) { - tspec_t t; + tspec_t t; debug_step("%s: %s", __func__, type_name(tp)); if (tp->t_typedef) { @@ -397,7 +397,7 @@ merge_signedness(tspec_t t, tspec_t s) static type_t * typedef_error(type_t *td, tspec_t t) { - tspec_t t2; + tspec_t t2; t2 = td->t_tspec; @@ -464,7 +464,7 @@ invalid: static void set_first_typedef(type_t *tp, sym_t *sym) { - tspec_t t; + tspec_t t; if (is_struct_or_union(t = tp->t_tspec)) { if (tp->t_sou->sou_first_typedef == NULL) @@ -572,7 +572,7 @@ dcs_add_qualifier(tqual_t q) void begin_declaration_level(declaration_kind dk) { - dinfo_t *di; + dinfo_t *di
CVS commit: src/usr.bin/xlint
Module Name:src Committed By: rillig Date: Fri Jun 9 13:03:49 UTC 2023 Modified Files: src/usr.bin/xlint/common: emit.c inittyp.c src/usr.bin/xlint/lint1: decl.c emit1.c err.c func.c lex.c tree.c src/usr.bin/xlint/lint2: chk.c emit2.c hash.c main2.c msg.c read.c src/usr.bin/xlint/xlint: xlint.c Log Message: lint: indent local variables consistently No binary change. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/usr.bin/xlint/common/emit.c cvs rdiff -u -r1.34 -r1.35 src/usr.bin/xlint/common/inittyp.c cvs rdiff -u -r1.315 -r1.316 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.66 -r1.67 src/usr.bin/xlint/lint1/emit1.c cvs rdiff -u -r1.197 -r1.198 src/usr.bin/xlint/lint1/err.c cvs rdiff -u -r1.154 -r1.155 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.158 -r1.159 src/usr.bin/xlint/lint1/lex.c cvs rdiff -u -r1.525 -r1.526 src/usr.bin/xlint/lint1/tree.c cvs rdiff -u -r1.54 -r1.55 src/usr.bin/xlint/lint2/chk.c cvs rdiff -u -r1.30 -r1.31 src/usr.bin/xlint/lint2/emit2.c cvs rdiff -u -r1.24 -r1.25 src/usr.bin/xlint/lint2/hash.c cvs rdiff -u -r1.28 -r1.29 src/usr.bin/xlint/lint2/main2.c cvs rdiff -u -r1.19 -r1.20 src/usr.bin/xlint/lint2/msg.c cvs rdiff -u -r1.80 -r1.81 src/usr.bin/xlint/lint2/read.c cvs rdiff -u -r1.109 -r1.110 src/usr.bin/xlint/xlint/xlint.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: Fri Jun 9 11:22:31 UTC 2023 Modified Files: src/tests/usr.bin/indent: fmt_expr.c t_errors.sh src/usr.bin/indent: indent.c Log Message: indent: support C99 compound literals To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/fmt_expr.c cvs rdiff -u -r1.33 -r1.34 src/tests/usr.bin/indent/t_errors.sh cvs rdiff -u -r1.345 -r1.346 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/fmt_expr.c diff -u src/tests/usr.bin/indent/fmt_expr.c:1.5 src/tests/usr.bin/indent/fmt_expr.c:1.6 --- src/tests/usr.bin/indent/fmt_expr.c:1.5 Fri Jun 9 09:45:55 2023 +++ src/tests/usr.bin/indent/fmt_expr.c Fri Jun 9 11:22:31 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: fmt_expr.c,v 1.5 2023/06/09 09:45:55 rillig Exp $ */ +/* $NetBSD: fmt_expr.c,v 1.6 2023/06/09 11:22:31 rillig Exp $ */ /* * Tests for all kinds of expressions that are not directly related to unary @@ -9,24 +9,24 @@ * lsym_unary_op.c */ -/* See lsym_offsetof.c. */ //indent input -void t(void) { -int n = malloc(offsetof(struct s, f) + 1); -} -//indent end - -//indent run -void -t(void) { - int n = malloc(offsetof(struct s, f) + 1); -} -//indent end + // See lsym_offsetof.c. + malloc(offsetof(struct s, f) + 1); + // C99 compound literals use initializer braces. + println((const char[3]){'-', c, '\0'}); + x = ((struct point){0, 0}).x; + + // XXX: GCC statement expressions are not supported yet. + int var = + ( + { + 1 + } + ) + ; -//indent input -{ for (ln = gnodes->first; ln != NULL; ln = ln->next) // $ FIXME: No space after the cast. *(GNode **) Vector_Push(&vec) = ln->datum; Index: src/tests/usr.bin/indent/t_errors.sh diff -u src/tests/usr.bin/indent/t_errors.sh:1.33 src/tests/usr.bin/indent/t_errors.sh:1.34 --- src/tests/usr.bin/indent/t_errors.sh:1.33 Mon Jun 5 08:22:00 2023 +++ src/tests/usr.bin/indent/t_errors.sh Fri Jun 9 11:22:31 2023 @@ -1,5 +1,5 @@ #! /bin/sh -# $NetBSD: t_errors.sh,v 1.33 2023/06/05 08:22:00 rillig Exp $ +# $NetBSD: t_errors.sh,v 1.34 2023/06/09 11:22:31 rillig Exp $ # # Copyright (c) 2021 The NetBSD Foundation, Inc. # All rights reserved. @@ -396,8 +396,8 @@ preprocessing_unrecognized_body() "$indent" code.c } -atf_test_case 'unbalanced_parentheses_1' -unbalanced_parentheses_1_body() +atf_test_case 'unbalanced_parentheses' +unbalanced_parentheses_body() { cat <<-\EOF > code.c int var = @@ -415,30 +415,8 @@ unbalanced_parentheses_1_body() "$indent" code.c } -atf_test_case 'unbalanced_parentheses_2' -unbalanced_parentheses_2_body() -{ - # '({...})' is the GCC extension "Statement expression". - cat <<-\EOF > code.c - int var = - ( - { - 1 - } - ) - ; - EOF - cat <<-\EOF > stderr.exp - error: code.c:3: Unbalanced parentheses - warning: code.c:6: Extra ')' - EOF - - atf_check -s 'exit:1' -e 'file:stderr.exp' \ - "$indent" code.c -} - -atf_test_case 'unbalanced_parentheses_3' -unbalanced_parentheses_3_body() +atf_test_case 'gcc_statement_expression' +gcc_statement_expression_body() { # '({...})' is the GCC extension "Statement expression". cat <<-\EOF > code.c @@ -508,48 +486,6 @@ EOF } -atf_test_case 'compound_literal' -compound_literal_body() -{ - # Test handling of compound literals (C99 6.5.2.5), as well as casts. - - cat < code.c -void -function(void) -{ - origin = - ((int) - ((-1)* - (struct point){0,0} - ) - ); -} -EOF - - sed '/^#/d' < expected.out -void -function(void) -{ - origin = - ((int) - ((-1) * - (struct point){0, 0} -# FIXME: the ')' must be aligned with the corresponding '('. - ) - ); -} -EOF - sed '/^#/d' < expected.err -# FIXME: The parentheses _are_ balanced, the '}' does not end the block. -error: code.c:7: Unbalanced parentheses -warning: code.c:8: Extra ')' -warning: code.c:9: Extra ')' -EOF - - atf_check -s 'exit:1' -o 'file:expected.out' -e 'file:expected.err' \ - "$indent" -nfc1 -ci12 code.c -st -} - atf_init_test_cases() { atf_add_test_case 'option_unknown' @@ -584,10 +520,8 @@ atf_init_test_cases() 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_1' - atf_add_test_case 'unbalanced_parentheses_2' - atf_add_test_case 'unbalanced_parentheses_3' + atf_add_test_case 'unbalanced_parentheses' + atf_add_test_case 'gcc_statement_expression' atf_add_test_case 'crash_comment_after_controlling_expression' atf_add_test_case 'comment_fits_in_one_line' - atf_add_test_case 'compound_literal' } Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.345 src/usr.bin/indent/indent.c:1.346 --- src/usr.bin/indent/indent.c:1.345 Fri Jun 9 10:24:55 2023 +++ src/usr.bin/indent/indent.c Fri Jun 9 11:22:31 2023 @@ -1,4
CVS commit: src
Module Name:src Committed By: rillig Date: Fri Jun 9 11:22:31 UTC 2023 Modified Files: src/tests/usr.bin/indent: fmt_expr.c t_errors.sh src/usr.bin/indent: indent.c Log Message: indent: support C99 compound literals To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/fmt_expr.c cvs rdiff -u -r1.33 -r1.34 src/tests/usr.bin/indent/t_errors.sh cvs rdiff -u -r1.345 -r1.346 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
Module Name:src Committed By: rillig Date: Fri Jun 9 10:24:56 UTC 2023 Modified Files: src/tests/usr.bin/indent: psym_stmt.c src/usr.bin/indent: debug.c indent.c indent.h Log Message: indent: don't treat function call expressions as cast expressions To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/psym_stmt.c cvs rdiff -u -r1.41 -r1.42 src/usr.bin/indent/debug.c cvs rdiff -u -r1.344 -r1.345 src/usr.bin/indent/indent.c cvs rdiff -u -r1.180 -r1.181 src/usr.bin/indent/indent.h 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/psym_stmt.c diff -u src/tests/usr.bin/indent/psym_stmt.c:1.5 src/tests/usr.bin/indent/psym_stmt.c:1.6 --- src/tests/usr.bin/indent/psym_stmt.c:1.5 Fri Jun 9 09:45:55 2023 +++ src/tests/usr.bin/indent/psym_stmt.c Fri Jun 9 10:24:55 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: psym_stmt.c,v 1.5 2023/06/09 09:45:55 rillig Exp $ */ +/* $NetBSD: psym_stmt.c,v 1.6 2023/06/09 10:24:55 rillig Exp $ */ /* * Tests for the parser symbol psym_stmt, which represents a statement on the @@ -28,14 +28,12 @@ function(void) //indent run-equals-input +// Ensure that '(something) {' is not treated as a cast expression. //indent input { TAILQ_FOREACH(a, b, c) { a = -// $ FIXME: The 'b' must be indented as a continuation. -// $ The '{' in line 2 sets ps.block_init though, even though it does not -// $ follow a '='. - b; + b; } } //indent end Index: src/usr.bin/indent/debug.c diff -u src/usr.bin/indent/debug.c:1.41 src/usr.bin/indent/debug.c:1.42 --- src/usr.bin/indent/debug.c:1.41 Fri Jun 9 08:10:58 2023 +++ src/usr.bin/indent/debug.c Fri Jun 9 10:24:55 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.41 2023/06/09 08:10:58 rillig Exp $ */ +/* $NetBSD: debug.c,v 1.42 2023/06/09 10:24:55 rillig Exp $ */ /*- * Copyright (c) 2023 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: debug.c,v 1.41 2023/06/09 08:10:58 rillig Exp $"); +__RCSID("$NetBSD: debug.c,v 1.42 2023/06/09 10:24:55 rillig Exp $"); #include @@ -306,6 +306,7 @@ debug_parser_state(void) debug_ps_bool(seen_case); debug_ps_enum(spaced_expr_psym, psym_name); debug_ps_enum(lbrace_kind, psym_name); + debug_ps_bool(prev_paren_was_cast); debug_println("indentation of statements and declarations"); debug_ps_int(ind_level); Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.344 src/usr.bin/indent/indent.c:1.345 --- src/usr.bin/indent/indent.c:1.344 Fri Jun 9 08:16:06 2023 +++ src/usr.bin/indent/indent.c Fri Jun 9 10:24:55 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.344 2023/06/09 08:16:06 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.345 2023/06/09 10:24:55 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: indent.c,v 1.344 2023/06/09 08:16:06 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.345 2023/06/09 10:24:55 rillig Exp $"); #include #include @@ -507,9 +507,10 @@ process_rparen(void) } enum paren_level_cast cast = ps.paren[--ps.nparen].cast; - if (ps.decl_on_line && !ps.block_init) + if (ps.in_func_def_params || (ps.decl_on_line && !ps.block_init)) cast = cast_no; + ps.prev_paren_was_cast = cast == cast_maybe; if (cast == cast_maybe) { ps.next_unary = true; ps.want_blank = opt.space_after_cast; @@ -669,11 +670,7 @@ process_semicolon(void) static void process_lbrace(void) { - parser_symbol psym = ps.psyms.sym[ps.psyms.top]; - if (ps.prev_lsym == lsym_rparen - && ps.psyms.top >= 2 - && !(psym == psym_for_exprs || psym == psym_if_expr - || psym == psym_switch_expr || psym == psym_while_expr)) { + if (ps.prev_lsym == lsym_rparen && ps.prev_paren_was_cast) { ps.block_init = true; ps.init_or_struct = true; } Index: src/usr.bin/indent/indent.h diff -u src/usr.bin/indent/indent.h:1.180 src/usr.bin/indent/indent.h:1.181 --- src/usr.bin/indent/indent.h:1.180 Fri Jun 9 08:10:58 2023 +++ src/usr.bin/indent/indent.h Fri Jun 9 10:24:55 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.h,v 1.180 2023/06/09 08:10:58 rillig Exp $ */ +/* $NetBSD: indent.h,v 1.181 2023/06/09 10:24:55 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -331,6 +331,7 @@ extern struct parser_state { * 'while'; or psym_0 */ parser_symbol lbrace_kind; /* the kind of brace to be pushed to * the parser symbol stack next */ + bool prev_paren_was_cast; /* Indentation of statements and declarations */
CVS commit: src
Module Name:src Committed By: rillig Date: Fri Jun 9 10:24:56 UTC 2023 Modified Files: src/tests/usr.bin/indent: psym_stmt.c src/usr.bin/indent: debug.c indent.c indent.h Log Message: indent: don't treat function call expressions as cast expressions To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/psym_stmt.c cvs rdiff -u -r1.41 -r1.42 src/usr.bin/indent/debug.c cvs rdiff -u -r1.344 -r1.345 src/usr.bin/indent/indent.c cvs rdiff -u -r1.180 -r1.181 src/usr.bin/indent/indent.h 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: Fri Jun 9 09:49:07 UTC 2023 Modified Files: src/tests/usr.bin/indent: fmt_decl.c src/usr.bin/indent: lexi.c Log Message: indent: improve heuristics for function declaration vs. definition To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/tests/usr.bin/indent/fmt_decl.c cvs rdiff -u -r1.218 -r1.219 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/tests/usr.bin/indent/fmt_decl.c diff -u src/tests/usr.bin/indent/fmt_decl.c:1.51 src/tests/usr.bin/indent/fmt_decl.c:1.52 --- src/tests/usr.bin/indent/fmt_decl.c:1.51 Fri Jun 9 09:45:55 2023 +++ src/tests/usr.bin/indent/fmt_decl.c Fri Jun 9 09:49:07 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: fmt_decl.c,v 1.51 2023/06/09 09:45:55 rillig Exp $ */ +/* $NetBSD: fmt_decl.c,v 1.52 2023/06/09 09:49:07 rillig Exp $ */ /* * Tests for declarations of global variables, external functions, and local @@ -1026,10 +1026,9 @@ typedef struct { //indent end //indent run -fbs -di0 -psl -// $ FIXME: Must be detected as a function declaration, not a definition. -static FILE * -ArchFindMember(const char *, const char *, - struct ar_hdr *, const char *); +// $ Must be detected as a function declaration, not a definition. +static FILE *ArchFindMember(const char *, const char *, + struct ar_hdr *, const char *); bool Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...)) Index: src/usr.bin/indent/lexi.c diff -u src/usr.bin/indent/lexi.c:1.218 src/usr.bin/indent/lexi.c:1.219 --- src/usr.bin/indent/lexi.c:1.218 Fri Jun 9 07:20:30 2023 +++ src/usr.bin/indent/lexi.c Fri Jun 9 09:49:07 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lexi.c,v 1.218 2023/06/09 07:20:30 rillig Exp $ */ +/* $NetBSD: lexi.c,v 1.219 2023/06/09 09:49:07 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: lexi.c,v 1.218 2023/06/09 07:20:30 rillig Exp $"); +__RCSID("$NetBSD: lexi.c,v 1.219 2023/06/09 09:49:07 rillig Exp $"); #include #include @@ -338,6 +338,9 @@ probably_looking_at_definition(void) else break; /* func(...) { ... */ } + + if (paren_level == 1 && p[0] == '*' && p[1] == ',') + return false; } /* To further reduce the cases where indent wrongly treats an
CVS commit: src
Module Name:src Committed By: rillig Date: Fri Jun 9 09:49:07 UTC 2023 Modified Files: src/tests/usr.bin/indent: fmt_decl.c src/usr.bin/indent: lexi.c Log Message: indent: improve heuristics for function declaration vs. definition To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/tests/usr.bin/indent/fmt_decl.c cvs rdiff -u -r1.218 -r1.219 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.
CVS commit: src/tests/usr.bin/indent
Module Name:src Committed By: rillig Date: Fri Jun 9 09:45:55 UTC 2023 Modified Files: src/tests/usr.bin/indent: fmt_decl.c fmt_expr.c psym_stmt.c Log Message: tests/indent: add real-life test cases from make(1) and lint(1) To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/tests/usr.bin/indent/fmt_decl.c cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/fmt_expr.c \ src/tests/usr.bin/indent/psym_stmt.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_decl.c diff -u src/tests/usr.bin/indent/fmt_decl.c:1.50 src/tests/usr.bin/indent/fmt_decl.c:1.51 --- src/tests/usr.bin/indent/fmt_decl.c:1.50 Thu Jun 8 21:18:54 2023 +++ src/tests/usr.bin/indent/fmt_decl.c Fri Jun 9 09:45:55 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: fmt_decl.c,v 1.50 2023/06/08 21:18:54 rillig Exp $ */ +/* $NetBSD: fmt_decl.c,v 1.51 2023/06/09 09:45:55 rillig Exp $ */ /* * Tests for declarations of global variables, external functions, and local @@ -153,6 +153,7 @@ t2(char *x, int y) //indent input const int int_minimum_size = +// $ FIXME: Missing indentation. MAXALIGN(offsetof(int, test)) + MAXIMUM_ALIGNOF; //indent end @@ -1002,3 +1003,49 @@ struct a { //indent end //indent run-equals-input -di0 + + +//indent input +static FILE *ArchFindMember(const char *, const char *, + struct ar_hdr *, const char *); + +bool +Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...)) +{ +} + +static void MAKE_ATTR_PRINTFLIKE(5, 0) +ParseVErrorInternal(FILE *f, bool useVars, const GNode *gn, + ParseErrorLevel level, const char *fmt, va_list ap) +{ +} + +typedef struct { + const char *m_name; +} mod_t; +//indent end + +//indent run -fbs -di0 -psl +// $ FIXME: Must be detected as a function declaration, not a definition. +static FILE * +ArchFindMember(const char *, const char *, + struct ar_hdr *, const char *); + +bool +Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...)) +{ +} + +static void +MAKE_ATTR_PRINTFLIKE(5, 0) +ParseVErrorInternal(FILE *f, bool useVars, const GNode *gn, + ParseErrorLevel level, const char *fmt, va_list ap) +{ +} + +typedef struct { + const char *m_name; +} +// $ FIXME: Remove this line break. +mod_t; +//indent end Index: src/tests/usr.bin/indent/fmt_expr.c diff -u src/tests/usr.bin/indent/fmt_expr.c:1.4 src/tests/usr.bin/indent/fmt_expr.c:1.5 --- src/tests/usr.bin/indent/fmt_expr.c:1.4 Sun Apr 24 09:04:12 2022 +++ src/tests/usr.bin/indent/fmt_expr.c Fri Jun 9 09:45:55 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: fmt_expr.c,v 1.4 2022/04/24 09:04:12 rillig Exp $ */ +/* $NetBSD: fmt_expr.c,v 1.5 2023/06/09 09:45:55 rillig Exp $ */ /* * Tests for all kinds of expressions that are not directly related to unary @@ -23,3 +23,14 @@ t(void) int n = malloc(offsetof(struct s, f) + 1); } //indent end + + +//indent input +{ + for (ln = gnodes->first; ln != NULL; ln = ln->next) +// $ FIXME: No space after the cast. + *(GNode **) Vector_Push(&vec) = ln->datum; +} +//indent end + +//indent run-equals-input Index: src/tests/usr.bin/indent/psym_stmt.c diff -u src/tests/usr.bin/indent/psym_stmt.c:1.4 src/tests/usr.bin/indent/psym_stmt.c:1.5 --- src/tests/usr.bin/indent/psym_stmt.c:1.4 Sun Apr 24 10:36:37 2022 +++ src/tests/usr.bin/indent/psym_stmt.c Fri Jun 9 09:45:55 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: psym_stmt.c,v 1.4 2022/04/24 10:36:37 rillig Exp $ */ +/* $NetBSD: psym_stmt.c,v 1.5 2023/06/09 09:45:55 rillig Exp $ */ /* * Tests for the parser symbol psym_stmt, which represents a statement on the @@ -26,3 +26,18 @@ function(void) * syntactic macro, especially not when its definition is in a header file. */ //indent run-equals-input + + +//indent input +{ + TAILQ_FOREACH(a, b, c) { + a = +// $ FIXME: The 'b' must be indented as a continuation. +// $ The '{' in line 2 sets ps.block_init though, even though it does not +// $ follow a '='. + b; + } +} +//indent end + +//indent run-equals-input -di0 -nlp -ci4
CVS commit: src/tests/usr.bin/indent
Module Name:src Committed By: rillig Date: Fri Jun 9 09:45:55 UTC 2023 Modified Files: src/tests/usr.bin/indent: fmt_decl.c fmt_expr.c psym_stmt.c Log Message: tests/indent: add real-life test cases from make(1) and lint(1) To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/tests/usr.bin/indent/fmt_decl.c cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/fmt_expr.c \ src/tests/usr.bin/indent/psym_stmt.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: Fri Jun 9 08:16:06 UTC 2023 Modified Files: src/usr.bin/indent: indent.c Log Message: indent: eliminate unused variable No functional change. To generate a diff of this commit: cvs rdiff -u -r1.343 -r1.344 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: Fri Jun 9 08:16:06 UTC 2023 Modified Files: src/usr.bin/indent: indent.c Log Message: indent: eliminate unused variable No functional change. To generate a diff of this commit: cvs rdiff -u -r1.343 -r1.344 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.343 src/usr.bin/indent/indent.c:1.344 --- src/usr.bin/indent/indent.c:1.343 Fri Jun 9 08:10:58 2023 +++ src/usr.bin/indent/indent.c Fri Jun 9 08:16:06 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.343 2023/06/09 08:10:58 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.344 2023/06/09 08:16:06 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: indent.c,v 1.343 2023/06/09 08:10:58 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.344 2023/06/09 08:16:06 rillig Exp $"); #include #include @@ -92,7 +92,6 @@ FILE *input; FILE *output; static const char *in_name = "Standard Input"; -static const char *out_name = "Standard Output"; static const char *backup_suffix = ".BAK"; static char bakfile[MAXPATHLEN] = ""; @@ -259,12 +258,11 @@ parse_command_line(int argc, char **argv err(1, "%s", in_name); } else if (output == NULL) { - out_name = arg; - if (strcmp(in_name, out_name) == 0) + if (strcmp(arg, in_name) == 0) errx(1, "input and output files " "must be different"); - if ((output = fopen(out_name, "w")) == NULL) -err(1, "%s", out_name); + if ((output = fopen(arg, "w")) == NULL) +err(1, "%s", arg); } else errx(1, "too many arguments: %s", arg); @@ -273,10 +271,8 @@ parse_command_line(int argc, char **argv if (input == NULL) { input = stdin; output = stdout; - } else if (output == NULL) { - out_name = in_name; + } else if (output == NULL) bakcopy(); - } if (opt.comment_column <= 1) opt.comment_column = 2; /* don't put normal comments in column
CVS commit: src
Module Name:src Committed By: rillig Date: Fri Jun 9 08:10:58 UTC 2023 Modified Files: src/tests/usr.bin/indent: opt_eei.c src/usr.bin/indent: debug.c indent.c indent.h io.c Log Message: indent: when an indentation is ambiguous, indent one level further The '-eei' mode now applies whenever the indentation from a multi-line expression could be confused with a following statement. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/tests/usr.bin/indent/opt_eei.c cvs rdiff -u -r1.40 -r1.41 src/usr.bin/indent/debug.c cvs rdiff -u -r1.342 -r1.343 src/usr.bin/indent/indent.c cvs rdiff -u -r1.179 -r1.180 src/usr.bin/indent/indent.h cvs rdiff -u -r1.206 -r1.207 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
Module Name:src Committed By: rillig Date: Fri Jun 9 08:10:58 UTC 2023 Modified Files: src/tests/usr.bin/indent: opt_eei.c src/usr.bin/indent: debug.c indent.c indent.h io.c Log Message: indent: when an indentation is ambiguous, indent one level further The '-eei' mode now applies whenever the indentation from a multi-line expression could be confused with a following statement. To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/tests/usr.bin/indent/opt_eei.c cvs rdiff -u -r1.40 -r1.41 src/usr.bin/indent/debug.c cvs rdiff -u -r1.342 -r1.343 src/usr.bin/indent/indent.c cvs rdiff -u -r1.179 -r1.180 src/usr.bin/indent/indent.h cvs rdiff -u -r1.206 -r1.207 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/tests/usr.bin/indent/opt_eei.c diff -u src/tests/usr.bin/indent/opt_eei.c:1.13 src/tests/usr.bin/indent/opt_eei.c:1.14 --- src/tests/usr.bin/indent/opt_eei.c:1.13 Fri Jun 9 07:54:05 2023 +++ src/tests/usr.bin/indent/opt_eei.c Fri Jun 9 08:10:58 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: opt_eei.c,v 1.13 2023/06/09 07:54:05 rillig Exp $ */ +/* $NetBSD: opt_eei.c,v 1.14 2023/06/09 08:10:58 rillig Exp $ */ /* * Tests for the options '-eei' and '-neei'. @@ -62,18 +62,14 @@ b) //indent run -eei { if (a < -/* $ XXX: No extra indentation necessary. */ - b) + b) stmt(); if (a -/* $ XXX: No extra indentation necessary. */ - < -/* $ XXX: No extra indentation necessary. */ - b) + < + b) stmt(); while (a -/* $ XXX: No extra indentation necessary. */ - < b) + < b) stmt(); switch ( a) @@ -110,8 +106,7 @@ b) b) stmt(); while (a -/* $ XXX: No extra indentation necessary. */ - < b) + < b) stmt(); switch ( /* $ XXX: No extra indentation necessary. */ @@ -208,10 +203,9 @@ b) //indent run -eei { if (fun( -// $ TODO: Indent one level further. - 1, - 2, - 3)) + 1, + 2, + 3)) stmt; } //indent end @@ -239,9 +233,8 @@ b) 3 ))) stmt; -// $ XXX: The indentation of '4' may be considered ambiguous. if - 4 + 4 stmt; } Index: src/usr.bin/indent/debug.c diff -u src/usr.bin/indent/debug.c:1.40 src/usr.bin/indent/debug.c:1.41 --- src/usr.bin/indent/debug.c:1.40 Thu Jun 8 21:18:54 2023 +++ src/usr.bin/indent/debug.c Fri Jun 9 08:10:58 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.40 2023/06/08 21:18:54 rillig Exp $ */ +/* $NetBSD: debug.c,v 1.41 2023/06/09 08:10:58 rillig Exp $ */ /*- * Copyright (c) 2023 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include -__RCSID("$NetBSD: debug.c,v 1.40 2023/06/08 21:18:54 rillig Exp $"); +__RCSID("$NetBSD: debug.c,v 1.41 2023/06/09 08:10:58 rillig Exp $"); #include @@ -131,7 +131,7 @@ const char *const line_kind_name[] = { static const char *const extra_expr_indent_name[] = { "no", - "yes", + "maybe", "last", }; Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.342 src/usr.bin/indent/indent.c:1.343 --- src/usr.bin/indent/indent.c:1.342 Fri Jun 9 07:20:30 2023 +++ src/usr.bin/indent/indent.c Fri Jun 9 08:10:58 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.342 2023/06/09 07:20:30 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.343 2023/06/09 08:10:58 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: indent.c,v 1.342 2023/06/09 07:20:30 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.343 2023/06/09 08:10:58 rillig Exp $"); #include #include @@ -453,10 +453,8 @@ process_lparen(void) ps.want_blank = false; buf_add_char(&code, token.s[0]); - if (opt.extra_expr_indent && !opt.lineup_to_parens - && ps.spaced_expr_psym != psym_0 && ps.nparen == 1 - && opt.continuation_indent == opt.indent_size) - ps.extra_expr_indent = eei_yes; + if (opt.extra_expr_indent && ps.spaced_expr_psym != psym_0) + ps.extra_expr_indent = eei_maybe; if (ps.init_or_struct && ps.psyms.top <= 2) { /* A kludge to correctly align function definitions. */ @@ -465,9 +463,6 @@ process_lparen(void) } int indent = ind_add(0, code.s, code.len); - if (opt.extra_expr_indent && ps.spaced_expr_psym != psym_0 - && ps.nparen == 1 && indent < 2 * opt.indent_size) - indent = 2 * opt.indent_size; enum paren_level_cast cast = cast_unknown; if (ps.prev_lsym == lsym_offsetof @@ -532,7 +527,7 @@ unbalanced: buf_add_char(&code, token.s[0]); if (ps.spaced_expr_psym != psym_0 && ps.nparen == 0) { - if (ps.extra_expr_indent == eei_yes) + if (ps.extra_expr_indent == eei_maybe) ps.extra_expr_indent = eei_last; ps.force_nl = true; ps.next_unary = true; Index: src/usr.bin/indent/indent.h diff -u src/usr.bin/indent/indent.h:1.179 src/usr.bin/indent/indent.h:1.180 --- src/usr.bin/indent/indent.h:1.179 Thu Jun 8 21:18:54 2023 +++ src/usr.bin/indent/indent.h Fri Jun 9 08:10:58 2023 @@
CVS commit: src/tests/usr.bin/indent
Module Name:src Committed By: rillig Date: Fri Jun 9 07:54:05 UTC 2023 Modified Files: src/tests/usr.bin/indent: opt_eei.c Log Message: tests/indent: test extra indentation in expressions To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/tests/usr.bin/indent/opt_eei.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/opt_eei.c diff -u src/tests/usr.bin/indent/opt_eei.c:1.12 src/tests/usr.bin/indent/opt_eei.c:1.13 --- src/tests/usr.bin/indent/opt_eei.c:1.12 Mon May 15 13:33:19 2023 +++ src/tests/usr.bin/indent/opt_eei.c Fri Jun 9 07:54:05 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: opt_eei.c,v 1.12 2023/05/15 13:33:19 rillig Exp $ */ +/* $NetBSD: opt_eei.c,v 1.13 2023/06/09 07:54:05 rillig Exp $ */ /* * Tests for the options '-eei' and '-neei'. @@ -187,3 +187,62 @@ b) ); } //indent end + + +/* + * When multi-line expressions are aligned on the parentheses, they may have an + * ambiguous indentation as well. + */ +//indent input +{ + if (fun( + 1, + 2, + 3)) + stmt; +} +//indent end + +//indent run-equals-input + +//indent run -eei +{ + if (fun( +// $ TODO: Indent one level further. + 1, + 2, + 3)) + stmt; +} +//indent end + + +/* + * + */ +//indent input +{ + if ((( + 3 + ))) + stmt; + if + 4 + + stmt; +} +//indent end + +//indent run -ci2 -nlp -eei +{ + if ((( + 3 + ))) + stmt; +// $ XXX: The indentation of '4' may be considered ambiguous. + if + 4 + + stmt; +} +//indent end
CVS commit: src/tests/usr.bin/indent
Module Name:src Committed By: rillig Date: Fri Jun 9 07:54:05 UTC 2023 Modified Files: src/tests/usr.bin/indent: opt_eei.c Log Message: tests/indent: test extra indentation in expressions To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/tests/usr.bin/indent/opt_eei.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: Fri Jun 9 07:20:31 UTC 2023 Modified Files: src/usr.bin/indent: indent.c io.c lexi.c parse.c pr_comment.c Log Message: indent: format its own code To generate a diff of this commit: cvs rdiff -u -r1.341 -r1.342 src/usr.bin/indent/indent.c cvs rdiff -u -r1.205 -r1.206 src/usr.bin/indent/io.c cvs rdiff -u -r1.217 -r1.218 src/usr.bin/indent/lexi.c cvs rdiff -u -r1.69 -r1.70 src/usr.bin/indent/parse.c cvs rdiff -u -r1.157 -r1.158 src/usr.bin/indent/pr_comment.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.341 src/usr.bin/indent/indent.c:1.342 --- src/usr.bin/indent/indent.c:1.341 Thu Jun 8 21:18:54 2023 +++ src/usr.bin/indent/indent.c Fri Jun 9 07:20:30 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.341 2023/06/08 21:18:54 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.342 2023/06/09 07:20:30 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: indent.c,v 1.341 2023/06/08 21:18:54 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.342 2023/06/09 07:20:30 rillig Exp $"); #include #include @@ -569,7 +569,7 @@ process_unary_op(void) indent_declarator(ind, ps.tabs_to_var); ps.want_blank = false; } else if ((token.s[0] == '+' || token.s[0] == '-') - && code.len > 0 && code.s[code.len - 1] == token.s[0]) + && code.len > 0 && code.s[code.len - 1] == token.s[0]) ps.want_blank = true; if (ps.want_blank) @@ -682,7 +682,7 @@ process_lbrace(void) if (ps.prev_lsym == lsym_rparen && ps.psyms.top >= 2 && !(psym == psym_for_exprs || psym == psym_if_expr - || psym == psym_switch_expr || psym == psym_while_expr)) { + || psym == psym_switch_expr || psym == psym_while_expr)) { ps.block_init = true; ps.init_or_struct = true; } @@ -901,8 +901,8 @@ process_comma(void) ps.block_init = false; int typical_varname_length = 8; if (ps.break_after_comma && (opt.break_after_comma || - ind_add(compute_code_indent(), code.s, code.len) - >= opt.max_line_length - typical_varname_length)) + ind_add(compute_code_indent(), code.s, code.len) + >= opt.max_line_length - typical_varname_length)) ps.force_nl = true; } } Index: src/usr.bin/indent/io.c diff -u src/usr.bin/indent/io.c:1.205 src/usr.bin/indent/io.c:1.206 --- src/usr.bin/indent/io.c:1.205 Fri Jun 9 06:36:57 2023 +++ src/usr.bin/indent/io.c Fri Jun 9 07:20:30 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: io.c,v 1.205 2023/06/09 06:36:57 rillig Exp $ */ +/* $NetBSD: io.c,v 1.206 2023/06/09 07:20:30 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: io.c,v 1.205 2023/06/09 06:36:57 rillig Exp $"); +__RCSID("$NetBSD: io.c,v 1.206 2023/06/09 07:20:30 rillig Exp $"); #include @@ -375,7 +375,7 @@ prepare_next_line: if (ps.extra_expr_indent == eei_last) ps.extra_expr_indent = eei_no; if (!(ps.psyms.sym[ps.psyms.top] == psym_if_expr_stmt_else - && ps.nparen > 0)) + && ps.nparen > 0)) ps.ind_level = ps.ind_level_follow; ps.line_start_nparen = ps.nparen; ps.want_blank = false; Index: src/usr.bin/indent/lexi.c diff -u src/usr.bin/indent/lexi.c:1.217 src/usr.bin/indent/lexi.c:1.218 --- src/usr.bin/indent/lexi.c:1.217 Thu Jun 8 21:18:54 2023 +++ src/usr.bin/indent/lexi.c Fri Jun 9 07:20:30 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lexi.c,v 1.217 2023/06/08 21:18:54 rillig Exp $ */ +/* $NetBSD: lexi.c,v 1.218 2023/06/09 07:20:30 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: lexi.c,v 1.217 2023/06/08 21:18:54 rillig Exp $"); +__RCSID("$NetBSD: lexi.c,v 1.218 2023/06/09 07:20:30 rillig Exp $"); #include #include @@ -689,7 +689,7 @@ register_typename(const char *name) if (typenames.len >= typenames.cap) { typenames.cap = 16 + 2 * typenames.cap; typenames.items = nonnull(realloc(typenames.items, - sizeof(typenames.items[0]) * typenames.cap)); + sizeof(typenames.items[0]) * typenames.cap)); } int pos = bsearch_typenames(name); Index: src/usr.bin/indent/parse.c diff -u src/usr.bin/indent/parse.c:1.69 src/usr.bin/indent/parse.c:1.70 --- src/usr.bin/indent/parse.c:1.69 Wed Jun 7 15:46:12 2023 +++ src/usr.bin/indent/parse.c Fri Jun 9 07:20:30 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.69 2023/06/07 15:46:12 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.70 2023/06/09 07:20:30 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: parse.c,v 1.69 2023/06/07 15:46:12 rillig Exp $"); +__RCSID("$NetBSD: parse.c,v 1.70 2023/06/09 07:20:30 rillig Exp $"); #include @@ -236,7 +236,7 @@ parse(parser_symbol psym) case psym_rbrace: /* stack should have or */ if (!(psyms->top > 0 - && is_lbra
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Fri Jun 9 07:20:31 UTC 2023 Modified Files: src/usr.bin/indent: indent.c io.c lexi.c parse.c pr_comment.c Log Message: indent: format its own code To generate a diff of this commit: cvs rdiff -u -r1.341 -r1.342 src/usr.bin/indent/indent.c cvs rdiff -u -r1.205 -r1.206 src/usr.bin/indent/io.c cvs rdiff -u -r1.217 -r1.218 src/usr.bin/indent/lexi.c cvs rdiff -u -r1.69 -r1.70 src/usr.bin/indent/parse.c cvs rdiff -u -r1.157 -r1.158 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: Fri Jun 9 07:18:53 UTC 2023 Modified Files: src/tests/usr.bin/indent: opt_cdb.c src/usr.bin/indent: pr_comment.c Log Message: indent: preserve block comments with delimiters To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/indent/opt_cdb.c cvs rdiff -u -r1.156 -r1.157 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/opt_cdb.c diff -u src/tests/usr.bin/indent/opt_cdb.c:1.9 src/tests/usr.bin/indent/opt_cdb.c:1.10 --- src/tests/usr.bin/indent/opt_cdb.c:1.9 Fri May 19 07:05:26 2023 +++ src/tests/usr.bin/indent/opt_cdb.c Fri Jun 9 07:18:52 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: opt_cdb.c,v 1.9 2023/05/19 07:05:26 rillig Exp $ */ +/* $NetBSD: opt_cdb.c,v 1.10 2023/06/09 07:18:52 rillig Exp $ */ /* * Tests for the options '-cdb' and '-ncdb'. @@ -7,8 +7,7 @@ * a separate line. This only affects block comments, but not comments to the * right of the code. * - * The option '-ncdb' compresses multi-line comments to single-line comments, - * as far as possible. + * The option '-ncdb' preserves comments with delimiters. */ //indent input @@ -50,9 +49,13 @@ /* Multiple lines without delimiters. */ -/* A single line with delimiters. */ +/* + * A single line with delimiters. + */ -/* Multiple lines with delimiters. */ +/* + * Multiple lines with delimiters. + */ //indent end @@ -153,10 +156,14 @@ example(void) /* Multiple lines without delimiters. */ int local_multi_without; - /* A single line with delimiters. */ + /* + * A single line with delimiters. + */ int local_single_with; - /* Multiple lines with delimiters. */ + /* + * Multiple lines with delimiters. + */ int local_multi_with; } //indent end @@ -174,11 +181,7 @@ example(void) */ //indent end -/* FIXME: Looks bad. */ -//indent run -ncdb -/* - * */ -//indent end +//indent run-equals-prev-output -ncdb //indent input @@ -193,18 +196,12 @@ example(void) */ //indent end -/* FIXME: Looks bad. */ -//indent run -ncdb -/* - * */ -//indent end +//indent run-equals-prev-output -ncdb /* - * Since 2019-04-04, the -ncdb option condenses multi-line comments as well, - * not only single-line comments. - * - * XXX: Is this intended? + * Between 2019-04-04 and 2023-06-09, the -ncdb option condensed multi-line + * comments as well, not only single-line comments. */ //indent input { @@ -218,10 +215,4 @@ example(void) //indent run-equals-input -cdb -//indent run -ncdb -{ - /* This is the first paragraph. - * - * This is the second paragraph. */ -} -//indent end +//indent run-equals-input -ncdb Index: src/usr.bin/indent/pr_comment.c diff -u src/usr.bin/indent/pr_comment.c:1.156 src/usr.bin/indent/pr_comment.c:1.157 --- src/usr.bin/indent/pr_comment.c:1.156 Fri Jun 9 07:04:51 2023 +++ src/usr.bin/indent/pr_comment.c Fri Jun 9 07:18:52 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: pr_comment.c,v 1.156 2023/06/09 07:04:51 rillig Exp $ */ +/* $NetBSD: pr_comment.c,v 1.157 2023/06/09 07:18:52 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: pr_comment.c,v 1.156 2023/06/09 07:04:51 rillig Exp $"); +__RCSID("$NetBSD: pr_comment.c,v 1.157 2023/06/09 07:18:52 rillig Exp $"); #include @@ -103,7 +103,10 @@ analyze_comment(bool *p_may_wrap, bool * if (ind <= 0) ind = opt.format_col1_comments ? 0 : 1; line_length = opt.block_comment_max_line_length; - delim = opt.comment_delimiter_on_blankline; + if (may_wrap && inp_p[0] == '\n') +delim = true; + if (may_wrap && opt.comment_delimiter_on_blankline) +delim = true; } else { int target_ind = code.len > 0 ? ind_add(compute_code_indent(), code.s, code.len)
CVS commit: src
Module Name:src Committed By: rillig Date: Fri Jun 9 07:18:53 UTC 2023 Modified Files: src/tests/usr.bin/indent: opt_cdb.c src/usr.bin/indent: pr_comment.c Log Message: indent: preserve block comments with delimiters To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/indent/opt_cdb.c cvs rdiff -u -r1.156 -r1.157 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: Fri Jun 9 07:04:51 UTC 2023 Modified Files: src/usr.bin/indent: pr_comment.c Log Message: indent: express more clearly how delimited and no-wrap comments relate No functional change. To generate a diff of this commit: cvs rdiff -u -r1.155 -r1.156 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/pr_comment.c diff -u src/usr.bin/indent/pr_comment.c:1.155 src/usr.bin/indent/pr_comment.c:1.156 --- src/usr.bin/indent/pr_comment.c:1.155 Tue Jun 6 07:51:35 2023 +++ src/usr.bin/indent/pr_comment.c Fri Jun 9 07:04:51 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: pr_comment.c,v 1.155 2023/06/06 07:51:35 rillig Exp $ */ +/* $NetBSD: pr_comment.c,v 1.156 2023/06/09 07:04:51 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: pr_comment.c,v 1.155 2023/06/06 07:51:35 rillig Exp $"); +__RCSID("$NetBSD: pr_comment.c,v 1.156 2023/06/09 07:04:51 rillig Exp $"); #include @@ -80,22 +80,18 @@ analyze_comment(bool *p_may_wrap, bool * int *p_ind, int *p_line_length) { bool may_wrap = true; - bool delim = opt.comment_delimiter_on_blankline; + bool delim = false; int ind; int line_length = opt.max_line_length; if (ps.curr_col_1 && !opt.format_col1_comments) { may_wrap = false; - delim = false; ind = 0; - } else { if (inp_p[0] == '-' || inp_p[0] == '*' || token.s[token.len - 1] == '/' || - (inp_p[0] == '\n' && !opt.format_block_comments)) { + (inp_p[0] == '\n' && !opt.format_block_comments)) may_wrap = false; - delim = false; - } if (code.len == 0 && inp_p[strspn(inp_p, "*")] == '\n') out.line_kind = lk_block_comment; @@ -107,9 +103,8 @@ analyze_comment(bool *p_may_wrap, bool * if (ind <= 0) ind = opt.format_col1_comments ? 0 : 1; line_length = opt.block_comment_max_line_length; + delim = opt.comment_delimiter_on_blankline; } else { - delim = false; - int target_ind = code.len > 0 ? ind_add(compute_code_indent(), code.s, code.len) : ind_add(compute_label_indent(), lab.s, lab.len); @@ -151,15 +146,16 @@ copy_comment_start(bool may_wrap, bool * com_add_char('/'); com_add_char(token.s[token.len - 1]); /* either '*' or '/' */ - if (may_wrap && !ch_isblank(inp_p[0])) - com_add_char(' '); - - if (*delim && fits_in_one_line(ind, line_length)) - *delim = false; + if (may_wrap) { + if (!ch_isblank(inp_p[0])) + com_add_char(' '); - if (*delim) { - output_line(); - com_add_delim(); + if (*delim && fits_in_one_line(ind, line_length)) + *delim = false; + if (*delim) { + output_line(); + com_add_delim(); + } } }
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Fri Jun 9 07:04:51 UTC 2023 Modified Files: src/usr.bin/indent: pr_comment.c Log Message: indent: express more clearly how delimited and no-wrap comments relate No functional change. To generate a diff of this commit: cvs rdiff -u -r1.155 -r1.156 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.