CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Dec 10 18:59:50 UTC 2023 Modified Files: src/usr.bin/make: var.c Log Message: make: document how to trigger a use-after-free bug Since 2017-02-01. To generate a diff of this commit: cvs rdiff -u -r1.1077 -r1.1078 src/usr.bin/make/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libcurses/director
Module Name:src Committed By: rillig Date: Sun Dec 10 18:04:55 UTC 2023 Modified Files: src/tests/lib/libcurses/director: testlang_conf.l Log Message: tests/libcurses: require 3 digits in octal character escapes Previously, the string literal "\0" had been interpreted as "0", which would have made the backslash redundant. The tests don't use this form. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/tests/lib/libcurses/director/testlang_conf.l Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libcurses/director
Module Name:src Committed By: rillig Date: Sun Dec 10 18:04:55 UTC 2023 Modified Files: src/tests/lib/libcurses/director: testlang_conf.l Log Message: tests/libcurses: require 3 digits in octal character escapes Previously, the string literal "\0" had been interpreted as "0", which would have made the backslash redundant. The tests don't use this form. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/tests/lib/libcurses/director/testlang_conf.l Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/director/testlang_conf.l diff -u src/tests/lib/libcurses/director/testlang_conf.l:1.26 src/tests/lib/libcurses/director/testlang_conf.l:1.27 --- src/tests/lib/libcurses/director/testlang_conf.l:1.26 Mon Nov 15 21:45:46 2021 +++ src/tests/lib/libcurses/director/testlang_conf.l Sun Dec 10 18:04:55 2023 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: testlang_conf.l,v 1.26 2021/11/15 21:45:46 blymn Exp $ */ +/* $NetBSD: testlang_conf.l,v 1.27 2023/12/10 18:04:55 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -86,7 +86,11 @@ dequote(const char *s, size_t *len) (p[2] - '0'); p += 3; } else { - *q++ = *p++; + errx(2, + "%s:%zu: Invalid escape sequence " + "'\\%c' in string literal; octal " + "numbers must be 3 digits wide", + cur_file, line, *p); } continue; }
CVS commit: src
Module Name:src Committed By: rillig Date: Sun Dec 10 17:45:35 UTC 2023 Modified Files: src/tests/usr.bin/indent: t_misc.sh src/usr.bin/indent: args.c Log Message: indent: be strict about options from profile files Previously, the "option" 'xdi0' was treated the same as '-xdi0'. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/tests/usr.bin/indent/t_misc.sh cvs rdiff -u -r1.86 -r1.87 src/usr.bin/indent/args.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/indent/t_misc.sh diff -u src/tests/usr.bin/indent/t_misc.sh:1.27 src/tests/usr.bin/indent/t_misc.sh:1.28 --- src/tests/usr.bin/indent/t_misc.sh:1.27 Mon Jun 5 10:12:21 2023 +++ src/tests/usr.bin/indent/t_misc.sh Sun Dec 10 17:45:35 2023 @@ -1,5 +1,5 @@ #! /bin/sh -# $NetBSD: t_misc.sh,v 1.27 2023/06/05 10:12:21 rillig Exp $ +# $NetBSD: t_misc.sh,v 1.28 2023/12/10 17:45:35 rillig Exp $ # # Copyright (c) 2021 The NetBSD Foundation, Inc. # All rights reserved. @@ -88,12 +88,12 @@ verbose_profile_body() profile: -fc1 EOF - # The code in args.c function set_profile suggests that options from - # profile files are echoed to stdout during startup. But since the + # The code in args.c function load_profile suggests that options from + # profile files are echoed to stderr during startup. But since the # command line options are handled after the profile files, a '-v' in # the command line has no effect. That's why '-bacc' is not listed - # in stdout, but '-fc1' is. The second round of '-bacc', '-v', '-fc1' - # is listed because when running ATF, $HOME equals $PWD. + # on stderr, but '-fc1' is. The second round of '-bacc', '-v', '-fc1' + # is listed because when running the test via ATF, $HOME equals $PWD. atf_check \ -e 'file:stderr.exp' \ @@ -205,15 +205,17 @@ option_P_in_profile_file_body() atf_test_case 'option_without_hyphen' option_without_hyphen_body() { - # TODO: Options in profile files should be required to start with - # '-', just like in the command line arguments. + # Ensure that options in profile files start with '-', just like + # command line options. printf ' -i3 xi5 +di0\n' > .indent.pro printf '%s\n' 'int var[] = {' '1,' '}' > code.c printf '%s\n' 'int var[] = {' ' 1,' '}' > code.exp - atf_check -o 'file:code.exp' \ + atf_check \ + -s 'exit:1' \ + -e "match:/.indent.pro: option \"xi5\" must start with '-'" \ "$indent" < code.c } Index: src/usr.bin/indent/args.c diff -u src/usr.bin/indent/args.c:1.86 src/usr.bin/indent/args.c:1.87 --- src/usr.bin/indent/args.c:1.86 Sun Dec 3 21:44:42 2023 +++ src/usr.bin/indent/args.c Sun Dec 10 17:45:35 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: args.c,v 1.86 2023/12/03 21:44:42 rillig Exp $ */ +/* $NetBSD: args.c,v 1.87 2023/12/10 17:45:35 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: args.c,v 1.86 2023/12/03 21:44:42 rillig Exp $"); +__RCSID("$NetBSD: args.c,v 1.87 2023/12/10 17:45:35 rillig Exp $"); /* Read options from profile files and from the command line. */ @@ -293,8 +293,13 @@ load_profile(const char *fname, bool mus buf[n] = '\0'; if (opt.verbose) fprintf(stderr, "profile: %s\n", buf); + if (buf[0] != '-') +errx(1, +"%s: option \"%s\" must start with '-'", +fname, buf); set_option(buf, fname); - } else if (ch == EOF) + } + if (ch == EOF) break; } (void)fclose(f);
CVS commit: src
Module Name:src Committed By: rillig Date: Sun Dec 10 17:45:35 UTC 2023 Modified Files: src/tests/usr.bin/indent: t_misc.sh src/usr.bin/indent: args.c Log Message: indent: be strict about options from profile files Previously, the "option" 'xdi0' was treated the same as '-xdi0'. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/tests/usr.bin/indent/t_misc.sh cvs rdiff -u -r1.86 -r1.87 src/usr.bin/indent/args.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libcurses/director
Module Name:src Committed By: rillig Date: Sun Dec 10 15:51:13 UTC 2023 Modified Files: src/tests/lib/libcurses/director: testlang_parse.y Log Message: tests/libcurses: constify To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/tests/lib/libcurses/director/testlang_parse.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libcurses/director
Module Name:src Committed By: rillig Date: Sun Dec 10 15:51:13 UTC 2023 Modified Files: src/tests/lib/libcurses/director: testlang_parse.y Log Message: tests/libcurses: constify To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/tests/lib/libcurses/director/testlang_parse.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/director/testlang_parse.y diff -u src/tests/lib/libcurses/director/testlang_parse.y:1.53 src/tests/lib/libcurses/director/testlang_parse.y:1.54 --- src/tests/lib/libcurses/director/testlang_parse.y:1.53 Sun Jun 13 11:06:20 2021 +++ src/tests/lib/libcurses/director/testlang_parse.y Sun Dec 10 15:51:13 2023 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: testlang_parse.y,v 1.53 2021/06/13 11:06:20 rillig Exp $ */ +/* $NetBSD: testlang_parse.y,v 1.54 2023/12/10 15:51:13 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -141,7 +141,7 @@ static void save_slave_output(bool); static void validate_type(data_enum_t, ct_data_t *, int); static void set_var(data_enum_t, const char *, void *); static void validate_reference(int, void *); -static char * numeric_or(char *, char *); +static char * numeric_or(const char *, const char *); static char * get_numeric_var(const char *); static void perform_delay(struct timespec *); static void set_cchar(char *, void *); @@ -517,7 +517,7 @@ get_numeric_var(const char *var) * Perform a bitwise OR on two numbers and return the result. */ static char * -numeric_or(char *n1, char *n2) +numeric_or(const char *n1, const char *n2) { unsigned long i1, i2, result; char *ret;
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rillig Date: Sun Dec 10 15:42:29 UTC 2023 Modified Files: src/tests/lib/libcurses/slave: commands.c Log Message: tests/libcurses: fix typo in comment To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/tests/lib/libcurses/slave/commands.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/tests/lib/libcurses/slave
Module Name:src Committed By: rillig Date: Sun Dec 10 15:42:29 UTC 2023 Modified Files: src/tests/lib/libcurses/slave: commands.c Log Message: tests/libcurses: fix typo in comment To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/tests/lib/libcurses/slave/commands.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/lib/libcurses/slave/commands.c diff -u src/tests/lib/libcurses/slave/commands.c:1.17 src/tests/lib/libcurses/slave/commands.c:1.18 --- src/tests/lib/libcurses/slave/commands.c:1.17 Mon Dec 6 22:45:42 2021 +++ src/tests/lib/libcurses/slave/commands.c Sun Dec 10 15:42:29 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: commands.c,v 1.17 2021/12/06 22:45:42 rillig Exp $ */ +/* $NetBSD: commands.c,v 1.18 2023/12/10 15:42:29 rillig Exp $ */ /*- * Copyright 2009 Brett Lymn @@ -194,7 +194,7 @@ report_message(data_enum_t type, const c } /* - * Report a string of chtype back to the director via the command pipe. + * Report a single chtype back to the director via the command pipe. */ void report_byte(chtype c)
CVS commit: src/tests/usr.bin/indent
Module Name:src Committed By: rillig Date: Sun Dec 10 15:39:25 UTC 2023 Modified Files: src/tests/usr.bin/indent: t_errors.sh Log Message: tests/indent: fix name of test case To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/tests/usr.bin/indent/t_errors.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/indent/t_errors.sh diff -u src/tests/usr.bin/indent/t_errors.sh:1.37 src/tests/usr.bin/indent/t_errors.sh:1.38 --- src/tests/usr.bin/indent/t_errors.sh:1.37 Wed Jun 14 19:05:40 2023 +++ src/tests/usr.bin/indent/t_errors.sh Sun Dec 10 15:39:25 2023 @@ -1,5 +1,5 @@ #! /bin/sh -# $NetBSD: t_errors.sh,v 1.37 2023/06/14 19:05:40 rillig Exp $ +# $NetBSD: t_errors.sh,v 1.38 2023/12/10 15:39:25 rillig Exp $ # # Copyright (c) 2021 The NetBSD Foundation, Inc. # All rights reserved. @@ -57,8 +57,8 @@ option_bool_trailing_garbage_body() -bacchus } -atf_test_case 'option_int_missing_argument' -option_int_missing_argument_body() +atf_test_case 'option_int_wrong_argument' +option_int_wrong_argument_body() { expect_error \ 'indent: Command line: argument "x" to option "-ts" must be an integer' \ @@ -468,7 +468,7 @@ atf_init_test_cases() { atf_add_test_case 'option_unknown' atf_add_test_case 'option_bool_trailing_garbage' - atf_add_test_case 'option_int_missing_argument' + atf_add_test_case 'option_int_wrong_argument' atf_add_test_case 'option_profile_not_found' atf_add_test_case 'option_buffer_overflow' atf_add_test_case 'option_typedefs_not_found'
CVS commit: src/tests/usr.bin/indent
Module Name:src Committed By: rillig Date: Sun Dec 10 15:39:25 UTC 2023 Modified Files: src/tests/usr.bin/indent: t_errors.sh Log Message: tests/indent: fix name of test case To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/tests/usr.bin/indent/t_errors.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/bin/cat
Module Name:src Committed By: rillig Date: Sun Dec 10 15:31:53 UTC 2023 Modified Files: src/bin/cat: cat.c Log Message: cat: repeat storage class 'static' for local functions No binary change. To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/bin/cat/cat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/cat/cat.c diff -u src/bin/cat/cat.c:1.59 src/bin/cat/cat.c:1.60 --- src/bin/cat/cat.c:1.59 Thu Dec 7 20:02:07 2023 +++ src/bin/cat/cat.c Sun Dec 10 15:31:53 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: cat.c,v 1.59 2023/12/07 20:02:07 rillig Exp $ */ +/* $NetBSD: cat.c,v 1.60 2023/12/10 15:31:53 rillig Exp $ */ /* * Copyright (c) 1989, 1993 @@ -44,7 +44,7 @@ __COPYRIGHT( #if 0 static char sccsid[] = "@(#)cat.c 8.2 (Berkeley) 4/27/95"; #else -__RCSID("$NetBSD: cat.c,v 1.59 2023/12/07 20:02:07 rillig Exp $"); +__RCSID("$NetBSD: cat.c,v 1.60 2023/12/10 15:31:53 rillig Exp $"); #endif #endif /* not lint */ @@ -139,7 +139,7 @@ main(int argc, char *argv[]) return rval; } -void +static void cook_args(char **argv) { FILE *fp; @@ -167,7 +167,7 @@ cook_args(char **argv) } while (*argv); } -void +static void cook_buf(FILE *fp) { int ch, gobble, line, prev; @@ -231,7 +231,7 @@ cook_buf(FILE *fp) err(EXIT_FAILURE, "stdout"); } -void +static void raw_args(char **argv) { int fd; @@ -278,7 +278,7 @@ skipnomsg: } while (*argv); } -void +static void raw_cat(int rfd) { static char *buf;
CVS commit: src/bin/cat
Module Name:src Committed By: rillig Date: Sun Dec 10 15:31:53 UTC 2023 Modified Files: src/bin/cat: cat.c Log Message: cat: repeat storage class 'static' for local functions No binary change. To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/bin/cat/cat.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: Sun Dec 10 15:29:38 UTC 2023 Modified Files: src/tests/usr.bin/xlint/lint1: queries.c t_usage.sh src/usr.bin/xlint/lint1: decl.c err.c externs1.h Log Message: lint: allow querying for 'static' followed by non-'static' declaration To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/tests/usr.bin/xlint/lint1/queries.c cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/xlint/lint1/t_usage.sh cvs rdiff -u -r1.384 -r1.385 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.220 -r1.221 src/usr.bin/xlint/lint1/err.c cvs rdiff -u -r1.208 -r1.209 src/usr.bin/xlint/lint1/externs1.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/xlint/lint1/queries.c diff -u src/tests/usr.bin/xlint/lint1/queries.c:1.19 src/tests/usr.bin/xlint/lint1/queries.c:1.20 --- src/tests/usr.bin/xlint/lint1/queries.c:1.19 Mon Jul 3 15:29:42 2023 +++ src/tests/usr.bin/xlint/lint1/queries.c Sun Dec 10 15:29:38 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: queries.c,v 1.19 2023/07/03 15:29:42 rillig Exp $ */ +/* $NetBSD: queries.c,v 1.20 2023/12/10 15:29:38 rillig Exp $ */ # 3 "queries.c" /* @@ -15,7 +15,7 @@ * such as casts between arithmetic types. */ -/* lint1-extra-flags: -q 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 -X 351 */ +/* lint1-extra-flags: -q 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 -X 351 */ typedef unsigned char u8_t; typedef unsigned short u16_t; @@ -448,6 +448,17 @@ Q15(void) } /* + * Even though C99 6.2.2p4 allows a 'static' declaration followed by a + * non-'static' declaration, it may look confusing. + */ +static void Q16(void); +/* expect+2: 'Q16' was declared 'static', now non-'static' [Q16] */ +/* expect+1: warning: static function 'Q16' unused [236] */ +void Q16(void) +{ +} + +/* * Since queries do not affect the exit status, force a warning to make this * test conform to the general expectation that a test that produces output * exits non-successfully. Index: src/tests/usr.bin/xlint/lint1/t_usage.sh diff -u src/tests/usr.bin/xlint/lint1/t_usage.sh:1.11 src/tests/usr.bin/xlint/lint1/t_usage.sh:1.12 --- src/tests/usr.bin/xlint/lint1/t_usage.sh:1.11 Thu Aug 3 18:48:42 2023 +++ src/tests/usr.bin/xlint/lint1/t_usage.sh Sun Dec 10 15:29:38 2023 @@ -1,4 +1,4 @@ -# $NetBSD: t_usage.sh,v 1.11 2023/08/03 18:48:42 rillig Exp $ +# $NetBSD: t_usage.sh,v 1.12 2023/12/10 15:29:38 rillig Exp $ # # Copyright (c) 2023 The NetBSD Foundation, Inc. # All rights reserved. @@ -89,13 +89,13 @@ enable_queries_body() # The largest known query. atf_check \ - "$lint1" -q 15 code.c /dev/null + "$lint1" -q 16 code.c /dev/null # Larger than the largest known query. atf_check \ -s 'exit:1' \ - -e "inline:lint1: invalid query ID '16'\n" \ - "$lint1" -q 16 code.c /dev/null + -e "inline:lint1: invalid query ID '17'\n" \ + "$lint1" -q 17 code.c /dev/null # Whitespace is not allowed before a query ID. atf_check \ Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.384 src/usr.bin/xlint/lint1/decl.c:1.385 --- src/usr.bin/xlint/lint1/decl.c:1.384 Sun Dec 10 14:59:47 2023 +++ src/usr.bin/xlint/lint1/decl.c Sun Dec 10 15:29:38 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.384 2023/12/10 14:59:47 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.385 2023/12/10 15:29:38 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.384 2023/12/10 14:59:47 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.385 2023/12/10 15:29:38 rillig Exp $"); #endif #include @@ -1430,6 +1430,12 @@ declarator_name(sym_t *sym) dcs->d_redeclared_symbol = NULL; } else { dcs->d_redeclared_symbol = sym; + if (is_query_enabled[16] + && sym->s_scl == STATIC && dcs->d_scl != STATIC) { + /* '%s' was declared 'static', now non-'static' */ + query_message(16, sym->s_name); + print_previous_declaration(sym); + } sym = pushdown(sym); } Index: src/usr.bin/xlint/lint1/err.c diff -u src/usr.bin/xlint/lint1/err.c:1.220 src/usr.bin/xlint/lint1/err.c:1.221 --- src/usr.bin/xlint/lint1/err.c:1.220 Sun Dec 3 18:17:41 2023 +++ src/usr.bin/xlint/lint1/err.c Sun Dec 10 15:29:38 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: err.c,v 1.220 2023/12/03 18:17:41 rillig Exp $ */ +/* $NetBSD: err.c,v 1.221 2023/12/10 15:29:38 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: err.c,v 1.220 2023/12/03 18:17:41 rillig Exp $"); +__RCSID("$NetBSD: err.c,v 1.221 2023/12/10 15:29:38 rillig Exp $"); #endif #include @@ -714,10 +714,11 @@ static const char *queries[] = { "redundant 'extern' in function declaration of '%s'", /* Q13 */ "comparison '%s' of 'char' with plain integer %d", /* Q14 */ "implicit conversion from
CVS commit: src
Module Name:src Committed By: rillig Date: Sun Dec 10 15:29:38 UTC 2023 Modified Files: src/tests/usr.bin/xlint/lint1: queries.c t_usage.sh src/usr.bin/xlint/lint1: decl.c err.c externs1.h Log Message: lint: allow querying for 'static' followed by non-'static' declaration To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/tests/usr.bin/xlint/lint1/queries.c cvs rdiff -u -r1.11 -r1.12 src/tests/usr.bin/xlint/lint1/t_usage.sh cvs rdiff -u -r1.384 -r1.385 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.220 -r1.221 src/usr.bin/xlint/lint1/err.c cvs rdiff -u -r1.208 -r1.209 src/usr.bin/xlint/lint1/externs1.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: Sun Dec 10 14:59:48 UTC 2023 Modified Files: src/tests/usr.bin/xlint/lint1: d_c99_bool_strict.c src/usr.bin/xlint/lint1: decl.c init.c src/usr.bin/xlint/xlint: xlint.c Log Message: lint: clean up comments No functional change. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c cvs rdiff -u -r1.383 -r1.384 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.252 -r1.253 src/usr.bin/xlint/lint1/init.c cvs rdiff -u -r1.120 -r1.121 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/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c diff -u src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.44 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.45 --- src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c:1.44 Wed Aug 2 18:51:25 2023 +++ src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c Sun Dec 10 14:59:47 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: d_c99_bool_strict.c,v 1.44 2023/08/02 18:51:25 rillig Exp $ */ +/* $NetBSD: d_c99_bool_strict.c,v 1.45 2023/12/10 14:59:47 rillig Exp $ */ # 3 "d_c99_bool_strict.c" /* @@ -160,7 +160,7 @@ enum strict_bool_constant_expressions { /* * Without strict bool mode, these two variants of an expression can * occur when a preprocessor macro is either defined to 1 or left - * empty (since C99), as in lint1/ops.def. + * empty (since C99). * * In strict bool mode, the resulting expression can be compared * against 0 to achieve the same effect (so +0 != 0 or 1 + 0 != 0). Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.383 src/usr.bin/xlint/lint1/decl.c:1.384 --- src/usr.bin/xlint/lint1/decl.c:1.383 Sun Dec 3 18:17:41 2023 +++ src/usr.bin/xlint/lint1/decl.c Sun Dec 10 14:59:47 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.383 2023/12/03 18:17:41 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.384 2023/12/10 14:59:47 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.383 2023/12/03 18:17:41 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.384 2023/12/10 14:59:47 rillig Exp $"); #endif #include @@ -97,11 +97,8 @@ initdecl(void) } /* - * Returns a shared type structure for arithmetic types and void. - * - * It's important to duplicate this structure using block_dup_type or - * expr_dup_type if it is to be modified (adding qualifiers or anything - * else). + * Returns a shared type structure for arithmetic types and void. The returned + * type must not be modified; use block_dup_type or expr_dup_type if necessary. */ type_t * gettyp(tspec_t t) @@ -296,7 +293,6 @@ typedef_error(type_t *td, tspec_t t) return td; invalid: - /* Anything else is not accepted. */ dcs->d_invalid_type_combination = true; return td; } Index: src/usr.bin/xlint/lint1/init.c diff -u src/usr.bin/xlint/lint1/init.c:1.252 src/usr.bin/xlint/lint1/init.c:1.253 --- src/usr.bin/xlint/lint1/init.c:1.252 Sun Dec 3 13:12:40 2023 +++ src/usr.bin/xlint/lint1/init.c Sun Dec 10 14:59:47 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: init.c,v 1.252 2023/12/03 13:12:40 rillig Exp $ */ +/* $NetBSD: init.c,v 1.253 2023/12/10 14:59:47 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -38,7 +38,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: init.c,v 1.252 2023/12/03 13:12:40 rillig Exp $"); +__RCSID("$NetBSD: init.c,v 1.253 2023/12/10 14:59:47 rillig Exp $"); #endif #include @@ -100,7 +100,7 @@ typedef struct designator { /* * The path from the "current object" of a brace level to the sub-object that - * is initialized by an expression. Examples for designations are '.member' + * is initialized by an expression. Examples of designations are '.member' * or '.member[123].member.member[1][1]'. * * C99 6.7.8p6, 6.7.8p7 @@ -115,7 +115,7 @@ typedef struct designation { * Everything that happens between a '{' and the corresponding '}', as part * of an initialization. * - * Each brace level has a "current object". For the outermost brace level, + * Each brace level has a "current object". For the outermost brace level, * it is the same as the object to be initialized. Each nested '{' begins a * nested brace level, for the sub-object pointed to by the designator of the * outer brace level. Index: src/usr.bin/xlint/xlint/xlint.c diff -u src/usr.bin/xlint/xlint/xlint.c:1.120 src/usr.bin/xlint/xlint/xlint.c:1.121 --- src/usr.bin/xlint/xlint/xlint.c:1.120 Sun Dec 3 18:17:41 2023 +++ src/usr.bin/xlint/xlint/xlint.c Sun Dec 10 14:59:47 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: xlint.c,v 1.120 2023/12/03 18:17:41 rillig Exp $ */ +/* $NetBSD: xlint.c,v 1.121 2023/12/10 14:59:47 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@
CVS commit: src
Module Name:src Committed By: rillig Date: Sun Dec 10 14:59:48 UTC 2023 Modified Files: src/tests/usr.bin/xlint/lint1: d_c99_bool_strict.c src/usr.bin/xlint/lint1: decl.c init.c src/usr.bin/xlint/xlint: xlint.c Log Message: lint: clean up comments No functional change. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/tests/usr.bin/xlint/lint1/d_c99_bool_strict.c cvs rdiff -u -r1.383 -r1.384 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.252 -r1.253 src/usr.bin/xlint/lint1/init.c cvs rdiff -u -r1.120 -r1.121 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/make
Module Name:src Committed By: rillig Date: Sun Dec 10 14:30:51 UTC 2023 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: varmod-subst-regex.mk Log Message: make: fix crash in ':C' modifier on an empty expression Since var.c 1.982 from 2021-12-13. To generate a diff of this commit: cvs rdiff -u -r1.1076 -r1.1077 src/usr.bin/make/var.c cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-subst-regex.mk 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/make/var.c diff -u src/usr.bin/make/var.c:1.1076 src/usr.bin/make/var.c:1.1077 --- src/usr.bin/make/var.c:1.1076 Sat Dec 9 00:13:38 2023 +++ src/usr.bin/make/var.c Sun Dec 10 14:30:50 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1076 2023/12/09 00:13:38 sjg Exp $ */ +/* $NetBSD: var.c,v 1.1077 2023/12/10 14:30:50 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -139,7 +139,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1076 2023/12/09 00:13:38 sjg Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1077 2023/12/10 14:30:50 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -1002,7 +1002,7 @@ Var_SetWithFlags(GNode *scope, const cha * If requested, don't export these in the * environment individually. We still put * them in .MAKEOVERRIDES so that the - * command-line settings continue to override + * command-line settings continue to override * Makefile settings. */ if (!opts.varNoExportEnv) @@ -1629,7 +1629,7 @@ ok: wp += (size_t)m[0].rm_eo; if (args->pflags.subGlobal) { flags |= REG_NOTBOL; - if (m[0].rm_so == 0 && m[0].rm_eo == 0) { + if (m[0].rm_so == 0 && m[0].rm_eo == 0 && *wp != '\0') { SepBuf_AddBytes(buf, wp, 1); wp++; } Index: src/usr.bin/make/unit-tests/varmod-subst-regex.mk diff -u src/usr.bin/make/unit-tests/varmod-subst-regex.mk:1.8 src/usr.bin/make/unit-tests/varmod-subst-regex.mk:1.9 --- src/usr.bin/make/unit-tests/varmod-subst-regex.mk:1.8 Sun Nov 19 21:47:52 2023 +++ src/usr.bin/make/unit-tests/varmod-subst-regex.mk Sun Dec 10 14:30:51 2023 @@ -1,4 +1,4 @@ -# $NetBSD: varmod-subst-regex.mk,v 1.8 2023/11/19 21:47:52 rillig Exp $ +# $NetBSD: varmod-subst-regex.mk,v 1.9 2023/12/10 14:30:51 rillig Exp $ # # Tests for the :C,from,to, variable modifier. @@ -84,6 +84,31 @@ all: unmatched-subexpression . error .endif + +# Contrary to the ':S' modifier, the ':C' modifier matches on an expression +# that contains no words at all, but only if the regular expression matches an +# empty string, for example, when the regular expression is anchored at the +# beginning or the end. +.if "<${U:S,^,prefix,}> <${:U:C,^,prefix,}>" != "<> " +. error +.endif +.if "<${U:S,$,suffix,}> <${:U:C,$,suffix,}>" != "<> " +. error +.endif +.if "<${U:S,^$,whole,}> <${:U:C,^$,whole,}>" != "<> " +. error +.endif +.if "<${U:S,^,prefix,g}> <${:U:C,^,prefix,g}>" != "<> " +. error +.endif +.if "<${U:S,$,suffix,g}> <${:U:C,$,suffix,g}>" != "<> " +. error +.endif +.if "<${U:S,^$,whole,g}> <${:U:C,^$,whole,g}>" != "<> " +. error +.endif + + # Multiple asterisks form an invalid regular expression. This produces an # error message and (as of 2020-08-28) stops parsing in the middle of the # expression. The unparsed part of the expression is then copied
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Dec 10 14:30:51 UTC 2023 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: varmod-subst-regex.mk Log Message: make: fix crash in ':C' modifier on an empty expression Since var.c 1.982 from 2021-12-13. To generate a diff of this commit: cvs rdiff -u -r1.1076 -r1.1077 src/usr.bin/make/var.c cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-subst-regex.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/bin/cat
Module Name:src Committed By: rillig Date: Thu Dec 7 20:02:07 UTC 2023 Modified Files: src/bin/cat: cat.c Log Message: cat: reduce visibility of local functions No functional change. To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/bin/cat/cat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/cat/cat.c diff -u src/bin/cat/cat.c:1.58 src/bin/cat/cat.c:1.59 --- src/bin/cat/cat.c:1.58 Fri May 19 05:28:54 2023 +++ src/bin/cat/cat.c Thu Dec 7 20:02:07 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: cat.c,v 1.58 2023/05/19 05:28:54 rillig Exp $ */ +/* $NetBSD: cat.c,v 1.59 2023/12/07 20:02:07 rillig Exp $ */ /* * Copyright (c) 1989, 1993 @@ -44,7 +44,7 @@ __COPYRIGHT( #if 0 static char sccsid[] = "@(#)cat.c 8.2 (Berkeley) 4/27/95"; #else -__RCSID("$NetBSD: cat.c,v 1.58 2023/05/19 05:28:54 rillig Exp $"); +__RCSID("$NetBSD: cat.c,v 1.59 2023/12/07 20:02:07 rillig Exp $"); #endif #endif /* not lint */ @@ -66,10 +66,10 @@ static size_t bsize; static int rval; static const char *filename; -void cook_args(char *argv[]); -void cook_buf(FILE *); -void raw_args(char *argv[]); -void raw_cat(int); +static void cook_args(char *argv[]); +static void cook_buf(FILE *); +static void raw_args(char *argv[]); +static void raw_cat(int); int main(int argc, char *argv[])
CVS commit: src/bin/cat
Module Name:src Committed By: rillig Date: Thu Dec 7 20:02:07 UTC 2023 Modified Files: src/bin/cat: cat.c Log Message: cat: reduce visibility of local functions No functional change. To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/bin/cat/cat.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/make/unit-tests
Module Name:src Committed By: rillig Date: Wed Dec 6 22:28:20 UTC 2023 Modified Files: src/usr.bin/make/unit-tests: directive-for.exp directive-for.mk Log Message: tests/make: show how global variables are unaffected by .for loops To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/directive-for.exp cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/unit-tests/directive-for.mk 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/make/unit-tests/directive-for.exp diff -u src/usr.bin/make/unit-tests/directive-for.exp:1.20 src/usr.bin/make/unit-tests/directive-for.exp:1.21 --- src/usr.bin/make/unit-tests/directive-for.exp:1.20 Thu Oct 19 18:24:33 2023 +++ src/usr.bin/make/unit-tests/directive-for.exp Wed Dec 6 22:28:20 2023 @@ -17,15 +17,15 @@ make: "directive-for.mk" line 146: }{ }{ make: "directive-for.mk" line 166: invalid character ':' in .for loop variable name make: "directive-for.mk" line 173: invalid character '$' in .for loop variable name make: "directive-for.mk" line 185: invalid character '$' in .for loop variable name -make: "directive-for.mk" line 196: Unknown modifier "Z" -make: "directive-for.mk" line 197: XXX: Should not reach word1 -make: "directive-for.mk" line 197: XXX: Should not reach before--after -make: "directive-for.mk" line 197: XXX: Should not reach word3 -make: "directive-for.mk" line 205: no iteration variables in for -make: "directive-for.mk" line 231: 1 open conditional -make: "directive-for.mk" line 247: for-less endfor -make: "directive-for.mk" line 248: if-less endif -make: "directive-for.mk" line 256: if-less endif +make: "directive-for.mk" line 210: Unknown modifier "Z" +make: "directive-for.mk" line 211: XXX: Should not reach word1 +make: "directive-for.mk" line 211: XXX: Should not reach before--after +make: "directive-for.mk" line 211: XXX: Should not reach word3 +make: "directive-for.mk" line 219: no iteration variables in for +make: "directive-for.mk" line 245: 1 open conditional +make: "directive-for.mk" line 261: for-less endfor +make: "directive-for.mk" line 262: if-less endif +make: "directive-for.mk" line 270: if-less endif For: new loop 2 For: end for 2 For: end for 1 @@ -36,7 +36,7 @@ For: loop body with outer = o: endfor For: end for 1 For: loop body with inner = i: -make: "directive-for.mk" line 304: newline-item=(a) +make: "directive-for.mk" line 318: newline-item=(a) make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/directive-for.mk diff -u src/usr.bin/make/unit-tests/directive-for.mk:1.23 src/usr.bin/make/unit-tests/directive-for.mk:1.24 --- src/usr.bin/make/unit-tests/directive-for.mk:1.23 Thu Oct 19 18:24:33 2023 +++ src/usr.bin/make/unit-tests/directive-for.mk Wed Dec 6 22:28:20 2023 @@ -1,4 +1,4 @@ -# $NetBSD: directive-for.mk,v 1.23 2023/10/19 18:24:33 rillig Exp $ +# $NetBSD: directive-for.mk,v 1.24 2023/12/06 22:28:20 rillig Exp $ # # Tests for the .for directive. # @@ -25,7 +25,7 @@ NUMBERS+= ${num} # The .for loop also works for multiple iteration variables. -# This is something that the modifier :@ cannot do. +# This is something that the modifier :@ cannot do as easily. .for name value in VARNAME value NAME2 value2 ${name}= ${value} .endfor @@ -189,6 +189,20 @@ INDIRECT= direct .endfor +# Regular global variables and the "variables" from the .for loop don't +# interfere with each other. In the following snippet, the variable 'DIRECT' +# is used both as a global variable, as well as an iteration variable in the +# .for loop. The expression '${INDIRECT}' refers to the global variable, not +# to the one from the .for loop. +DIRECT= global +INDIRECT= ${DIRECT} +.for DIRECT in iteration +. if "${DIRECT} ${INDIRECT}" != "iteration global" +.error +. endif +.endfor + + # XXX: A parse error or evaluation error in the items of the .for loop # should skip the whole loop. As of 2023-05-09, the loop is expanded as # usual.
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Wed Dec 6 22:28:20 UTC 2023 Modified Files: src/usr.bin/make/unit-tests: directive-for.exp directive-for.mk Log Message: tests/make: show how global variables are unaffected by .for loops To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/directive-for.exp cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/unit-tests/directive-for.mk 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: Sun Dec 3 21:44:43 UTC 2023 Modified Files: src/usr.bin/indent: args.c indent.c indent.h io.c lexi.c pr_comment.c Log Message: indent: inline input-related macros No binary change. To generate a diff of this commit: cvs rdiff -u -r1.85 -r1.86 src/usr.bin/indent/args.c cvs rdiff -u -r1.389 -r1.390 src/usr.bin/indent/indent.c cvs rdiff -u -r1.206 -r1.207 src/usr.bin/indent/indent.h cvs rdiff -u -r1.234 -r1.235 src/usr.bin/indent/io.c cvs rdiff -u -r1.241 -r1.242 src/usr.bin/indent/lexi.c cvs rdiff -u -r1.172 -r1.173 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: Sun Dec 3 21:44:43 UTC 2023 Modified Files: src/usr.bin/indent: args.c indent.c indent.h io.c lexi.c pr_comment.c Log Message: indent: inline input-related macros No binary change. To generate a diff of this commit: cvs rdiff -u -r1.85 -r1.86 src/usr.bin/indent/args.c cvs rdiff -u -r1.389 -r1.390 src/usr.bin/indent/indent.c cvs rdiff -u -r1.206 -r1.207 src/usr.bin/indent/indent.h cvs rdiff -u -r1.234 -r1.235 src/usr.bin/indent/io.c cvs rdiff -u -r1.241 -r1.242 src/usr.bin/indent/lexi.c cvs rdiff -u -r1.172 -r1.173 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/args.c diff -u src/usr.bin/indent/args.c:1.85 src/usr.bin/indent/args.c:1.86 --- src/usr.bin/indent/args.c:1.85 Thu Jun 15 09:19:06 2023 +++ src/usr.bin/indent/args.c Sun Dec 3 21:44:42 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: args.c,v 1.85 2023/06/15 09:19:06 rillig Exp $ */ +/* $NetBSD: args.c,v 1.86 2023/12/03 21:44:42 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: args.c,v 1.85 2023/06/15 09:19:06 rillig Exp $"); +__RCSID("$NetBSD: args.c,v 1.86 2023/12/03 21:44:42 rillig Exp $"); /* Read options from profile files and from the command line. */ @@ -168,8 +168,8 @@ set_special_option(const char *arg, cons } if (strcmp(arg, "st") == 0) { - if (input == NULL) - input = stdin; + if (in.f == NULL) + in.f = stdin; if (output == NULL) output = stdout; return true; Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.389 src/usr.bin/indent/indent.c:1.390 --- src/usr.bin/indent/indent.c:1.389 Sun Dec 3 21:40:44 2023 +++ src/usr.bin/indent/indent.c Sun Dec 3 21:44:42 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.389 2023/12/03 21:40:44 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.390 2023/12/03 21:44:42 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: indent.c,v 1.389 2023/12/03 21:40:44 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.390 2023/12/03 21:44:42 rillig Exp $"); #include #include @@ -156,7 +156,7 @@ diag(int level, const char *msg, ...) va_start(ap, msg); fprintf(stderr, "%s: %s:%d: ", - level == 0 ? "warning" : "error", in_name, token_start_line_no); + level == 0 ? "warning" : "error", in_name, in.token_start_line); vfprintf(stderr, msg, ap); fprintf(stderr, "\n"); va_end(ap); @@ -228,17 +228,17 @@ copy_to_bak_file(void) if (bak == NULL) err(1, "%s", backup_name); - while ((n = fread(buff, 1, sizeof(buff), input)) > 0) + while ((n = fread(buff, 1, sizeof(buff), in.f)) > 0) if (fwrite(buff, 1, n, bak) != n) err(1, "%s", backup_name); - if (fclose(input) != 0) + if (fclose(in.f) != 0) err(1, "%s", in_name); if (fclose(bak) != 0) err(1, "%s", backup_name); /* re-open the backup file as the input file */ - input = fopen(backup_name, "r"); - if (input == NULL) + in.f = fopen(backup_name, "r"); + if (in.f == NULL) err(1, "%s", backup_name); /* now the original input file will be the output */ output = fopen(in_name, "w"); @@ -257,9 +257,9 @@ parse_command_line(int argc, char **argv if (arg[0] == '-') { set_option(arg, "Command line"); - } else if (input == NULL) { + } else if (in.f == NULL) { in_name = arg; - if ((input = fopen(in_name, "r")) == NULL) + if ((in.f = fopen(in_name, "r")) == NULL) err(1, "%s", in_name); } else if (output == NULL) { @@ -273,8 +273,8 @@ parse_command_line(int argc, char **argv errx(1, "too many arguments: %s", arg); } - if (input == NULL) { - input = stdin; + if (in.f == NULL) { + in.f = stdin; output = stdout; } else if (output == NULL) copy_to_bak_file(); @@ -300,7 +300,7 @@ set_initial_indentation(void) inp_read_line(); int ind = 0; - for (const char *p = inp_p;; p++) { + for (const char *p = in.p;; p++) { if (*p == ' ') ind++; else if (*p == '\t') @@ -417,7 +417,7 @@ read_preprocessing_line(void) buf_add_char(, '#'); - while (inp_p[0] != '\n' || (state == COMM && !had_eof)) { + while (in.p[0] != '\n' || (state == COMM && !had_eof)) { buf_add_char(, inp_next()); switch (lab.s[lab.len - 1]) { case '\\': @@ -425,9 +425,9 @@ read_preprocessing_line(void) buf_add_char(, inp_next()); break; case '/': - if (inp_p[0] == '*' && state == PLAIN) { + if (in.p[0] == '*' && state == PLAIN) { state = COMM; -buf_add_char(, *inp_p++); +buf_add_char(, *in.p++); } break; case '"': @@ -443,9 +443,9 @@ read_preprocessing_line(void) state = CHR; break; case '*': - if (inp_p[0] == '/' && state == COMM) { + if (in.p[0] == '/' && state == COMM) { state = PLAIN; -buf_add_char(, *inp_p++); +buf_add_char(, *in.p++); } break; } @@ -578,7
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Sun Dec 3 21:40:44 UTC 2023 Modified Files: src/usr.bin/indent: indent.c indent.h io.c Log Message: indent: group input-related variables into a struct No functional change. To generate a diff of this commit: cvs rdiff -u -r1.388 -r1.389 src/usr.bin/indent/indent.c cvs rdiff -u -r1.205 -r1.206 src/usr.bin/indent/indent.h cvs rdiff -u -r1.233 -r1.234 src/usr.bin/indent/io.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Sun Dec 3 21:40:44 UTC 2023 Modified Files: src/usr.bin/indent: indent.c indent.h io.c Log Message: indent: group input-related variables into a struct No functional change. To generate a diff of this commit: cvs rdiff -u -r1.388 -r1.389 src/usr.bin/indent/indent.c cvs rdiff -u -r1.205 -r1.206 src/usr.bin/indent/indent.h cvs rdiff -u -r1.233 -r1.234 src/usr.bin/indent/io.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.388 src/usr.bin/indent/indent.c:1.389 --- src/usr.bin/indent/indent.c:1.388 Sun Dec 3 21:03:58 2023 +++ src/usr.bin/indent/indent.c Sun Dec 3 21:40:44 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.388 2023/12/03 21:03:58 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.389 2023/12/03 21:40:44 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: indent.c,v 1.388 2023/12/03 21:03:58 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.389 2023/12/03 21:40:44 rillig Exp $"); #include #include @@ -87,7 +87,6 @@ static struct { size_t cap; } ifdef; -FILE *input; FILE *output; static const char *in_name = "Standard Input"; Index: src/usr.bin/indent/indent.h diff -u src/usr.bin/indent/indent.h:1.205 src/usr.bin/indent/indent.h:1.206 --- src/usr.bin/indent/indent.h:1.205 Sun Dec 3 21:03:58 2023 +++ src/usr.bin/indent/indent.h Sun Dec 3 21:40:44 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.h,v 1.205 2023/12/03 21:03:58 rillig Exp $ */ +/* $NetBSD: indent.h,v 1.206 2023/12/03 21:40:44 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -146,18 +146,28 @@ struct buffer { size_t cap; }; -extern FILE *input; -extern FILE *output; - /* - * The current line from the input file, used by the lexer to generate tokens. - * To read from the line, start at inp_p and continue up to and including the + * The current input file, used by the lexer to generate tokens. + * To read from the input, start at p and continue up to and including the * next '\n'. To read beyond the '\n', call inp_skip or inp_next, which will * make the next line available, invalidating any pointers into the previous * line. */ -extern struct buffer inp; -extern const char *inp_p; +extern struct input_state { + FILE *f; + struct buffer line; + const char *p; + int token_start_line; + int token_end_line; +} in; + +#define input in.f +#define inp in.line +#define inp_p in.p +#define token_start_line_no in.token_start_line +#define token_end_line_no in.token_end_line + +extern FILE *output; extern struct buffer token; /* the current token to be processed, is * typically copied to the buffer 'code', or in @@ -249,8 +259,6 @@ extern struct options { extern bool found_err; extern bool had_eof; /* whether input is exhausted */ -extern int token_start_line_no; -extern int token_end_line_no; extern enum indent_enabled { indent_on, indent_off, Index: src/usr.bin/indent/io.c diff -u src/usr.bin/indent/io.c:1.233 src/usr.bin/indent/io.c:1.234 --- src/usr.bin/indent/io.c:1.233 Sun Dec 3 21:03:58 2023 +++ src/usr.bin/indent/io.c Sun Dec 3 21:40:44 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: io.c,v 1.233 2023/12/03 21:03:58 rillig Exp $ */ +/* $NetBSD: io.c,v 1.234 2023/12/03 21:40:44 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,16 +38,15 @@ */ #include -__RCSID("$NetBSD: io.c,v 1.233 2023/12/03 21:03:58 rillig Exp $"); +__RCSID("$NetBSD: io.c,v 1.234 2023/12/03 21:40:44 rillig Exp $"); #include #include "indent.h" -struct buffer inp; -const char *inp_p; -int token_start_line_no; -int token_end_line_no = 1; +struct input_state in = { + .token_end_line = 1, +}; struct output_state out; enum indent_enabled indent_enabled;
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Sun Dec 3 21:03:58 UTC 2023 Modified Files: src/usr.bin/indent: indent.c indent.h io.c lexi.c pr_comment.c Log Message: indent: use line number of the token start in diagnostics Previously, the line number of the end of the token was used, which was confusing in debug mode. To generate a diff of this commit: cvs rdiff -u -r1.387 -r1.388 src/usr.bin/indent/indent.c cvs rdiff -u -r1.204 -r1.205 src/usr.bin/indent/indent.h cvs rdiff -u -r1.232 -r1.233 src/usr.bin/indent/io.c cvs rdiff -u -r1.240 -r1.241 src/usr.bin/indent/lexi.c cvs rdiff -u -r1.171 -r1.172 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.387 src/usr.bin/indent/indent.c:1.388 --- src/usr.bin/indent/indent.c:1.387 Tue Jun 27 04:41:23 2023 +++ src/usr.bin/indent/indent.c Sun Dec 3 21:03:58 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.387 2023/06/27 04:41:23 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.388 2023/12/03 21:03:58 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: indent.c,v 1.387 2023/06/27 04:41:23 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.388 2023/12/03 21:03:58 rillig Exp $"); #include #include @@ -80,7 +80,6 @@ struct buffer com; bool found_err; bool had_eof; -int line_no = 1; static struct { struct parser_state *item; @@ -158,7 +157,7 @@ diag(int level, const char *msg, ...) va_start(ap, msg); fprintf(stderr, "%s: %s:%d: ", - level == 0 ? "warning" : "error", in_name, line_no); + level == 0 ? "warning" : "error", in_name, token_start_line_no); vfprintf(stderr, msg, ap); fprintf(stderr, "\n"); va_end(ap); @@ -580,7 +579,7 @@ process_newline(void) output_line(); stay_in_line: - line_no++; + token_end_line_no++; } static bool @@ -1109,7 +1108,8 @@ indent(void) lexer_symbol lsym = lexi(); debug_blank_line(); - debug_printf("line %d: %s", line_no, lsym_name[lsym]); + debug_printf("line %d: %s", + token_start_line_no, lsym_name[lsym]); debug_print_buf("token", ); debug_buffers(); debug_blank_line(); Index: src/usr.bin/indent/indent.h diff -u src/usr.bin/indent/indent.h:1.204 src/usr.bin/indent/indent.h:1.205 --- src/usr.bin/indent/indent.h:1.204 Mon Jun 26 20:03:09 2023 +++ src/usr.bin/indent/indent.h Sun Dec 3 21:03:58 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.h,v 1.204 2023/06/26 20:03:09 rillig Exp $ */ +/* $NetBSD: indent.h,v 1.205 2023/12/03 21:03:58 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -249,7 +249,8 @@ extern struct options { extern bool found_err; extern bool had_eof; /* whether input is exhausted */ -extern int line_no; /* the current input line number */ +extern int token_start_line_no; +extern int token_end_line_no; extern enum indent_enabled { indent_on, indent_off, Index: src/usr.bin/indent/io.c diff -u src/usr.bin/indent/io.c:1.232 src/usr.bin/indent/io.c:1.233 --- src/usr.bin/indent/io.c:1.232 Tue Jun 27 04:41:23 2023 +++ src/usr.bin/indent/io.c Sun Dec 3 21:03:58 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: io.c,v 1.232 2023/06/27 04:41:23 rillig Exp $ */ +/* $NetBSD: io.c,v 1.233 2023/12/03 21:03:58 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: io.c,v 1.232 2023/06/27 04:41:23 rillig Exp $"); +__RCSID("$NetBSD: io.c,v 1.233 2023/12/03 21:03:58 rillig Exp $"); #include @@ -46,6 +46,8 @@ __RCSID("$NetBSD: io.c,v 1.232 2023/06/2 struct buffer inp; const char *inp_p; +int token_start_line_no; +int token_end_line_no = 1; struct output_state out; enum indent_enabled indent_enabled; Index: src/usr.bin/indent/lexi.c diff -u src/usr.bin/indent/lexi.c:1.240 src/usr.bin/indent/lexi.c:1.241 --- src/usr.bin/indent/lexi.c:1.240 Sun Dec 3 20:42:31 2023 +++ src/usr.bin/indent/lexi.c Sun Dec 3 21:03:58 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lexi.c,v 1.240 2023/12/03 20:42:31 rillig Exp $ */ +/* $NetBSD: lexi.c,v 1.241 2023/12/03 21:03:58 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: lexi.c,v 1.240 2023/12/03 20:42:31 rillig Exp $"); +__RCSID("$NetBSD: lexi.c,v 1.241 2023/12/03 21:03:58 rillig Exp $"); #include #include @@ -188,7 +188,7 @@ skip_line_continuation(void) if (inp_p[0] == '\\' && inp_p[1] == '\n') { inp_p++; inp_skip(); - line_no++; + token_end_line_no++; return true; } return false; @@ -245,7 +245,7 @@ lex_char_or_string(void) if (token.s[token.len - 1] == '\\') { if (*inp_p == '\n') -line_no++; +token_end_line_no++; token_add_char(inp_next()); } } @@ -524,7 +524,7 @@ lex_asterisk_unary(void) if (*inp_p == '*') token_add_char('*'); if (*inp_p == '\n') - line_no++; +
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Sun Dec 3 21:03:58 UTC 2023 Modified Files: src/usr.bin/indent: indent.c indent.h io.c lexi.c pr_comment.c Log Message: indent: use line number of the token start in diagnostics Previously, the line number of the end of the token was used, which was confusing in debug mode. To generate a diff of this commit: cvs rdiff -u -r1.387 -r1.388 src/usr.bin/indent/indent.c cvs rdiff -u -r1.204 -r1.205 src/usr.bin/indent/indent.h cvs rdiff -u -r1.232 -r1.233 src/usr.bin/indent/io.c cvs rdiff -u -r1.240 -r1.241 src/usr.bin/indent/lexi.c cvs rdiff -u -r1.171 -r1.172 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: Sun Dec 3 20:42:32 UTC 2023 Modified Files: src/usr.bin/indent: lexi.c Log Message: indent: fix line number counting in function definition In a function definition that is split on two lines, if the first line ends with a '*', the following line break didn't include the line number. To generate a diff of this commit: cvs rdiff -u -r1.239 -r1.240 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.bin/indent
Module Name:src Committed By: rillig Date: Sun Dec 3 20:42:32 UTC 2023 Modified Files: src/usr.bin/indent: lexi.c Log Message: indent: fix line number counting in function definition In a function definition that is split on two lines, if the first line ends with a '*', the following line break didn't include the line number. To generate a diff of this commit: cvs rdiff -u -r1.239 -r1.240 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.239 src/usr.bin/indent/lexi.c:1.240 --- src/usr.bin/indent/lexi.c:1.239 Mon Jun 26 20:23:40 2023 +++ src/usr.bin/indent/lexi.c Sun Dec 3 20:42:31 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lexi.c,v 1.239 2023/06/26 20:23:40 rillig Exp $ */ +/* $NetBSD: lexi.c,v 1.240 2023/12/03 20:42:31 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -38,7 +38,7 @@ */ #include -__RCSID("$NetBSD: lexi.c,v 1.239 2023/06/26 20:23:40 rillig Exp $"); +__RCSID("$NetBSD: lexi.c,v 1.240 2023/12/03 20:42:31 rillig Exp $"); #include #include @@ -523,6 +523,8 @@ lex_asterisk_unary(void) while (*inp_p == '*' || ch_isspace(*inp_p)) { if (*inp_p == '*') token_add_char('*'); + if (*inp_p == '\n') + line_no++; inp_skip(); }
CVS commit: src/usr.bin/xlint
Module Name:src Committed By: rillig Date: Sun Dec 3 18:17:41 UTC 2023 Modified Files: src/usr.bin/xlint/common: externs.h inittyp.c lint.h src/usr.bin/xlint/lint1: cgram.y decl.c emit1.c err.c externs1.h func.c lex.c lint1.h main1.c mem1.c op.h tree.c src/usr.bin/xlint/lint2: chk.c emit2.c externs2.h hash.c lint2.h main2.c msg.c read.c src/usr.bin/xlint/xlint: xlint.c Log Message: lint: in declarations, replace tab with space Previously, in some cases, the keywords 'const' or 'struct' were followed by a tab, which doesn't make sense. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/usr.bin/xlint/common/externs.h cvs rdiff -u -r1.40 -r1.41 src/usr.bin/xlint/common/inittyp.c cvs rdiff -u -r1.45 -r1.46 src/usr.bin/xlint/common/lint.h cvs rdiff -u -r1.476 -r1.477 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.382 -r1.383 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.80 -r1.81 src/usr.bin/xlint/lint1/emit1.c cvs rdiff -u -r1.219 -r1.220 src/usr.bin/xlint/lint1/err.c cvs rdiff -u -r1.207 -r1.208 src/usr.bin/xlint/lint1/externs1.h cvs rdiff -u -r1.177 -r1.178 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.195 -r1.196 src/usr.bin/xlint/lint1/lex.c cvs rdiff -u -r1.204 -r1.205 src/usr.bin/xlint/lint1/lint1.h cvs rdiff -u -r1.77 -r1.78 src/usr.bin/xlint/lint1/main1.c cvs rdiff -u -r1.76 -r1.77 src/usr.bin/xlint/lint1/mem1.c cvs rdiff -u -r1.25 -r1.26 src/usr.bin/xlint/lint1/op.h cvs rdiff -u -r1.586 -r1.587 src/usr.bin/xlint/lint1/tree.c cvs rdiff -u -r1.64 -r1.65 src/usr.bin/xlint/lint2/chk.c cvs rdiff -u -r1.36 -r1.37 src/usr.bin/xlint/lint2/emit2.c cvs rdiff -u -r1.21 -r1.22 src/usr.bin/xlint/lint2/externs2.h cvs rdiff -u -r1.28 -r1.29 src/usr.bin/xlint/lint2/hash.c cvs rdiff -u -r1.26 -r1.27 src/usr.bin/xlint/lint2/lint2.h cvs rdiff -u -r1.34 -r1.35 src/usr.bin/xlint/lint2/main2.c cvs rdiff -u -r1.24 -r1.25 src/usr.bin/xlint/lint2/msg.c cvs rdiff -u -r1.89 -r1.90 src/usr.bin/xlint/lint2/read.c cvs rdiff -u -r1.119 -r1.120 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: Sun Dec 3 18:17:41 UTC 2023 Modified Files: src/usr.bin/xlint/common: externs.h inittyp.c lint.h src/usr.bin/xlint/lint1: cgram.y decl.c emit1.c err.c externs1.h func.c lex.c lint1.h main1.c mem1.c op.h tree.c src/usr.bin/xlint/lint2: chk.c emit2.c externs2.h hash.c lint2.h main2.c msg.c read.c src/usr.bin/xlint/xlint: xlint.c Log Message: lint: in declarations, replace tab with space Previously, in some cases, the keywords 'const' or 'struct' were followed by a tab, which doesn't make sense. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/usr.bin/xlint/common/externs.h cvs rdiff -u -r1.40 -r1.41 src/usr.bin/xlint/common/inittyp.c cvs rdiff -u -r1.45 -r1.46 src/usr.bin/xlint/common/lint.h cvs rdiff -u -r1.476 -r1.477 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.382 -r1.383 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.80 -r1.81 src/usr.bin/xlint/lint1/emit1.c cvs rdiff -u -r1.219 -r1.220 src/usr.bin/xlint/lint1/err.c cvs rdiff -u -r1.207 -r1.208 src/usr.bin/xlint/lint1/externs1.h cvs rdiff -u -r1.177 -r1.178 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.195 -r1.196 src/usr.bin/xlint/lint1/lex.c cvs rdiff -u -r1.204 -r1.205 src/usr.bin/xlint/lint1/lint1.h cvs rdiff -u -r1.77 -r1.78 src/usr.bin/xlint/lint1/main1.c cvs rdiff -u -r1.76 -r1.77 src/usr.bin/xlint/lint1/mem1.c cvs rdiff -u -r1.25 -r1.26 src/usr.bin/xlint/lint1/op.h cvs rdiff -u -r1.586 -r1.587 src/usr.bin/xlint/lint1/tree.c cvs rdiff -u -r1.64 -r1.65 src/usr.bin/xlint/lint2/chk.c cvs rdiff -u -r1.36 -r1.37 src/usr.bin/xlint/lint2/emit2.c cvs rdiff -u -r1.21 -r1.22 src/usr.bin/xlint/lint2/externs2.h cvs rdiff -u -r1.28 -r1.29 src/usr.bin/xlint/lint2/hash.c cvs rdiff -u -r1.26 -r1.27 src/usr.bin/xlint/lint2/lint2.h cvs rdiff -u -r1.34 -r1.35 src/usr.bin/xlint/lint2/main2.c cvs rdiff -u -r1.24 -r1.25 src/usr.bin/xlint/lint2/msg.c cvs rdiff -u -r1.89 -r1.90 src/usr.bin/xlint/lint2/read.c cvs rdiff -u -r1.119 -r1.120 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/externs.h diff -u src/usr.bin/xlint/common/externs.h:1.30 src/usr.bin/xlint/common/externs.h:1.31 --- src/usr.bin/xlint/common/externs.h:1.30 Sat Aug 12 20:48:24 2023 +++ src/usr.bin/xlint/common/externs.h Sun Dec 3 18:17:41 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: externs.h,v 1.30 2023/08/12 20:48:24 rillig Exp $ */ +/* $NetBSD: externs.h,v 1.31 2023/12/03 18:17:41 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -42,21 +42,21 @@ const char *tspec_name(tspec_t); /* * mem.c */ -void *xmalloc(size_t); -void *xcalloc(size_t, size_t); -void *xrealloc(void *, size_t); -char *xstrdup(const char *); -char *xasprintf(const char *, ...) __printflike(1, 2); +void *xmalloc(size_t); +void *xcalloc(size_t, size_t); +void *xrealloc(void *, size_t); +char *xstrdup(const char *); +char *xasprintf(const char *, ...) __printflike(1, 2); /* * emit.c */ #if defined(IS_LINT1) || defined(IS_LINT2) -void outopen(const char *); -void outclose(void); -void outchar(char); -void outstrg(const char *); -void outint(int); -void outname(const char *); -void outsrc(const char *); +void outopen(const char *); +void outclose(void); +void outchar(char); +void outstrg(const char *); +void outint(int); +void outname(const char *); +void outsrc(const char *); #endif Index: src/usr.bin/xlint/common/inittyp.c diff -u src/usr.bin/xlint/common/inittyp.c:1.40 src/usr.bin/xlint/common/inittyp.c:1.41 --- src/usr.bin/xlint/common/inittyp.c:1.40 Thu Jul 13 08:40:38 2023 +++ src/usr.bin/xlint/common/inittyp.c Sun Dec 3 18:17:41 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: inittyp.c,v 1.40 2023/07/13 08:40:38 rillig Exp $ */ +/* $NetBSD: inittyp.c,v 1.41 2023/12/03 18:17:41 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: inittyp.c,v 1.40 2023/07/13 08:40:38 rillig Exp $"); +__RCSID("$NetBSD: inittyp.c,v 1.41 2023/12/03 18:17:41 rillig Exp $"); #endif #if defined(IS_LINT1) @@ -78,7 +78,7 @@ __RCSID("$NetBSD: inittyp.c,v 1.40 2023/ #endif /* various type information */ -ttab_t ttab[NTSPEC] = { +ttab_t ttab[NTSPEC] = { typeinfo(NULL, NO_TSPEC, NO_TSPEC, 0, 0, ' '), typeinfo("signed", SIGNED, UNSIGN, 0, 0, ' '), typeinfo("unsigned", SIGNED, UNSIGN, 0, 0, ' '), Index: src/usr.bin/xlint/common/lint.h diff -u src/usr.bin/xlint/common/lint.h:1.45 src/usr.bin/xlint/common/lint.h:1.46 --- src/usr.bin/xlint/common/lint.h:1.45 Sun Dec 3 12:24:48 2023 +++ src/usr.bin/xlint/common/lint.h Sun Dec 3 18:17:41 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lint.h,v 1.45 2023/12/03 12:24:48 rillig Exp $ */ +/* $NetBSD: lint.h,v 1.46 2023/12/03 18:17:41 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -92,7 +92,7 @@ typedef
CVS commit: src/tests/usr.bin/indent
Module Name:src Committed By: rillig Date: Sun Dec 3 14:26:10 UTC 2023 Modified Files: src/tests/usr.bin/indent: fmt_expr.c Log Message: tests/indent: test compound expressions To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/indent/fmt_expr.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.10 src/tests/usr.bin/indent/fmt_expr.c:1.11 --- src/tests/usr.bin/indent/fmt_expr.c:1.10 Fri Jun 16 23:19:01 2023 +++ src/tests/usr.bin/indent/fmt_expr.c Sun Dec 3 14:26:10 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: fmt_expr.c,v 1.10 2023/06/16 23:19:01 rillig Exp $ */ +/* $NetBSD: fmt_expr.c,v 1.11 2023/12/03 14:26:10 rillig Exp $ */ /* * Tests for all kinds of expressions that are not directly related to unary @@ -57,3 +57,28 @@ // error: Standard Input:7: Unbalanced parentheses // warning: Standard Input:9: Extra ')' //indent end + + +// A compound expression with an unknown type is indented other than one with +// a known type. Ideally, both cases should be treated the same. +//indent input +{ + var = (type) { .member = value }; + var = (type) { value, value, value }; + var = (struct s) { .member = value }; + var = (struct s) { value, value, value }; +} +//indent end + +//indent run +{ + var = (type) { + .member = value + }; + var = (type) { + value, value, value + }; + var = (struct s){.member = value}; + var = (struct s){value, value, value}; +} +//indent end
CVS commit: src/tests/usr.bin/indent
Module Name:src Committed By: rillig Date: Sun Dec 3 14:26:10 UTC 2023 Modified Files: src/tests/usr.bin/indent: fmt_expr.c Log Message: tests/indent: test compound expressions To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/indent/fmt_expr.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: Sun Dec 3 13:12:40 UTC 2023 Modified Files: src/usr.bin/xlint/lint1: ckctype.c ckgetopt.c decl.c emit1.c err.c func.c init.c lex.c lint1.h mem1.c tree.c src/usr.bin/xlint/lint2: chk.c lint2.h read.c src/usr.bin/xlint/xlint: xlint.c Log Message: lint: re-wrap comments No functional change. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/usr.bin/xlint/lint1/ckctype.c cvs rdiff -u -r1.16 -r1.17 src/usr.bin/xlint/lint1/ckgetopt.c cvs rdiff -u -r1.381 -r1.382 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.79 -r1.80 src/usr.bin/xlint/lint1/emit1.c cvs rdiff -u -r1.218 -r1.219 src/usr.bin/xlint/lint1/err.c cvs rdiff -u -r1.176 -r1.177 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.251 -r1.252 src/usr.bin/xlint/lint1/init.c cvs rdiff -u -r1.194 -r1.195 src/usr.bin/xlint/lint1/lex.c cvs rdiff -u -r1.203 -r1.204 src/usr.bin/xlint/lint1/lint1.h cvs rdiff -u -r1.75 -r1.76 src/usr.bin/xlint/lint1/mem1.c cvs rdiff -u -r1.585 -r1.586 src/usr.bin/xlint/lint1/tree.c cvs rdiff -u -r1.63 -r1.64 src/usr.bin/xlint/lint2/chk.c cvs rdiff -u -r1.25 -r1.26 src/usr.bin/xlint/lint2/lint2.h cvs rdiff -u -r1.88 -r1.89 src/usr.bin/xlint/lint2/read.c cvs rdiff -u -r1.118 -r1.119 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/lint1/ckctype.c diff -u src/usr.bin/xlint/lint1/ckctype.c:1.8 src/usr.bin/xlint/lint1/ckctype.c:1.9 --- src/usr.bin/xlint/lint1/ckctype.c:1.8 Sun Dec 3 12:03:38 2023 +++ src/usr.bin/xlint/lint1/ckctype.c Sun Dec 3 13:12:40 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ckctype.c,v 1.8 2023/12/03 12:03:38 rillig Exp $ */ +/* $NetBSD: ckctype.c,v 1.9 2023/12/03 13:12:40 rillig Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: ckctype.c,v 1.8 2023/12/03 12:03:38 rillig Exp $"); +__RCSID("$NetBSD: ckctype.c,v 1.9 2023/12/03 13:12:40 rillig Exp $"); #endif #include @@ -106,7 +106,7 @@ check_ctype_arg(const char *func, const return; if (arg->tn_op == CVT && arg->tn_cast) { - /* argument to '%s' must be cast to 'unsigned char', not to '%s' */ + /* argument to '%s' must be cast to 'unsigned char', not ... */ warning(342, func, type_name(arg->tn_type)); return; } Index: src/usr.bin/xlint/lint1/ckgetopt.c diff -u src/usr.bin/xlint/lint1/ckgetopt.c:1.16 src/usr.bin/xlint/lint1/ckgetopt.c:1.17 --- src/usr.bin/xlint/lint1/ckgetopt.c:1.16 Fri May 20 21:18:55 2022 +++ src/usr.bin/xlint/lint1/ckgetopt.c Sun Dec 3 13:12:40 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ckgetopt.c,v 1.16 2022/05/20 21:18:55 rillig Exp $ */ +/* $NetBSD: ckgetopt.c,v 1.17 2023/12/03 13:12:40 rillig Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: ckgetopt.c,v 1.16 2022/05/20 21:18:55 rillig Exp $"); +__RCSID("$NetBSD: ckgetopt.c,v 1.17 2023/12/03 13:12:40 rillig Exp $"); #endif #include @@ -51,7 +51,7 @@ __RCSID("$NetBSD: ckgetopt.c,v 1.16 2022 */ static struct { - /* + /*- * 0 means outside a while loop with a getopt call. * 1 means directly inside a while loop with a getopt call. * > 1 means in a nested while loop; this is used for finishing the @@ -61,8 +61,8 @@ static struct { /* * The options string from the getopt call. Whenever an option is - * handled by a case label, it is set to ' '. In the end, only ' ' - * and ':' should remain. + * handled by a case label, it is set to ' '. In the end, only ' ' and + * ':' should remain. */ pos_t options_pos; char *options; Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.381 src/usr.bin/xlint/lint1/decl.c:1.382 --- src/usr.bin/xlint/lint1/decl.c:1.381 Sun Dec 3 12:03:38 2023 +++ src/usr.bin/xlint/lint1/decl.c Sun Dec 3 13:12:40 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.381 2023/12/03 12:03:38 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.382 2023/12/03 13:12:40 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.381 2023/12/03 12:03:38 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.382 2023/12/03 13:12:40 rillig Exp $"); #endif #include @@ -150,10 +150,10 @@ expr_unqualified_type(const type_t *tp) /* * In case of a struct or union type, the members should lose their - * qualifiers as well, but that would require a deep copy of the - * struct or union type. This in turn would defeat the type - * comparison in types_compatible, which simply tests whether - * tp1->t_sou == tp2->t_sou. + * qualifiers as well, but that would require a deep copy of the struct + * or union type. This in turn would defeat the type comparison in + * types_compatible, which simply tests
CVS commit: src/usr.bin/xlint
Module Name:src Committed By: rillig Date: Sun Dec 3 13:12:40 UTC 2023 Modified Files: src/usr.bin/xlint/lint1: ckctype.c ckgetopt.c decl.c emit1.c err.c func.c init.c lex.c lint1.h mem1.c tree.c src/usr.bin/xlint/lint2: chk.c lint2.h read.c src/usr.bin/xlint/xlint: xlint.c Log Message: lint: re-wrap comments No functional change. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/usr.bin/xlint/lint1/ckctype.c cvs rdiff -u -r1.16 -r1.17 src/usr.bin/xlint/lint1/ckgetopt.c cvs rdiff -u -r1.381 -r1.382 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.79 -r1.80 src/usr.bin/xlint/lint1/emit1.c cvs rdiff -u -r1.218 -r1.219 src/usr.bin/xlint/lint1/err.c cvs rdiff -u -r1.176 -r1.177 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.251 -r1.252 src/usr.bin/xlint/lint1/init.c cvs rdiff -u -r1.194 -r1.195 src/usr.bin/xlint/lint1/lex.c cvs rdiff -u -r1.203 -r1.204 src/usr.bin/xlint/lint1/lint1.h cvs rdiff -u -r1.75 -r1.76 src/usr.bin/xlint/lint1/mem1.c cvs rdiff -u -r1.585 -r1.586 src/usr.bin/xlint/lint1/tree.c cvs rdiff -u -r1.63 -r1.64 src/usr.bin/xlint/lint2/chk.c cvs rdiff -u -r1.25 -r1.26 src/usr.bin/xlint/lint2/lint2.h cvs rdiff -u -r1.88 -r1.89 src/usr.bin/xlint/lint2/read.c cvs rdiff -u -r1.118 -r1.119 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: Sun Dec 3 12:24:49 UTC 2023 Modified Files: src/usr.bin/xlint/common: lint.h src/usr.bin/xlint/lint1: tree.c src/usr.bin/xlint/lint2: lint2.h Log Message: lint: move function body brace to the left No functional change. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/usr.bin/xlint/common/lint.h cvs rdiff -u -r1.584 -r1.585 src/usr.bin/xlint/lint1/tree.c cvs rdiff -u -r1.24 -r1.25 src/usr.bin/xlint/lint2/lint2.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/xlint/common/lint.h diff -u src/usr.bin/xlint/common/lint.h:1.44 src/usr.bin/xlint/common/lint.h:1.45 --- src/usr.bin/xlint/common/lint.h:1.44 Wed Sep 13 20:31:58 2023 +++ src/usr.bin/xlint/common/lint.h Sun Dec 3 12:24:48 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lint.h,v 1.44 2023/09/13 20:31:58 rillig Exp $ */ +/* $NetBSD: lint.h,v 1.45 2023/12/03 12:24:48 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -120,7 +120,8 @@ typedef struct { extern ttab_t ttab[]; static inline const ttab_t * -type_properties(tspec_t t) { +type_properties(tspec_t t) +{ return ttab + t; } @@ -154,12 +155,31 @@ typedef struct lint2_type type_t; #include "externs.h" static inline bool -ch_isalnum(char ch) { return isalnum((unsigned char)ch) != 0; } +ch_isalnum(char ch) +{ + return isalnum((unsigned char)ch) != 0; +} + static inline bool -ch_isdigit(char ch) { return isdigit((unsigned char)ch) != 0; } +ch_isdigit(char ch) +{ + return isdigit((unsigned char)ch) != 0; +} + static inline bool -ch_isprint(char ch) { return isprint((unsigned char)ch) != 0; } +ch_isprint(char ch) +{ + return isprint((unsigned char)ch) != 0; +} + static inline bool -ch_isspace(char ch) { return isspace((unsigned char)ch) != 0; } +ch_isspace(char ch) +{ + return isspace((unsigned char)ch) != 0; +} + static inline bool -ch_isupper(char ch) { return isupper((unsigned char)ch) != 0; } +ch_isupper(char ch) +{ + return isupper((unsigned char)ch) != 0; +} Index: src/usr.bin/xlint/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.584 src/usr.bin/xlint/lint1/tree.c:1.585 --- src/usr.bin/xlint/lint1/tree.c:1.584 Sun Dec 3 12:03:38 2023 +++ src/usr.bin/xlint/lint1/tree.c Sun Dec 3 12:24:49 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.584 2023/12/03 12:03:38 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.585 2023/12/03 12:24:49 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: tree.c,v 1.584 2023/12/03 12:03:38 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.585 2023/12/03 12:24:49 rillig Exp $"); #endif #include @@ -93,7 +93,8 @@ width_in_bits(const type_t *tp) } static int -portable_rank_cmp(tspec_t t1, tspec_t t2) { +portable_rank_cmp(tspec_t t1, tspec_t t2) +{ const ttab_t *p1 = type_properties(t1), *p2 = type_properties(t2); lint_assert(p1->tt_rank_kind == p2->tt_rank_kind); lint_assert(p1->tt_rank_value > 0); Index: src/usr.bin/xlint/lint2/lint2.h diff -u src/usr.bin/xlint/lint2/lint2.h:1.24 src/usr.bin/xlint/lint2/lint2.h:1.25 --- src/usr.bin/xlint/lint2/lint2.h:1.24 Thu Jul 13 08:40:38 2023 +++ src/usr.bin/xlint/lint2/lint2.h Sun Dec 3 12:24:49 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lint2.h,v 1.24 2023/07/13 08:40:38 rillig Exp $ */ +/* $NetBSD: lint2.h,v 1.25 2023/12/03 12:24:49 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -186,7 +186,8 @@ typedef struct hte { /* maps type indices into pointers to type structs */ static inline type_t * -TP(unsigned short type_id) { +TP(unsigned short type_id) +{ /* force sequence point for newly parsed type_id */ return tlst[type_id]; }
CVS commit: src/usr.bin/xlint
Module Name:src Committed By: rillig Date: Sun Dec 3 12:24:49 UTC 2023 Modified Files: src/usr.bin/xlint/common: lint.h src/usr.bin/xlint/lint1: tree.c src/usr.bin/xlint/lint2: lint2.h Log Message: lint: move function body brace to the left No functional change. To generate a diff of this commit: cvs rdiff -u -r1.44 -r1.45 src/usr.bin/xlint/common/lint.h cvs rdiff -u -r1.584 -r1.585 src/usr.bin/xlint/lint1/tree.c cvs rdiff -u -r1.24 -r1.25 src/usr.bin/xlint/lint2/lint2.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: Sun Dec 3 12:03:38 UTC 2023 Modified Files: src/usr.bin/xlint/lint1: ckbool.c ckctype.c debug.c decl.c emit1.c func.c lex.c mem1.c tree.c src/usr.bin/xlint/lint2: chk.c read.c src/usr.bin/xlint/xlint: xlint.c Log Message: lint: indent statement continuations consistently No binary change. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/usr.bin/xlint/lint1/ckbool.c cvs rdiff -u -r1.7 -r1.8 src/usr.bin/xlint/lint1/ckctype.c cvs rdiff -u -r1.64 -r1.65 src/usr.bin/xlint/lint1/debug.c cvs rdiff -u -r1.380 -r1.381 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.78 -r1.79 src/usr.bin/xlint/lint1/emit1.c cvs rdiff -u -r1.175 -r1.176 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.193 -r1.194 src/usr.bin/xlint/lint1/lex.c cvs rdiff -u -r1.74 -r1.75 src/usr.bin/xlint/lint1/mem1.c cvs rdiff -u -r1.583 -r1.584 src/usr.bin/xlint/lint1/tree.c cvs rdiff -u -r1.62 -r1.63 src/usr.bin/xlint/lint2/chk.c cvs rdiff -u -r1.87 -r1.88 src/usr.bin/xlint/lint2/read.c cvs rdiff -u -r1.117 -r1.118 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/lint1/ckbool.c diff -u src/usr.bin/xlint/lint1/ckbool.c:1.26 src/usr.bin/xlint/lint1/ckbool.c:1.27 --- src/usr.bin/xlint/lint1/ckbool.c:1.26 Wed Aug 2 18:51:25 2023 +++ src/usr.bin/xlint/lint1/ckbool.c Sun Dec 3 12:03:38 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ckbool.c,v 1.26 2023/08/02 18:51:25 rillig Exp $ */ +/* $NetBSD: ckbool.c,v 1.27 2023/12/03 12:03:38 rillig Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: ckbool.c,v 1.26 2023/08/02 18:51:25 rillig Exp $"); +__RCSID("$NetBSD: ckbool.c,v 1.27 2023/12/03 12:03:38 rillig Exp $"); #endif #include @@ -58,16 +58,16 @@ static bool is_assignment_bool_or_other(op_t op) { return op == ASSIGN || - op == ANDASS || op == XORASS || op == ORASS || - op == RETURN || op == INIT || op == FARG; + op == ANDASS || op == XORASS || op == ORASS || + op == RETURN || op == INIT || op == FARG; } static bool is_symmetric_bool_or_other(op_t op) { return op == EQ || op == NE || - op == BITAND || op == BITXOR || op == BITOR || - op == COLON; + op == BITAND || op == BITXOR || op == BITOR || + op == COLON; } static bool Index: src/usr.bin/xlint/lint1/ckctype.c diff -u src/usr.bin/xlint/lint1/ckctype.c:1.7 src/usr.bin/xlint/lint1/ckctype.c:1.8 --- src/usr.bin/xlint/lint1/ckctype.c:1.7 Wed Sep 13 20:31:58 2023 +++ src/usr.bin/xlint/lint1/ckctype.c Sun Dec 3 12:03:38 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: ckctype.c,v 1.7 2023/09/13 20:31:58 rillig Exp $ */ +/* $NetBSD: ckctype.c,v 1.8 2023/12/03 12:03:38 rillig Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: ckctype.c,v 1.7 2023/09/13 20:31:58 rillig Exp $"); +__RCSID("$NetBSD: ckctype.c,v 1.8 2023/12/03 12:03:38 rillig Exp $"); #endif #include @@ -61,21 +61,21 @@ is_ctype_function(const char *name) if (name[0] == 'i' && name[1] == 's') return strcmp(name, "isalnum") == 0 || - strcmp(name, "isalpha") == 0 || - strcmp(name, "isblank") == 0 || - strcmp(name, "iscntrl") == 0 || - strcmp(name, "isdigit") == 0 || - strcmp(name, "isgraph") == 0 || - strcmp(name, "islower") == 0 || - strcmp(name, "isprint") == 0 || - strcmp(name, "ispunct") == 0 || - strcmp(name, "isspace") == 0 || - strcmp(name, "isupper") == 0 || - strcmp(name, "isxdigit") == 0; + strcmp(name, "isalpha") == 0 || + strcmp(name, "isblank") == 0 || + strcmp(name, "iscntrl") == 0 || + strcmp(name, "isdigit") == 0 || + strcmp(name, "isgraph") == 0 || + strcmp(name, "islower") == 0 || + strcmp(name, "isprint") == 0 || + strcmp(name, "ispunct") == 0 || + strcmp(name, "isspace") == 0 || + strcmp(name, "isupper") == 0 || + strcmp(name, "isxdigit") == 0; if (name[0] == 't' && name[1] == 'o') return strcmp(name, "tolower") == 0 || - strcmp(name, "toupper") == 0; + strcmp(name, "toupper") == 0; return false; } Index: src/usr.bin/xlint/lint1/debug.c diff -u src/usr.bin/xlint/lint1/debug.c:1.64 src/usr.bin/xlint/lint1/debug.c:1.65 --- src/usr.bin/xlint/lint1/debug.c:1.64 Sat Dec 2 21:47:05 2023 +++ src/usr.bin/xlint/lint1/debug.c Sun Dec 3 12:03:38 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.64 2023/12/02 21:47:05 rillig Exp $ */ +/* $NetBSD: debug.c,v 1.65 2023/12/03 12:03:38 rillig Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: debug.c,v 1.64 2023/12/02 21:47:05 rillig Exp $"); +__RCSID("$NetBSD: debug.c,v 1.65
CVS commit: src/usr.bin/xlint
Module Name:src Committed By: rillig Date: Sun Dec 3 12:03:38 UTC 2023 Modified Files: src/usr.bin/xlint/lint1: ckbool.c ckctype.c debug.c decl.c emit1.c func.c lex.c mem1.c tree.c src/usr.bin/xlint/lint2: chk.c read.c src/usr.bin/xlint/xlint: xlint.c Log Message: lint: indent statement continuations consistently No binary change. To generate a diff of this commit: cvs rdiff -u -r1.26 -r1.27 src/usr.bin/xlint/lint1/ckbool.c cvs rdiff -u -r1.7 -r1.8 src/usr.bin/xlint/lint1/ckctype.c cvs rdiff -u -r1.64 -r1.65 src/usr.bin/xlint/lint1/debug.c cvs rdiff -u -r1.380 -r1.381 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.78 -r1.79 src/usr.bin/xlint/lint1/emit1.c cvs rdiff -u -r1.175 -r1.176 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.193 -r1.194 src/usr.bin/xlint/lint1/lex.c cvs rdiff -u -r1.74 -r1.75 src/usr.bin/xlint/lint1/mem1.c cvs rdiff -u -r1.583 -r1.584 src/usr.bin/xlint/lint1/tree.c cvs rdiff -u -r1.62 -r1.63 src/usr.bin/xlint/lint2/chk.c cvs rdiff -u -r1.87 -r1.88 src/usr.bin/xlint/lint2/read.c cvs rdiff -u -r1.117 -r1.118 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/tests/lib/libcurses
Module Name:src Committed By: rillig Date: Sun Dec 3 09:42:36 UTC 2023 Modified Files: src/tests/lib/libcurses: testframe.txt Log Message: tests/libcurses: sync documentation with reality Unknown escape sequences in string literals trigger an error, since testlang_conf.l 1.22 from 2021-02-25. The '\b' is recognized since testlang_conf.l 1.26 from 2021-11-15. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libcurses/testframe.txt Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/lib/libcurses/testframe.txt diff -u src/tests/lib/libcurses/testframe.txt:1.8 src/tests/lib/libcurses/testframe.txt:1.9 --- src/tests/lib/libcurses/testframe.txt:1.8 Tue Feb 9 20:31:02 2021 +++ src/tests/lib/libcurses/testframe.txt Sun Dec 3 09:42:36 2023 @@ -1,4 +1,4 @@ -$NetBSD: testframe.txt,v 1.8 2021/02/09 20:31:02 rillig Exp $ +$NetBSD: testframe.txt,v 1.9 2023/12/03 09:42:36 rillig Exp $ CURSES TESTFRAME @@ -231,6 +231,7 @@ performed on them when they are parsed. embed some control characters into the string. Valid substitutions are: + \b backspace \e escape \n new line \r carriage return @@ -240,9 +241,6 @@ are: represented by the octal number will be inserted into the string. -Any other invalid conversions will have the \ stripped and the -subsequent characters inserted into the string. - Integers may be specified by either a plain numeric (e.g. 12345) or by hexadecimal notation by prefixing the number with 0x (e.g. 0x3039). Internally, no distinction is made between the two formats and they
CVS commit: src/tests/lib/libcurses
Module Name:src Committed By: rillig Date: Sun Dec 3 09:42:36 UTC 2023 Modified Files: src/tests/lib/libcurses: testframe.txt Log Message: tests/libcurses: sync documentation with reality Unknown escape sequences in string literals trigger an error, since testlang_conf.l 1.22 from 2021-02-25. The '\b' is recognized since testlang_conf.l 1.26 from 2021-11-15. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libcurses/testframe.txt 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/xlint/lint1
Module Name:src Committed By: rillig Date: Sat Dec 2 23:54:49 UTC 2023 Modified Files: src/tests/usr.bin/xlint/lint1: platform_schar.c platform_uchar.c Log Message: tests/lint: add more test cases for nonportable character comparison To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/platform_schar.c cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/platform_uchar.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/xlint/lint1/platform_schar.c diff -u src/tests/usr.bin/xlint/lint1/platform_schar.c:1.4 src/tests/usr.bin/xlint/lint1/platform_schar.c:1.5 --- src/tests/usr.bin/xlint/lint1/platform_schar.c:1.4 Wed Feb 22 22:30:40 2023 +++ src/tests/usr.bin/xlint/lint1/platform_schar.c Sat Dec 2 23:54:49 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: platform_schar.c,v 1.4 2023/02/22 22:30:40 rillig Exp $ */ +/* $NetBSD: platform_schar.c,v 1.5 2023/12/02 23:54:49 rillig Exp $ */ # 3 "platform_schar.c" /* @@ -6,9 +6,14 @@ * representation as signed char. */ -/* lint1-extra-flags: -c -h -a -p -b -r -z */ +/* lint1-extra-flags: -c -h -a -p -b -r -z -X 161 */ /* lint1-only-if: schar */ -/* CONSTCOND */ /* expect+1: warning: nonportable character comparison '-128 < ?' [230] */ -typedef int is_signed[(char)'\200' < (char)'\177' ? 1 : -1]; +typedef int char_char[(char)'\200' < (char)'\177' ? 1 : -1]; +/* expect+1: warning: nonportable character comparison '-128 < ?' [230] */ +typedef int char_int[(char)'\200' < (char)127 ? 1 : -1]; +/* expect+1: warning: nonportable character comparison '-128 < ?' [230] */ +typedef int int_char[(char)-128 < (char)'\177' ? 1 : -1]; +/* expect+1: warning: nonportable character comparison '-128 < ?' [230] */ +typedef int int_int[(char)-128 < (char)127 ? 1 : -1]; Index: src/tests/usr.bin/xlint/lint1/platform_uchar.c diff -u src/tests/usr.bin/xlint/lint1/platform_uchar.c:1.3 src/tests/usr.bin/xlint/lint1/platform_uchar.c:1.4 --- src/tests/usr.bin/xlint/lint1/platform_uchar.c:1.3 Wed Feb 22 22:12:35 2023 +++ src/tests/usr.bin/xlint/lint1/platform_uchar.c Sat Dec 2 23:54:49 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: platform_uchar.c,v 1.3 2023/02/22 22:12:35 rillig Exp $ */ +/* $NetBSD: platform_uchar.c,v 1.4 2023/12/02 23:54:49 rillig Exp $ */ # 3 "platform_uchar.c" /* @@ -6,9 +6,14 @@ * representation as unsigned char. */ -/* lint1-extra-flags: -c -h -a -p -b -r -z */ +/* lint1-extra-flags: -c -h -a -p -b -r -z -X 161 */ /* lint1-only-if: uchar */ -/* CONSTCOND */ /* expect+1: warning: nonportable character comparison '< 128' [230] */ -typedef int is_unsigned[(char)'\177' < (char)'\200' ? 1 : -1]; +typedef int char_char[(char)'\177' < (char)'\200' ? 1 : -1]; +/* expect+1: warning: nonportable character comparison '< 128' [230] */ +typedef int int_char[(char)127 < (char)'\200' ? 1 : -1]; +/* expect+1: warning: nonportable character comparison '< 128' [230] */ +typedef int char_int[(char)'\177' < (char)128 ? 1 : -1]; +/* expect+1: warning: nonportable character comparison '< 128' [230] */ +typedef int int_int[(char)127 < (char)128 ? 1 : -1];
CVS commit: src/tests/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sat Dec 2 23:54:49 UTC 2023 Modified Files: src/tests/usr.bin/xlint/lint1: platform_schar.c platform_uchar.c Log Message: tests/lint: add more test cases for nonportable character comparison To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/xlint/lint1/platform_schar.c cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/xlint/lint1/platform_uchar.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/lint1
Module Name:src Committed By: rillig Date: Sat Dec 2 21:53:15 UTC 2023 Modified Files: src/usr.bin/xlint/lint1: tree.c Log Message: lint: extract nonportable char comparison to separate function No functional change. To generate a diff of this commit: cvs rdiff -u -r1.582 -r1.583 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/lint1/tree.c diff -u src/usr.bin/xlint/lint1/tree.c:1.582 src/usr.bin/xlint/lint1/tree.c:1.583 --- src/usr.bin/xlint/lint1/tree.c:1.582 Sat Dec 2 21:47:05 2023 +++ src/usr.bin/xlint/lint1/tree.c Sat Dec 2 21:53:15 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.582 2023/12/02 21:47:05 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.583 2023/12/02 21:53:15 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: tree.c,v 1.582 2023/12/02 21:47:05 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.583 2023/12/02 21:53:15 rillig Exp $"); #endif #include @@ -576,6 +576,33 @@ is_out_of_char_range(const tnode_t *tn) tn->tn_val.u.integer < 1 << (CHAR_SIZE - 1)); } +static bool +check_nonportable_char_comparison(op_t op, + const tnode_t *ln, tspec_t lt, + const tnode_t *rn, tspec_t rt) +{ + if (!(hflag || pflag)) + return true; + + if (lt == CHAR && is_out_of_char_range(rn)) { + char buf[128]; + (void)snprintf(buf, sizeof(buf), "%s %d", + op_name(op), (int)rn->tn_val.u.integer); + /* nonportable character comparison '%s' */ + warning(230, buf); + return false; + } + if (rt == CHAR && is_out_of_char_range(ln)) { + char buf[128]; + (void)snprintf(buf, sizeof(buf), "%d %s ?", + (int)ln->tn_val.u.integer, op_name(op)); + /* nonportable character comparison '%s' */ + warning(230, buf); + return false; + } + return true; +} + static void check_integer_comparison(op_t op, tnode_t *ln, tnode_t *rn) { @@ -604,24 +631,8 @@ check_integer_comparison(op_t op, tnode_ } } - if (hflag || pflag) { - if (lt == CHAR && is_out_of_char_range(rn)) { - char buf[128]; - (void)snprintf(buf, sizeof(buf), "%s %d", - op_name(op), (int)rn->tn_val.u.integer); - /* nonportable character comparison '%s' */ - warning(230, buf); - return; - } - if (rt == CHAR && is_out_of_char_range(ln)) { - char buf[128]; - (void)snprintf(buf, sizeof(buf), "%d %s ?", - (int)ln->tn_val.u.integer, op_name(op)); - /* nonportable character comparison '%s' */ - warning(230, buf); - return; - } - } + if (!check_nonportable_char_comparison(op, ln, lt, rn, rt)) + return; if (is_uinteger(lt) && !is_uinteger(rt) && rn->tn_op == CON && rn->tn_val.u.integer <= 0) {
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sat Dec 2 21:53:15 UTC 2023 Modified Files: src/usr.bin/xlint/lint1: tree.c Log Message: lint: extract nonportable char comparison to separate function No functional change. To generate a diff of this commit: cvs rdiff -u -r1.582 -r1.583 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: Sat Dec 2 21:50:21 UTC 2023 Modified Files: src/usr.bin/xlint/lint1: emit1.c func.c init.c src/usr.bin/xlint/lint2: chk.c Log Message: lint: remove redundant empty lines No functional change. To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/usr.bin/xlint/lint1/emit1.c cvs rdiff -u -r1.174 -r1.175 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.250 -r1.251 src/usr.bin/xlint/lint1/init.c cvs rdiff -u -r1.61 -r1.62 src/usr.bin/xlint/lint2/chk.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/lint1/emit1.c diff -u src/usr.bin/xlint/lint1/emit1.c:1.77 src/usr.bin/xlint/lint1/emit1.c:1.78 --- src/usr.bin/xlint/lint1/emit1.c:1.77 Wed Sep 13 20:31:58 2023 +++ src/usr.bin/xlint/lint1/emit1.c Sat Dec 2 21:50:20 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: emit1.c,v 1.77 2023/09/13 20:31:58 rillig Exp $ */ +/* $NetBSD: emit1.c,v 1.78 2023/12/02 21:50:20 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.77 2023/09/13 20:31:58 rillig Exp $"); +__RCSID("$NetBSD: emit1.c,v 1.78 2023/12/02 21:50:20 rillig Exp $"); #endif #include "lint1.h" @@ -374,7 +374,6 @@ outcall(const tnode_t *tn, bool retval_u outint(n); outfstrg(arg->tn_left->tn_string); } - } outchar((char)(retval_discarded ? 'd' : retval_used ? 'u' : 'i')); @@ -539,7 +538,6 @@ outfstrg(strg_t *strg) } } } - } outchar('"'); Index: src/usr.bin/xlint/lint1/func.c diff -u src/usr.bin/xlint/lint1/func.c:1.174 src/usr.bin/xlint/lint1/func.c:1.175 --- src/usr.bin/xlint/lint1/func.c:1.174 Sun Aug 6 19:44:50 2023 +++ src/usr.bin/xlint/lint1/func.c Sat Dec 2 21:50:20 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: func.c,v 1.174 2023/08/06 19:44:50 rillig Exp $ */ +/* $NetBSD: func.c,v 1.175 2023/12/02 21:50:20 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: func.c,v 1.174 2023/08/06 19:44:50 rillig Exp $"); +__RCSID("$NetBSD: func.c,v 1.175 2023/12/02 21:50:20 rillig Exp $"); #endif #include @@ -318,12 +318,10 @@ begin_function(sym_t *fsym) if (rdsym->s_inline) fsym->s_inline = true; - } /* remove the old symbol from the symbol table */ rmsym(rdsym); - } if (fsym->s_osdef && !fsym->s_type->t_proto) { Index: src/usr.bin/xlint/lint1/init.c diff -u src/usr.bin/xlint/lint1/init.c:1.250 src/usr.bin/xlint/lint1/init.c:1.251 --- src/usr.bin/xlint/lint1/init.c:1.250 Sun Jul 30 22:27:21 2023 +++ src/usr.bin/xlint/lint1/init.c Sat Dec 2 21:50:20 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: init.c,v 1.250 2023/07/30 22:27:21 rillig Exp $ */ +/* $NetBSD: init.c,v 1.251 2023/12/02 21:50:20 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -38,7 +38,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: init.c,v 1.250 2023/07/30 22:27:21 rillig Exp $"); +__RCSID("$NetBSD: init.c,v 1.251 2023/12/02 21:50:20 rillig Exp $"); #endif #include @@ -598,7 +598,6 @@ warn_too_many_initializers(designator_ki /* too many initializers */ error(174); } - } static bool Index: src/usr.bin/xlint/lint2/chk.c diff -u src/usr.bin/xlint/lint2/chk.c:1.61 src/usr.bin/xlint/lint2/chk.c:1.62 --- src/usr.bin/xlint/lint2/chk.c:1.61 Sat Aug 26 10:43:53 2023 +++ src/usr.bin/xlint/lint2/chk.c Sat Dec 2 21:50:21 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: chk.c,v 1.61 2023/08/26 10:43:53 rillig Exp $ */ +/* $NetBSD: chk.c,v 1.62 2023/12/02 21:50:21 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: chk.c,v 1.61 2023/08/26 10:43:53 rillig Exp $"); +__RCSID("$NetBSD: chk.c,v 1.62 2023/12/02 21:50:21 rillig Exp $"); #endif #include @@ -1302,7 +1302,6 @@ types_compatible(type_t *tp1, type_t *tp ignqual = promot = false; to = t; indir++; - } return tp1 == tp2; @@ -1329,7 +1328,6 @@ prototypes_compatible(type_t *tp1, type_ a1++; a2++; - } return *a1 == *a2;
CVS commit: src/usr.bin/xlint
Module Name:src Committed By: rillig Date: Sat Dec 2 21:50:21 UTC 2023 Modified Files: src/usr.bin/xlint/lint1: emit1.c func.c init.c src/usr.bin/xlint/lint2: chk.c Log Message: lint: remove redundant empty lines No functional change. To generate a diff of this commit: cvs rdiff -u -r1.77 -r1.78 src/usr.bin/xlint/lint1/emit1.c cvs rdiff -u -r1.174 -r1.175 src/usr.bin/xlint/lint1/func.c cvs rdiff -u -r1.250 -r1.251 src/usr.bin/xlint/lint1/init.c cvs rdiff -u -r1.61 -r1.62 src/usr.bin/xlint/lint2/chk.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/lint1
Module Name:src Committed By: rillig Date: Sat Dec 2 21:47:05 UTC 2023 Modified Files: src/usr.bin/xlint/lint1: debug.c decl.c lex.c lint1.h tree.c Log Message: lint: rename NOSCL to NO_SCL For symmetry with NO_TSPEC. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.63 -r1.64 src/usr.bin/xlint/lint1/debug.c cvs rdiff -u -r1.379 -r1.380 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.192 -r1.193 src/usr.bin/xlint/lint1/lex.c cvs rdiff -u -r1.202 -r1.203 src/usr.bin/xlint/lint1/lint1.h cvs rdiff -u -r1.581 -r1.582 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/lint1
Module Name:src Committed By: rillig Date: Sat Dec 2 21:47:05 UTC 2023 Modified Files: src/usr.bin/xlint/lint1: debug.c decl.c lex.c lint1.h tree.c Log Message: lint: rename NOSCL to NO_SCL For symmetry with NO_TSPEC. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.63 -r1.64 src/usr.bin/xlint/lint1/debug.c cvs rdiff -u -r1.379 -r1.380 src/usr.bin/xlint/lint1/decl.c cvs rdiff -u -r1.192 -r1.193 src/usr.bin/xlint/lint1/lex.c cvs rdiff -u -r1.202 -r1.203 src/usr.bin/xlint/lint1/lint1.h cvs rdiff -u -r1.581 -r1.582 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/lint1/debug.c diff -u src/usr.bin/xlint/lint1/debug.c:1.63 src/usr.bin/xlint/lint1/debug.c:1.64 --- src/usr.bin/xlint/lint1/debug.c:1.63 Tue Oct 17 19:29:09 2023 +++ src/usr.bin/xlint/lint1/debug.c Sat Dec 2 21:47:05 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.63 2023/10/17 19:29:09 rillig Exp $ */ +/* $NetBSD: debug.c,v 1.64 2023/12/02 21:47:05 rillig Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: debug.c,v 1.63 2023/10/17 19:29:09 rillig Exp $"); +__RCSID("$NetBSD: debug.c,v 1.64 2023/12/02 21:47:05 rillig Exp $"); #endif #include @@ -385,7 +385,7 @@ debug_sym(const char *prefix, const sym_ debug_word(sym->s_osdef, "old-style"); debug_word(sym->s_inline, "inline"); debug_word(sym->s_ext_sym != NULL, "has-external"); - debug_word(sym->s_scl != NOSCL, scl_name(sym->s_scl)); + debug_word(sym->s_scl != NO_SCL, scl_name(sym->s_scl)); debug_word(sym->s_keyword == NULL, def_name(sym->s_def)); if (sym->s_def_pos.p_file != NULL) @@ -441,7 +441,7 @@ debug_decl_level(const decl_level *dl) { debug_printf("kind=%s", decl_level_kind_name(dl->d_kind)); - if (dl->d_scl != NOSCL) + if (dl->d_scl != NO_SCL) debug_printf(" %s", scl_name(dl->d_scl)); if (dl->d_type != NULL) debug_printf(" '%s'", type_name(dl->d_type)); Index: src/usr.bin/xlint/lint1/decl.c diff -u src/usr.bin/xlint/lint1/decl.c:1.379 src/usr.bin/xlint/lint1/decl.c:1.380 --- src/usr.bin/xlint/lint1/decl.c:1.379 Thu Sep 14 21:53:02 2023 +++ src/usr.bin/xlint/lint1/decl.c Sat Dec 2 21:47:05 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.379 2023/09/14 21:53:02 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.380 2023/12/02 21:47:05 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.379 2023/09/14 21:53:02 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.380 2023/12/02 21:47:05 rillig Exp $"); #endif #include @@ -206,7 +206,7 @@ dcs_add_storage_class(scl_t sc) warning(83); } - if (dcs->d_scl == NOSCL) + if (dcs->d_scl == NO_SCL) dcs->d_scl = sc; else if ((dcs->d_scl == EXTERN && sc == THREAD_LOCAL) || (dcs->d_scl == THREAD_LOCAL && sc == EXTERN)) @@ -607,7 +607,7 @@ dcs_begin_type(void) dcs->d_complex_mod = NO_TSPEC; dcs->d_sign_mod = NO_TSPEC; dcs->d_rank_mod = NO_TSPEC; - dcs->d_scl = NOSCL; + dcs->d_scl = NO_SCL; dcs->d_type = NULL; dcs->d_redeclared_symbol = NULL; dcs->d_qual = (type_qualifiers) { .tq_const = false }; @@ -630,14 +630,14 @@ dcs_adjust_storage_class(void) if (dcs->d_scl == REG || dcs->d_scl == AUTO) { /* illegal storage class */ error(8); - dcs->d_scl = NOSCL; + dcs->d_scl = NO_SCL; } } else if (dcs->d_kind == DLK_OLD_STYLE_PARAMS || dcs->d_kind == DLK_PROTO_PARAMS) { - if (dcs->d_scl != NOSCL && dcs->d_scl != REG) { + if (dcs->d_scl != NO_SCL && dcs->d_scl != REG) { /* only 'register' is valid as storage class ... */ error(9); - dcs->d_scl = NOSCL; + dcs->d_scl = NO_SCL; } } } @@ -1431,9 +1431,9 @@ check_function_definition(sym_t *sym, bo sym_t * declarator_name(sym_t *sym) { - scl_t sc = NOSCL; + scl_t sc = NO_SCL; - if (sym->s_scl == NOSCL) + if (sym->s_scl == NO_SCL) dcs->d_redeclared_symbol = NULL; else if (sym->s_defparam) { sym->s_defparam = false; @@ -1458,7 +1458,7 @@ declarator_name(sym_t *sym) * or this is a function definition. */ sc = dcs->d_scl; - if (sc == NOSCL || sc == THREAD_LOCAL) { + if (sc == NO_SCL || sc == THREAD_LOCAL) { sc = EXTERN; sym->s_def = TDEF; } else if (sc == STATIC) @@ -1474,13 +1474,13 @@ declarator_name(sym_t *sym) sym->s_param = true; /* FALLTHROUGH */ case DLK_OLD_STYLE_PARAMS: - lint_assert(dcs->d_scl == NOSCL || dcs->d_scl == REG); + lint_assert(dcs->d_scl == NO_SCL || dcs->d_scl == REG); sym->s_register = dcs->d_scl == REG; sc = AUTO; sym->s_def = DEF; break; case DLK_AUTO: - if ((sc = dcs->d_scl) == NOSCL) { + if ((sc = dcs->d_scl) == NO_SCL) { /* * XXX somewhat ugly because we don't know whether this * is AUTO or EXTERN (functions). If we are wrong, it @@ -1504,7
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 19 22:50:11 UTC 2023 Modified Files: src/usr.bin/make: arch.c cond.c for.c parse.c suff.c var.c Log Message: make: replace 'variable expression' with 'expression' in comments No binary change. To generate a diff of this commit: cvs rdiff -u -r1.213 -r1.214 src/usr.bin/make/arch.c cvs rdiff -u -r1.354 -r1.355 src/usr.bin/make/cond.c cvs rdiff -u -r1.176 -r1.177 src/usr.bin/make/for.c cvs rdiff -u -r1.709 -r1.710 src/usr.bin/make/parse.c cvs rdiff -u -r1.369 -r1.370 src/usr.bin/make/suff.c cvs rdiff -u -r1.1074 -r1.1075 src/usr.bin/make/var.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/make/arch.c diff -u src/usr.bin/make/arch.c:1.213 src/usr.bin/make/arch.c:1.214 --- src/usr.bin/make/arch.c:1.213 Tue Feb 14 21:08:00 2023 +++ src/usr.bin/make/arch.c Sun Nov 19 22:50:11 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: arch.c,v 1.213 2023/02/14 21:08:00 rillig Exp $ */ +/* $NetBSD: arch.c,v 1.214 2023/11/19 22:50:11 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -126,7 +126,7 @@ #include "config.h" /* "@(#)arch.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: arch.c,v 1.213 2023/02/14 21:08:00 rillig Exp $"); +MAKE_RCSID("$NetBSD: arch.c,v 1.214 2023/11/19 22:50:11 rillig Exp $"); typedef struct List ArchList; typedef struct ListNode ArchListNode; @@ -205,7 +205,7 @@ Arch_ParseArchive(char **pp, GNodeList * FStr lib; /* Library-part of specification */ FStr mem; /* Member-part of specification */ char saveChar; /* Ending delimiter of member-name */ - bool expandLib; /* Whether the parsed lib contains variable + bool expandLib; /* Whether the parsed lib contains * expressions that need to be expanded */ spec = *pp; @@ -214,7 +214,7 @@ Arch_ParseArchive(char **pp, GNodeList * for (cp = lib.str; *cp != '(' && *cp != '\0';) { if (*cp == '$') { - /* Expand nested variable expressions. */ + /* Expand nested expressions. */ /* XXX: This code can probably be shortened. */ const char *nested_p = cp; FStr result; @@ -251,7 +251,7 @@ Arch_ParseArchive(char **pp, GNodeList * mem = FStr_InitRefer(cp); while (*cp != '\0' && *cp != ')' && !ch_isspace(*cp)) { if (*cp == '$') { -/* Expand nested variable expressions. */ +/* Expand nested expressions. */ /* * XXX: This code can probably be shortened. */ Index: src/usr.bin/make/cond.c diff -u src/usr.bin/make/cond.c:1.354 src/usr.bin/make/cond.c:1.355 --- src/usr.bin/make/cond.c:1.354 Fri Aug 11 04:56:31 2023 +++ src/usr.bin/make/cond.c Sun Nov 19 22:50:11 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.354 2023/08/11 04:56:31 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.355 2023/11/19 22:50:11 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -92,7 +92,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.354 2023/08/11 04:56:31 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.355 2023/11/19 22:50:11 rillig Exp $"); /* * Conditional expressions conform to this grammar: @@ -154,10 +154,10 @@ typedef struct CondParser { * expanded before it is evaluated, due to ease of implementation. * This means that at the point where the condition is evaluated, * make cannot know anymore whether the left-hand side had originally - * been a variable expression or a plain word. + * been an expression or a plain word. * * In conditional directives like '.if', the left-hand side must - * either be a variable expression, a quoted string or a number. + * either be an expression, a quoted string or a number. */ bool leftUnquotedOK; @@ -383,7 +383,7 @@ is_separator(char ch) } /* - * In a quoted or unquoted string literal or a number, parse a variable + * In a quoted or unquoted string literal or a number, parse an * expression and add its value to the buffer. * * Return whether to continue parsing the leaf. @@ -429,7 +429,7 @@ CondParser_StringExpr(CondParser *par, c } /* - * Parse a string from a variable expression or an optionally quoted string, + * Parse a string from an expression or an optionally quoted string, * on the left-hand and right-hand sides of comparisons. * * Results: @@ -489,7 +489,7 @@ CondParser_Leaf(CondParser *par, bool do !ch_isdigit(*start)) { /* * The left-hand side must be quoted, - * a variable expression or a number. + * an expression or a number. */ str = FStr_InitRefer(NULL); goto return_str; @@ -734,7 +734,7 @@ CondParser_FuncCall(CondParser *par, boo /* * Parse a comparison that neither starts with '"' nor '$', such as the * unusual 'bare == right' or '3 == ${VAR}', or a simple leaf without - * operator, which is a number, a variable expression or a string literal. + * operator, which is a number, an
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 19 22:50:11 UTC 2023 Modified Files: src/usr.bin/make: arch.c cond.c for.c parse.c suff.c var.c Log Message: make: replace 'variable expression' with 'expression' in comments No binary change. To generate a diff of this commit: cvs rdiff -u -r1.213 -r1.214 src/usr.bin/make/arch.c cvs rdiff -u -r1.354 -r1.355 src/usr.bin/make/cond.c cvs rdiff -u -r1.176 -r1.177 src/usr.bin/make/for.c cvs rdiff -u -r1.709 -r1.710 src/usr.bin/make/parse.c cvs rdiff -u -r1.369 -r1.370 src/usr.bin/make/suff.c cvs rdiff -u -r1.1074 -r1.1075 src/usr.bin/make/var.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/make/unit-tests
Module Name:src Committed By: rillig Date: Sun Nov 19 22:32:44 UTC 2023 Modified Files: src/usr.bin/make/unit-tests: cond-short.mk dep-var.mk deptgt-makeflags.mk directive-for-escape.mk directive.mk moderrs.exp moderrs.mk var-op-default.mk varmod-indirect.mk varname-make_print_var_on_error-jobs.mk varparse-dynamic.mk varparse-errors.mk Log Message: tests/make: replace 'variable expressions' with 'expressions' To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/cond-short.mk \ src/usr.bin/make/unit-tests/directive-for-escape.mk cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/dep-var.mk cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/deptgt-makeflags.mk \ src/usr.bin/make/unit-tests/directive.mk cvs rdiff -u -r1.33 -r1.34 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.30 -r1.31 src/usr.bin/make/unit-tests/moderrs.mk cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/var-op-default.mk cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod-indirect.mk cvs rdiff -u -r1.3 -r1.4 \ src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.mk cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varparse-dynamic.mk cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/varparse-errors.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sun Nov 19 22:32:44 UTC 2023 Modified Files: src/usr.bin/make/unit-tests: cond-short.mk dep-var.mk deptgt-makeflags.mk directive-for-escape.mk directive.mk moderrs.exp moderrs.mk var-op-default.mk varmod-indirect.mk varname-make_print_var_on_error-jobs.mk varparse-dynamic.mk varparse-errors.mk Log Message: tests/make: replace 'variable expressions' with 'expressions' To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/cond-short.mk \ src/usr.bin/make/unit-tests/directive-for-escape.mk cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/dep-var.mk cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/deptgt-makeflags.mk \ src/usr.bin/make/unit-tests/directive.mk cvs rdiff -u -r1.33 -r1.34 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.30 -r1.31 src/usr.bin/make/unit-tests/moderrs.mk cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/var-op-default.mk cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod-indirect.mk cvs rdiff -u -r1.3 -r1.4 \ src/usr.bin/make/unit-tests/varname-make_print_var_on_error-jobs.mk cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varparse-dynamic.mk cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/varparse-errors.mk 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/make/unit-tests/cond-short.mk diff -u src/usr.bin/make/unit-tests/cond-short.mk:1.22 src/usr.bin/make/unit-tests/cond-short.mk:1.23 --- src/usr.bin/make/unit-tests/cond-short.mk:1.22 Sun Nov 19 21:47:52 2023 +++ src/usr.bin/make/unit-tests/cond-short.mk Sun Nov 19 22:32:44 2023 @@ -1,4 +1,4 @@ -# $NetBSD: cond-short.mk,v 1.22 2023/11/19 21:47:52 rillig Exp $ +# $NetBSD: cond-short.mk,v 1.23 2023/11/19 22:32:44 rillig Exp $ # # Demonstrates that in conditions, the right-hand side of an && or || # is only evaluated if it can actually influence the result. @@ -11,7 +11,7 @@ # Var_Parse got a new parameter named 'wantit'. Since then it would have been # possible to skip evaluation of irrelevant expressions and only # parse them. They were still evaluated though, the only difference to -# relevant expressions was that in the irrelevant variable +# relevant expressions was that in the irrelevant # expressions, undefined variables were allowed. This allowed for conditions # like 'defined(VAR) && ${VAR:S,from,to,} != ""', which no longer produced an # error message 'Malformed conditional', but the irrelevant expression was Index: src/usr.bin/make/unit-tests/directive-for-escape.mk diff -u src/usr.bin/make/unit-tests/directive-for-escape.mk:1.22 src/usr.bin/make/unit-tests/directive-for-escape.mk:1.23 --- src/usr.bin/make/unit-tests/directive-for-escape.mk:1.22 Sun Nov 19 21:47:52 2023 +++ src/usr.bin/make/unit-tests/directive-for-escape.mk Sun Nov 19 22:32:44 2023 @@ -1,4 +1,4 @@ -# $NetBSD: directive-for-escape.mk,v 1.22 2023/11/19 21:47:52 rillig Exp $ +# $NetBSD: directive-for-escape.mk,v 1.23 2023/11/19 22:32:44 rillig Exp $ # # Test escaping of special characters in the iteration values of a .for loop. # These values get expanded later using the :U variable modifier, and this @@ -156,7 +156,7 @@ NUMBERS= one two three .endfor # Before for.c 1.173 from 2023-05-08, the name of the iteration variable -# could contain braces, which allowed to replace sequences of variable +# could contain braces, which allowed to replace sequences of # expressions. This possibility was neither intended nor documented. BASENAME= one EXT= .c Index: src/usr.bin/make/unit-tests/dep-var.mk diff -u src/usr.bin/make/unit-tests/dep-var.mk:1.9 src/usr.bin/make/unit-tests/dep-var.mk:1.10 --- src/usr.bin/make/unit-tests/dep-var.mk:1.9 Sun Nov 19 21:47:52 2023 +++ src/usr.bin/make/unit-tests/dep-var.mk Sun Nov 19 22:32:44 2023 @@ -1,4 +1,4 @@ -# $NetBSD: dep-var.mk,v 1.9 2023/11/19 21:47:52 rillig Exp $ +# $NetBSD: dep-var.mk,v 1.10 2023/11/19 22:32:44 rillig Exp $ # # Tests for variable references in dependency declarations. # @@ -63,7 +63,7 @@ INDIRECT_3= indirect UNDEF1= undef1 DEF2= def2 -# Cover the code in SuffExpandChildren that deals with malformed variable +# Cover the code in SuffExpandChildren that deals with malformed # expressions. # # This seems to be an edge case that never happens in practice, and it would Index: src/usr.bin/make/unit-tests/deptgt-makeflags.mk diff -u src/usr.bin/make/unit-tests/deptgt-makeflags.mk:1.8 src/usr.bin/make/unit-tests/deptgt-makeflags.mk:1.9 --- src/usr.bin/make/unit-tests/deptgt-makeflags.mk:1.8 Sun Nov 19 21:47:52 2023 +++ src/usr.bin/make/unit-tests/deptgt-makeflags.mk Sun Nov 19 22:32:44 2023 @@ -1,4 +1,4 @@ -# $NetBSD: deptgt-makeflags.mk,v 1.8 2023/11/19 21:47:52 rillig Exp $ +# $NetBSD: deptgt-makeflags.mk,v 1.9 2023/11/19 22:32:44 rillig Exp $ # # Tests for the special
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 19 22:06:15 UTC 2023 Modified Files: src/usr.bin/make: suff.c var.c src/usr.bin/make/unit-tests: cmd-errors-jobs.exp cmd-errors-lint.exp cmd-errors.exp dep-var.exp directive-for-escape.exp moderrs.exp varmisc.exp varmod-edge.exp varmod-edge.mk varmod-order.exp varparse-errors.exp Log Message: make: replace 'variable expression' with 'expression' in diagnostics To generate a diff of this commit: cvs rdiff -u -r1.368 -r1.369 src/usr.bin/make/suff.c cvs rdiff -u -r1.1073 -r1.1074 src/usr.bin/make/var.c cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp \ src/usr.bin/make/unit-tests/cmd-errors-lint.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cmd-errors.exp cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/dep-var.exp cvs rdiff -u -r1.22 -r1.23 \ src/usr.bin/make/unit-tests/directive-for-escape.exp cvs rdiff -u -r1.32 -r1.33 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/varmisc.exp \ src/usr.bin/make/unit-tests/varmod-edge.mk cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/varmod-edge.exp cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-order.exp cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/varparse-errors.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 19 22:06:15 UTC 2023 Modified Files: src/usr.bin/make: suff.c var.c src/usr.bin/make/unit-tests: cmd-errors-jobs.exp cmd-errors-lint.exp cmd-errors.exp dep-var.exp directive-for-escape.exp moderrs.exp varmisc.exp varmod-edge.exp varmod-edge.mk varmod-order.exp varparse-errors.exp Log Message: make: replace 'variable expression' with 'expression' in diagnostics To generate a diff of this commit: cvs rdiff -u -r1.368 -r1.369 src/usr.bin/make/suff.c cvs rdiff -u -r1.1073 -r1.1074 src/usr.bin/make/var.c cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp \ src/usr.bin/make/unit-tests/cmd-errors-lint.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cmd-errors.exp cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/dep-var.exp cvs rdiff -u -r1.22 -r1.23 \ src/usr.bin/make/unit-tests/directive-for-escape.exp cvs rdiff -u -r1.32 -r1.33 src/usr.bin/make/unit-tests/moderrs.exp cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/varmisc.exp \ src/usr.bin/make/unit-tests/varmod-edge.mk cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/varmod-edge.exp cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/varmod-order.exp cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/varparse-errors.exp 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/make/suff.c diff -u src/usr.bin/make/suff.c:1.368 src/usr.bin/make/suff.c:1.369 --- src/usr.bin/make/suff.c:1.368 Tue Feb 14 21:38:31 2023 +++ src/usr.bin/make/suff.c Sun Nov 19 22:06:15 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: suff.c,v 1.368 2023/02/14 21:38:31 rillig Exp $ */ +/* $NetBSD: suff.c,v 1.369 2023/11/19 22:06:15 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -115,7 +115,7 @@ #include "dir.h" /* "@(#)suff.c 8.4 (Berkeley) 3/21/94" */ -MAKE_RCSID("$NetBSD: suff.c,v 1.368 2023/02/14 21:38:31 rillig Exp $"); +MAKE_RCSID("$NetBSD: suff.c,v 1.369 2023/11/19 22:06:15 rillig Exp $"); typedef List SuffixList; typedef ListNode SuffixListNode; @@ -1316,7 +1316,7 @@ ExpandChildrenRegular(char *cp, GNode *p /* TODO: handle errors */ if (junk.str == var_Error) { Parse_Error(PARSE_FATAL, -"Malformed variable expression at \"%s\"", +"Malformed expression at \"%s\"", cp); cp++; } else { Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.1073 src/usr.bin/make/var.c:1.1074 --- src/usr.bin/make/var.c:1.1073 Sun Nov 19 12:11:34 2023 +++ src/usr.bin/make/var.c Sun Nov 19 22:06:15 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1073 2023/11/19 12:11:34 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1074 2023/11/19 22:06:15 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -139,7 +139,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1073 2023/11/19 12:11:34 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1074 2023/11/19 22:06:15 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -3972,8 +3972,8 @@ ApplyModifiersIndirect(ModChain *ch, con if (*p == ':') p++; else if (*p == '\0' && ch->endc != '\0') { - Error("Unclosed variable expression after indirect " - "modifier, expecting '%c' for variable \"%s\"", + Error("Unclosed expression after indirect modifier, " + "expecting '%c' for variable \"%s\"", ch->endc, expr->name); *pp = p; return AMIR_OUT; @@ -4025,7 +4025,7 @@ ApplySingleModifier(const char **pp, Mod if (*p == '\0' && ch->endc != '\0') { Error( - "Unclosed variable expression, expecting '%c' for " + "Unclosed expression, expecting '%c' for " "modifier \"%.*s\" of variable \"%s\" with value \"%s\"", ch->endc, (int)(p - mod), mod, @@ -4083,7 +4083,7 @@ ApplyModifiers( if (*p == '\0' && endc != '\0') { Error( - "Unclosed variable expression (expecting '%c') for \"%s\"", + "Unclosed expression, expecting '%c' for \"%s\"", ch.endc, expr->name); goto cleanup; } Index: src/usr.bin/make/unit-tests/cmd-errors-jobs.exp diff -u src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.3 src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.4 --- src/usr.bin/make/unit-tests/cmd-errors-jobs.exp:1.3 Sun Sep 25 12:51:37 2022 +++ src/usr.bin/make/unit-tests/cmd-errors-jobs.exp Sun Nov 19 22:06:15 2023 @@ -1,7 +1,7 @@ : undefined--eol make: Unclosed variable "UNCLOSED" : unclosed-variable- -make: Unclosed variable expression (expecting '}') for "UNCLOSED" +make: Unclosed expression, expecting '}' for "UNCLOSED" : unclosed-modifier- make: Unknown modifier "Z" : unknown-modifier--eol Index: src/usr.bin/make/unit-tests/cmd-errors-lint.exp diff -u src/usr.bin/make/unit-tests/cmd-errors-lint.exp:1.3 src/usr.bin/make/unit-tests/cmd-errors-lint.exp:1.4 ---
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sun Nov 19 21:47:52 UTC 2023 Modified Files: src/usr.bin/make/unit-tests: cmdline-undefined.mk comment.mk cond-cmp-string.mk cond-cmp-unary.mk cond-eof.mk cond-func-defined.exp cond-func-defined.mk cond-func-empty.mk cond-func-exists.mk cond-func.mk cond-late.mk cond-short.mk cond-token-number.mk cond-token-plain.exp cond-token-plain.mk cond-token-string.exp cond-token-string.mk cond-token-var.mk dep-var.mk deptgt-makeflags.mk deptgt.mk directive-else.mk directive-for-empty.mk directive-for-errors.mk directive-for-escape.mk directive-for-if.mk directive-ifmake.mk lint.mk opt-debug-file.mk opt-debug-jobs.mk opt-debug-lint.mk opt-debug-var.mk parse-var.mk sh-dots.mk var-op-assign.mk var-op-default.mk var-op-expand.mk var-recursive.mk var-scope-cmdline.mk var-scope-local.mk varmod-assign.mk varmod-defined.mk varmod-edge.mk varmod-gmtime.mk varmod-ifelse.exp varmod-ifelse.mk varmod-indirect.mk varmod-l-name-to-value.mk varmod-localtime.mk varmod-loop-varname.mk varmod-loop.mk varmod-match-escape.mk varmod-match.mk varmod-range.mk varmod-subst-regex.mk varmod-sysv.mk varmod-to-separator.mk varmod-undefined.mk varmod.mk varname-empty.mk varname.mk varparse-errors.mk varparse-mod.mk varparse-undef-partial.mk Log Message: tests/make: replace 'variable expression' with 'expression' Each expression is based on a variable, there's no need for the verbosity. The wording in make's diagnostics will be changed in a follow-up commit. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/cmdline-undefined.mk \ src/usr.bin/make/unit-tests/sh-dots.mk \ src/usr.bin/make/unit-tests/var-op-default.mk \ src/usr.bin/make/unit-tests/var-scope-cmdline.mk \ src/usr.bin/make/unit-tests/varparse-undef-partial.mk cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/comment.mk \ src/usr.bin/make/unit-tests/cond-cmp-unary.mk \ src/usr.bin/make/unit-tests/cond-eof.mk \ src/usr.bin/make/unit-tests/opt-debug-jobs.mk \ src/usr.bin/make/unit-tests/var-recursive.mk \ src/usr.bin/make/unit-tests/varmod-loop-varname.mk cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/cond-cmp-string.mk \ src/usr.bin/make/unit-tests/varmod-edge.mk \ src/usr.bin/make/unit-tests/varmod-ifelse.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cond-func-defined.exp \ src/usr.bin/make/unit-tests/cond-token-var.mk \ src/usr.bin/make/unit-tests/deptgt-makeflags.mk \ src/usr.bin/make/unit-tests/var-scope-local.mk \ src/usr.bin/make/unit-tests/varmod-l-name-to-value.mk \ src/usr.bin/make/unit-tests/varmod-subst-regex.mk cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/cond-func-defined.mk \ src/usr.bin/make/unit-tests/cond-token-string.exp \ src/usr.bin/make/unit-tests/var-op-assign.mk cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/cond-func-empty.mk cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cond-func-exists.mk \ src/usr.bin/make/unit-tests/directive-for-errors.mk cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/cond-func.mk \ src/usr.bin/make/unit-tests/varmod-localtime.mk \ src/usr.bin/make/unit-tests/varname.mk cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cond-late.mk \ src/usr.bin/make/unit-tests/lint.mk cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/unit-tests/cond-short.mk \ src/usr.bin/make/unit-tests/directive-for-escape.mk cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/cond-token-number.mk \ src/usr.bin/make/unit-tests/opt-debug-file.mk \ src/usr.bin/make/unit-tests/varname-empty.mk \ src/usr.bin/make/unit-tests/varparse-errors.mk cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/cond-token-plain.exp cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/cond-token-plain.mk \ src/usr.bin/make/unit-tests/var-op-expand.mk cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/cond-token-string.mk \ src/usr.bin/make/unit-tests/dep-var.mk \ src/usr.bin/make/unit-tests/directive-else.mk \ src/usr.bin/make/unit-tests/parse-var.mk \ src/usr.bin/make/unit-tests/varmod-range.mk \ src/usr.bin/make/unit-tests/varmod-undefined.mk \ src/usr.bin/make/unit-tests/varmod.mk cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/deptgt.mk cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/directive-for-empty.mk \ src/usr.bin/make/unit-tests/directive-for-if.mk \ src/usr.bin/make/unit-tests/opt-debug-var.mk cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/directive-ifmake.mk \ src/usr.bin/make/unit-tests/varmod-match-escape.mk cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/opt-debug-lint.mk \
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sun Nov 19 21:47:52 UTC 2023 Modified Files: src/usr.bin/make/unit-tests: cmdline-undefined.mk comment.mk cond-cmp-string.mk cond-cmp-unary.mk cond-eof.mk cond-func-defined.exp cond-func-defined.mk cond-func-empty.mk cond-func-exists.mk cond-func.mk cond-late.mk cond-short.mk cond-token-number.mk cond-token-plain.exp cond-token-plain.mk cond-token-string.exp cond-token-string.mk cond-token-var.mk dep-var.mk deptgt-makeflags.mk deptgt.mk directive-else.mk directive-for-empty.mk directive-for-errors.mk directive-for-escape.mk directive-for-if.mk directive-ifmake.mk lint.mk opt-debug-file.mk opt-debug-jobs.mk opt-debug-lint.mk opt-debug-var.mk parse-var.mk sh-dots.mk var-op-assign.mk var-op-default.mk var-op-expand.mk var-recursive.mk var-scope-cmdline.mk var-scope-local.mk varmod-assign.mk varmod-defined.mk varmod-edge.mk varmod-gmtime.mk varmod-ifelse.exp varmod-ifelse.mk varmod-indirect.mk varmod-l-name-to-value.mk varmod-localtime.mk varmod-loop-varname.mk varmod-loop.mk varmod-match-escape.mk varmod-match.mk varmod-range.mk varmod-subst-regex.mk varmod-sysv.mk varmod-to-separator.mk varmod-undefined.mk varmod.mk varname-empty.mk varname.mk varparse-errors.mk varparse-mod.mk varparse-undef-partial.mk Log Message: tests/make: replace 'variable expression' with 'expression' Each expression is based on a variable, there's no need for the verbosity. The wording in make's diagnostics will be changed in a follow-up commit. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/cmdline-undefined.mk \ src/usr.bin/make/unit-tests/sh-dots.mk \ src/usr.bin/make/unit-tests/var-op-default.mk \ src/usr.bin/make/unit-tests/var-scope-cmdline.mk \ src/usr.bin/make/unit-tests/varparse-undef-partial.mk cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/comment.mk \ src/usr.bin/make/unit-tests/cond-cmp-unary.mk \ src/usr.bin/make/unit-tests/cond-eof.mk \ src/usr.bin/make/unit-tests/opt-debug-jobs.mk \ src/usr.bin/make/unit-tests/var-recursive.mk \ src/usr.bin/make/unit-tests/varmod-loop-varname.mk cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/cond-cmp-string.mk \ src/usr.bin/make/unit-tests/varmod-edge.mk \ src/usr.bin/make/unit-tests/varmod-ifelse.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cond-func-defined.exp \ src/usr.bin/make/unit-tests/cond-token-var.mk \ src/usr.bin/make/unit-tests/deptgt-makeflags.mk \ src/usr.bin/make/unit-tests/var-scope-local.mk \ src/usr.bin/make/unit-tests/varmod-l-name-to-value.mk \ src/usr.bin/make/unit-tests/varmod-subst-regex.mk cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/cond-func-defined.mk \ src/usr.bin/make/unit-tests/cond-token-string.exp \ src/usr.bin/make/unit-tests/var-op-assign.mk cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/cond-func-empty.mk cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/cond-func-exists.mk \ src/usr.bin/make/unit-tests/directive-for-errors.mk cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/cond-func.mk \ src/usr.bin/make/unit-tests/varmod-localtime.mk \ src/usr.bin/make/unit-tests/varname.mk cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cond-late.mk \ src/usr.bin/make/unit-tests/lint.mk cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/unit-tests/cond-short.mk \ src/usr.bin/make/unit-tests/directive-for-escape.mk cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/cond-token-number.mk \ src/usr.bin/make/unit-tests/opt-debug-file.mk \ src/usr.bin/make/unit-tests/varname-empty.mk \ src/usr.bin/make/unit-tests/varparse-errors.mk cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/cond-token-plain.exp cvs rdiff -u -r1.18 -r1.19 src/usr.bin/make/unit-tests/cond-token-plain.mk \ src/usr.bin/make/unit-tests/var-op-expand.mk cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/cond-token-string.mk \ src/usr.bin/make/unit-tests/dep-var.mk \ src/usr.bin/make/unit-tests/directive-else.mk \ src/usr.bin/make/unit-tests/parse-var.mk \ src/usr.bin/make/unit-tests/varmod-range.mk \ src/usr.bin/make/unit-tests/varmod-undefined.mk \ src/usr.bin/make/unit-tests/varmod.mk cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/deptgt.mk cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/directive-for-empty.mk \ src/usr.bin/make/unit-tests/directive-for-if.mk \ src/usr.bin/make/unit-tests/opt-debug-var.mk cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/directive-ifmake.mk \ src/usr.bin/make/unit-tests/varmod-match-escape.mk cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/opt-debug-lint.mk \
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 19 12:11:34 UTC 2023 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: varmod-mtime.exp varmod-mtime.mk Log Message: tests/make: cover all code paths for the ':mtime' modifier To generate a diff of this commit: cvs rdiff -u -r1.1072 -r1.1073 src/usr.bin/make/var.c cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-mtime.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod-mtime.mk 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/make/var.c diff -u src/usr.bin/make/var.c:1.1072 src/usr.bin/make/var.c:1.1073 --- src/usr.bin/make/var.c:1.1072 Sun Nov 19 11:47:49 2023 +++ src/usr.bin/make/var.c Sun Nov 19 12:11:34 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1072 2023/11/19 11:47:49 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1073 2023/11/19 12:11:34 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -139,7 +139,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1072 2023/11/19 11:47:49 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1073 2023/11/19 12:11:34 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -2897,9 +2897,8 @@ ApplyModifier_Mtime(const char **pp, Mod goto invalid_argument; *pp = p; } - if (!ModChain_ShouldEval(ch)) - return AMR_OK; - ModifyWords(ch, ModifyWord_Mtime, , ch->oneBigWord); + if (ModChain_ShouldEval(ch)) + ModifyWords(ch, ModifyWord_Mtime, , ch->oneBigWord); return args.rc; invalid_argument: Index: src/usr.bin/make/unit-tests/varmod-mtime.exp diff -u src/usr.bin/make/unit-tests/varmod-mtime.exp:1.6 src/usr.bin/make/unit-tests/varmod-mtime.exp:1.7 --- src/usr.bin/make/unit-tests/varmod-mtime.exp:1.6 Sun Nov 19 11:47:49 2023 +++ src/usr.bin/make/unit-tests/varmod-mtime.exp Sun Nov 19 12:11:34 2023 @@ -5,6 +5,10 @@ make: "varmod-mtime.mk" line 70: Cannot make: "varmod-mtime.mk" line 70: Malformed conditional (${no/such/file1 no/such/file2:L:mtime=error}) make: "varmod-mtime.mk" line 81: Invalid argument 'errorhandler-no' for modifier ':mtime' make: "varmod-mtime.mk" line 81: Malformed conditional (${MAKEFILE:mtime=errorhandler-no} > 0) +make: "varmod-mtime.mk" line 90: Invalid argument 'warn' for modifier ':mtime' +make: "varmod-mtime.mk" line 90: Malformed conditional (${MAKEFILE:mtime=warn} > 0) +make: "varmod-mtime.mk" line 115: Unknown modifier "mtim" +make: "varmod-mtime.mk" line 115: Malformed conditional (${anything:L:mtim}) make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/varmod-mtime.mk diff -u src/usr.bin/make/unit-tests/varmod-mtime.mk:1.7 src/usr.bin/make/unit-tests/varmod-mtime.mk:1.8 --- src/usr.bin/make/unit-tests/varmod-mtime.mk:1.7 Sun Nov 19 11:47:49 2023 +++ src/usr.bin/make/unit-tests/varmod-mtime.mk Sun Nov 19 12:11:34 2023 @@ -1,4 +1,4 @@ -# $NetBSD: varmod-mtime.mk,v 1.7 2023/11/19 11:47:49 rillig Exp $ +# $NetBSD: varmod-mtime.mk,v 1.8 2023/11/19 12:11:34 rillig Exp $ # # Tests for the ':mtime' variable modifier, which maps each word of the # expression to that file's modification time. @@ -84,9 +84,36 @@ _!= rm -f ${COOKIE} .endif +# Only the word 'error' can be used as a fallback argument to the modifier. +# expect+2: Invalid argument 'warn' for modifier ':mtime' +# expect+1: Malformed conditional (${MAKEFILE:mtime=warn} > 0) +.if ${MAKEFILE:mtime=warn} > 0 +. error +.else +. error +.endif + + # Ensure that the fallback for a missing modification time is indeed the # current time, and not any later time. end:= ${%s:L:gmtime} .if ${not_found_mtime} > ${end} . error .endif + + +# If the expression is irrelevant, the ':mtime' modifier is only parsed, it +# does not perform any filesystem operations. +.if 0 && ${anything:L:mtime} +. error +.endif + + +# If there is a typo in the modifier name, it does not match. +# expect+2: Unknown modifier "mtim" +# expect+1: Malformed conditional (${anything:L:mtim}) +.if ${anything:L:mtim} +. error +.else +. error +.endif
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 19 12:11:34 UTC 2023 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: varmod-mtime.exp varmod-mtime.mk Log Message: tests/make: cover all code paths for the ':mtime' modifier To generate a diff of this commit: cvs rdiff -u -r1.1072 -r1.1073 src/usr.bin/make/var.c cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-mtime.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod-mtime.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 19 11:47:49 UTC 2023 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: varmod-mtime.exp varmod-mtime.mk Log Message: make: produce more accurate error message for invalid ':mtime' argument To generate a diff of this commit: cvs rdiff -u -r1.1071 -r1.1072 src/usr.bin/make/var.c cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-mtime.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-mtime.mk 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/make/var.c diff -u src/usr.bin/make/var.c:1.1071 src/usr.bin/make/var.c:1.1072 --- src/usr.bin/make/var.c:1.1071 Sun Nov 19 11:30:28 2023 +++ src/usr.bin/make/var.c Sun Nov 19 11:47:49 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1071 2023/11/19 11:30:28 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1072 2023/11/19 11:47:49 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -139,7 +139,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1071 2023/11/19 11:30:28 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1072 2023/11/19 11:47:49 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -2888,22 +2888,25 @@ ApplyModifier_Mtime(const char **pp, Mod if (args.use_fallback) { p++; if (TryParseTime(, )) { - } else if (strncmp(p, "error", 5) == 0 - && IsDelimiter(p[5], ch)) { + } else if (strncmp(p, "error", 5) == 0) { p += 5; args.error = true; - } else { - Parse_Error(PARSE_FATAL, - "Invalid argument '%.*s' for modifier ':mtime'", - (int)strcspn(p, ":{}()"), p); - return AMR_CLEANUP; - } + } else + goto invalid_argument; + if (!IsDelimiter(*p, ch)) + goto invalid_argument; *pp = p; } if (!ModChain_ShouldEval(ch)) return AMR_OK; ModifyWords(ch, ModifyWord_Mtime, , ch->oneBigWord); return args.rc; + +invalid_argument: + Parse_Error(PARSE_FATAL, + "Invalid argument '%.*s' for modifier ':mtime'", + (int)strcspn(*pp + 1, ":{}()"), *pp + 1); + return AMR_CLEANUP; } static void Index: src/usr.bin/make/unit-tests/varmod-mtime.exp diff -u src/usr.bin/make/unit-tests/varmod-mtime.exp:1.5 src/usr.bin/make/unit-tests/varmod-mtime.exp:1.6 --- src/usr.bin/make/unit-tests/varmod-mtime.exp:1.5 Sun Nov 19 11:37:44 2023 +++ src/usr.bin/make/unit-tests/varmod-mtime.exp Sun Nov 19 11:47:49 2023 @@ -1,4 +1,4 @@ -make: "varmod-mtime.mk" line 47: Unknown modifier "x" +make: "varmod-mtime.mk" line 47: Invalid argument '123x' for modifier ':mtime' make: "varmod-mtime.mk" line 47: Malformed conditional (${no/such/file:L:mtime=123x}) make: "varmod-mtime.mk" line 70: Cannot determine mtime for 'no/such/file1': make: "varmod-mtime.mk" line 70: Cannot determine mtime for 'no/such/file2': Index: src/usr.bin/make/unit-tests/varmod-mtime.mk diff -u src/usr.bin/make/unit-tests/varmod-mtime.mk:1.6 src/usr.bin/make/unit-tests/varmod-mtime.mk:1.7 --- src/usr.bin/make/unit-tests/varmod-mtime.mk:1.6 Sun Nov 19 11:37:44 2023 +++ src/usr.bin/make/unit-tests/varmod-mtime.mk Sun Nov 19 11:47:49 2023 @@ -1,4 +1,4 @@ -# $NetBSD: varmod-mtime.mk,v 1.6 2023/11/19 11:37:44 rillig Exp $ +# $NetBSD: varmod-mtime.mk,v 1.7 2023/11/19 11:47:49 rillig Exp $ # # Tests for the ':mtime' variable modifier, which maps each word of the # expression to that file's modification time. @@ -42,7 +42,7 @@ not_found_mtime:= ${no/such/file:L:mtime # The fallback timestamp must only be an integer, without trailing characters. -# expect+2: Unknown modifier "x" +# expect+2: Invalid argument '123x' for modifier ':mtime' # expect+1: Malformed conditional (${no/such/file:L:mtime=123x}) .if ${no/such/file:L:mtime=123x} . error
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 19 11:47:49 UTC 2023 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: varmod-mtime.exp varmod-mtime.mk Log Message: make: produce more accurate error message for invalid ':mtime' argument To generate a diff of this commit: cvs rdiff -u -r1.1071 -r1.1072 src/usr.bin/make/var.c cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-mtime.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-mtime.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sun Nov 19 11:37:44 UTC 2023 Modified Files: src/usr.bin/make/unit-tests: varmod-mtime.exp varmod-mtime.mk Log Message: tests/make: test non-integer fallback in ':mtime' modifier To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-mtime.exp cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-mtime.mk 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/make/unit-tests/varmod-mtime.exp diff -u src/usr.bin/make/unit-tests/varmod-mtime.exp:1.4 src/usr.bin/make/unit-tests/varmod-mtime.exp:1.5 --- src/usr.bin/make/unit-tests/varmod-mtime.exp:1.4 Sat Aug 19 01:34:21 2023 +++ src/usr.bin/make/unit-tests/varmod-mtime.exp Sun Nov 19 11:37:44 2023 @@ -1,8 +1,10 @@ -make: "varmod-mtime.mk" line 60: Cannot determine mtime for 'no/such/file1': -make: "varmod-mtime.mk" line 60: Cannot determine mtime for 'no/such/file2': -make: "varmod-mtime.mk" line 60: Malformed conditional (${no/such/file1 no/such/file2:L:mtime=error}) -make: "varmod-mtime.mk" line 71: Invalid argument 'errorhandler-no' for modifier ':mtime' -make: "varmod-mtime.mk" line 71: Malformed conditional (${MAKEFILE:mtime=errorhandler-no} > 0) +make: "varmod-mtime.mk" line 47: Unknown modifier "x" +make: "varmod-mtime.mk" line 47: Malformed conditional (${no/such/file:L:mtime=123x}) +make: "varmod-mtime.mk" line 70: Cannot determine mtime for 'no/such/file1': +make: "varmod-mtime.mk" line 70: Cannot determine mtime for 'no/such/file2': +make: "varmod-mtime.mk" line 70: Malformed conditional (${no/such/file1 no/such/file2:L:mtime=error}) +make: "varmod-mtime.mk" line 81: Invalid argument 'errorhandler-no' for modifier ':mtime' +make: "varmod-mtime.mk" line 81: Malformed conditional (${MAKEFILE:mtime=errorhandler-no} > 0) make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/varmod-mtime.mk diff -u src/usr.bin/make/unit-tests/varmod-mtime.mk:1.5 src/usr.bin/make/unit-tests/varmod-mtime.mk:1.6 --- src/usr.bin/make/unit-tests/varmod-mtime.mk:1.5 Sat Aug 19 08:19:25 2023 +++ src/usr.bin/make/unit-tests/varmod-mtime.mk Sun Nov 19 11:37:44 2023 @@ -1,4 +1,4 @@ -# $NetBSD: varmod-mtime.mk,v 1.5 2023/08/19 08:19:25 rillig Exp $ +# $NetBSD: varmod-mtime.mk,v 1.6 2023/11/19 11:37:44 rillig Exp $ # # Tests for the ':mtime' variable modifier, which maps each word of the # expression to that file's modification time. @@ -41,6 +41,16 @@ not_found_mtime:= ${no/such/file:L:mtime .endif +# The fallback timestamp must only be an integer, without trailing characters. +# expect+2: Unknown modifier "x" +# expect+1: Malformed conditional (${no/such/file:L:mtime=123x}) +.if ${no/such/file:L:mtime=123x} +. error +.else +. error +.endif + + # The timestamp of a newly created file must be at least as great as the # timestamp when parsing of this makefile started. COOKIE= ${TMPDIR:U/tmp}/varmod-mtime.cookie
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Sun Nov 19 11:37:44 UTC 2023 Modified Files: src/usr.bin/make/unit-tests: varmod-mtime.exp varmod-mtime.mk Log Message: tests/make: test non-integer fallback in ':mtime' modifier To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/varmod-mtime.exp cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varmod-mtime.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 19 11:30:28 UTC 2023 Modified Files: src/usr.bin/make: var.c Log Message: make: extract detection of ':from=to' to a separate function No functional change. To generate a diff of this commit: cvs rdiff -u -r1.1070 -r1.1071 src/usr.bin/make/var.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/make/var.c diff -u src/usr.bin/make/var.c:1.1070 src/usr.bin/make/var.c:1.1071 --- src/usr.bin/make/var.c:1.1070 Sun Nov 19 09:45:19 2023 +++ src/usr.bin/make/var.c Sun Nov 19 11:30:28 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1070 2023/11/19 09:45:19 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1071 2023/11/19 11:30:28 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -139,7 +139,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1070 2023/11/19 09:45:19 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1071 2023/11/19 11:30:28 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -3687,6 +3687,26 @@ ApplyModifier_Unique(const char **pp, Mo } #ifdef SYSVVARSUB +/* Test whether the modifier has the form '='. */ +static bool +IsSysVModifier(const char *p, char startc, char endc) +{ + bool eqFound = false; + + int depth = 1; + while (*p != '\0' && depth > 0) { + if (*p == '=') /* XXX: should also test depth == 1 */ + eqFound = true; + else if (*p == endc) + depth--; + else if (*p == startc) + depth++; + if (depth > 0) + p++; + } + return *p == endc && eqFound; +} + /* :from=to */ static ApplyModifierResult ApplyModifier_SysV(const char **pp, ModChain *ch) @@ -3699,26 +3719,8 @@ ApplyModifier_SysV(const char **pp, ModC const char *lhsSuffix; const char *mod = *pp; - bool eqFound = false; - /* - * First we make a pass through the string trying to verify it is a - * SysV-make-style translation. It must be: = - */ - int depth = 1; - const char *p = mod; - while (*p != '\0' && depth > 0) { - if (*p == '=') { /* XXX: should also test depth == 1 */ - eqFound = true; - /* continue looking for ch->endc */ - } else if (*p == ch->endc) - depth--; - else if (*p == ch->startc) - depth++; - if (depth > 0) - p++; - } - if (*p != ch->endc || !eqFound) + if (!IsSysVModifier(mod, ch->startc, ch->endc)) return AMR_UNKNOWN; if (!ParseModifierPart(pp, '=', expr->emode, ch, ))
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 19 11:30:28 UTC 2023 Modified Files: src/usr.bin/make: var.c Log Message: make: extract detection of ':from=to' to a separate function No functional change. To generate a diff of this commit: cvs rdiff -u -r1.1070 -r1.1071 src/usr.bin/make/var.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/make
Module Name:src Committed By: rillig Date: Sun Nov 19 09:45:19 UTC 2023 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: directive-export-gmake.exp directive-export-gmake.mk directive-export.exp directive-export.mk Log Message: tests/make: test and explain exporting of variables To generate a diff of this commit: cvs rdiff -u -r1.1069 -r1.1070 src/usr.bin/make/var.c cvs rdiff -u -r1.5 -r1.6 \ src/usr.bin/make/unit-tests/directive-export-gmake.exp \ src/usr.bin/make/unit-tests/directive-export.exp cvs rdiff -u -r1.7 -r1.8 \ src/usr.bin/make/unit-tests/directive-export-gmake.mk cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/directive-export.mk 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/make/var.c diff -u src/usr.bin/make/var.c:1.1069 src/usr.bin/make/var.c:1.1070 --- src/usr.bin/make/var.c:1.1069 Sat Nov 18 20:19:08 2023 +++ src/usr.bin/make/var.c Sun Nov 19 09:45:19 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1069 2023/11/18 20:19:08 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1070 2023/11/19 09:45:19 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -139,7 +139,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1069 2023/11/18 20:19:08 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1070 2023/11/19 09:45:19 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -615,13 +615,8 @@ ExportVarEnv(Var *v) return true; } - if (v->inUse) { - /* - * We recursed while exporting in a child. - * This isn't going to end well, just skip it. - */ - return false; - } + if (v->inUse) + return false; /* see EMPTY_SHELL in directive-export.mk */ /* XXX: name is injected without escaping it */ expr = str_concat3("${", name, "}"); Index: src/usr.bin/make/unit-tests/directive-export-gmake.exp diff -u src/usr.bin/make/unit-tests/directive-export-gmake.exp:1.5 src/usr.bin/make/unit-tests/directive-export-gmake.exp:1.6 --- src/usr.bin/make/unit-tests/directive-export-gmake.exp:1.5 Sun Aug 20 20:48:32 2023 +++ src/usr.bin/make/unit-tests/directive-export-gmake.exp Sun Nov 19 09:45:19 2023 @@ -1,5 +1,6 @@ make: "directive-export-gmake.mk" line 71: Invalid line 'export VAR=${:U1}', expanded to 'export VAR=1' make: "directive-export-gmake.mk" line 85: 16:00:00 +make: "directive-export-gmake.mk" line 92: Variable/Value missing from "export" make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/directive-export.exp diff -u src/usr.bin/make/unit-tests/directive-export.exp:1.5 src/usr.bin/make/unit-tests/directive-export.exp:1.6 --- src/usr.bin/make/unit-tests/directive-export.exp:1.5 Sun Aug 20 20:48:32 2023 +++ src/usr.bin/make/unit-tests/directive-export.exp Sun Nov 19 09:45:19 2023 @@ -1,4 +1,4 @@ -make: "directive-export.mk" line 50: 00:00:00 -make: "directive-export.mk" line 55: 00:00:00 -make: "directive-export.mk" line 58: 16:00:00 +make: "directive-export.mk" line 56: 00:00:00 +make: "directive-export.mk" line 61: 00:00:00 +make: "directive-export.mk" line 64: 16:00:00 exit status 0 Index: src/usr.bin/make/unit-tests/directive-export-gmake.mk diff -u src/usr.bin/make/unit-tests/directive-export-gmake.mk:1.7 src/usr.bin/make/unit-tests/directive-export-gmake.mk:1.8 --- src/usr.bin/make/unit-tests/directive-export-gmake.mk:1.7 Sun Aug 20 20:48:32 2023 +++ src/usr.bin/make/unit-tests/directive-export-gmake.mk Sun Nov 19 09:45:19 2023 @@ -1,4 +1,4 @@ -# $NetBSD: directive-export-gmake.mk,v 1.7 2023/08/20 20:48:32 rillig Exp $ +# $NetBSD: directive-export-gmake.mk,v 1.8 2023/11/19 09:45:19 rillig Exp $ # # Tests for the export directive (without leading dot), as in GNU make. @@ -83,3 +83,24 @@ INDIRECT_TZ= ${:UAmerica/Los_Angeles} export TZ=${INDIRECT_TZ} # expect+1: 16:00:00 .info ${%T:L:localtime=86400} + + +# The '=' must be present in the unexpanded line, it cannot be generated by +# an expression. +EQ= = +# expect+1: Variable/Value missing from "export" +export EQ_VAR${EQ}eq-value +.if ${:!env!:MEQ_VAR=*} +. error +.endif + + +# The variable name must be given directly, it is not expanded. The name of +# the exported variable thus starts with a '$', and that name may be filtered +# out by the platform. +INDIRECT_NAME= I_NAME +INDIRECT_VALUE= indirect value +export ${INDIRECT_NAME}=${INDIRECT_VALUE} +.if ${:!env!:MI_NAME=*} +. error +.endif Index: src/usr.bin/make/unit-tests/directive-export.mk diff -u src/usr.bin/make/unit-tests/directive-export.mk:1.9 src/usr.bin/make/unit-tests/directive-export.mk:1.10 --- src/usr.bin/make/unit-tests/directive-export.mk:1.9 Sun Aug 20 20:48:32 2023 +++ src/usr.bin/make/unit-tests/directive-export.mk Sun Nov 19 09:45:19 2023 @@ -1,4 +1,4 @@ -# $NetBSD: directive-export.mk,v 1.9 2023/08/20
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 19 09:45:19 UTC 2023 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: directive-export-gmake.exp directive-export-gmake.mk directive-export.exp directive-export.mk Log Message: tests/make: test and explain exporting of variables To generate a diff of this commit: cvs rdiff -u -r1.1069 -r1.1070 src/usr.bin/make/var.c cvs rdiff -u -r1.5 -r1.6 \ src/usr.bin/make/unit-tests/directive-export-gmake.exp \ src/usr.bin/make/unit-tests/directive-export.exp cvs rdiff -u -r1.7 -r1.8 \ src/usr.bin/make/unit-tests/directive-export-gmake.mk cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/directive-export.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Nov 18 20:19:08 UTC 2023 Modified Files: src/usr.bin/make: var.c Log Message: make: clean up the modifier ':[...]' No functional change. To generate a diff of this commit: cvs rdiff -u -r1.1068 -r1.1069 src/usr.bin/make/var.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/make/var.c diff -u src/usr.bin/make/var.c:1.1068 src/usr.bin/make/var.c:1.1069 --- src/usr.bin/make/var.c:1.1068 Thu Nov 2 06:09:07 2023 +++ src/usr.bin/make/var.c Sat Nov 18 20:19:08 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1068 2023/11/02 06:09:07 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1069 2023/11/18 20:19:08 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -139,7 +139,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1068 2023/11/02 06:09:07 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1069 2023/11/18 20:19:08 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -3236,7 +3236,6 @@ static ApplyModifierResult ApplyModifier_Words(const char **pp, ModChain *ch) { Expr *expr = ch->expr; - const char *estr; int first, last; const char *p; LazyBuf estrBuf; @@ -3246,7 +3245,7 @@ ApplyModifier_Words(const char **pp, Mod if (!ParseModifierPart(pp, ']', expr->emode, ch, )) return AMR_CLEANUP; festr = LazyBuf_DoneGet(); - estr = festr.str; + p = festr.str; if (!IsDelimiter(**pp, ch)) goto bad_modifier; /* Found junk after ']' */ @@ -3254,13 +3253,13 @@ ApplyModifier_Words(const char **pp, Mod if (!ModChain_ShouldEval(ch)) goto ok; - if (estr[0] == '\0') - goto bad_modifier; /* Found ":[]". */ + if (p[0] == '\0') + goto bad_modifier; /* Found ":[]". */ - if (estr[0] == '#' && estr[1] == '\0') { /* Found ":[#]" */ - if (ch->oneBigWord) { + if (strcmp(p, "#") == 0) { /* Found ":[#]" */ + if (ch->oneBigWord) Expr_SetValueRefer(expr, "1"); - } else { + else { Buffer buf; SubstringWords words = Expr_Words(expr); @@ -3275,49 +3274,37 @@ ApplyModifier_Words(const char **pp, Mod goto ok; } - if (estr[0] == '*' && estr[1] == '\0') { /* Found ":[*]" */ + if (strcmp(p, "*") == 0) { /* ":[*]" */ ch->oneBigWord = true; goto ok; } - if (estr[0] == '@' && estr[1] == '\0') { /* Found ":[@]" */ + if (strcmp(p, "@") == 0) { /* ":[@]" */ ch->oneBigWord = false; goto ok; } - /* - * We expect estr to contain a single integer for :[N], or two - * integers separated by ".." for :[start..end]. - */ - p = estr; + /* Expect ":[N]" or ":[start..end]" */ if (!TryParseIntBase0(, )) - goto bad_modifier; /* Found junk instead of a number */ + goto bad_modifier; - if (p[0] == '\0') { /* Found only one integer in :[N] */ + if (p[0] == '\0') /* ":[N]" */ last = first; - } else if (p[0] == '.' && p[1] == '.' && p[2] != '\0') { - /* Expecting another integer after ".." */ + else if (strncmp(p, "..", 2) == 0) { p += 2; if (!TryParseIntBase0(, ) || *p != '\0') - goto bad_modifier; /* Found junk after ".." */ + goto bad_modifier; } else - goto bad_modifier; /* Found junk instead of ".." */ + goto bad_modifier; - /* - * Now first and last are properly filled in, but we still have to - * check for 0 as a special case. - */ - if (first == 0 && last == 0) { - /* ":[0]" or perhaps ":[0..0]" */ + if (first == 0 && last == 0) { /* ":[0]" or ":[0..0]" */ ch->oneBigWord = true; goto ok; } - /* ":[0..N]" or ":[N..0]" */ - if (first == 0 || last == 0) + if (first == 0 || last == 0) /* ":[0..N]" or ":[N..0]" */ goto bad_modifier; - /* Normal case: select the words described by first and last. */ Expr_SetValueOwn(expr, VarSelectWords(Expr_Str(expr), first, last, ch->sep, ch->oneBigWord));
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sat Nov 18 20:19:08 UTC 2023 Modified Files: src/usr.bin/make: var.c Log Message: make: clean up the modifier ':[...]' No functional change. To generate a diff of this commit: cvs rdiff -u -r1.1068 -r1.1069 src/usr.bin/make/var.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/make/unit-tests
Module Name:src Committed By: rillig Date: Sat Nov 18 19:25:43 UTC 2023 Modified Files: src/usr.bin/make/unit-tests: varmod-ifelse.mk Log Message: tests/make: test parsing of the ':?' modifier To generate a diff of this commit: cvs rdiff -u -r1.23 -r1.24 src/usr.bin/make/unit-tests/varmod-ifelse.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Nov 2 06:09:07 UTC 2023 Modified Files: src/usr.bin/make: var.c Log Message: make: when comparing substrings, don't read beyond the substring's end Right now, Substring_Words terminates each word with a '\0', but that's an implementation detail that is not required by the interface, so don't rely on it. To generate a diff of this commit: cvs rdiff -u -r1.1067 -r1.1068 src/usr.bin/make/var.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/make/var.c diff -u src/usr.bin/make/var.c:1.1067 src/usr.bin/make/var.c:1.1068 --- src/usr.bin/make/var.c:1.1067 Thu Nov 2 05:55:22 2023 +++ src/usr.bin/make/var.c Thu Nov 2 06:09:07 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1067 2023/11/02 05:55:22 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1068 2023/11/02 06:09:07 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -139,7 +139,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1067 2023/11/02 05:55:22 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1068 2023/11/02 06:09:07 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -3382,10 +3382,19 @@ SubNumDesc(const void *sa, const void *s } static int +Substring_Cmp(Substring a, Substring b) +{ + for (; a.start < a.end && b.start < b.end; a.start++, b.start++) + if (a.start[0] != b.start[0]) + return (unsigned char)a.start[0] + - (unsigned char)b.start[0]; + return (int)((a.end - a.start) - (b.end - b.start)); +} + +static int SubStrAsc(const void *sa, const void *sb) { - return strcmp( - ((const Substring *)sa)->start, ((const Substring *)sb)->start); + return Substring_Cmp(*(const Substring *)sa, *(const Substring *)sb); } static int
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Nov 2 06:09:07 UTC 2023 Modified Files: src/usr.bin/make: var.c Log Message: make: when comparing substrings, don't read beyond the substring's end Right now, Substring_Words terminates each word with a '\0', but that's an implementation detail that is not required by the interface, so don't rely on it. To generate a diff of this commit: cvs rdiff -u -r1.1067 -r1.1068 src/usr.bin/make/var.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/make
Module Name:src Committed By: rillig Date: Thu Nov 2 05:55:22 UTC 2023 Modified Files: src/usr.bin/make: main.c parse.c var.c Log Message: make: miscellaneous cleanups No functional change. To generate a diff of this commit: cvs rdiff -u -r1.602 -r1.603 src/usr.bin/make/main.c cvs rdiff -u -r1.708 -r1.709 src/usr.bin/make/parse.c cvs rdiff -u -r1.1066 -r1.1067 src/usr.bin/make/var.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/make/main.c diff -u src/usr.bin/make/main.c:1.602 src/usr.bin/make/main.c:1.603 --- src/usr.bin/make/main.c:1.602 Thu Nov 2 05:40:49 2023 +++ src/usr.bin/make/main.c Thu Nov 2 05:55:22 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.602 2023/11/02 05:40:49 rillig Exp $ */ +/* $NetBSD: main.c,v 1.603 2023/11/02 05:55:22 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -111,8 +111,8 @@ #include "trace.h" /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.602 2023/11/02 05:40:49 rillig Exp $"); -#if defined(MAKE_NATIVE) && !defined(lint) +MAKE_RCSID("$NetBSD: main.c,v 1.603 2023/11/02 05:55:22 rillig Exp $"); +#if defined(MAKE_NATIVE) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " "All rights reserved."); @@ -439,7 +439,7 @@ MainParseArgJobs(const char *arg) static void MainParseArgSysInc(const char *argvalue) { - if (strncmp(".../", argvalue, 4) == 0) { + if (strncmp(argvalue, ".../", 4) == 0) { char *found_path = Dir_FindHereOrAbove(curdir, argvalue + 4); if (found_path == NULL) return; @@ -686,18 +686,18 @@ Main_ParseArgLine(const char *line) { Words words; char *buf; + const char *p; if (line == NULL) return; - /* XXX: don't use line as an iterator variable */ - for (; *line == ' '; line++) + for (p = line; *p == ' '; p++) continue; - if (line[0] == '\0') + if (p[0] == '\0') return; { FStr argv0 = Var_Value(SCOPE_GLOBAL, ".MAKE"); - buf = str_concat3(argv0.str, " ", line); + buf = str_concat3(argv0.str, " ", p); FStr_Done(); } Index: src/usr.bin/make/parse.c diff -u src/usr.bin/make/parse.c:1.708 src/usr.bin/make/parse.c:1.709 --- src/usr.bin/make/parse.c:1.708 Thu Nov 2 05:40:49 2023 +++ src/usr.bin/make/parse.c Thu Nov 2 05:55:22 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.708 2023/11/02 05:40:49 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.709 2023/11/02 05:55:22 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -105,7 +105,7 @@ #include "pathnames.h" /* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: parse.c,v 1.708 2023/11/02 05:40:49 rillig Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.709 2023/11/02 05:55:22 rillig Exp $"); /* Detects a multiple-inclusion guard in a makefile. */ typedef enum { @@ -235,7 +235,7 @@ static StringList targCmds = LST_INIT; */ static GNode *order_pred; -static int parseErrors = 0; +static int parseErrors; /* * The include chain of makefiles. At index 0 is the top-level makefile from @@ -858,7 +858,8 @@ MaybeUpdateMainTarget(void) for (ln = targets->first; ln != NULL; ln = ln->next) { GNode *gn = ln->datum; if (GNode_IsMainCandidate(gn)) { - DEBUG1(MAKE, "Setting main node to \"%s\"\n", gn->name); + DEBUG1(MAKE, "Setting main node to \"%s\"\n", + gn->name); mainNode = gn; return; } @@ -880,31 +881,31 @@ InvalidLineType(const char *line, const } else if (strcmp(line, unexpanded_line) == 0) Parse_Error(PARSE_FATAL, "Invalid line '%s'", line); else - Parse_Error(PARSE_FATAL, "Invalid line '%s', expanded to '%s'", + Parse_Error(PARSE_FATAL, + "Invalid line '%s', expanded to '%s'", unexpanded_line, line); } static void ParseDependencyTargetWord(char **pp, const char *lstart) { - const char *cp = *pp; + const char *p = *pp; - while (*cp != '\0') { - if ((ch_isspace(*cp) || *cp == '!' || *cp == ':' || - *cp == '(') && - !IsEscaped(lstart, cp)) + while (*p != '\0') { + if ((ch_isspace(*p) || *p == '!' || *p == ':' || *p == '(') + && !IsEscaped(lstart, p)) break; - if (*cp == '$') { - FStr val = Var_Parse(, SCOPE_CMDLINE, + if (*p == '$') { + FStr val = Var_Parse(, SCOPE_CMDLINE, VARE_PARSE_ONLY); /* TODO: handle errors */ FStr_Done(); } else - cp++; + p++; } - *pp += cp - *pp; + *pp += p - *pp; } /* @@ -1331,6 +1332,7 @@ ParseDependencySourceSpecial(ParseSpecia Suff_AddSuffix(word); break; case SP_PATH: + case SP_SYSPATH: AddToPaths(word, paths); break; case SP_INCLUDES: @@ -1351,9 +1353,6 @@ ParseDependencySourceSpecial(ParseSpecia case SP_READONLY: Var_ReadOnly(word, true); break; - case SP_SYSPATH: - AddToPaths(word, paths); - break; default: break; } @@ -1364,7 +1363,7 @@ ApplyDependencyTarget(char *name, char * GNodeType *inout_targetAttr,
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Nov 2 05:55:22 UTC 2023 Modified Files: src/usr.bin/make: main.c parse.c var.c Log Message: make: miscellaneous cleanups No functional change. To generate a diff of this commit: cvs rdiff -u -r1.602 -r1.603 src/usr.bin/make/main.c cvs rdiff -u -r1.708 -r1.709 src/usr.bin/make/parse.c cvs rdiff -u -r1.1066 -r1.1067 src/usr.bin/make/var.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/make/unit-tests
Module Name:src Committed By: rillig Date: Thu Nov 2 05:46:26 UTC 2023 Modified Files: src/usr.bin/make/unit-tests: var-op-append.mk Log Message: tests/make: test appending to an environment variable To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/var-op-append.mk 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/make/unit-tests/var-op-append.mk diff -u src/usr.bin/make/unit-tests/var-op-append.mk:1.11 src/usr.bin/make/unit-tests/var-op-append.mk:1.12 --- src/usr.bin/make/unit-tests/var-op-append.mk:1.11 Thu Nov 2 05:14:58 2023 +++ src/usr.bin/make/unit-tests/var-op-append.mk Thu Nov 2 05:46:26 2023 @@ -1,4 +1,4 @@ -# $NetBSD: var-op-append.mk,v 1.11 2023/11/02 05:14:58 rillig Exp $ +# $NetBSD: var-op-append.mk,v 1.12 2023/11/02 05:46:26 rillig Exp $ # # Tests for the '+=' variable assignment operator, which appends to a # variable, creating it if necessary. @@ -56,4 +56,33 @@ VAR.${:U\$\$\$\$\$\$\$\$}+= dollars . error .endif + +# Appending to an environment variable in the global scope creates a global +# variable of the same name, taking its initial value from the environment +# variable. After the assignment, the environment variable is left as-is, +# the value of the global variable is not synced back to the environment +# variable. +export ENV_PLUS_GLOBAL=from-env-value +ENV_PLUS_GLOBAL+= appended-value +.if ${ENV_PLUS_GLOBAL} != "from-env-value appended-value" +. error +.endif +EXPORTED!= echo "$$ENV_PLUS_GLOBAL" +.if ${EXPORTED} != "from-env-value" +. error +.endif + +# Appending to an environment variable in the command line scope ignores the +# environment variable. +export ENV_PLUS_COMMAND=from-env-value +.MAKEFLAGS: ENV_PLUS_COMMAND+=appended-command +.if ${ENV_PLUS_COMMAND} != "appended-command" +. error ${ENV_PLUS_COMMAND} +.endif +EXPORTED!= echo "$$ENV_PLUS_GLOBAL" +.if ${EXPORTED} != "from-env-value" +. error +.endif + + all:
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Thu Nov 2 05:46:26 UTC 2023 Modified Files: src/usr.bin/make/unit-tests: var-op-append.mk Log Message: tests/make: test appending to an environment variable To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/var-op-append.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Nov 2 05:40:49 UTC 2023 Modified Files: src/usr.bin/make: main.c parse.c var.c src/usr.bin/make/unit-tests: varmod-defined.mk Log Message: make: clean up comments No functional change. To generate a diff of this commit: cvs rdiff -u -r1.601 -r1.602 src/usr.bin/make/main.c cvs rdiff -u -r1.707 -r1.708 src/usr.bin/make/parse.c cvs rdiff -u -r1.1065 -r1.1066 src/usr.bin/make/var.c cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/varmod-defined.mk 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/make/main.c diff -u src/usr.bin/make/main.c:1.601 src/usr.bin/make/main.c:1.602 --- src/usr.bin/make/main.c:1.601 Thu Nov 2 04:50:44 2023 +++ src/usr.bin/make/main.c Thu Nov 2 05:40:49 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.601 2023/11/02 04:50:44 rillig Exp $ */ +/* $NetBSD: main.c,v 1.602 2023/11/02 05:40:49 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -111,7 +111,7 @@ #include "trace.h" /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.601 2023/11/02 04:50:44 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.602 2023/11/02 05:40:49 rillig Exp $"); #if defined(MAKE_NATIVE) && !defined(lint) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -121,7 +121,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19 CmdOpts opts; time_t now; /* Time at start of make */ GNode *defaultNode; /* .DEFAULT node */ -bool allPrecious; /* .PRECIOUS given on line by itself */ +bool allPrecious; /* .PRECIOUS given on a line by itself */ bool deleteOnError; /* .DELETE_ON_ERROR: set */ static int maxJobTokens; /* -j argument */ @@ -148,7 +148,7 @@ static HashTable cached_realpaths; /* * For compatibility with the POSIX version of MAKEFLAGS that includes - * all the options without '-', convert 'flags' to '-f -l -a -g -s'. + * all the options without '-', convert 'flags' to '-f -l -a -g -s '. */ static char * explode(const char *flags) @@ -439,7 +439,6 @@ MainParseArgJobs(const char *arg) static void MainParseArgSysInc(const char *argvalue) { - /* look for magic parent directory search string */ if (strncmp(".../", argvalue, 4) == 0) { char *found_path = Dir_FindHereOrAbove(curdir, argvalue + 4); if (found_path == NULL) @@ -1015,20 +1014,14 @@ InitVarMachineArch(void) #ifndef NO_PWD_OVERRIDE /* - * All this code is so that we know where we are when we start up - * on a different machine with pmake. - * - * XXX: Make no longer has "local" and "remote" mode. Is this code still - * necessary? - * * Overriding getcwd() with $PWD totally breaks MAKEOBJDIRPREFIX * since the value of curdir can vary depending on how we got - * here. Ie sitting at a shell prompt (shell that provides $PWD) - * or via subdir.mk in which case its likely a shell which does + * here. That is, sitting at a shell prompt (shell that provides $PWD) + * or via subdir.mk, in which case it's likely a shell which does * not provide it. * * So, to stop it breaking this case only, we ignore PWD if - * MAKEOBJDIRPREFIX is set or MAKEOBJDIR contains a variable expression. + * MAKEOBJDIRPREFIX is set or MAKEOBJDIR contains an expression. */ static void HandlePWD(const struct stat *curdir_st) @@ -1346,22 +1339,12 @@ main_Init(int argc, char **argv) exit(2); } - /* - * Get the name of this type of MACHINE from utsname - * so we can share an executable for similar machines. - * (i.e. m68k: amiga hp300, mac68k, sun3, ...) - * - * Note that both MACHINE and MACHINE_ARCH are decided at - * run-time. - */ machine = InitVarMachine(); machine_arch = InitVarMachineArch(); myPid = getpid(); /* remember this for vFork() */ - /* - * Just in case MAKEOBJDIR wants us to do something tricky. - */ + /* Just in case MAKEOBJDIR wants us to do something tricky. */ Targ_Init(); Var_Init(); Global_Set_ReadOnly(".MAKE.OS", utsname.sysname); @@ -1370,7 +1353,7 @@ main_Init(int argc, char **argv) #ifdef MAKE_VERSION Global_Set("MAKE_VERSION", MAKE_VERSION); #endif - Global_Set_ReadOnly(".newline", "\n"); /* handy for :@ loops */ + Global_Set_ReadOnly(".newline", "\n"); #ifndef MAKEFILE_PREFERENCE_LIST /* This is the traditional preference for makefiles. */ # define MAKEFILE_PREFERENCE_LIST "makefile Makefile" Index: src/usr.bin/make/parse.c diff -u src/usr.bin/make/parse.c:1.707 src/usr.bin/make/parse.c:1.708 --- src/usr.bin/make/parse.c:1.707 Thu Nov 2 04:50:44 2023 +++ src/usr.bin/make/parse.c Thu Nov 2 05:40:49 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.707 2023/11/02 04:50:44 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.708 2023/11/02 05:40:49 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -105,7 +105,7 @@ #include "pathnames.h" /* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Nov 2 05:40:49 UTC 2023 Modified Files: src/usr.bin/make: main.c parse.c var.c src/usr.bin/make/unit-tests: varmod-defined.mk Log Message: make: clean up comments No functional change. To generate a diff of this commit: cvs rdiff -u -r1.601 -r1.602 src/usr.bin/make/main.c cvs rdiff -u -r1.707 -r1.708 src/usr.bin/make/parse.c cvs rdiff -u -r1.1065 -r1.1066 src/usr.bin/make/var.c cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/varmod-defined.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Nov 2 05:14:58 UTC 2023 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: var-op-append.mk varmod-defined.mk varmod-match-escape.mk varmod-match.mk Log Message: make: sync comments with the extracted ParseModifier_Match No functional change. To generate a diff of this commit: cvs rdiff -u -r1.1064 -r1.1065 src/usr.bin/make/var.c cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/var-op-append.mk \ src/usr.bin/make/unit-tests/varmod-match-escape.mk cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod-defined.mk cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/varmod-match.mk 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/make/var.c diff -u src/usr.bin/make/var.c:1.1064 src/usr.bin/make/var.c:1.1065 --- src/usr.bin/make/var.c:1.1064 Sat Aug 19 19:59:17 2023 +++ src/usr.bin/make/var.c Thu Nov 2 05:14:58 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1064 2023/08/19 19:59:17 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1065 2023/11/02 05:14:58 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -139,7 +139,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1064 2023/08/19 19:59:17 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1065 2023/11/02 05:14:58 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -2457,7 +2457,7 @@ ParseModifier_Defined(const char **pp, M /* * XXX: This code is similar to the one in Var_Parse. See if - * the code can be merged. See also ApplyModifier_Match and + * the code can be merged. See also ParseModifier_Match and * ParseModifierPart. */ Index: src/usr.bin/make/unit-tests/var-op-append.mk diff -u src/usr.bin/make/unit-tests/var-op-append.mk:1.10 src/usr.bin/make/unit-tests/var-op-append.mk:1.11 --- src/usr.bin/make/unit-tests/var-op-append.mk:1.10 Wed Jun 21 07:30:50 2023 +++ src/usr.bin/make/unit-tests/var-op-append.mk Thu Nov 2 05:14:58 2023 @@ -1,4 +1,4 @@ -# $NetBSD: var-op-append.mk,v 1.10 2023/06/21 07:30:50 rillig Exp $ +# $NetBSD: var-op-append.mk,v 1.11 2023/11/02 05:14:58 rillig Exp $ # # Tests for the '+=' variable assignment operator, which appends to a # variable, creating it if necessary. @@ -39,7 +39,7 @@ VAR+= # empty # '+=' assignment operator. As far as possible, the '+' is interpreted as # part of the assignment operator. # -# See Parse_Var +# See Parse_Var, AdjustVarassignOp. C++= value .if ${C+} != "value" || defined(C++) . error Index: src/usr.bin/make/unit-tests/varmod-match-escape.mk diff -u src/usr.bin/make/unit-tests/varmod-match-escape.mk:1.10 src/usr.bin/make/unit-tests/varmod-match-escape.mk:1.11 --- src/usr.bin/make/unit-tests/varmod-match-escape.mk:1.10 Fri Jun 23 04:56:54 2023 +++ src/usr.bin/make/unit-tests/varmod-match-escape.mk Thu Nov 2 05:14:58 2023 @@ -1,8 +1,8 @@ -# $NetBSD: varmod-match-escape.mk,v 1.10 2023/06/23 04:56:54 rillig Exp $ +# $NetBSD: varmod-match-escape.mk,v 1.11 2023/11/02 05:14:58 rillig Exp $ # # As of 2020-08-01, the :M and :N modifiers interpret backslashes differently, # depending on whether there was a variable expression somewhere before the -# first backslash or not. See ApplyModifier_Match, "copy = true". +# first backslash or not. See ParseModifier_Match, "copy = true". # # Apart from the different and possibly confusing debug output, there is no # difference in behavior. When parsing the modifier text, only \{, \} and \: @@ -34,7 +34,7 @@ SPECIALS= \: : \\ * \* # Therefore the escaped ':' is kept as-is, and the final pattern becomes # ':\:'. # -# If ApplyModifier_Match had used the same parsing algorithm as Var_Subst, +# If ParseModifier_Match had used the same parsing algorithm as Var_Subst, # both patterns would end up as '::'. # VALUES= : :: :\: @@ -53,7 +53,7 @@ VALUES= : :: :\: .endif # XXX: As of 2020-11-01, unlike all other variable modifiers, '\$' is not -# parsed as an escaped '$'. Instead, ApplyModifier_Match first scans for +# parsed as an escaped '$'. Instead, ParseModifier_Match first scans for # the ':' at the end of the modifier, which results in the pattern '\$'. # No unescaping takes place since the pattern neither contained '\:' nor # '\{' nor '\}'. But the text is expanded, and a lonely '$' at the end Index: src/usr.bin/make/unit-tests/varmod-defined.mk diff -u src/usr.bin/make/unit-tests/varmod-defined.mk:1.13 src/usr.bin/make/unit-tests/varmod-defined.mk:1.14 --- src/usr.bin/make/unit-tests/varmod-defined.mk:1.13 Wed Aug 24 20:22:10 2022 +++ src/usr.bin/make/unit-tests/varmod-defined.mk Thu Nov 2 05:14:58 2023 @@ -1,4 +1,4 @@ -# $NetBSD: varmod-defined.mk,v 1.13 2022/08/24 20:22:10 rillig Exp $ +# $NetBSD: varmod-defined.mk,v 1.14 2023/11/02 05:14:58 rillig Exp $ # # Tests for the :D
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Nov 2 05:14:58 UTC 2023 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: var-op-append.mk varmod-defined.mk varmod-match-escape.mk varmod-match.mk Log Message: make: sync comments with the extracted ParseModifier_Match No functional change. To generate a diff of this commit: cvs rdiff -u -r1.1064 -r1.1065 src/usr.bin/make/var.c cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/var-op-append.mk \ src/usr.bin/make/unit-tests/varmod-match-escape.mk cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/varmod-defined.mk cvs rdiff -u -r1.15 -r1.16 src/usr.bin/make/unit-tests/varmod-match.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Nov 2 04:50:44 UTC 2023 Modified Files: src/usr.bin/make: main.c make.h parse.c Log Message: make: inline a single-line cross-file function No functional change. To generate a diff of this commit: cvs rdiff -u -r1.600 -r1.601 src/usr.bin/make/main.c cvs rdiff -u -r1.325 -r1.326 src/usr.bin/make/make.h cvs rdiff -u -r1.706 -r1.707 src/usr.bin/make/parse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/usr.bin/make/main.c diff -u src/usr.bin/make/main.c:1.600 src/usr.bin/make/main.c:1.601 --- src/usr.bin/make/main.c:1.600 Tue Sep 19 17:43:43 2023 +++ src/usr.bin/make/main.c Thu Nov 2 04:50:44 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.600 2023/09/19 17:43:43 rillig Exp $ */ +/* $NetBSD: main.c,v 1.601 2023/11/02 04:50:44 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -111,7 +111,7 @@ #include "trace.h" /* "@(#)main.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: main.c,v 1.600 2023/09/19 17:43:43 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.601 2023/11/02 04:50:44 rillig Exp $"); #if defined(MAKE_NATIVE) && !defined(lint) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -476,7 +476,7 @@ MainParseOption(char c, const char *argv Global_Append(MAKEFLAGS, argvalue); break; case 'I': - Parse_AddIncludeDir(argvalue); + SearchPath_Add(parseIncPath, argvalue); Global_Append(MAKEFLAGS, "-I"); Global_Append(MAKEFLAGS, argvalue); break; Index: src/usr.bin/make/make.h diff -u src/usr.bin/make/make.h:1.325 src/usr.bin/make/make.h:1.326 --- src/usr.bin/make/make.h:1.325 Sun Sep 10 11:52:29 2023 +++ src/usr.bin/make/make.h Thu Nov 2 04:50:44 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.325 2023/09/10 11:52:29 rillig Exp $ */ +/* $NetBSD: make.h,v 1.326 2023/11/02 04:50:44 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -859,7 +859,6 @@ void PrintLocation(FILE *, bool, const G void PrintStackTrace(bool); void Parse_Error(ParseErrorLevel, const char *, ...) MAKE_ATTR_PRINTFLIKE(2, 3); bool Parse_VarAssign(const char *, bool, GNode *) MAKE_ATTR_USE; -void Parse_AddIncludeDir(const char *); void Parse_File(const char *, int); void Parse_PushInput(const char *, unsigned, unsigned, Buffer, struct ForLoop *); Index: src/usr.bin/make/parse.c diff -u src/usr.bin/make/parse.c:1.706 src/usr.bin/make/parse.c:1.707 --- src/usr.bin/make/parse.c:1.706 Sat Aug 19 11:09:02 2023 +++ src/usr.bin/make/parse.c Thu Nov 2 04:50:44 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.706 2023/08/19 11:09:02 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.707 2023/11/02 04:50:44 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -105,7 +105,7 @@ #include "pathnames.h" /* "@(#)parse.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: parse.c,v 1.706 2023/08/19 11:09:02 rillig Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.707 2023/11/02 04:50:44 rillig Exp $"); /* Detects a multiple-inclusion guard in a makefile. */ typedef enum { @@ -2014,17 +2014,6 @@ GNode_AddCommand(GNode *gn, char *cmd) } /* - * Add a directory to the path searched for included makefiles bracketed - * by double-quotes. - */ -void -Parse_AddIncludeDir(const char *dir) -{ - (void)SearchPath_Add(parseIncPath, dir); -} - - -/* * Parse a directive like '.include' or '.-include'. * * .include "user-makefile.mk"
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Thu Nov 2 04:50:44 UTC 2023 Modified Files: src/usr.bin/make: main.c make.h parse.c Log Message: make: inline a single-line cross-file function No functional change. To generate a diff of this commit: cvs rdiff -u -r1.600 -r1.601 src/usr.bin/make/main.c cvs rdiff -u -r1.325 -r1.326 src/usr.bin/make/make.h cvs rdiff -u -r1.706 -r1.707 src/usr.bin/make/parse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/xlint/xlint
Module Name:src Committed By: rillig Date: Thu Oct 26 20:21:13 UTC 2023 Modified Files: src/usr.bin/xlint/xlint: xlint.c Log Message: lint: reduce number of negations, fix variable name No functional change. To generate a diff of this commit: cvs rdiff -u -r1.116 -r1.117 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/xlint
Module Name:src Committed By: rillig Date: Thu Oct 26 20:21:13 UTC 2023 Modified Files: src/usr.bin/xlint/xlint: xlint.c Log Message: lint: reduce number of negations, fix variable name No functional change. To generate a diff of this commit: cvs rdiff -u -r1.116 -r1.117 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.116 src/usr.bin/xlint/xlint/xlint.c:1.117 --- src/usr.bin/xlint/xlint/xlint.c:1.116 Thu Oct 26 19:56:31 2023 +++ src/usr.bin/xlint/xlint/xlint.c Thu Oct 26 20:21:13 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: xlint.c,v 1.116 2023/10/26 19:56:31 rillig Exp $ */ +/* $NetBSD: xlint.c,v 1.117 2023/10/26 20:21:13 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.116 2023/10/26 19:56:31 rillig Exp $"); +__RCSID("$NetBSD: xlint.c,v 1.117 2023/10/26 20:21:13 rillig Exp $"); #endif #include @@ -97,7 +97,7 @@ static list library_search_path; static const char *libexec_dir; static bool Cflag, dflag, Fflag, iflag, sflag, tflag, Vflag; static char *output_filename; /* filename for -o */ -static bool seen_c_source; +static bool seen_filename; /* * name of a file which is currently written by a child and should @@ -427,13 +427,13 @@ handle_filename(const char *name) return; } - if (strcmp(suff, "c") != 0 && - (strncmp(base, "llib-l", 6) != 0 || base != suff)) { + if (!(strcmp(suff, "c") == 0 || + (strncmp(base, "llib-l", 6) == 0 && base == suff))) { warnx("unknown file type: %s", name); return; } - if (!iflag || seen_c_source) + if (!iflag || seen_filename) (void)printf("%s:\n", Fflag ? name : base); /* build the name of the output file of lint1 */ @@ -794,11 +794,11 @@ main(int argc, char *argv[]) usage("Missing argument for l or L"); } else { handle_filename(arg); - seen_c_source = true; + seen_filename = true; } } - if (!seen_c_source) + if (!seen_filename) usage("Missing filename"); if (iflag)
CVS commit: src/usr.bin/xlint/xlint
Module Name:src Committed By: rillig Date: Thu Oct 26 19:56:31 UTC 2023 Modified Files: src/usr.bin/xlint/xlint: xlint.c Log Message: lint: merge redundant variables No functional change. To generate a diff of this commit: cvs rdiff -u -r1.115 -r1.116 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.115 src/usr.bin/xlint/xlint/xlint.c:1.116 --- src/usr.bin/xlint/xlint/xlint.c:1.115 Wed Oct 25 23:05:14 2023 +++ src/usr.bin/xlint/xlint/xlint.c Thu Oct 26 19:56:31 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: xlint.c,v 1.115 2023/10/25 23:05:14 rillig Exp $ */ +/* $NetBSD: xlint.c,v 1.116 2023/10/26 19:56:31 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.115 2023/10/25 23:05:14 rillig Exp $"); +__RCSID("$NetBSD: xlint.c,v 1.116 2023/10/26 19:56:31 rillig Exp $"); #endif #include @@ -95,8 +95,8 @@ static list default_libraries; static list additional_libraries; static list library_search_path; static const char *libexec_dir; -static bool Cflag, dflag, Fflag, iflag, oflag, sflag, tflag, Vflag; -static char *outputfn; /* filename for oflag */ +static bool Cflag, dflag, Fflag, iflag, sflag, tflag, Vflag; +static char *output_filename; /* filename for -o */ static bool seen_c_source; /* @@ -438,10 +438,9 @@ handle_filename(const char *name) /* build the name of the output file of lint1 */ char *ofn; - if (oflag) { - ofn = outputfn; - outputfn = NULL; - oflag = false; + if (output_filename != NULL) { + ofn = output_filename; + output_filename = NULL; } else if (iflag) { size_t len = base == suff ? strlen(base) @@ -702,7 +701,7 @@ main(int argc, char *argv[]) case 'C': if (Cflag) usage("%c flag already specified", 'C'); - if (oflag || iflag) + if (output_filename != NULL || iflag) usage("%c and %s flags cannot be specified " "together", 'C', "o or i"); Cflag = true; @@ -734,13 +733,12 @@ main(int argc, char *argv[]) break; case 'o': - if (oflag) + if (output_filename != NULL) usage("%c flag already specified", 'o'); if (Cflag) usage("%c and %s flags cannot be specified " "together", 'C', "o"); - oflag = true; - outputfn = xstrdup(optarg); + output_filename = xstrdup(optarg); break; case 'L': @@ -806,7 +804,7 @@ main(int argc, char *argv[]) if (iflag) terminate(0); - if (!oflag) { + if (output_filename == NULL) { const char *ks = getenv("LIBDIR"); if (ks == NULL || ks[0] == '\0') ks = PATH_LINTLIB; @@ -817,8 +815,8 @@ main(int argc, char *argv[]) run_lint2(); - if (oflag) - cat(, outputfn); + if (output_filename != NULL) + cat(, output_filename); if (Cflag) lint2.outlib = NULL;
CVS commit: src/usr.bin/xlint/xlint
Module Name:src Committed By: rillig Date: Thu Oct 26 19:56:31 UTC 2023 Modified Files: src/usr.bin/xlint/xlint: xlint.c Log Message: lint: merge redundant variables No functional change. To generate a diff of this commit: cvs rdiff -u -r1.115 -r1.116 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/xlint
Module Name:src Committed By: rillig Date: Wed Oct 25 23:05:15 UTC 2023 Modified Files: src/usr.bin/xlint/xlint: xlint.c Log Message: lint: make variable names more expressive, remove redundant comments No functional change. To generate a diff of this commit: cvs rdiff -u -r1.114 -r1.115 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.114 src/usr.bin/xlint/xlint/xlint.c:1.115 --- src/usr.bin/xlint/xlint/xlint.c:1.114 Thu Jul 13 08:40:38 2023 +++ src/usr.bin/xlint/xlint/xlint.c Wed Oct 25 23:05:14 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: xlint.c,v 1.114 2023/07/13 08:40:38 rillig Exp $ */ +/* $NetBSD: xlint.c,v 1.115 2023/10/25 23:05:14 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.114 2023/07/13 08:40:38 rillig Exp $"); +__RCSID("$NetBSD: xlint.c,v 1.115 2023/10/25 23:05:14 rillig Exp $"); #endif #include @@ -90,31 +90,14 @@ static struct { char *outlib; /* output library that will be created */ } lint2; -/* directory for temporary files */ -static const char *tmpdir; - -/* default libraries */ -static list deflibs; - -/* additional libraries */ -static list libs; - -/* search path for libraries */ -static list libsrchpath; - +static const char *tmpdir; +static list default_libraries; +static list additional_libraries; +static list library_search_path; static const char *libexec_dir; - -/* flags */ -static bool iflag, oflag, Cflag, sflag, tflag, Fflag, dflag; - -/* print the commands executed to run the stages of compilation */ -static bool Vflag; - -/* filename for oflag */ -static char *outputfn; - -/* reset after first .c source has been processed */ -static bool first = true; +static bool Cflag, dflag, Fflag, iflag, oflag, sflag, tflag, Vflag; +static char *outputfn; /* filename for oflag */ +static bool seen_c_source; /* * name of a file which is currently written by a child and should @@ -204,7 +187,7 @@ set_tmpdir(void) } /* Clean up after a signal or at the regular end. */ -static void __attribute__((__noreturn__)) +__dead static void terminate(int signo) { @@ -235,7 +218,7 @@ terminate(int signo) exit(signo != 0 ? 1 : 0); } -static void __attribute__((__noreturn__, __format__(__printf__, 1, 2))) +__dead __printflike(1, 2) static void usage(const char *fmt, ...) { va_list ap; @@ -313,7 +296,6 @@ needs_quoting: 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]); @@ -350,7 +332,9 @@ run_child(const char *path, list *args, /* NOTREACHED */ } - while ((rv = wait()) == -1 && errno == EINTR) ; + int status, rv, signo; + while ((rv = wait()) == -1 && errno == EINTR) + continue; if (rv == -1) { warn("wait"); terminate(-1); @@ -432,13 +416,9 @@ run_lint1(const char *out_fname) static void handle_filename(const char *name) { - const char *bn, *suff; - char *ofn; - size_t len; - int fd; - bn = lbasename(name, '/'); - suff = lbasename(bn, '.'); + const char *base = lbasename(name, '/'); + const char *suff = lbasename(base, '.'); if (strcmp(suff, "ln") == 0) { /* only for lint2 */ @@ -448,25 +428,28 @@ handle_filename(const char *name) } if (strcmp(suff, "c") != 0 && - (strncmp(bn, "llib-l", 6) != 0 || bn != suff)) { + (strncmp(base, "llib-l", 6) != 0 || base != suff)) { warnx("unknown file type: %s", name); return; } - if (!iflag || !first) - (void)printf("%s:\n", Fflag ? name : bn); + if (!iflag || seen_c_source) + (void)printf("%s:\n", Fflag ? name : base); /* build the name of the output file of lint1 */ + char *ofn; if (oflag) { ofn = outputfn; outputfn = NULL; oflag = false; } else if (iflag) { - len = bn == suff ? strlen(bn) : (size_t)((suff - 1) - bn); - ofn = xasprintf("%.*s.ln", (int)len, bn); + size_t len = base == suff + ? strlen(base) + : (size_t)((suff - 1) - base); + ofn = xasprintf("%.*s.ln", (int)len, base); } else { ofn = xasprintf("%slint1.XX", tmpdir); - fd = mkstemp(ofn); + int fd = mkstemp(ofn); if (fd == -1) { warn("can't make temp"); terminate(-1); @@ -488,13 +471,9 @@ file_is_readable(const char *path) { struct stat sbuf; - if (stat(path, ) == -1) - return false; - if (!S_ISREG(sbuf.st_mode)) - return false; - if (access(path, R_OK) == -1) - return false; - return true; + return stat(path, ) == 0 + && S_ISREG(sbuf.st_mode) + && access(path, R_OK) == 0; } static void @@ -502,8 +481,8 @@ find_lib(const char *lib) { char *lfn; - for (size_t i = 0; i < libsrchpath.len; i++) { - const char *dir = libsrchpath.items[i]; + for (size_t i = 0; i < library_search_path.len; i++) {
CVS commit: src/usr.bin/xlint/xlint
Module Name:src Committed By: rillig Date: Wed Oct 25 23:05:15 UTC 2023 Modified Files: src/usr.bin/xlint/xlint: xlint.c Log Message: lint: make variable names more expressive, remove redundant comments No functional change. To generate a diff of this commit: cvs rdiff -u -r1.114 -r1.115 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/tests/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Oct 22 21:30:32 UTC 2023 Modified Files: src/tests/usr.bin/xlint/lint1: decl_direct_abstract.c Log Message: tests/lint: test GCC attributes after abstract function type To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 \ src/tests/usr.bin/xlint/lint1/decl_direct_abstract.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/xlint/lint1/decl_direct_abstract.c diff -u src/tests/usr.bin/xlint/lint1/decl_direct_abstract.c:1.10 src/tests/usr.bin/xlint/lint1/decl_direct_abstract.c:1.11 --- src/tests/usr.bin/xlint/lint1/decl_direct_abstract.c:1.10 Wed Aug 2 21:11:35 2023 +++ src/tests/usr.bin/xlint/lint1/decl_direct_abstract.c Sun Oct 22 21:30:32 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: decl_direct_abstract.c,v 1.10 2023/08/02 21:11:35 rillig Exp $ */ +/* $NetBSD: decl_direct_abstract.c,v 1.11 2023/10/22 21:30:32 rillig Exp $ */ # 3 "decl_direct_abstract.c" /* @@ -215,3 +215,12 @@ int prototype_named_32_return_04[-1000 - /* expect+2: error: cannot take size/alignment of function type 'function(struct typedef a32) returning struct typedef a08' [144] */ /* expect+1: error: negative array dimension (-1000) [20] */ int prototype_named_32_return_08[-1000 - (int)sizeof(a08(a32 arg))]; + +void +abstract_decl_param_list_with_attributes(void) +{ + typedef int unspecified_parameters(void (*)() __attribute__(())); + typedef int no_parameters(void (*)(void) __attribute__(())); + typedef int single_parameter(void (*)(int) __attribute__(())); + typedef int several_parameters(void (*)(int, int) __attribute__(())); +}
CVS commit: src/tests/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Oct 22 21:30:32 UTC 2023 Modified Files: src/tests/usr.bin/xlint/lint1: decl_direct_abstract.c Log Message: tests/lint: test GCC attributes after abstract function type To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 \ src/tests/usr.bin/xlint/lint1/decl_direct_abstract.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: Sun Oct 22 21:03:08 UTC 2023 Modified Files: src/tests/usr.bin/indent: lsym_unary_op.c opt_bad.c Log Message: tests/indent: clean up comments To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/tests/usr.bin/indent/lsym_unary_op.c \ src/tests/usr.bin/indent/opt_bad.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: Sun Oct 22 21:03:08 UTC 2023 Modified Files: src/tests/usr.bin/indent: lsym_unary_op.c opt_bad.c Log Message: tests/indent: clean up comments To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/tests/usr.bin/indent/lsym_unary_op.c \ src/tests/usr.bin/indent/opt_bad.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_unary_op.c diff -u src/tests/usr.bin/indent/lsym_unary_op.c:1.12 src/tests/usr.bin/indent/lsym_unary_op.c:1.13 --- src/tests/usr.bin/indent/lsym_unary_op.c:1.12 Sat Jun 17 22:09:24 2023 +++ src/tests/usr.bin/indent/lsym_unary_op.c Sun Oct 22 21:03:08 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: lsym_unary_op.c,v 1.12 2023/06/17 22:09:24 rillig Exp $ */ +/* $NetBSD: lsym_unary_op.c,v 1.13 2023/10/22 21:03:08 rillig Exp $ */ /* * Tests for the token lsym_unary_op, which represents a unary operator. @@ -50,8 +50,8 @@ int same = + + + + +- - - - -3; /* - * A special kind of unary operator is '->', which additionally suppresses the - * next space. + * The operator '->' is special as it additionally suppresses the space between + * the operator and its right operand. */ //indent input int var = p -> member; Index: src/tests/usr.bin/indent/opt_bad.c diff -u src/tests/usr.bin/indent/opt_bad.c:1.12 src/tests/usr.bin/indent/opt_bad.c:1.13 --- src/tests/usr.bin/indent/opt_bad.c:1.12 Mon Jun 26 14:54:40 2023 +++ src/tests/usr.bin/indent/opt_bad.c Sun Oct 22 21:03:08 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: opt_bad.c,v 1.12 2023/06/26 14:54:40 rillig Exp $ */ +/* $NetBSD: opt_bad.c,v 1.13 2023/10/22 21:03:08 rillig Exp $ */ /* * Tests for the options '-bad' and '-nbad'. @@ -174,7 +174,7 @@ initializer_with_blank(void) /* comment */ int decl2; // $ If the declaration is followed by a '}' that terminates the block - // $ statement, * there is no need for a blank line before the '}'. + // $ statement, there is no need for a blank line before the '}'. } //indent end
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Thu Oct 19 18:24:33 UTC 2023 Modified Files: src/usr.bin/make/unit-tests: cond-short.exp cond-short.mk directive-for.exp directive-for.mk directive-ifndef.mk directive-include-guard.exp directive-include-guard.mk escape.exp escape.mk hanoi-include.mk recursive.exp recursive.mk unexport.mk var-eval-short.mk varmisc.exp varmisc.mk varmod-gmtime.mk Log Message: tests/make: clean up, explain and reorganize several tests To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/cond-short.exp \ src/usr.bin/make/unit-tests/directive-include-guard.mk cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/cond-short.mk cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/directive-for.exp \ src/usr.bin/make/unit-tests/varmod-gmtime.mk cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/directive-for.mk cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/directive-ifndef.mk cvs rdiff -u -r1.11 -r1.12 \ src/usr.bin/make/unit-tests/directive-include-guard.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/escape.exp cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/escape.mk cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/hanoi-include.mk \ src/usr.bin/make/unit-tests/recursive.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/recursive.mk cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/unexport.mk cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/var-eval-short.mk cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/varmisc.exp cvs rdiff -u -r1.32 -r1.33 src/usr.bin/make/unit-tests/varmisc.mk 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/make/unit-tests/cond-short.exp diff -u src/usr.bin/make/unit-tests/cond-short.exp:1.12 src/usr.bin/make/unit-tests/cond-short.exp:1.13 --- src/usr.bin/make/unit-tests/cond-short.exp:1.12 Sat Mar 4 13:42:36 2023 +++ src/usr.bin/make/unit-tests/cond-short.exp Thu Oct 19 18:24:33 2023 @@ -7,7 +7,7 @@ expected M pattern expected or expected or exists expected or empty -make: "cond-short.mk" line 214: Comparison with '<' requires both operands '' and '42' to be numeric +make: "cond-short.mk" line 231: Comparison with '<' requires both operands '' and '42' to be numeric make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/directive-include-guard.mk diff -u src/usr.bin/make/unit-tests/directive-include-guard.mk:1.12 src/usr.bin/make/unit-tests/directive-include-guard.mk:1.13 --- src/usr.bin/make/unit-tests/directive-include-guard.mk:1.12 Fri Aug 11 04:56:31 2023 +++ src/usr.bin/make/unit-tests/directive-include-guard.mk Thu Oct 19 18:24:33 2023 @@ -1,4 +1,4 @@ -# $NetBSD: directive-include-guard.mk,v 1.12 2023/08/11 04:56:31 rillig Exp $ +# $NetBSD: directive-include-guard.mk,v 1.13 2023/10/19 18:24:33 rillig Exp $ # # Tests for multiple-inclusion guards in makefiles. # @@ -15,8 +15,9 @@ # .endif # # When such a file is included for the second or later time, and the guard -# variable or the guard target is defined, including the file has no effect, -# as all its content is skipped. +# variable or the guard target is defined, the file is skipped completely, as +# including it would not have any effect, not even on the special variable +# '.MAKE.MAKEFILES', as that variable skips duplicate pathnames. # # See also: # https://gcc.gnu.org/onlinedocs/cppinternals/Guard-Macros.html @@ -46,6 +47,25 @@ LINES.variable-ifndef-reuse= \ # expect: Parse_PushInput: file variable-ifndef-reuse.tmp, line 1 # expect: Skipping 'variable-ifndef-reuse.tmp' because 'VARIABLE_IFNDEF' is defined +# The guard variable cannot be a number, as numbers are interpreted +# differently from bare words. +INCS+= variable-ifndef-zero +LINES.variable-ifndef-zero= \ + '.ifndef 0e0' \ + 'syntax error' \ + '.endif' +# expect: Parse_PushInput: file variable-ifndef-zero.tmp, line 1 +# expect: Parse_PushInput: file variable-ifndef-zero.tmp, line 1 + +# The guard variable cannot be a number, as numbers are interpreted +# differently from bare words. +INCS+= variable-ifndef-one +LINES.variable-ifndef-one= \ + '.ifndef 1' \ + '.endif' +# expect: Parse_PushInput: file variable-ifndef-one.tmp, line 1 +# expect: Parse_PushInput: file variable-ifndef-one.tmp, line 1 + # Comments and empty lines do not affect the multiple-inclusion guard. INCS+= comments LINES.comments= \ @@ -124,10 +144,10 @@ LINES.variable-name-exclamation= \ # expect: Parse_PushInput: file variable-name-exclamation.tmp, line 1 # expect: Parse_PushInput: file variable-name-exclamation.tmp, line 1 -# A variable name can contain a '!' in the middle, as that character is -# interpreted as an ordinary character in conditions as well as on the left -# side of a variable
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Thu Oct 19 18:24:33 UTC 2023 Modified Files: src/usr.bin/make/unit-tests: cond-short.exp cond-short.mk directive-for.exp directive-for.mk directive-ifndef.mk directive-include-guard.exp directive-include-guard.mk escape.exp escape.mk hanoi-include.mk recursive.exp recursive.mk unexport.mk var-eval-short.mk varmisc.exp varmisc.mk varmod-gmtime.mk Log Message: tests/make: clean up, explain and reorganize several tests To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/cond-short.exp \ src/usr.bin/make/unit-tests/directive-include-guard.mk cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/unit-tests/cond-short.mk cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/directive-for.exp \ src/usr.bin/make/unit-tests/varmod-gmtime.mk cvs rdiff -u -r1.22 -r1.23 src/usr.bin/make/unit-tests/directive-for.mk cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/directive-ifndef.mk cvs rdiff -u -r1.11 -r1.12 \ src/usr.bin/make/unit-tests/directive-include-guard.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/escape.exp cvs rdiff -u -r1.14 -r1.15 src/usr.bin/make/unit-tests/escape.mk cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/hanoi-include.mk \ src/usr.bin/make/unit-tests/recursive.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/recursive.mk cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/unexport.mk cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/var-eval-short.mk cvs rdiff -u -r1.17 -r1.18 src/usr.bin/make/unit-tests/varmisc.exp cvs rdiff -u -r1.32 -r1.33 src/usr.bin/make/unit-tests/varmisc.mk 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/lint1
Module Name:src Committed By: rillig Date: Tue Oct 17 19:33:16 UTC 2023 Modified Files: src/usr.bin/xlint/lint1: cgram.y Log Message: lint: resolve shift/reduce conflict in labels with attributes To generate a diff of this commit: cvs rdiff -u -r1.475 -r1.476 src/usr.bin/xlint/lint1/cgram.y 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/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.475 src/usr.bin/xlint/lint1/cgram.y:1.476 --- src/usr.bin/xlint/lint1/cgram.y:1.475 Tue Oct 17 19:29:09 2023 +++ src/usr.bin/xlint/lint1/cgram.y Tue Oct 17 19:33:16 2023 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.475 2023/10/17 19:29:09 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.476 2023/10/17 19:33:16 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: cgram.y,v 1.475 2023/10/17 19:29:09 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.476 2023/10/17 19:33:16 rillig Exp $"); #endif #include @@ -132,7 +132,7 @@ is_either(const char *s, const char *a, %} -%expect 104 +%expect 103 %union { val_t *y_val; @@ -386,7 +386,9 @@ is_either(const char *s, const char *a, /* No type for init_rbrace. */ %type asm_or_symbolrename_opt /* No type for statement. */ +/* No type for no_attr_statement. */ /* No type for non_expr_statement. */ +/* No type for no_attr_non_expr_statement. */ /* No type for labeled_statement. */ /* No type for label. */ /* No type for compound_statement. */ @@ -1752,9 +1754,20 @@ statement: | non_expr_statement ; +/* Helper to avoid shift/reduce conflict in 'label: __attribute__ ;'. */ +no_attr_statement: + expression_statement +| no_attr_non_expr_statement +; + non_expr_statement: /* helper for C99 6.8 */ gcc_attribute_specifier /* ((__fallthrough__)) */ T_SEMI -| labeled_statement +| no_attr_non_expr_statement +; + +/* Helper to avoid shift/reduce conflict in 'label: __attribute__ ;'. */ +no_attr_non_expr_statement: + labeled_statement | compound_statement | selection_statement | iteration_statement @@ -1765,7 +1778,7 @@ non_expr_statement: /* helper for C99 6 ; labeled_statement: /* C99 6.8.1 */ - label gcc_attribute_specifier_list_opt statement + label gcc_attribute_specifier_list_opt no_attr_statement ; label:
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Tue Oct 17 19:33:16 UTC 2023 Modified Files: src/usr.bin/xlint/lint1: cgram.y Log Message: lint: resolve shift/reduce conflict in labels with attributes To generate a diff of this commit: cvs rdiff -u -r1.475 -r1.476 src/usr.bin/xlint/lint1/cgram.y 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/lint1
Module Name:src Committed By: rillig Date: Tue Oct 17 19:29:09 UTC 2023 Modified Files: src/usr.bin/xlint/lint1: cgram.y debug.c Log Message: lint: fix debug output of convert/cast operators The default name of the 'CVT' operator is 'convert', therefore the override is only needed for 'cast'. To generate a diff of this commit: cvs rdiff -u -r1.474 -r1.475 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.62 -r1.63 src/usr.bin/xlint/lint1/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/xlint/lint1/cgram.y diff -u src/usr.bin/xlint/lint1/cgram.y:1.474 src/usr.bin/xlint/lint1/cgram.y:1.475 --- src/usr.bin/xlint/lint1/cgram.y:1.474 Thu Sep 14 22:20:08 2023 +++ src/usr.bin/xlint/lint1/cgram.y Tue Oct 17 19:29:09 2023 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.474 2023/09/14 22:20:08 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.475 2023/10/17 19:29:09 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: cgram.y,v 1.474 2023/09/14 22:20:08 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.475 2023/10/17 19:29:09 rillig Exp $"); #endif #include @@ -159,7 +159,7 @@ is_either(const char *s, const char *a, /* for Bison: %printer { if (is_integer($$->v_tspec)) - fprintf(yyo, "%lld", (unsigned long long)$$->u.integer); + fprintf(yyo, "%lld", (long long)$$->u.integer); else fprintf(yyo, "%Lg", $$->u.floating); } @@ -2280,8 +2280,8 @@ cgram_declare(sym_t *decl, bool has_init } /* - * Discard all input tokens up to and including the next - * unmatched right paren + * Discard all input tokens up to and including the next unmatched right + * parenthesis. */ static void read_until_rparen(void) Index: src/usr.bin/xlint/lint1/debug.c diff -u src/usr.bin/xlint/lint1/debug.c:1.62 src/usr.bin/xlint/lint1/debug.c:1.63 --- src/usr.bin/xlint/lint1/debug.c:1.62 Wed Sep 13 20:31:58 2023 +++ src/usr.bin/xlint/lint1/debug.c Tue Oct 17 19:29:09 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: debug.c,v 1.62 2023/09/13 20:31:58 rillig Exp $ */ +/* $NetBSD: debug.c,v 1.63 2023/10/17 19:29:09 rillig Exp $ */ /*- * Copyright (c) 2021 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) -__RCSID("$NetBSD: debug.c,v 1.62 2023/09/13 20:31:58 rillig Exp $"); +__RCSID("$NetBSD: debug.c,v 1.63 2023/10/17 19:29:09 rillig Exp $"); #endif #include @@ -187,16 +187,15 @@ debug_type(const type_t *tp) void debug_node(const tnode_t *tn) // NOLINT(misc-no-recursion) { - op_t op; if (tn == NULL) { debug_step("null"); return; } - op = tn->tn_op; + op_t op = tn->tn_op; debug_printf("'%s'", - op == CVT && !tn->tn_cast ? "convert" : op_name(op)); + op == CVT && tn->tn_cast ? "cast" : op_name(op)); if (op == NAME) debug_printf(" '%s' with %s", tn->tn_sym->s_name,
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Tue Oct 17 19:29:09 UTC 2023 Modified Files: src/usr.bin/xlint/lint1: cgram.y debug.c Log Message: lint: fix debug output of convert/cast operators The default name of the 'CVT' operator is 'convert', therefore the override is only needed for 'cast'. To generate a diff of this commit: cvs rdiff -u -r1.474 -r1.475 src/usr.bin/xlint/lint1/cgram.y cvs rdiff -u -r1.62 -r1.63 src/usr.bin/xlint/lint1/debug.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.