CVS commit: src/bin/df
Module Name:src Committed By: simonb Date: Mon Nov 29 05:59:58 UTC 2021 Modified Files: src/bin/df: df.c Log Message: Set totals.f_frsize to DEV_BSIZE instead of totals.f_bsize so that addstat() uses an initialised value for total size calculations. Fixes core dump for "df -c". To generate a diff of this commit: cvs rdiff -u -r1.98 -r1.99 src/bin/df/df.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/df/df.c diff -u src/bin/df/df.c:1.98 src/bin/df/df.c:1.99 --- src/bin/df/df.c:1.98 Sun Jan 3 01:43:12 2021 +++ src/bin/df/df.c Mon Nov 29 05:59:58 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: df.c,v 1.98 2021/01/03 01:43:12 ginsbach Exp $ */ +/* $NetBSD: df.c,v 1.99 2021/11/29 05:59:58 simonb Exp $ */ /* * Copyright (c) 1980, 1990, 1993, 1994 @@ -45,7 +45,7 @@ __COPYRIGHT( #if 0 static char sccsid[] = "@(#)df.c 8.7 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: df.c,v 1.98 2021/01/03 01:43:12 ginsbach Exp $"); +__RCSID("$NetBSD: df.c,v 1.99 2021/11/29 05:59:58 simonb Exp $"); #endif #endif /* not lint */ @@ -213,7 +213,7 @@ main(int argc, char *argv[]) if (cflag) { memset(&totals, 0, sizeof(totals)); - totals.f_bsize = DEV_BSIZE; + totals.f_frsize = DEV_BSIZE; strlcpy(totals.f_mntfromname, "total", sizeof(totals.f_mntfromname)); }
CVS commit: src/bin/df
Module Name:src Committed By: simonb Date: Mon Nov 29 05:59:58 UTC 2021 Modified Files: src/bin/df: df.c Log Message: Set totals.f_frsize to DEV_BSIZE instead of totals.f_bsize so that addstat() uses an initialised value for total size calculations. Fixes core dump for "df -c". To generate a diff of this commit: cvs rdiff -u -r1.98 -r1.99 src/bin/df/df.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/lgpl3/gmp/dist/mpz
Module Name:src Committed By: mrg Date: Mon Nov 29 03:57:22 UTC 2021 Modified Files: src/external/lgpl3/gmp/dist/mpz: inp_raw.c Log Message: gmp: pullover fixes for https://nvd.nist.gov/vuln/detail/CVE-2021-43618 changeset 18135:561a9c25298e mpz/inp_raw.c: Avoid bit size overflows author Marco Bodrato XXX: pullup-8, pullup-9 To generate a diff of this commit: cvs rdiff -u -r1.1.1.4 -r1.2 src/external/lgpl3/gmp/dist/mpz/inp_raw.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/external/lgpl3/gmp/dist/mpz
Module Name:src Committed By: mrg Date: Mon Nov 29 03:57:22 UTC 2021 Modified Files: src/external/lgpl3/gmp/dist/mpz: inp_raw.c Log Message: gmp: pullover fixes for https://nvd.nist.gov/vuln/detail/CVE-2021-43618 changeset 18135:561a9c25298e mpz/inp_raw.c: Avoid bit size overflows author Marco Bodrato XXX: pullup-8, pullup-9 To generate a diff of this commit: cvs rdiff -u -r1.1.1.4 -r1.2 src/external/lgpl3/gmp/dist/mpz/inp_raw.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/external/lgpl3/gmp/dist/mpz/inp_raw.c diff -u src/external/lgpl3/gmp/dist/mpz/inp_raw.c:1.1.1.4 src/external/lgpl3/gmp/dist/mpz/inp_raw.c:1.2 --- src/external/lgpl3/gmp/dist/mpz/inp_raw.c:1.1.1.4 Sun Sep 27 00:27:05 2020 +++ src/external/lgpl3/gmp/dist/mpz/inp_raw.c Mon Nov 29 03:57:22 2021 @@ -88,8 +88,11 @@ mpz_inp_raw (mpz_ptr x, FILE *fp) abs_csize = ABS (csize); + if (UNLIKELY (abs_csize > ~(mp_bitcnt_t) 0 / 8)) +return 0; /* Bit size overflows */ + /* round up to a multiple of limbs */ - abs_xsize = BITS_TO_LIMBS (abs_csize*8); + abs_xsize = BITS_TO_LIMBS ((mp_bitcnt_t) abs_csize * 8); if (abs_xsize != 0) {
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Mon Nov 29 00:17:10 UTC 2021 Modified Files: src/usr.bin/make/unit-tests: deptgt-makeflags.mk Log Message: tests/make: test escape sequences in string literals for .MAKEFLAGS These escape sequences differ from those in string literals in conditions. In "assignments" to .MAKEFLAGS, \n is a newline, while in a line like '.if ${VAR} == "\n"', it is simply the letter 'n'. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/deptgt-makeflags.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/deptgt-makeflags.mk diff -u src/usr.bin/make/unit-tests/deptgt-makeflags.mk:1.6 src/usr.bin/make/unit-tests/deptgt-makeflags.mk:1.7 --- src/usr.bin/make/unit-tests/deptgt-makeflags.mk:1.6 Sun Nov 15 20:20:58 2020 +++ src/usr.bin/make/unit-tests/deptgt-makeflags.mk Mon Nov 29 00:17:10 2021 @@ -1,4 +1,4 @@ -# $NetBSD: deptgt-makeflags.mk,v 1.6 2020/11/15 20:20:58 rillig Exp $ +# $NetBSD: deptgt-makeflags.mk,v 1.7 2021/11/29 00:17:10 rillig Exp $ # # Tests for the special target .MAKEFLAGS in dependency declarations, # which adds command line options later, at parse time. @@ -65,7 +65,7 @@ .endif # Next try at defining another newline variable. Since whitespace around the -# variable value is trimmed, two empty variable expressions surround the +# variable value is trimmed, two empty variable expressions ${:U} surround the # literal newline now. This prevents the newline from being skipped during # parsing. The ':=' assignment operator expands the empty variable # expressions, leaving only the newline as the variable value. @@ -81,6 +81,31 @@ .endif #.MAKEFLAGS: -d0 +# Now do the same for the other escape sequences; see Substring_Words. +.MAKEFLAGS: CHAR_BS:="$${:U}\b$${:U}" +.MAKEFLAGS: CHAR_FF:="$${:U}\f$${:U}" +.MAKEFLAGS: CHAR_NL:="$${:U}\n$${:U}" +.MAKEFLAGS: CHAR_CR:="$${:U}\r$${:U}" +.MAKEFLAGS: CHAR_TAB:="$${:U}\t$${:U}" + +# Note: backspace is not whitespace, it is a control character. +.if ${CHAR_BS:C,^[[:cntrl:]]$,found,W} != "found" +. error +.endif +.if ${CHAR_FF:C,^[[:space:]]$,found,W} != "found" +. error +.endif +.if ${CHAR_NL:C,^[[:space:]]$,found,W} != "found" +. error +.endif +.if ${CHAR_CR:C,^[[:space:]]$,found,W} != "found" +. error +.endif +.if ${CHAR_TAB:C,^[[:space:]]$,found,W} != "found" +. error +.endif + + # Unbalanced quotes produce an error message. If they occur anywhere in the # command line, the whole command line is skipped. .MAKEFLAGS: VAR=previous
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: rillig Date: Mon Nov 29 00:17:10 UTC 2021 Modified Files: src/usr.bin/make/unit-tests: deptgt-makeflags.mk Log Message: tests/make: test escape sequences in string literals for .MAKEFLAGS These escape sequences differ from those in string literals in conditions. In "assignments" to .MAKEFLAGS, \n is a newline, while in a line like '.if ${VAR} == "\n"', it is simply the letter 'n'. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/deptgt-makeflags.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 28 23:12:51 UTC 2021 Modified Files: src/usr.bin/make: compat.c make.c make.h Log Message: make: fix a few lint warnings about type mismatch in enum comparisons These warnings were triggered with the lint flag '-e', which enables additional checks on enums. This check would have detected the type mismatch from the previous commit. The check has a few strange warnings though, complaining about initialization of 'unsigned long' with 'unsigned long', so don't enable it for the official builds. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.228 -r1.229 src/usr.bin/make/compat.c cvs rdiff -u -r1.247 -r1.248 src/usr.bin/make/make.c cvs rdiff -u -r1.269 -r1.270 src/usr.bin/make/make.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/make
Module Name:src Committed By: rillig Date: Sun Nov 28 23:12:51 UTC 2021 Modified Files: src/usr.bin/make: compat.c make.c make.h Log Message: make: fix a few lint warnings about type mismatch in enum comparisons These warnings were triggered with the lint flag '-e', which enables additional checks on enums. This check would have detected the type mismatch from the previous commit. The check has a few strange warnings though, complaining about initialization of 'unsigned long' with 'unsigned long', so don't enable it for the official builds. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.228 -r1.229 src/usr.bin/make/compat.c cvs rdiff -u -r1.247 -r1.248 src/usr.bin/make/make.c cvs rdiff -u -r1.269 -r1.270 src/usr.bin/make/make.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/make/compat.c diff -u src/usr.bin/make/compat.c:1.228 src/usr.bin/make/compat.c:1.229 --- src/usr.bin/make/compat.c:1.228 Sun Nov 28 19:51:06 2021 +++ src/usr.bin/make/compat.c Sun Nov 28 23:12:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: compat.c,v 1.228 2021/11/28 19:51:06 rillig Exp $ */ +/* $NetBSD: compat.c,v 1.229 2021/11/28 23:12:51 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -96,7 +96,7 @@ #include "pathnames.h" /* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: compat.c,v 1.228 2021/11/28 19:51:06 rillig Exp $"); +MAKE_RCSID("$NetBSD: compat.c,v 1.229 2021/11/28 23:12:51 rillig Exp $"); static GNode *curTarg = NULL; static pid_t compatChild; @@ -237,7 +237,7 @@ Compat_RunCommand(const char *cmdp, GNod * using a shell */ const char *volatile cmd = cmdp; - silent = (gn->type & OP_SILENT) != 0; + silent = (gn->type & OP_SILENT) != OP_NONE; errCheck = !(gn->type & OP_IGNORE); doIt = false; @@ -562,7 +562,7 @@ MakeUnmade(GNode *gn, GNode *pgn) RunCommands(gn); curTarg = NULL; } else { - Job_Touch(gn, (gn->type & OP_SILENT) != 0); + Job_Touch(gn, (gn->type & OP_SILENT) != OP_NONE); } } else { gn->made = ERROR; Index: src/usr.bin/make/make.c diff -u src/usr.bin/make/make.c:1.247 src/usr.bin/make/make.c:1.248 --- src/usr.bin/make/make.c:1.247 Sun Nov 28 22:48:06 2021 +++ src/usr.bin/make/make.c Sun Nov 28 23:12:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: make.c,v 1.247 2021/11/28 22:48:06 rillig Exp $ */ +/* $NetBSD: make.c,v 1.248 2021/11/28 23:12:51 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -104,7 +104,7 @@ #include "job.h" /* "@(#)make.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: make.c,v 1.247 2021/11/28 22:48:06 rillig Exp $"); +MAKE_RCSID("$NetBSD: make.c,v 1.248 2021/11/28 23:12:51 rillig Exp $"); /* Sequence # to detect recursion. */ static unsigned int checked_seqno = 1; @@ -144,7 +144,7 @@ GNodeType_ToString(GNodeType type, void Buffer buf; Buf_InitSize(&buf, 32); -#define ADD(flag) Buf_AddFlag(&buf, (type & (flag)) != 0, #flag) +#define ADD(flag) Buf_AddFlag(&buf, (type & (flag)) != OP_NONE, #flag) ADD(OP_DEPENDS); ADD(OP_FORCE); ADD(OP_DOUBLEDEP); Index: src/usr.bin/make/make.h diff -u src/usr.bin/make/make.h:1.269 src/usr.bin/make/make.h:1.270 --- src/usr.bin/make/make.h:1.269 Sun Nov 28 20:11:45 2021 +++ src/usr.bin/make/make.h Sun Nov 28 23:12:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.269 2021/11/28 20:11:45 rillig Exp $ */ +/* $NetBSD: make.h,v 1.270 2021/11/28 23:12:51 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -706,7 +706,7 @@ bool GNode_ShouldExecute(GNode *gn); MAKE_INLINE bool GNode_IsTarget(const GNode *gn) { - return (gn->type & OP_OPMASK) != 0; + return (gn->type & OP_OPMASK) != OP_NONE; } MAKE_INLINE const char *
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 28 22:58:55 UTC 2021 Modified Files: src/usr.bin/make: var.c Log Message: make: fix type of variable in ApplyModifier_IfElse No functional change. To generate a diff of this commit: cvs rdiff -u -r1.954 -r1.955 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.954 src/usr.bin/make/var.c:1.955 --- src/usr.bin/make/var.c:1.954 Sat Nov 20 17:51:48 2021 +++ src/usr.bin/make/var.c Sun Nov 28 22:58:55 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.954 2021/11/20 17:51:48 rillig Exp $ */ +/* $NetBSD: var.c,v 1.955 2021/11/28 22:58:55 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -140,7 +140,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.954 2021/11/20 17:51:48 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.955 2021/11/28 22:58:55 rillig Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -3417,7 +3417,7 @@ ApplyModifier_IfElse(const char **pp, Mo VarEvalMode then_emode = VARE_PARSE_ONLY; VarEvalMode else_emode = VARE_PARSE_ONLY; - int cond_rc = COND_PARSE; /* anything other than COND_INVALID */ + CondEvalResult cond_rc = COND_PARSE; /* just not COND_INVALID */ if (Expr_ShouldEval(expr)) { cond_rc = Cond_EvalCondition(expr->name, &value); if (cond_rc != COND_INVALID && value)
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 28 22:58:55 UTC 2021 Modified Files: src/usr.bin/make: var.c Log Message: make: fix type of variable in ApplyModifier_IfElse No functional change. To generate a diff of this commit: cvs rdiff -u -r1.954 -r1.955 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 28 22:48:07 UTC 2021 Modified Files: src/usr.bin/make: buf.c buf.h make.c suff.c Log Message: make: move duplicate function Buf_AddFlag to buf.c It is used only for debug output, therefore performance doesn't matter. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/usr.bin/make/buf.c cvs rdiff -u -r1.43 -r1.44 src/usr.bin/make/buf.h cvs rdiff -u -r1.246 -r1.247 src/usr.bin/make/make.c cvs rdiff -u -r1.354 -r1.355 src/usr.bin/make/suff.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/buf.c diff -u src/usr.bin/make/buf.c:1.52 src/usr.bin/make/buf.c:1.53 --- src/usr.bin/make/buf.c:1.52 Mon Jun 21 19:59:58 2021 +++ src/usr.bin/make/buf.c Sun Nov 28 22:48:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: buf.c,v 1.52 2021/06/21 19:59:58 rillig Exp $ */ +/* $NetBSD: buf.c,v 1.53 2021/11/28 22:48:06 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -75,7 +75,7 @@ #include "make.h" /* "@(#)buf.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: buf.c,v 1.52 2021/06/21 19:59:58 rillig Exp $"); +MAKE_RCSID("$NetBSD: buf.c,v 1.53 2021/11/28 22:48:06 rillig Exp $"); /* Make space in the buffer for adding at least 16 more bytes. */ void @@ -128,6 +128,16 @@ Buf_AddInt(Buffer *buf, int n) Buf_AddBytes(buf, str, len); } +void +Buf_AddFlag(Buffer *buf, bool flag, const char *name) +{ + if (flag) { + if (buf->len > 0) + Buf_AddByte(buf, '|'); + Buf_AddBytes(buf, name, strlen(name)); + } +} + /* Mark the buffer as empty, so it can be filled with data again. */ void Buf_Empty(Buffer *buf) Index: src/usr.bin/make/buf.h diff -u src/usr.bin/make/buf.h:1.43 src/usr.bin/make/buf.h:1.44 --- src/usr.bin/make/buf.h:1.43 Sat Apr 3 11:08:40 2021 +++ src/usr.bin/make/buf.h Sun Nov 28 22:48:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: buf.h,v 1.43 2021/04/03 11:08:40 rillig Exp $ */ +/* $NetBSD: buf.h,v 1.44 2021/11/28 22:48:06 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -111,6 +111,7 @@ void Buf_AddBytes(Buffer *, const char * void Buf_AddBytesBetween(Buffer *, const char *, const char *); void Buf_AddStr(Buffer *, const char *); void Buf_AddInt(Buffer *, int); +void Buf_AddFlag(Buffer *, bool, const char *); void Buf_Empty(Buffer *); void Buf_Init(Buffer *); void Buf_InitSize(Buffer *, size_t); Index: src/usr.bin/make/make.c diff -u src/usr.bin/make/make.c:1.246 src/usr.bin/make/make.c:1.247 --- src/usr.bin/make/make.c:1.246 Sun Nov 28 19:51:06 2021 +++ src/usr.bin/make/make.c Sun Nov 28 22:48:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: make.c,v 1.246 2021/11/28 19:51:06 rillig Exp $ */ +/* $NetBSD: make.c,v 1.247 2021/11/28 22:48:06 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -104,7 +104,7 @@ #include "job.h" /* "@(#)make.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: make.c,v 1.246 2021/11/28 19:51:06 rillig Exp $"); +MAKE_RCSID("$NetBSD: make.c,v 1.247 2021/11/28 22:48:06 rillig Exp $"); /* Sequence # to detect recursion. */ static unsigned int checked_seqno = 1; @@ -138,16 +138,6 @@ make_abort(GNode *gn, int lineno) abort(); } -static void -Buf_AddFlag(Buffer *buf, bool flag, const char *name) -{ - if (flag) { - if (buf->len > 0) - Buf_AddByte(buf, '|'); - Buf_AddBytes(buf, name, strlen(name)); - } -} - static const char * GNodeType_ToString(GNodeType type, void **freeIt) { Index: src/usr.bin/make/suff.c diff -u src/usr.bin/make/suff.c:1.354 src/usr.bin/make/suff.c:1.355 --- src/usr.bin/make/suff.c:1.354 Sun Nov 28 22:38:17 2021 +++ src/usr.bin/make/suff.c Sun Nov 28 22:48:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: suff.c,v 1.354 2021/11/28 22:38:17 rillig Exp $ */ +/* $NetBSD: suff.c,v 1.355 2021/11/28 22:48:06 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.354 2021/11/28 22:38:17 rillig Exp $"); +MAKE_RCSID("$NetBSD: suff.c,v 1.355 2021/11/28 22:48:06 rillig Exp $"); typedef List SuffixList; typedef ListNode SuffixListNode; @@ -2125,16 +2125,6 @@ PrintSuffNames(const char *prefix, const } static void -Buf_AddFlag(Buffer *buf, bool flag, const char *name) -{ - if (flag) { - if (buf->len > 0) - Buf_AddByte(buf, '|'); - Buf_AddBytes(buf, name, strlen(name)); - } -} - -static void Suffix_Print(const Suffix *suff) { Buffer buf;
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 28 22:48:07 UTC 2021 Modified Files: src/usr.bin/make: buf.c buf.h make.c suff.c Log Message: make: move duplicate function Buf_AddFlag to buf.c It is used only for debug output, therefore performance doesn't matter. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/usr.bin/make/buf.c cvs rdiff -u -r1.43 -r1.44 src/usr.bin/make/buf.h cvs rdiff -u -r1.246 -r1.247 src/usr.bin/make/make.c cvs rdiff -u -r1.354 -r1.355 src/usr.bin/make/suff.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 28 22:38:17 UTC 2021 Modified Files: src/usr.bin/make: suff.c Log Message: make: inline SuffixFlags_ToString into Suffix_Print This gets rid of the string literal "none" and the complicated memory handling. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.353 -r1.354 src/usr.bin/make/suff.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 28 22:38:17 UTC 2021 Modified Files: src/usr.bin/make: suff.c Log Message: make: inline SuffixFlags_ToString into Suffix_Print This gets rid of the string literal "none" and the complicated memory handling. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.353 -r1.354 src/usr.bin/make/suff.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/suff.c diff -u src/usr.bin/make/suff.c:1.353 src/usr.bin/make/suff.c:1.354 --- src/usr.bin/make/suff.c:1.353 Sun Nov 28 22:27:35 2021 +++ src/usr.bin/make/suff.c Sun Nov 28 22:38:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: suff.c,v 1.353 2021/11/28 22:27:35 rillig Exp $ */ +/* $NetBSD: suff.c,v 1.354 2021/11/28 22:38:17 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.353 2021/11/28 22:27:35 rillig Exp $"); +MAKE_RCSID("$NetBSD: suff.c,v 1.354 2021/11/28 22:38:17 rillig Exp $"); typedef List SuffixList; typedef ListNode SuffixListNode; @@ -2134,31 +2134,24 @@ Buf_AddFlag(Buffer *buf, bool flag, cons } } -static const char * -SuffixFlags_ToString(const Suffix *suff, void **freeIt) +static void +Suffix_Print(const Suffix *suff) { Buffer buf; - Buf_InitSize(&buf, 32); + Buf_InitSize(&buf, 16); Buf_AddFlag(&buf, suff->include, "SUFF_INCLUDE"); Buf_AddFlag(&buf, suff->library, "SUFF_LIBRARY"); Buf_AddFlag(&buf, suff->isNull, "SUFF_NULL"); - return buf.len == 0 ? "none" : (*freeIt = Buf_DoneData(&buf)); -} -static void -Suffix_Print(const Suffix *suff) -{ debug_printf("# \"%s\" (num %d, ref %d)", suff->name, suff->sNum, suff->refCount); - if (suff->include || suff->library || suff->isNull) { - void *flags_freeIt = NULL; - debug_printf(" (%s)", - SuffixFlags_ToString(suff, &flags_freeIt)); - free(flags_freeIt); - } + if (buf.len > 0) + debug_printf(" (%s)", buf.data); debug_printf("\n"); + Buf_Done(&buf); + PrintSuffNames("To", &suff->parents); PrintSuffNames("From", &suff->children);
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 28 22:27:35 UTC 2021 Modified Files: src/usr.bin/make: suff.c Log Message: make: inline SuffixFlags into the Suffix itself No functional change. To generate a diff of this commit: cvs rdiff -u -r1.352 -r1.353 src/usr.bin/make/suff.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 28 22:27:35 UTC 2021 Modified Files: src/usr.bin/make: suff.c Log Message: make: inline SuffixFlags into the Suffix itself No functional change. To generate a diff of this commit: cvs rdiff -u -r1.352 -r1.353 src/usr.bin/make/suff.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/suff.c diff -u src/usr.bin/make/suff.c:1.352 src/usr.bin/make/suff.c:1.353 --- src/usr.bin/make/suff.c:1.352 Sun Nov 28 18:58:58 2021 +++ src/usr.bin/make/suff.c Sun Nov 28 22:27:35 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: suff.c,v 1.352 2021/11/28 18:58:58 rillig Exp $ */ +/* $NetBSD: suff.c,v 1.353 2021/11/28 22:27:35 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.352 2021/11/28 18:58:58 rillig Exp $"); +MAKE_RCSID("$NetBSD: suff.c,v 1.353 2021/11/28 22:27:35 rillig Exp $"); typedef List SuffixList; typedef ListNode SuffixListNode; @@ -142,21 +142,27 @@ static GNodeList transforms = LST_INIT; */ static int sNum = 0; -typedef enum SuffixFlags { - SUFF_NONE = 0, +typedef List SuffixListList; +/* + * A suffix such as ".c" or ".o" that is used in suffix transformation rules + * such as ".c.o:". + */ +typedef struct Suffix { + /* The suffix itself, such as ".c" */ + char *name; + /* Length of the name, to avoid strlen calls */ + size_t nameLen; /* * This suffix marks include files. Their search path ends up in the * undocumented special variable '.INCLUDES'. */ - SUFF_INCLUDE = 1 << 0, - + bool include:1; /* * This suffix marks library files. Their search path ends up in the * undocumented special variable '.LIBS'. */ - SUFF_LIBRARY = 1 << 1, - + bool library:1; /* * The empty suffix. * @@ -166,39 +172,26 @@ typedef enum SuffixFlags { * XXX: Why is SUFF_NULL needed at all? Wouldn't nameLen == 0 mean * the same? */ - SUFF_NULL = 1 << 2 - -} SuffixFlags; - -typedef List SuffixListList; - -/* - * A suffix such as ".c" or ".o" that is used in suffix transformation rules - * such as ".c.o:". - */ -typedef struct Suffix { - /* The suffix itself, such as ".c" */ - char *name; - /* Length of the name, to avoid strlen calls */ - size_t nameLen; - /* Type of suffix */ - SuffixFlags flags; + bool isNull:1; /* The path along which files of this suffix may be found */ SearchPath *searchPath; + /* The suffix number; TODO: document the purpose of this number */ int sNum; /* Reference count of list membership and several other places */ int refCount; + /* Suffixes we have a transformation to */ SuffixList parents; /* Suffixes we have a transformation from */ SuffixList children; - - /* Lists in which this suffix is referenced. + /* + * Lists in which this suffix is referenced. * * XXX: These lists are used nowhere, they are just appended to, for * no apparent reason. They do have the side effect of increasing - * refCount though. */ + * refCount though. + */ SuffixListList ref; } Suffix; @@ -472,7 +465,9 @@ Suffix_New(const char *name) Lst_Init(&suff->parents); Lst_Init(&suff->ref); suff->sNum = sNum++; - suff->flags = SUFF_NONE; + suff->include = false; + suff->library = false; + suff->isNull = false; suff->refCount = 1; /* XXX: why 1? It's not assigned anywhere yet. */ return suff; @@ -499,7 +494,9 @@ Suff_ClearSuffixes(void) emptySuff = nullSuff = Suffix_New(""); SearchPath_AddAll(nullSuff->searchPath, &dirSearchPath); - nullSuff->flags = SUFF_NULL; + nullSuff->include = false; + nullSuff->library = false; + nullSuff->isNull = true; } /* @@ -886,12 +883,12 @@ Suff_ExtendPaths(void) Suffix *suff = ln->datum; if (!Lst_IsEmpty(&suff->searchPath->dirs)) { #ifdef INCLUDES - if (suff->flags & SUFF_INCLUDE) + if (suff->include) SearchPath_AddAll(includesPath, suff->searchPath); #endif #ifdef LIBRARIES - if (suff->flags & SUFF_LIBRARY) + if (suff->library) SearchPath_AddAll(libsPath, suff->searchPath); #endif SearchPath_AddAll(suff->searchPath, &dirSearchPath); @@ -924,7 +921,7 @@ Suff_AddInclude(const char *suffName) { Suffix *suff = FindSuffixByName(suffName); if (suff != NULL) - suff->flags |= SUFF_INCLUDE; + suff->include = true; } /* @@ -938,7 +935,7 @@ Suff_AddLib(const char *suffName) { Suffix *suff = FindSuffixByName(suffName); if (suff != NULL) - suff->flags |= SUFF_LIBRARY; + suff->library = true; } /** Implicit Source Search Functions */ @@ -1041,7 +1038,7 @@ CandidateList_AddCandidatesFor(Candidate for (ln = cand->suff->children.first; ln != NULL; ln = ln->next) { Suffix *suff = ln->datum; - if ((suff->flags & SUFF_NULL) && suff->name[0] != '\0') { + if (suff->isNull && suff->name[0] != '\0') { /* * If the suffix has been marked as
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 28 21:46:17 UTC 2021 Modified Files: src/usr.bin/make: dir.c Log Message: make: eliminate CachedStatsFlags Having two boolean flags as parameters should be easier to understand than bit manipulations. The variable names now match more directly. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.274 -r1.275 src/usr.bin/make/dir.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/dir.c diff -u src/usr.bin/make/dir.c:1.274 src/usr.bin/make/dir.c:1.275 --- src/usr.bin/make/dir.c:1.274 Sun Nov 28 19:51:06 2021 +++ src/usr.bin/make/dir.c Sun Nov 28 21:46:17 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.274 2021/11/28 19:51:06 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.275 2021/11/28 21:46:17 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -138,7 +138,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.274 2021/11/28 19:51:06 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.275 2021/11/28 21:46:17 rillig Exp $"); /* * A search path is a list of CachedDir structures. A CachedDir has in it the @@ -246,12 +246,6 @@ typedef struct OpenDirs { HashTable /* of CachedDirListNode */ table; } OpenDirs; -typedef enum CachedStatsFlags { - CST_NONE = 0, - CST_LSTAT = 1 << 0, /* call lstat(2) instead of stat(2) */ - CST_UPDATE = 1 << 1 /* ignore existing cached entry */ -} CachedStatsFlags; - SearchPath dirSearchPath = { LST_INIT }; /* main search path */ @@ -419,9 +413,9 @@ OpenDirs_Remove(OpenDirs *odirs, const c */ static int cached_stats(const char *pathname, struct cached_stat *out_cst, - CachedStatsFlags flags) + bool useLstat, bool forceRefresh) { - HashTable *tbl = flags & CST_LSTAT ? &lmtimes : &mtimes; + HashTable *tbl = useLstat ? &lmtimes : &mtimes; struct stat sys_st; struct cached_stat *cst; int rc; @@ -430,14 +424,14 @@ cached_stats(const char *pathname, struc return -1; /* This can happen in meta mode. */ cst = HashTable_FindValue(tbl, pathname); - if (cst != NULL && !(flags & CST_UPDATE)) { + if (cst != NULL && !forceRefresh) { *out_cst = *cst; DEBUG2(DIR, "Using cached time %s for %s\n", Targ_FmtTime(cst->cst_mtime), pathname); return 0; } - rc = (flags & CST_LSTAT ? lstat : stat)(pathname, &sys_st); + rc = (useLstat ? lstat : stat)(pathname, &sys_st); if (rc == -1) return -1; /* don't cache negative lookups */ @@ -462,13 +456,13 @@ cached_stats(const char *pathname, struc int cached_stat(const char *pathname, struct cached_stat *cst) { - return cached_stats(pathname, cst, CST_NONE); + return cached_stats(pathname, cst, false, false); } int cached_lstat(const char *pathname, struct cached_stat *cst) { - return cached_stats(pathname, cst, CST_LSTAT); + return cached_stats(pathname, cst, true, false); } /* Initialize the directories module. */ @@ -1470,7 +1464,7 @@ ResolveFullName(GNode *gn) * The found file is stored in gn->path, unless the node already had a path. */ void -Dir_UpdateMTime(GNode *gn, bool recheck) +Dir_UpdateMTime(GNode *gn, bool forceRefresh) { char *fullName; struct cached_stat cst; @@ -1487,7 +1481,7 @@ Dir_UpdateMTime(GNode *gn, bool recheck) fullName = ResolveFullName(gn); - if (cached_stats(fullName, &cst, recheck ? CST_UPDATE : CST_NONE) < 0) { + if (cached_stats(fullName, &cst, false, forceRefresh) < 0) { if (gn->type & OP_MEMBER) { if (fullName != gn->path) free(fullName);
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 28 21:46:17 UTC 2021 Modified Files: src/usr.bin/make: dir.c Log Message: make: eliminate CachedStatsFlags Having two boolean flags as parameters should be easier to understand than bit manipulations. The variable names now match more directly. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.274 -r1.275 src/usr.bin/make/dir.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 28 20:11:45 UTC 2021 Modified Files: src/usr.bin/make: make.h Log Message: make: fix leftover typo from previous refactoring To generate a diff of this commit: cvs rdiff -u -r1.268 -r1.269 src/usr.bin/make/make.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/make/make.h diff -u src/usr.bin/make/make.h:1.268 src/usr.bin/make/make.h:1.269 --- src/usr.bin/make/make.h:1.268 Sun Nov 28 19:51:06 2021 +++ src/usr.bin/make/make.h Sun Nov 28 20:11:45 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.268 2021/11/28 19:51:06 rillig Exp $ */ +/* $NetBSD: make.h,v 1.269 2021/11/28 20:11:45 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -321,7 +321,7 @@ typedef enum GNodeType { OP_NOTARGET = OP_NOTMAIN | OP_USE | OP_EXEC | OP_TRANSFORM } GNodeType; -typedef struct GNodeFlagsS { +typedef struct GNodeFlags { /* this target needs to be (re)made */ bool remake:1; /* children of this target were made */
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 28 20:11:45 UTC 2021 Modified Files: src/usr.bin/make: make.h Log Message: make: fix leftover typo from previous refactoring To generate a diff of this commit: cvs rdiff -u -r1.268 -r1.269 src/usr.bin/make/make.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/make
Module Name:src Committed By: rillig Date: Sun Nov 28 19:51:06 UTC 2021 Modified Files: src/usr.bin/make: arch.c compat.c dir.c job.c make.c make.h targ.c Log Message: make: convert GNodeFlags from enum into bit-fields Now that Enum_ToString is implemented for each type separately, it's easy to convert them to bit-fields. This gets rid of the magic numbers 12 for CYCLE and 13 for DONECYCLE that left a suspicious gap in the numbers. This gap was not needed since the code didn't make use of the relative ordering of the enum constants. The effects of this conversion are fewer capital letters in the code, smaller scope for the GNode flags, and clearer code especially when setting a flag back to false. One strange thing is that GCC 10.3.0 doesn't optimize GNodeFlags_IsNone to an single bitmasking instruction, at least on x86_64. Instead it generates a testb instruction for each of the flags, even loading bit 8 separately from the others. Clang 12.0.1 knows this optimization though and generates the obvious sequence of movzwl, testl, jz. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.203 -r1.204 src/usr.bin/make/arch.c cvs rdiff -u -r1.227 -r1.228 src/usr.bin/make/compat.c cvs rdiff -u -r1.273 -r1.274 src/usr.bin/make/dir.c cvs rdiff -u -r1.439 -r1.440 src/usr.bin/make/job.c cvs rdiff -u -r1.245 -r1.246 src/usr.bin/make/make.c cvs rdiff -u -r1.267 -r1.268 src/usr.bin/make/make.h cvs rdiff -u -r1.172 -r1.173 src/usr.bin/make/targ.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.203 src/usr.bin/make/arch.c:1.204 --- src/usr.bin/make/arch.c:1.203 Wed Aug 25 22:14:38 2021 +++ src/usr.bin/make/arch.c Sun Nov 28 19:51:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: arch.c,v 1.203 2021/08/25 22:14:38 rillig Exp $ */ +/* $NetBSD: arch.c,v 1.204 2021/11/28 19:51:06 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.203 2021/08/25 22:14:38 rillig Exp $"); +MAKE_RCSID("$NetBSD: arch.c,v 1.204 2021/11/28 19:51:06 rillig Exp $"); typedef struct List ArchList; typedef struct ListNode ArchListNode; @@ -944,12 +944,12 @@ Arch_UpdateMemberMTime(GNode *gn) const char *nameEnd = strchr(nameStart, ')'); size_t nameLen = (size_t)(nameEnd - nameStart); - if ((pgn->flags & REMAKE) && + if (pgn->flags.remake && strncmp(nameStart, gn->name, nameLen) == 0) { Arch_UpdateMTime(pgn); gn->mtime = pgn->mtime; } - } else if (pgn->flags & REMAKE) { + } else if (pgn->flags.remake) { /* * Something which isn't a library depends on the * existence of this target, so it needs to exist. Index: src/usr.bin/make/compat.c diff -u src/usr.bin/make/compat.c:1.227 src/usr.bin/make/compat.c:1.228 --- src/usr.bin/make/compat.c:1.227 Tue Apr 27 15:19:25 2021 +++ src/usr.bin/make/compat.c Sun Nov 28 19:51:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: compat.c,v 1.227 2021/04/27 15:19:25 christos Exp $ */ +/* $NetBSD: compat.c,v 1.228 2021/11/28 19:51:06 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -96,7 +96,7 @@ #include "pathnames.h" /* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: compat.c,v 1.227 2021/04/27 15:19:25 christos Exp $"); +MAKE_RCSID("$NetBSD: compat.c,v 1.228 2021/11/28 19:51:06 rillig Exp $"); static GNode *curTarg = NULL; static pid_t compatChild; @@ -494,7 +494,7 @@ MakeUnmade(GNode *gn, GNode *pgn) * again. This is our signal to not attempt to do anything but abort * our parent as well. */ - gn->flags |= REMAKE; + gn->flags.remake = true; gn->made = BEINGMADE; if (!(gn->type & OP_MADE)) @@ -502,9 +502,9 @@ MakeUnmade(GNode *gn, GNode *pgn) MakeNodes(&gn->children, gn); - if (!(gn->flags & REMAKE)) { + if (!gn->flags.remake) { gn->made = ABORTED; - pgn->flags &= ~(unsigned)REMAKE; + pgn->flags.remake = false; return false; } @@ -582,13 +582,13 @@ MakeUnmade(GNode *gn, GNode *pgn) */ gn->made = MADE; if (Make_Recheck(gn) == 0) - pgn->flags |= FORCE; + pgn->flags.force = true; if (!(gn->type & OP_EXEC)) { - pgn->flags |= CHILDMADE; + pgn->flags.childMade = true; GNode_UpdateYoungestChild(pgn, gn); } } else if (opts.keepgoing) { - pgn->flags &= ~(unsigned)REMAKE; + pgn->flags.remake = false; } else { PrintOnError(gn, "\nStop."); exit(1); @@ -609,11 +609,11 @@ MakeOther(GNode *gn, GNode *pgn) case BEINGMADE: Error("Graph cycles through %s", gn->name); gn->made = ERROR; - pgn->flags &= ~(unsigned)REMAKE; + pgn->flags.remake = false; break; case MADE: if (!(gn->type & OP_EXEC)) { - pgn->flags |= CHILDMADE; + pgn->flags.childMade = true; GNode_UpdateYoungestChild(pgn, gn); } break; @@ -660,
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 28 19:51:06 UTC 2021 Modified Files: src/usr.bin/make: arch.c compat.c dir.c job.c make.c make.h targ.c Log Message: make: convert GNodeFlags from enum into bit-fields Now that Enum_ToString is implemented for each type separately, it's easy to convert them to bit-fields. This gets rid of the magic numbers 12 for CYCLE and 13 for DONECYCLE that left a suspicious gap in the numbers. This gap was not needed since the code didn't make use of the relative ordering of the enum constants. The effects of this conversion are fewer capital letters in the code, smaller scope for the GNode flags, and clearer code especially when setting a flag back to false. One strange thing is that GCC 10.3.0 doesn't optimize GNodeFlags_IsNone to an single bitmasking instruction, at least on x86_64. Instead it generates a testb instruction for each of the flags, even loading bit 8 separately from the others. Clang 12.0.1 knows this optimization though and generates the obvious sequence of movzwl, testl, jz. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.203 -r1.204 src/usr.bin/make/arch.c cvs rdiff -u -r1.227 -r1.228 src/usr.bin/make/compat.c cvs rdiff -u -r1.273 -r1.274 src/usr.bin/make/dir.c cvs rdiff -u -r1.439 -r1.440 src/usr.bin/make/job.c cvs rdiff -u -r1.245 -r1.246 src/usr.bin/make/make.c cvs rdiff -u -r1.267 -r1.268 src/usr.bin/make/make.h cvs rdiff -u -r1.172 -r1.173 src/usr.bin/make/targ.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 28 18:58:58 UTC 2021 Modified Files: src/usr.bin/make: Makefile make.c make.h suff.c Removed Files: src/usr.bin/make: enum.c enum.h Log Message: make: replace bloated bit-set-to-string code with simple code It was a nice idea to implement a bit-set using an enum type and have a generic ToString function for them. In the end, the implementation involved really heavy preprocessor magic and was probably difficult to understand. Replace all the code with a few bits of straight-forward preprocessor magic that can be readily understood by just looking 5 lines around, instead of digging through 130 lines of lengthy macro definitions. Curiously, this reduces the binary size even though the 3 ToString functions now have a few lines of duplicate code and there are more explicit function calls. The ToString functions are only seldom used, so the additional memory allocation is acceptable. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.116 -r1.117 src/usr.bin/make/Makefile cvs rdiff -u -r1.15 -r0 src/usr.bin/make/enum.c cvs rdiff -u -r1.19 -r0 src/usr.bin/make/enum.h cvs rdiff -u -r1.244 -r1.245 src/usr.bin/make/make.c cvs rdiff -u -r1.266 -r1.267 src/usr.bin/make/make.h cvs rdiff -u -r1.351 -r1.352 src/usr.bin/make/suff.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/Makefile diff -u src/usr.bin/make/Makefile:1.116 src/usr.bin/make/Makefile:1.117 --- src/usr.bin/make/Makefile:1.116 Sat Jul 31 09:30:17 2021 +++ src/usr.bin/make/Makefile Sun Nov 28 18:58:58 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.116 2021/07/31 09:30:17 rillig Exp $ +# $NetBSD: Makefile,v 1.117 2021/11/28 18:58:58 rillig Exp $ # @(#)Makefile 5.2 (Berkeley) 12/28/90 PROG= make @@ -7,7 +7,6 @@ SRCS+= buf.c SRCS+= compat.c SRCS+= cond.c SRCS+= dir.c -SRCS+= enum.c SRCS+= for.c SRCS+= hash.c SRCS+= job.c Index: src/usr.bin/make/make.c diff -u src/usr.bin/make/make.c:1.244 src/usr.bin/make/make.c:1.245 --- src/usr.bin/make/make.c:1.244 Sun Apr 4 10:05:08 2021 +++ src/usr.bin/make/make.c Sun Nov 28 18:58:58 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: make.c,v 1.244 2021/04/04 10:05:08 rillig Exp $ */ +/* $NetBSD: make.c,v 1.245 2021/11/28 18:58:58 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -104,7 +104,7 @@ #include "job.h" /* "@(#)make.c 8.1 (Berkeley) 6/6/93" */ -MAKE_RCSID("$NetBSD: make.c,v 1.244 2021/04/04 10:05:08 rillig Exp $"); +MAKE_RCSID("$NetBSD: make.c,v 1.245 2021/11/28 18:58:58 rillig Exp $"); /* Sequence # to detect recursion. */ static unsigned int checked_seqno = 1; @@ -138,35 +138,93 @@ make_abort(GNode *gn, int lineno) abort(); } -ENUM_FLAGS_RTTI_31(GNodeType, -OP_DEPENDS, OP_FORCE, OP_DOUBLEDEP, -/* OP_OPMASK is omitted since it combines other flags */ -OP_OPTIONAL, OP_USE, OP_EXEC, OP_IGNORE, -OP_PRECIOUS, OP_SILENT, OP_MAKE, OP_JOIN, -OP_MADE, OP_SPECIAL, OP_USEBEFORE, OP_INVISIBLE, -OP_NOTMAIN, OP_PHONY, OP_NOPATH, OP_WAIT, -OP_NOMETA, OP_META, OP_NOMETA_CMP, OP_SUBMAKE, -OP_TRANSFORM, OP_MEMBER, OP_LIB, OP_ARCHV, -OP_HAS_COMMANDS, OP_SAVE_CMDS, OP_DEPS_FOUND, OP_MARK); - -ENUM_FLAGS_RTTI_9(GNodeFlags, -REMAKE, CHILDMADE, FORCE, DONE_WAIT, -DONE_ORDER, FROM_DEPEND, DONE_ALLSRC, CYCLE, -DONECYCLE); +static void +Buf_AddFlag(Buffer *buf, bool flag, const char *name) +{ + if (flag) { + if (buf->len > 0) + Buf_AddByte(buf, '|'); + Buf_AddBytes(buf, name, strlen(name)); + } +} + +static const char * +GNodeType_ToString(GNodeType type, void **freeIt) +{ + Buffer buf; + + Buf_InitSize(&buf, 32); +#define ADD(flag) Buf_AddFlag(&buf, (type & (flag)) != 0, #flag) + ADD(OP_DEPENDS); + ADD(OP_FORCE); + ADD(OP_DOUBLEDEP); + ADD(OP_OPTIONAL); + ADD(OP_USE); + ADD(OP_EXEC); + ADD(OP_IGNORE); + ADD(OP_PRECIOUS); + ADD(OP_SILENT); + ADD(OP_MAKE); + ADD(OP_JOIN); + ADD(OP_MADE); + ADD(OP_SPECIAL); + ADD(OP_USEBEFORE); + ADD(OP_INVISIBLE); + ADD(OP_NOTMAIN); + ADD(OP_PHONY); + ADD(OP_NOPATH); + ADD(OP_WAIT); + ADD(OP_NOMETA); + ADD(OP_META); + ADD(OP_NOMETA_CMP); + ADD(OP_SUBMAKE); + ADD(OP_TRANSFORM); + ADD(OP_MEMBER); + ADD(OP_LIB); + ADD(OP_ARCHV); + ADD(OP_HAS_COMMANDS); + ADD(OP_SAVE_CMDS); + ADD(OP_DEPS_FOUND); + ADD(OP_MARK); +#undef ADD + return buf.len == 0 ? "none" : (*freeIt = Buf_DoneData(&buf)); +} + +static const char * +GNodeFlags_ToString(GNodeFlags flags, void **freeIt) +{ + Buffer buf; + + Buf_InitSize(&buf, 32); +#define ADD(flag) Buf_AddFlag(&buf, (flags & (flag)) != 0, #flag) + ADD(REMAKE); + ADD(CHILDMADE); + ADD(FORCE); + ADD(DONE_WAIT); + ADD(DONE_ORDER); + ADD(FROM_DEPEND); + ADD(DONE_ALLSRC); + ADD(CYCLE); + ADD(DONECYCLE); +#undef ADD + return buf.len == 0 ? "none" : (*freeIt = Buf_DoneData(&buf)); +} void GNode_FprintDetails(FILE *f, const char *prefix, const GNode *gn, const char *suffix) { -
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 28 18:58:58 UTC 2021 Modified Files: src/usr.bin/make: Makefile make.c make.h suff.c Removed Files: src/usr.bin/make: enum.c enum.h Log Message: make: replace bloated bit-set-to-string code with simple code It was a nice idea to implement a bit-set using an enum type and have a generic ToString function for them. In the end, the implementation involved really heavy preprocessor magic and was probably difficult to understand. Replace all the code with a few bits of straight-forward preprocessor magic that can be readily understood by just looking 5 lines around, instead of digging through 130 lines of lengthy macro definitions. Curiously, this reduces the binary size even though the 3 ToString functions now have a few lines of duplicate code and there are more explicit function calls. The ToString functions are only seldom used, so the additional memory allocation is acceptable. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.116 -r1.117 src/usr.bin/make/Makefile cvs rdiff -u -r1.15 -r0 src/usr.bin/make/enum.c cvs rdiff -u -r1.19 -r0 src/usr.bin/make/enum.h cvs rdiff -u -r1.244 -r1.245 src/usr.bin/make/make.c cvs rdiff -u -r1.266 -r1.267 src/usr.bin/make/make.h cvs rdiff -u -r1.351 -r1.352 src/usr.bin/make/suff.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/share/man/man8
Module Name:src Committed By: ryo Date: Sun Nov 28 18:08:51 UTC 2021 Modified Files: src/share/man/man8: compat_linux.8 Log Message: aarch64 also now can execute both 32 and 64 bit To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/share/man/man8/compat_linux.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/share/man/man8
Module Name:src Committed By: ryo Date: Sun Nov 28 18:08:51 UTC 2021 Modified Files: src/share/man/man8: compat_linux.8 Log Message: aarch64 also now can execute both 32 and 64 bit To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/share/man/man8/compat_linux.8 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/man/man8/compat_linux.8 diff -u src/share/man/man8/compat_linux.8:1.45 src/share/man/man8/compat_linux.8:1.46 --- src/share/man/man8/compat_linux.8:1.45 Tue Oct 12 15:25:27 2021 +++ src/share/man/man8/compat_linux.8 Sun Nov 28 18:08:51 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: compat_linux.8,v 1.45 2021/10/12 15:25:27 andvar Exp $ +.\" $NetBSD: compat_linux.8,v 1.46 2021/11/28 18:08:51 ryo Exp $ .\" .\" Copyright (c) 1995 Frank van der Linden .\" All rights reserved. @@ -42,7 +42,7 @@ This applies to aarch64, alpha, amd64, a Both the a.out and ELF binary formats are supported. Most programs should work. .Nx -amd64 can execute both 32-bit and 64-bit Linux programs. +aarch64 and amd64 can execute both 32-bit and 64-bit Linux programs. Programs that will not work include some that use i386-specific calls, such as enabling virtual 8086 mode. Currently, sound is supported through OSSv3 compat.
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 28 17:26:07 UTC 2021 Modified Files: src/usr.bin/make: job.c Log Message: make: eliminate common subexpressions in DebugFailedJob No functional change. To generate a diff of this commit: cvs rdiff -u -r1.438 -r1.439 src/usr.bin/make/job.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/job.c diff -u src/usr.bin/make/job.c:1.438 src/usr.bin/make/job.c:1.439 --- src/usr.bin/make/job.c:1.438 Sun Nov 28 17:20:39 2021 +++ src/usr.bin/make/job.c Sun Nov 28 17:26:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.438 2021/11/28 17:20:39 rillig Exp $ */ +/* $NetBSD: job.c,v 1.439 2021/11/28 17:26:07 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -142,7 +142,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.438 2021/11/28 17:20:39 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.439 2021/11/28 17:26:07 rillig Exp $"); /* * A shell defines how the commands are run. All commands for a target are @@ -1072,15 +1072,14 @@ DebugFailedJob(const Job *job) debug_printf("*** Failed target: %s\n", job->node->name); debug_printf("*** Failed commands:\n"); for (ln = job->node->commands.first; ln != NULL; ln = ln->next) { - const char *unexpanded = (const char *)ln->datum; - debug_printf("\t%s\n", unexpanded); + const char *cmd = ln->datum; + debug_printf("\t%s\n", cmd); - if (strchr(unexpanded, '$') != NULL) { - char *expanded; - (void)Var_Subst((const char *)ln->datum, job->node, - VARE_WANTRES, &expanded); - debug_printf("\t=> %s\n", expanded); - free(expanded); + if (strchr(cmd, '$') != NULL) { + char *xcmd; + (void)Var_Subst(cmd, job->node, VARE_WANTRES, &xcmd); + debug_printf("\t=> %s\n", xcmd); + free(xcmd); } } }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 28 17:26:07 UTC 2021 Modified Files: src/usr.bin/make: job.c Log Message: make: eliminate common subexpressions in DebugFailedJob No functional change. To generate a diff of this commit: cvs rdiff -u -r1.438 -r1.439 src/usr.bin/make/job.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/sbin/cgdconfig
> On Nov 28, 2021, at 11:57 AM, Roland Illig wrote: > > Am 28.11.2021 um 17:37 schrieb Jason Thorpe: >>> On Nov 28, 2021, at 8:05 AM, Christos Zoulas >>> wrote: >>> >>> 1. which compilation flag should we add -pthread to? CFLAGS or >>> COPTS? What about c++? >> >> GCC defines some preprocessor macros in response to -pthread, so … >> CPPFLAGS? Perhaps a better choice is to have a USE_PTHREADS that >> individual program / library Makefiles can set to YES to cause the >> right magic to happen in bsd.sys.mk? > > I like the idea of USE_PTHREADS. > > The option -pthread is not specified by POSIX and the GCC manual doesn't > define which exact macros -pthread defines. Sure, Clang is compatible > with GCC, but PCC doesn't need to. I don't want to add support for 3 > different compilers to lint. Having all the magic hidden behind a simple > flag sounds easiest to me. > I agree! christos signature.asc Description: Message signed with OpenPGP
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 28 17:20:39 UTC 2021 Modified Files: src/usr.bin/make: job.c Log Message: make: fix memory leak in jobs mode with -de (since today) To generate a diff of this commit: cvs rdiff -u -r1.437 -r1.438 src/usr.bin/make/job.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/job.c diff -u src/usr.bin/make/job.c:1.437 src/usr.bin/make/job.c:1.438 --- src/usr.bin/make/job.c:1.437 Sun Nov 28 00:02:07 2021 +++ src/usr.bin/make/job.c Sun Nov 28 17:20:39 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.437 2021/11/28 00:02:07 rillig Exp $ */ +/* $NetBSD: job.c,v 1.438 2021/11/28 17:20:39 rillig Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -142,7 +142,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.437 2021/11/28 00:02:07 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.438 2021/11/28 17:20:39 rillig Exp $"); /* * A shell defines how the commands are run. All commands for a target are @@ -1080,6 +1080,7 @@ DebugFailedJob(const Job *job) (void)Var_Subst((const char *)ln->datum, job->node, VARE_WANTRES, &expanded); debug_printf("\t=> %s\n", expanded); + free(expanded); } } }
CVS commit: src/usr.bin/make
Module Name:src Committed By: rillig Date: Sun Nov 28 17:20:39 UTC 2021 Modified Files: src/usr.bin/make: job.c Log Message: make: fix memory leak in jobs mode with -de (since today) To generate a diff of this commit: cvs rdiff -u -r1.437 -r1.438 src/usr.bin/make/job.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/sbin/cgdconfig
Am 28.11.2021 um 17:37 schrieb Jason Thorpe: On Nov 28, 2021, at 8:05 AM, Christos Zoulas wrote: 1. which compilation flag should we add -pthread to? CFLAGS or COPTS? What about c++? GCC defines some preprocessor macros in response to -pthread, so … CPPFLAGS? Perhaps a better choice is to have a USE_PTHREADS that individual program / library Makefiles can set to YES to cause the right magic to happen in bsd.sys.mk? I like the idea of USE_PTHREADS. The option -pthread is not specified by POSIX and the GCC manual doesn't define which exact macros -pthread defines. Sure, Clang is compatible with GCC, but PCC doesn't need to. I don't want to add support for 3 different compilers to lint. Having all the magic hidden behind a simple flag sounds easiest to me. Roland
Re: CVS commit: src/sbin/cgdconfig
> On Nov 28, 2021, at 8:05 AM, Christos Zoulas wrote: > > The change is correct; this is how it is done everywhere else in the tree. > You are right about -pthread doing more than adding -lpthread, but > in that case, the -pthread should be added to CFLAGS/COPTS etc, > not LDADD so that it is effective during the compilation phase too, > not just the link phase. When I made the change, I considered going > through the tree and adding -pthread to the CFLAGS/COPTS in the > Makefiles where -pthread is in LDADD, but I did not want to do a > half-assed job without thinking about it more: > > 1. which compilation flag should we add -pthread to? CFLAGS or > COPTS? What about c++? GCC defines some preprocessor macros in response to -pthread, so … CPPFLAGS? Perhaps a better choice is to have a USE_PTHREADS that individual program / library Makefiles can set to YES to cause the right magic to happen in bsd.sys.mk? > 2. do we remove the LDADD/DPADD pthread settings? I am thinking >perhaps not, it does not hurt, plus the DPADD will cause a rebuild >when libpthread changes. That could be hidden away by the above suggestion. -- thorpej
CVS commit: src/tests/usr.bin/indent
Module Name:src Committed By: rillig Date: Sun Nov 28 16:31:39 UTC 2021 Modified Files: src/tests/usr.bin/indent: lsym_return.c Log Message: tests/indent: test variants of the 'return' statement To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/lsym_return.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_return.c diff -u src/tests/usr.bin/indent/lsym_return.c:1.1 src/tests/usr.bin/indent/lsym_return.c:1.2 --- src/tests/usr.bin/indent/lsym_return.c:1.1 Thu Nov 18 21:19:19 2021 +++ src/tests/usr.bin/indent/lsym_return.c Sun Nov 28 16:31:39 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lsym_return.c,v 1.1 2021/11/18 21:19:19 rillig Exp $ */ +/* $NetBSD: lsym_return.c,v 1.2 2021/11/28 16:31:39 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -6,8 +6,66 @@ * starts a 'return' statement for leaving the execution of a function. */ +/* + * Return statements having a single-line expression are simple to format. + * Since 'return' is not a function name, there is a space between the + * 'return' and the '('. + */ #indent input -// TODO: add input +void +function(bool cond) +{ + if (cond) + return; +} + +int +calculate(int a, int b) +{ + return a; + return (b); + return (((a))) + b; + return calculate(b, a); +} #indent end #indent run-equals-input + + +/* + * Returning complex expressions may spread the expression over several lines. + * The exact formatting depends on the option '-lp'. + */ +#indent input +int +multi_line(int a) +{ + return calculate(3, + 4); + return calculate( + 3, + 4); + return calculate( + 3, + 4 + ); +} +#indent end + +#indent run-equals-input + +#indent run -nlp +int +multi_line(int a) +{ + return calculate(3, + 4); + return calculate( + 3, + 4); + return calculate( + 3, + 4 + ); +} +#indent end
CVS commit: src/tests/usr.bin/indent
Module Name:src Committed By: rillig Date: Sun Nov 28 16:31:39 UTC 2021 Modified Files: src/tests/usr.bin/indent: lsym_return.c Log Message: tests/indent: test variants of the 'return' statement To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/lsym_return.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 Nov 28 16:20:13 UTC 2021 Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin/indent: Makefile lsym_question.c Removed Files: src/tests/usr.bin/indent: token_question.c Log Message: tests/indent: migrate token_question to lsym_question and extend it To generate a diff of this commit: cvs rdiff -u -r1.1172 -r1.1173 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.38 -r1.39 src/tests/usr.bin/indent/Makefile cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/lsym_question.c cvs rdiff -u -r1.1 -r0 src/tests/usr.bin/indent/token_question.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 Nov 28 16:20:13 UTC 2021 Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin/indent: Makefile lsym_question.c Removed Files: src/tests/usr.bin/indent: token_question.c Log Message: tests/indent: migrate token_question to lsym_question and extend it To generate a diff of this commit: cvs rdiff -u -r1.1172 -r1.1173 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.38 -r1.39 src/tests/usr.bin/indent/Makefile cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/lsym_question.c cvs rdiff -u -r1.1 -r0 src/tests/usr.bin/indent/token_question.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1172 src/distrib/sets/lists/tests/mi:1.1173 --- src/distrib/sets/lists/tests/mi:1.1172 Sun Nov 28 16:05:59 2021 +++ src/distrib/sets/lists/tests/mi Sun Nov 28 16:20:13 2021 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1172 2021/11/28 16:05:59 rillig Exp $ +# $NetBSD: mi,v 1.1173 2021/11/28 16:20:13 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -5268,7 +5268,7 @@ ./usr/tests/usr.bin/indent/token_period.ctests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/indent/token_postfix_op.ctests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/indent/token_preprocessing.c tests-usr.bin-tests compattestfile,atf -./usr/tests/usr.bin/indent/token_question.ctests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/indent/token_question.ctests-obsolete obsolete,atf ./usr/tests/usr.bin/indent/token_rbrace.ctests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/indent/token_rparen.ctests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/indent/token_semicolon.ctests-usr.bin-tests compattestfile,atf Index: src/tests/usr.bin/indent/Makefile diff -u src/tests/usr.bin/indent/Makefile:1.38 src/tests/usr.bin/indent/Makefile:1.39 --- src/tests/usr.bin/indent/Makefile:1.38 Sun Nov 28 16:05:59 2021 +++ src/tests/usr.bin/indent/Makefile Sun Nov 28 16:20:13 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.38 2021/11/28 16:05:59 rillig Exp $ +# $NetBSD: Makefile,v 1.39 2021/11/28 16:20:13 rillig Exp $ .include @@ -133,7 +133,6 @@ FILES+= token_newline.c FILES+= token_period.c FILES+= token_postfix_op.c FILES+= token_preprocessing.c -FILES+= token_question.c FILES+= token_rbrace.c FILES+= token_rparen.c FILES+= token_semicolon.c Index: src/tests/usr.bin/indent/lsym_question.c diff -u src/tests/usr.bin/indent/lsym_question.c:1.1 src/tests/usr.bin/indent/lsym_question.c:1.2 --- src/tests/usr.bin/indent/lsym_question.c:1.1 Thu Nov 18 21:19:19 2021 +++ src/tests/usr.bin/indent/lsym_question.c Sun Nov 28 16:20:13 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lsym_question.c,v 1.1 2021/11/18 21:19:19 rillig Exp $ */ +/* $NetBSD: lsym_question.c,v 1.2 2021/11/28 16:20:13 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -7,7 +7,62 @@ */ #indent input -// TODO: add input +const char *result = cond ? "then" : "else"; + +const char *multi = cond1 ? "cond1" : cond2 ? "cond2" : cond3 ? "cond3" : ""; +#indent end + +#indent run-equals-input -di0 + + +/* + * To make them easier to read, conditional expressions can be split into + * multiple lines. + */ +#indent input +const char *separate_lines = cond + ? "then" + : "else"; +#indent end + +#indent run -di0 +const char *separate_lines = cond +// $ XXX: Continuation lines in expressions should be indented, even in column 1. +? "then" +: "else"; +#indent end + + +/* + * In functions, conditional expressions are indented as intended. + */ +#indent input +void +function(void) +{ + return cond + ? "then" + : "else"; +} #indent end #indent run-equals-input + + +/* + * In functions, conditional expressions are indented as intended. + */ +#indent input +void +function(void) +{ + const char *branch = cond + // $ TODO: Indent these continuation lines as they are part of the + // $ TODO: initializer expression, not of the declarator part to the + // $ TODO: left of the '='. + ? "then" + : "else"; +} +#indent end + +#indent run-equals-input -di0
CVS commit: src
Module Name:src Committed By: rillig Date: Sun Nov 28 16:05:59 UTC 2021 Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin/indent: Makefile lsym_case_label.c lsym_colon.c opt_cli.c Removed Files: src/tests/usr.bin/indent: token_case_label.c Log Message: tests/indent: migrate test token_case_label to lsym_case_label To generate a diff of this commit: cvs rdiff -u -r1.1171 -r1.1172 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.37 -r1.38 src/tests/usr.bin/indent/Makefile cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/lsym_case_label.c cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/lsym_colon.c \ src/tests/usr.bin/indent/opt_cli.c cvs rdiff -u -r1.1 -r0 src/tests/usr.bin/indent/token_case_label.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1171 src/distrib/sets/lists/tests/mi:1.1172 --- src/distrib/sets/lists/tests/mi:1.1171 Sun Nov 28 15:26:22 2021 +++ src/distrib/sets/lists/tests/mi Sun Nov 28 16:05:59 2021 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1171 2021/11/28 15:26:22 rillig Exp $ +# $NetBSD: mi,v 1.1172 2021/11/28 16:05:59 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -5243,7 +5243,7 @@ ./usr/tests/usr.bin/indent/token-while_expr.0.pro tests-obsolete obsolete,atf ./usr/tests/usr.bin/indent/token-while_expr.0.stdout tests-obsolete obsolete,atf ./usr/tests/usr.bin/indent/token_binary_op.ctests-usr.bin-tests compattestfile,atf -./usr/tests/usr.bin/indent/token_case_label.ctests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/indent/token_case_label.ctests-obsolete obsolete,atf ./usr/tests/usr.bin/indent/token_colon.ctests-obsolete obsolete,atf ./usr/tests/usr.bin/indent/token_comma.ctests-obsolete obsolete,atf ./usr/tests/usr.bin/indent/token_comment.ctests-usr.bin-tests compattestfile,atf Index: src/tests/usr.bin/indent/Makefile diff -u src/tests/usr.bin/indent/Makefile:1.37 src/tests/usr.bin/indent/Makefile:1.38 --- src/tests/usr.bin/indent/Makefile:1.37 Sun Nov 28 15:26:22 2021 +++ src/tests/usr.bin/indent/Makefile Sun Nov 28 16:05:59 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.37 2021/11/28 15:26:22 rillig Exp $ +# $NetBSD: Makefile,v 1.38 2021/11/28 16:05:59 rillig Exp $ .include @@ -111,7 +111,6 @@ FILES+= psym_switch_expr.c FILES+= psym_while_expr.c FILES+= t_options.awk FILES+= token_binary_op.c -FILES+= token_case_label.c FILES+= token_comment.c FILES+= token_decl.c FILES+= token_do_stmt.c Index: src/tests/usr.bin/indent/lsym_case_label.c diff -u src/tests/usr.bin/indent/lsym_case_label.c:1.3 src/tests/usr.bin/indent/lsym_case_label.c:1.4 --- src/tests/usr.bin/indent/lsym_case_label.c:1.3 Wed Nov 24 21:34:34 2021 +++ src/tests/usr.bin/indent/lsym_case_label.c Sun Nov 28 16:05:59 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lsym_case_label.c,v 1.3 2021/11/24 21:34:34 rillig Exp $ */ +/* $NetBSD: lsym_case_label.c,v 1.4 2021/11/28 16:05:59 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -14,13 +14,29 @@ * C11 6.5.1.1 "Generic selection" */ -// TODO: test C11 _Generic - +/* + * A case label can be used in a 'switch' statement. + */ #indent input -// TODO: add input +void function(void){switch(expr){case 1:;case 2:break;default:switch(inner){case 4:break;}}} #indent end -#indent run-equals-input +#indent run +void +function(void) +{ + switch (expr) { + case 1: ; + case 2: + break; + default: + switch (inner) { + case 4: + break; + } + } +} +#indent end /* @@ -59,3 +75,42 @@ function(void) } } #indent end + + +/* + * Since C11, the _Generic selection expression allows a switch on the data + * type of an expression. + */ +#indent input +const char *type_name = _Generic( + ' ', + int: "character constants have type 'int'", + char: "character constants have type 'char'", + default: "character constants have some other type" +); +#indent end + +#indent run -di0 +const char *type_name = _Generic( +// $ XXX: It's strange to align the arguments at the parenthesis even though +// $ XXX: the first argument is already on a separate line. + ' ', +// $ TODO: indent the type names +int: "character constants have type 'int'", +char: "character constants have type 'char'", +default: +// $ TODO: remove the newline after 'default:' + "character constants have some other type" +); +#indent end + +#indent run -di0 -nlp +const char *type_name = _Generic( + ' ', +// $ TODO: indent the type names +int: "character constants have type 'int'", +char: "character constants have type 'char'", +default: + "character constants have some other type" +); +#indent end Index: src/tests/usr.bin/indent/lsym_colon.c diff -u src/tests/usr.bin/indent/lsym_colon.c:1.2 src/tests/usr.bin/indent/lsym_colon.c:1.3 --- src/tests/usr.bin/indent/lsym_colon.c:1.2 Su
CVS commit: src
Module Name:src Committed By: rillig Date: Sun Nov 28 16:05:59 UTC 2021 Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin/indent: Makefile lsym_case_label.c lsym_colon.c opt_cli.c Removed Files: src/tests/usr.bin/indent: token_case_label.c Log Message: tests/indent: migrate test token_case_label to lsym_case_label To generate a diff of this commit: cvs rdiff -u -r1.1171 -r1.1172 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.37 -r1.38 src/tests/usr.bin/indent/Makefile cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/lsym_case_label.c cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/lsym_colon.c \ src/tests/usr.bin/indent/opt_cli.c cvs rdiff -u -r1.1 -r0 src/tests/usr.bin/indent/token_case_label.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/sbin/cgdconfig
The change is correct; this is how it is done everywhere else in the tree. You are right about -pthread doing more than adding -lpthread, but in that case, the -pthread should be added to CFLAGS/COPTS etc, not LDADD so that it is effective during the compilation phase too, not just the link phase. When I made the change, I considered going through the tree and adding -pthread to the CFLAGS/COPTS in the Makefiles where -pthread is in LDADD, but I did not want to do a half-assed job without thinking about it more: 1. which compilation flag should we add -pthread to? CFLAGS or COPTS? What about c++? 2. do we remove the LDADD/DPADD pthread settings? I am thinking perhaps not, it does not hurt, plus the DPADD will cause a rebuild when libpthread changes. The libargon addition to cgdconfig broke lint building because lint h as not been taught about -pthread yet, and fixing it the way I fixed it, makes the lint build work again and is consistent with the rest of the tree. Best, christos > On Nov 28, 2021, at 10:42 AM, Jason Thorpe wrote: > > > >> On Nov 27, 2021, at 6:01 PM, Christos Zoulas wrote: >> >> Module Name: src >> Committed By:christos >> Date:Sun Nov 28 02:01:30 UTC 2021 >> >> Modified Files: >> src/sbin/cgdconfig: Makefile >> >> Log Message: >> -lpthread to LDADD (fixes lint build) > > This change is wrong. The -pthread option to the compiler does more than > just add -lpthread to the link phase. > > -- thorpej
CVS commit: src/share/mk
Module Name:src Committed By: christos Date: Sun Nov 28 15:49:36 UTC 2021 Modified Files: src/share/mk: bsd.prog.mk Log Message: When we build against DESTDIR, add the lint library path for DESTDIR during the link phase for lint. To generate a diff of this commit: cvs rdiff -u -r1.339 -r1.340 src/share/mk/bsd.prog.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/mk/bsd.prog.mk diff -u src/share/mk/bsd.prog.mk:1.339 src/share/mk/bsd.prog.mk:1.340 --- src/share/mk/bsd.prog.mk:1.339 Mon Aug 23 18:13:27 2021 +++ src/share/mk/bsd.prog.mk Sun Nov 28 10:49:36 2021 @@ -1,4 +1,4 @@ -# $NetBSD: bsd.prog.mk,v 1.339 2021/08/23 22:13:27 mrg Exp $ +# $NetBSD: bsd.prog.mk,v 1.340 2021/11/28 15:49:36 christos Exp $ # @(#)bsd.prog.mk 8.2 (Berkeley) 4/2/94 .ifndef HOSTPROG @@ -632,8 +632,12 @@ ${DESTDIR}${DEBUGDIR}${BINDIR.${_P}}/${_ lint: lint-${_P} lint-${_P}: ${LOBJS.${_P}} .if defined(LOBJS.${_P}) && !empty(LOBJS.${_P}) +.if defined(DESTDIR) + ${LINT} ${LINTFLAGS} ${_LDFLAGS.${_P}:C/-L[ ]*/-L/Wg:M-L*} -L${DESTDIR}/usr/libdata/lint ${LOBJS.${_P}} ${_LDADD.${_P}} +.else ${LINT} ${LINTFLAGS} ${_LDFLAGS.${_P}:C/-L[ ]*/-L/Wg:M-L*} ${LOBJS.${_P}} ${_LDADD.${_P}} .endif +.endif .endfor # _P in ${PROGS} ${PROGS_CXX} # }
CVS commit: src/share/mk
Module Name:src Committed By: christos Date: Sun Nov 28 15:49:36 UTC 2021 Modified Files: src/share/mk: bsd.prog.mk Log Message: When we build against DESTDIR, add the lint library path for DESTDIR during the link phase for lint. To generate a diff of this commit: cvs rdiff -u -r1.339 -r1.340 src/share/mk/bsd.prog.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/share/mk
Module Name:src Committed By: christos Date: Sun Nov 28 15:47:33 UTC 2021 Modified Files: src/share/mk: bsd.README bsd.lib.mk Log Message: For private and module libraries, build lint but do not install the lint libraries. We want to lint the private library code and we want to be able to link against the lint libraries, for example llib-largon2 from cgdconfig which is accessed via PROGDPLIBS. To generate a diff of this commit: cvs rdiff -u -r1.422 -r1.423 src/share/mk/bsd.README cvs rdiff -u -r1.387 -r1.388 src/share/mk/bsd.lib.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/share/mk/bsd.README diff -u src/share/mk/bsd.README:1.422 src/share/mk/bsd.README:1.423 --- src/share/mk/bsd.README:1.422 Mon Nov 1 06:05:19 2021 +++ src/share/mk/bsd.README Sun Nov 28 10:47:33 2021 @@ -1,4 +1,4 @@ -# $NetBSD: bsd.README,v 1.422 2021/11/01 10:05:19 nia Exp $ +# $NetBSD: bsd.README,v 1.423 2021/11/28 15:47:33 christos Exp $ # @(#)bsd.README 8.2 (Berkeley) 4/2/94 This is the README file for the make "include" files for the NetBSD @@ -1341,12 +1341,12 @@ USE_SHLIBDIR If not "no", use ${SHLIBINS Default: no LIBISMODULE If not "no", install as ${LIB}.so (without the "lib" prefix), - and act as "MKDEBUGLIB=no MKLINT=no MKPICINSTALL=no - MKPROFILE=no MKSTATICLIB=no". + and act as "MKDEBUGLIB=no MKPICINSTALL=no MKPROFILE=no + MKSTATICLIB=no". Also do not install the lint library. Default: no -LIBISPRIVATE If not "no", act as "MKDEBUGLIB=no MKLINT=no MKPIC=no - MKPROFILE=no", and don't install the (.a) library. +LIBISPRIVATE If not "no", act as "MKDEBUGLIB=no MKPIC=no MKPROFILE=no", + and don't install the (.a) library or the lint library. This is useful for "build only" helper libraries. If set to "pic", then a _pic.a library is also produced, so that it can be incorporated into other shared objects. Index: src/share/mk/bsd.lib.mk diff -u src/share/mk/bsd.lib.mk:1.387 src/share/mk/bsd.lib.mk:1.388 --- src/share/mk/bsd.lib.mk:1.387 Tue Oct 26 23:06:59 2021 +++ src/share/mk/bsd.lib.mk Sun Nov 28 10:47:33 2021 @@ -1,4 +1,4 @@ -# $NetBSD: bsd.lib.mk,v 1.387 2021/10/27 03:06:59 ryo Exp $ +# $NetBSD: bsd.lib.mk,v 1.388 2021/11/28 15:47:33 christos Exp $ # @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94 .include @@ -16,17 +16,16 @@ LIBISCXX?= no .if ${LIBISMODULE} != "no" _LIB_PREFIX?= # empty MKDEBUGLIB:= no -MKLINT:= no MKPICINSTALL:= no MKPROFILE:= no MKSTATICLIB:= no +_LINTINSTALL?= no .else _LIB_PREFIX?= lib .endif .if ${LIBISPRIVATE} != "no" MKDEBUGLIB:= no -MKLINT:= no MKPICINSTALL:= no . if defined(NOSTATICLIB) && ${MKPICLIB} != "no" MKSTATICLIB:= no @@ -34,8 +33,11 @@ MKSTATICLIB:= no MKPIC:= no . endif MKPROFILE:= no +_LINTINSTALL?= no .endif +_LINTINSTALL?= ${MKLINT} + # Basic targets .PHONY: checkver libinstall realinstall: checkver libinstall @@ -845,7 +847,7 @@ ${_DEST.DEBUG}/${_LIB.so.debug}: ${_LIB. .endif .endif -.if ${MKLINT} != "no" && !empty(LOBJS) +.if ${_LINTINSTALL} != "no" && !empty(LOBJS) libinstall:: ${_DEST.LINT}/${_LIB.ln} .PRECIOUS: ${_DEST.LINT}/${_LIB.ln}
CVS commit: src/share/mk
Module Name:src Committed By: christos Date: Sun Nov 28 15:47:33 UTC 2021 Modified Files: src/share/mk: bsd.README bsd.lib.mk Log Message: For private and module libraries, build lint but do not install the lint libraries. We want to lint the private library code and we want to be able to link against the lint libraries, for example llib-largon2 from cgdconfig which is accessed via PROGDPLIBS. To generate a diff of this commit: cvs rdiff -u -r1.422 -r1.423 src/share/mk/bsd.README cvs rdiff -u -r1.387 -r1.388 src/share/mk/bsd.lib.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/sbin/cgdconfig
> On Nov 27, 2021, at 6:01 PM, Christos Zoulas wrote: > > Module Name: src > Committed By: christos > Date: Sun Nov 28 02:01:30 UTC 2021 > > Modified Files: > src/sbin/cgdconfig: Makefile > > Log Message: > -lpthread to LDADD (fixes lint build) This change is wrong. The -pthread option to the compiler does more than just add -lpthread to the link phase. -- thorpej
CVS commit: src
Module Name:src Committed By: rillig Date: Sun Nov 28 15:26:22 UTC 2021 Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin/indent: Makefile lsym_comma.c Removed Files: src/tests/usr.bin/indent: token_comma.c Log Message: tests/indent: migrate token_comma to lsym_comma The section on initializer values is new. To generate a diff of this commit: cvs rdiff -u -r1.1170 -r1.1171 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.36 -r1.37 src/tests/usr.bin/indent/Makefile cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/lsym_comma.c cvs rdiff -u -r1.2 -r0 src/tests/usr.bin/indent/token_comma.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1170 src/distrib/sets/lists/tests/mi:1.1171 --- src/distrib/sets/lists/tests/mi:1.1170 Sun Nov 28 14:49:28 2021 +++ src/distrib/sets/lists/tests/mi Sun Nov 28 15:26:22 2021 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1170 2021/11/28 14:49:28 rillig Exp $ +# $NetBSD: mi,v 1.1171 2021/11/28 15:26:22 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -5245,7 +5245,7 @@ ./usr/tests/usr.bin/indent/token_binary_op.ctests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/indent/token_case_label.ctests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/indent/token_colon.ctests-obsolete obsolete,atf -./usr/tests/usr.bin/indent/token_comma.ctests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/indent/token_comma.ctests-obsolete obsolete,atf ./usr/tests/usr.bin/indent/token_comment.ctests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/indent/token_decl.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/indent/token_do_stmt.ctests-usr.bin-tests compattestfile,atf Index: src/tests/usr.bin/indent/Makefile diff -u src/tests/usr.bin/indent/Makefile:1.36 src/tests/usr.bin/indent/Makefile:1.37 --- src/tests/usr.bin/indent/Makefile:1.36 Sun Nov 28 14:49:28 2021 +++ src/tests/usr.bin/indent/Makefile Sun Nov 28 15:26:22 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.36 2021/11/28 14:49:28 rillig Exp $ +# $NetBSD: Makefile,v 1.37 2021/11/28 15:26:22 rillig Exp $ .include @@ -112,7 +112,6 @@ FILES+= psym_while_expr.c FILES+= t_options.awk FILES+= token_binary_op.c FILES+= token_case_label.c -FILES+= token_comma.c FILES+= token_comment.c FILES+= token_decl.c FILES+= token_do_stmt.c Index: src/tests/usr.bin/indent/lsym_comma.c diff -u src/tests/usr.bin/indent/lsym_comma.c:1.2 src/tests/usr.bin/indent/lsym_comma.c:1.3 --- src/tests/usr.bin/indent/lsym_comma.c:1.2 Sat Nov 20 16:54:17 2021 +++ src/tests/usr.bin/indent/lsym_comma.c Sun Nov 28 15:26:22 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lsym_comma.c,v 1.2 2021/11/20 16:54:17 rillig Exp $ */ +/* $NetBSD: lsym_comma.c,v 1.3 2021/11/28 15:26:22 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -22,10 +22,161 @@ * In a macro definition, a ',' separates the parameter names. * * In a macro invocation, a ',' separates the arguments. + * + * In an initializer list, a ',' separates the initializer expressions. */ +/* + * The ',' is a binary operator with very low precedence. + */ #indent input -// TODO: add input +int +comma_expression(void) +{ + return 1, 3; + return a = b, c = d; +} #indent end #indent run-equals-input + + +/* + * In a declaration, a ',' separates the declarators. + */ +#indent input +int decl, old_style(), prototype(const char *, double *); +int a, b, c; +#indent end + +#indent run-equals-input -di0 + + +/* + * In a parameter list of a function type, a ',' separates the parameter + * declarations. + */ +#indent input +double dbl_reduce(double init, const double *s, const double *e, double (*merge)(double, double)); +double dbl_reduce(double, const double *, const double *, double (*)(double, double)); +void debug_printf(const char *, ...); +#indent end + +#indent run-equals-input -di0 + + +/* + * In a traditional function definition, a ',' separates the parameter names. + */ +#indent input +double +trad_dbl_reduce(init, s, e, merge) + double init; + double *s, *e; + double (*merge)() +{ + double x = init; + while (s < e) + x = merge(x, *s++); + return x; +} +#indent end + +#indent run-equals-input -di0 + + +/* + * In a prototype function definition, a ',' separates the parameter + * declarations. + */ +#indent input +void +dbl_reduce(double init, const double *s, const double *e, double (*merge)(double, double)) +{ + double x = init; + while (s < e) + x = merge(x, *s++); + return x; +} +#indent end + +#indent run-equals-input -di0 + + +/* + * In a function call expression, a ',' separates the arguments. + */ +#indent input +void +function(void) +{ + function_call(arg1, arg2); + (*indirect_function_call)(arg1, arg2); +} +#indent end + +#indent run-equals-input -di0 + + +/* + * In a macro defini
CVS commit: src
Module Name:src Committed By: rillig Date: Sun Nov 28 15:26:22 UTC 2021 Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin/indent: Makefile lsym_comma.c Removed Files: src/tests/usr.bin/indent: token_comma.c Log Message: tests/indent: migrate token_comma to lsym_comma The section on initializer values is new. To generate a diff of this commit: cvs rdiff -u -r1.1170 -r1.1171 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.36 -r1.37 src/tests/usr.bin/indent/Makefile cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/lsym_comma.c cvs rdiff -u -r1.2 -r0 src/tests/usr.bin/indent/token_comma.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 Nov 28 14:49:28 UTC 2021 Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin/indent: Makefile lsym_colon.c Removed Files: src/tests/usr.bin/indent: token_colon.c Log Message: tests/indent: move test for ':' to lsym_token.c To generate a diff of this commit: cvs rdiff -u -r1.1169 -r1.1170 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.35 -r1.36 src/tests/usr.bin/indent/Makefile cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/lsym_colon.c cvs rdiff -u -r1.2 -r0 src/tests/usr.bin/indent/token_colon.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1169 src/distrib/sets/lists/tests/mi:1.1170 --- src/distrib/sets/lists/tests/mi:1.1169 Sun Nov 28 14:29:03 2021 +++ src/distrib/sets/lists/tests/mi Sun Nov 28 14:49:28 2021 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1169 2021/11/28 14:29:03 rillig Exp $ +# $NetBSD: mi,v 1.1170 2021/11/28 14:49:28 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -5244,7 +5244,7 @@ ./usr/tests/usr.bin/indent/token-while_expr.0.stdout tests-obsolete obsolete,atf ./usr/tests/usr.bin/indent/token_binary_op.ctests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/indent/token_case_label.ctests-usr.bin-tests compattestfile,atf -./usr/tests/usr.bin/indent/token_colon.ctests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/indent/token_colon.ctests-obsolete obsolete,atf ./usr/tests/usr.bin/indent/token_comma.ctests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/indent/token_comment.ctests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/indent/token_decl.c tests-usr.bin-tests compattestfile,atf Index: src/tests/usr.bin/indent/Makefile diff -u src/tests/usr.bin/indent/Makefile:1.35 src/tests/usr.bin/indent/Makefile:1.36 --- src/tests/usr.bin/indent/Makefile:1.35 Sun Nov 28 14:29:03 2021 +++ src/tests/usr.bin/indent/Makefile Sun Nov 28 14:49:28 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.35 2021/11/28 14:29:03 rillig Exp $ +# $NetBSD: Makefile,v 1.36 2021/11/28 14:49:28 rillig Exp $ .include @@ -112,7 +112,6 @@ FILES+= psym_while_expr.c FILES+= t_options.awk FILES+= token_binary_op.c FILES+= token_case_label.c -FILES+= token_colon.c FILES+= token_comma.c FILES+= token_comment.c FILES+= token_decl.c Index: src/tests/usr.bin/indent/lsym_colon.c diff -u src/tests/usr.bin/indent/lsym_colon.c:1.1 src/tests/usr.bin/indent/lsym_colon.c:1.2 --- src/tests/usr.bin/indent/lsym_colon.c:1.1 Thu Nov 18 21:19:19 2021 +++ src/tests/usr.bin/indent/lsym_colon.c Sun Nov 28 14:49:28 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lsym_colon.c,v 1.1 2021/11/18 21:19:19 rillig Exp $ */ +/* $NetBSD: lsym_colon.c,v 1.2 2021/11/28 14:49:28 rillig Exp $ */ /* $FreeBSD$ */ /* @@ -11,10 +11,96 @@ * As part of the conditional operator '?:'. * * In the declaration of a struct member that is a bit-field. + * + * See also: + * label.c + * lsym_question.c */ +/* + * The ':' marks a label that can be used in a 'goto' statement. + */ #indent input -// TODO: add input +void endless(void) +{ +label1: +goto label2; + +if (true)if (true)if (true)if (true)label2 :goto label1; +} +#indent end + +#indent run +void +endless(void) +{ +label1: + goto label2; + + if (true) + if (true) + if (true) +if (true) + label2: goto label1; +} +#indent end + + +/* + * The ':' is used in a 'switch' statement, after a 'case' label or a + * 'default' label. + */ +#indent input +void +example(void) +{ + switch (expr) { + case 'x': + return; + default: + return; + } +} #indent end #indent run-equals-input + + +/* + * The ':' is used as part of the conditional operator '?:'. + */ +#indent input +int constant_expression = true?4:12345; +#indent end + +#indent run +int constant_expression = true ? 4 : 12345; +#indent end + + +/* + * The ':' is used in the declaration of a struct member that is a bit-field. + */ +#indent input +struct bit_field { + bool flag:1; + int maybe_signed : 4; + signed int definitely_signed:3; + signed int : 0;/* padding */ + unsigned int definitely_unsigned:3; + unsigned int:0;/* padding */ +}; +#indent end + +#indent run +struct bit_field { + bool flag:1; + int maybe_signed:4; + signed int definitely_signed:3; +/* $ XXX: Placing the colon directly at the type looks inconsistent. */ + signed int: 0; /* padding */ + unsigned int definitely_unsigned:3; +/* $ XXX: Placing the colon directly at the type looks inconsistent. */ + unsigned int: 0; /* padding */ +}; +#indent end
CVS commit: src
Module Name:src Committed By: rillig Date: Sun Nov 28 14:49:28 UTC 2021 Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin/indent: Makefile lsym_colon.c Removed Files: src/tests/usr.bin/indent: token_colon.c Log Message: tests/indent: move test for ':' to lsym_token.c To generate a diff of this commit: cvs rdiff -u -r1.1169 -r1.1170 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.35 -r1.36 src/tests/usr.bin/indent/Makefile cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/lsym_colon.c cvs rdiff -u -r1.2 -r0 src/tests/usr.bin/indent/token_colon.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 Nov 28 14:29:03 UTC 2021 Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin/indent: Makefile src/usr.bin/indent: indent.c indent.h lexi.c Removed Files: src/tests/usr.bin/indent: lsym_string_prefix.c Log Message: indent: treat L"string" as a single token There is never whitespace between the 'L' and the string literal or the character constant. There might be a backslash-newline between them, but that case was not handled before either. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.1168 -r1.1169 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.34 -r1.35 src/tests/usr.bin/indent/Makefile cvs rdiff -u -r1.1 -r0 src/tests/usr.bin/indent/lsym_string_prefix.c cvs rdiff -u -r1.238 -r1.239 src/usr.bin/indent/indent.c cvs rdiff -u -r1.106 -r1.107 src/usr.bin/indent/indent.h cvs rdiff -u -r1.166 -r1.167 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/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1168 src/distrib/sets/lists/tests/mi:1.1169 --- src/distrib/sets/lists/tests/mi:1.1168 Thu Nov 18 21:19:18 2021 +++ src/distrib/sets/lists/tests/mi Sun Nov 28 14:29:03 2021 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1168 2021/11/18 21:19:18 rillig Exp $ +# $NetBSD: mi,v 1.1169 2021/11/28 14:29:03 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -4823,7 +4823,7 @@ ./usr/tests/usr.bin/indent/lsym_semicolon.ctests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/indent/lsym_sizeof.ctests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/indent/lsym_storage_class.ctests-usr.bin-tests compattestfile,atf -./usr/tests/usr.bin/indent/lsym_string_prefix.ctests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/indent/lsym_string_prefix.ctests-obsolete obsolete,atf ./usr/tests/usr.bin/indent/lsym_switch.ctests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/indent/lsym_tag.c tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/indent/lsym_type_in_parentheses.c tests-usr.bin-tests compattestfile,atf Index: src/tests/usr.bin/indent/Makefile diff -u src/tests/usr.bin/indent/Makefile:1.34 src/tests/usr.bin/indent/Makefile:1.35 --- src/tests/usr.bin/indent/Makefile:1.34 Thu Nov 18 21:19:19 2021 +++ src/tests/usr.bin/indent/Makefile Sun Nov 28 14:29:03 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.34 2021/11/18 21:19:19 rillig Exp $ +# $NetBSD: Makefile,v 1.35 2021/11/28 14:29:03 rillig Exp $ .include @@ -43,7 +43,6 @@ FILES+= lsym_rparen_or_rbracket.c FILES+= lsym_semicolon.c FILES+= lsym_sizeof.c FILES+= lsym_storage_class.c -FILES+= lsym_string_prefix.c FILES+= lsym_switch.c FILES+= lsym_tag.c FILES+= lsym_type_in_parentheses.c Index: src/usr.bin/indent/indent.c diff -u src/usr.bin/indent/indent.c:1.238 src/usr.bin/indent/indent.c:1.239 --- src/usr.bin/indent/indent.c:1.238 Sun Nov 28 11:49:10 2021 +++ src/usr.bin/indent/indent.c Sun Nov 28 14:29:03 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.238 2021/11/28 11:49:10 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.239 2021/11/28 14:29:03 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c 5.1 #include #if defined(__NetBSD__) -__RCSID("$NetBSD: indent.c,v 1.238 2021/11/28 11:49:10 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.239 2021/11/28 14:29:03 rillig Exp $"); #elif defined(__FreeBSD__) __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $"); #endif @@ -1120,13 +1120,6 @@ copy_token(void) } static void -process_string_prefix(void) -{ -copy_token(); -ps.want_blank = false; -} - -static void process_period(void) { if (code.e > code.s && code.e[-1] == ',') @@ -1440,10 +1433,6 @@ main_loop(void) ps.want_blank = true; break; - case lsym_string_prefix: - process_string_prefix(); - break; - case lsym_period: process_period(); break; Index: src/usr.bin/indent/indent.h diff -u src/usr.bin/indent/indent.h:1.106 src/usr.bin/indent/indent.h:1.107 --- src/usr.bin/indent/indent.h:1.106 Sun Nov 28 11:49:10 2021 +++ src/usr.bin/indent/indent.h Sun Nov 28 14:29:03 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.h,v 1.106 2021/11/28 11:49:10 rillig Exp $ */ +/* $NetBSD: indent.h,v 1.107 2021/11/28 14:29:03 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -96,7 +96,6 @@ typedef enum lexer_symbol { lsym_type_in_parentheses, lsym_tag, /* 'struct', 'union' or 'enum' */ lsym_case_label, /* 'case' or 'default' */ -lsym_string_prefix, /* 'L' */ lsym_sizeof, lsym_offsetof, lsym_word, /* identifier, constant or string */ Index: src/usr.bin/indent/lexi.c diff -u src/usr.bin/indent/lexi.c:1.166
CVS commit: src
Module Name:src Committed By: rillig Date: Sun Nov 28 14:29:03 UTC 2021 Modified Files: src/distrib/sets/lists/tests: mi src/tests/usr.bin/indent: Makefile src/usr.bin/indent: indent.c indent.h lexi.c Removed Files: src/tests/usr.bin/indent: lsym_string_prefix.c Log Message: indent: treat L"string" as a single token There is never whitespace between the 'L' and the string literal or the character constant. There might be a backslash-newline between them, but that case was not handled before either. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.1168 -r1.1169 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.34 -r1.35 src/tests/usr.bin/indent/Makefile cvs rdiff -u -r1.1 -r0 src/tests/usr.bin/indent/lsym_string_prefix.c cvs rdiff -u -r1.238 -r1.239 src/usr.bin/indent/indent.c cvs rdiff -u -r1.106 -r1.107 src/usr.bin/indent/indent.h cvs rdiff -u -r1.166 -r1.167 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 Nov 28 11:49:11 UTC 2021 Modified Files: src/usr.bin/indent: indent.c indent.h io.c Log Message: indent: clean up and document input handling The transformation of moving comments from after an 'if (expr)' after the following brace has a large implementation cost (about 300 lines of code) and makes input handling quite complicated. Document the overall idea to save future readers some time. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.237 -r1.238 src/usr.bin/indent/indent.c cvs rdiff -u -r1.105 -r1.106 src/usr.bin/indent/indent.h cvs rdiff -u -r1.142 -r1.143 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.237 src/usr.bin/indent/indent.c:1.238 --- src/usr.bin/indent/indent.c:1.237 Sat Nov 27 21:15:58 2021 +++ src/usr.bin/indent/indent.c Sun Nov 28 11:49:10 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.237 2021/11/27 21:15:58 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.238 2021/11/28 11:49:10 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c 5.1 #include #if defined(__NetBSD__) -__RCSID("$NetBSD: indent.c,v 1.237 2021/11/27 21:15:58 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.238 2021/11/28 11:49:10 rillig Exp $"); #elif defined(__FreeBSD__) __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $"); #endif @@ -322,7 +322,7 @@ search_stmt_other(lexer_symbol lsym, boo } debug_inp(__func__); -inp_comment_rtrim(); +inp_comment_rtrim_blank(); if (opt.swallow_optional_blanklines || (!comment_buffered && remove_newlines)) { Index: src/usr.bin/indent/indent.h diff -u src/usr.bin/indent/indent.h:1.105 src/usr.bin/indent/indent.h:1.106 --- src/usr.bin/indent/indent.h:1.105 Sat Nov 27 21:15:58 2021 +++ src/usr.bin/indent/indent.h Sun Nov 28 11:49:10 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.h,v 1.105 2021/11/27 21:15:58 rillig Exp $ */ +/* $NetBSD: indent.h,v 1.106 2021/11/28 11:49:10 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD @@ -377,7 +377,7 @@ void inp_comment_add_char(char); void inp_comment_add_range(const char *, const char *); bool inp_comment_complete_block(void); bool inp_comment_seen(void); -void inp_comment_rtrim(void); +void inp_comment_rtrim_blank(void); void inp_comment_rtrim_newline(void); void inp_comment_insert_lbrace(void); Index: src/usr.bin/indent/io.c diff -u src/usr.bin/indent/io.c:1.142 src/usr.bin/indent/io.c:1.143 --- src/usr.bin/indent/io.c:1.142 Sat Nov 27 21:15:58 2021 +++ src/usr.bin/indent/io.c Sun Nov 28 11:49:10 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: io.c,v 1.142 2021/11/27 21:15:58 rillig Exp $ */ +/* $NetBSD: io.c,v 1.143 2021/11/28 11:49:10 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -43,7 +43,7 @@ static char sccsid[] = "@(#)io.c 8.1 (Be #include #if defined(__NetBSD__) -__RCSID("$NetBSD: io.c,v 1.142 2021/11/27 21:15:58 rillig Exp $"); +__RCSID("$NetBSD: io.c,v 1.143 2021/11/28 11:49:10 rillig Exp $"); #elif defined(__FreeBSD__) __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $"); #endif @@ -55,18 +55,41 @@ __FBSDID("$FreeBSD: head/usr.bin/indent/ #include "indent.h" +/* + * There are 3 modes for reading the input. + * + * default: In this mode, the input comes from the input file. The buffer + * 'inp' contains the current line, terminated with '\n'. The current read + * position is inp.s, and there is always inp.buf <= inp.s < inp.e. All other + * pointers are null. + * + * copy-in: After reading 'if (expr)' or similar tokens, the input still comes + * from 'inp', but instead of processing it, it is copied to 'save_com'. The + * goal of this mode is to move the comments after the '{', that is to + * transform 'if (expr) comment {' to 'if (expr) { comment'. When the next + * token cannot be part of this transformation, switch to copy-out. + * + * copy-out: In this mode, the input comes from 'save_com', which contains the + * tokens to be placed after the '{'. The input still comes from the range + * [inp.s, inp.e), but these two members have been overwritten with pointers + * into save_com_buf, so inp.buf and inp.s are unrelated, which is unusual. + * In this mode, inp.e[-1] is usually not terminated with '\n'. After reading + * all tokens from save_com, switch to default mode again. + */ static struct { struct buffer inp; /* one line of input, ready to be split into - * tokens; occasionally this buffer switches + * tokens; occasionally 's' and 'e' switch * to save_com_buf */ char save_com_buf[5000]; /* input text is saved here when looking for * the brace after an if, while, etc */ -char *save_com_s; /* start of the comment in s
CVS commit: src/usr.bin/indent
Module Name:src Committed By: rillig Date: Sun Nov 28 11:49:11 UTC 2021 Modified Files: src/usr.bin/indent: indent.c indent.h io.c Log Message: indent: clean up and document input handling The transformation of moving comments from after an 'if (expr)' after the following brace has a large implementation cost (about 300 lines of code) and makes input handling quite complicated. Document the overall idea to save future readers some time. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.237 -r1.238 src/usr.bin/indent/indent.c cvs rdiff -u -r1.105 -r1.106 src/usr.bin/indent/indent.h cvs rdiff -u -r1.142 -r1.143 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/tests/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Nov 28 10:11:15 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: emit.c Log Message: tests/lint: update history of exporting unnamed objects To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/xlint/lint1/emit.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/emit.c diff -u src/tests/usr.bin/xlint/lint1/emit.c:1.8 src/tests/usr.bin/xlint/lint1/emit.c:1.9 --- src/tests/usr.bin/xlint/lint1/emit.c:1.8 Sun Nov 28 09:47:18 2021 +++ src/tests/usr.bin/xlint/lint1/emit.c Sun Nov 28 10:11:15 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: emit.c,v 1.8 2021/11/28 09:47:18 rillig Exp $ */ +/* $NetBSD: emit.c,v 1.9 2021/11/28 10:11:15 rillig Exp $ */ # 3 "emit.c" /* @@ -293,7 +293,7 @@ use_vars(void) * The objects that are created for these compound literals are unnamed, * therefore there is no point in exporting them to the .ln file. * - * Before TODO, lint exported them. + * Before emit1.c 1.60 from 2021-11-28, lint exported them. */ struct compound_expression_in_initializer { const char * const *info;
CVS commit: src/tests/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Nov 28 10:11:15 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: emit.c Log Message: tests/lint: update history of exporting unnamed objects To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/xlint/lint1/emit.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 Nov 28 10:01:37 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: emit.exp-ln src/usr.bin/xlint/lint1: emit1.c Log Message: lint: do not export unnamed objects to the .ln file Since these objects are unnamed, they cannot be referenced by other files or even create name clashes. Seen in usr.sbin/cpuctl/aarch64.c, reported by Christos. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/xlint/lint1/emit.exp-ln cvs rdiff -u -r1.59 -r1.60 src/usr.bin/xlint/lint1/emit1.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/emit.exp-ln diff -u src/tests/usr.bin/xlint/lint1/emit.exp-ln:1.8 src/tests/usr.bin/xlint/lint1/emit.exp-ln:1.9 --- src/tests/usr.bin/xlint/lint1/emit.exp-ln:1.8 Sun Nov 28 09:47:18 2021 +++ src/tests/usr.bin/xlint/lint1/emit.exp-ln Sun Nov 28 10:01:36 2021 @@ -82,5 +82,3 @@ Semit.c 286u0.286x16defined_used_var 283d0.283d8use_varsF0V 302d0.302d8compoundsT134compound_expression_in_initializer -303d-1.0d12_tmpA16PcC -305u0.305x12_tmp Index: src/usr.bin/xlint/lint1/emit1.c diff -u src/usr.bin/xlint/lint1/emit1.c:1.59 src/usr.bin/xlint/lint1/emit1.c:1.60 --- src/usr.bin/xlint/lint1/emit1.c:1.59 Sun Sep 12 10:06:03 2021 +++ src/usr.bin/xlint/lint1/emit1.c Sun Nov 28 10:01:36 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: emit1.c,v 1.59 2021/09/12 10:06:03 rillig Exp $ */ +/* $NetBSD: emit1.c,v 1.60 2021/11/28 10:01:36 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: emit1.c,v 1.59 2021/09/12 10:06:03 rillig Exp $"); +__RCSID("$NetBSD: emit1.c,v 1.60 2021/11/28 10:01:36 rillig Exp $"); #endif #include "lint1.h" @@ -187,6 +187,8 @@ outsym(const sym_t *sym, scl_t sc, def_t */ if (sc != EXTERN && !(sc == STATIC && sym->s_type->t_tspec == FUNC)) return; + if (ch_isdigit(sym->s_name[0])) /* _tmp */ + return; /* reset buffer */ outclr(); @@ -586,6 +588,9 @@ outfstrg(strg_t *strg) void outusg(const sym_t *sym) { + if (ch_isdigit(sym->s_name[0])) /* _tmp */ + return; + /* reset buffer */ outclr();
CVS commit: src
Module Name:src Committed By: rillig Date: Sun Nov 28 10:01:37 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: emit.exp-ln src/usr.bin/xlint/lint1: emit1.c Log Message: lint: do not export unnamed objects to the .ln file Since these objects are unnamed, they cannot be referenced by other files or even create name clashes. Seen in usr.sbin/cpuctl/aarch64.c, reported by Christos. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/xlint/lint1/emit.exp-ln cvs rdiff -u -r1.59 -r1.60 src/usr.bin/xlint/lint1/emit1.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: Sun Nov 28 09:59:59 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y Log Message: lint: allow Bison debug functions to be unused The grammar is only compiled using Bison during development time. In the official builds, it is built with byacc. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.371 -r1.372 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.371 src/usr.bin/xlint/lint1/cgram.y:1.372 --- src/usr.bin/xlint/lint1/cgram.y:1.371 Sat Nov 27 20:13:48 2021 +++ src/usr.bin/xlint/lint1/cgram.y Sun Nov 28 09:59:59 2021 @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.371 2021/11/27 20:13:48 christos Exp $ */ +/* $NetBSD: cgram.y,v 1.372 2021/11/28 09:59:59 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.371 2021/11/27 20:13:48 christos Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.372 2021/11/28 09:59:59 rillig Exp $"); #endif #include @@ -361,7 +361,7 @@ anonymize(sym_t *s) %{ #if defined(YYDEBUG) && defined(YYBISON) -static void cgram_print(FILE *, int, YYSTYPE); +static inline void cgram_print(FILE *, int, YYSTYPE); #endif %} @@ -2185,7 +2185,7 @@ cgram_to_string(int token, YYSTYPE val) #endif #if defined(YYDEBUG) && defined(YYBISON) -static void +static inline void cgram_print(FILE *output, int token, YYSTYPE val) { (void)fprintf(output, "%s", cgram_to_string(token, val));
CVS commit: src/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Nov 28 09:59:59 UTC 2021 Modified Files: src/usr.bin/xlint/lint1: cgram.y Log Message: lint: allow Bison debug functions to be unused The grammar is only compiled using Bison during development time. In the official builds, it is built with byacc. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.371 -r1.372 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/tests/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Nov 28 09:47:18 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: emit.c emit.exp-ln Log Message: tests/lint1: reproduce parse error for accidentally exported name Seen in usr.sbin/cpuctl/aarch64.c line 118. error: aarch64.ln:857: not alnum or _: (for '118d-1.0d12_tmpA16PcC') The name _tmp was not supposed to be exported. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/emit.c \ src/tests/usr.bin/xlint/lint1/emit.exp-ln 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/emit.c diff -u src/tests/usr.bin/xlint/lint1/emit.c:1.7 src/tests/usr.bin/xlint/lint1/emit.c:1.8 --- src/tests/usr.bin/xlint/lint1/emit.c:1.7 Fri Sep 10 20:02:51 2021 +++ src/tests/usr.bin/xlint/lint1/emit.c Sun Nov 28 09:47:18 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: emit.c,v 1.7 2021/09/10 20:02:51 rillig Exp $ */ +/* $NetBSD: emit.c,v 1.8 2021/11/28 09:47:18 rillig Exp $ */ # 3 "emit.c" /* @@ -285,3 +285,22 @@ use_vars(void) declared_used_var++; defined_used_var++; } + +/* + * Since C99, an initializer may contain a compound expression. This allows + * to create trees of pointer data structures at compile time. + * + * The objects that are created for these compound literals are unnamed, + * therefore there is no point in exporting them to the .ln file. + * + * Before TODO, lint exported them. + */ +struct compound_expression_in_initializer { + const char * const *info; +}; + +struct compound_expression_in_initializer compound = { + .info = (const char *[16]){ + [0] = "zero", + }, +}; Index: src/tests/usr.bin/xlint/lint1/emit.exp-ln diff -u src/tests/usr.bin/xlint/lint1/emit.exp-ln:1.7 src/tests/usr.bin/xlint/lint1/emit.exp-ln:1.8 --- src/tests/usr.bin/xlint/lint1/emit.exp-ln:1.7 Sat Sep 4 15:13:00 2021 +++ src/tests/usr.bin/xlint/lint1/emit.exp-ln Sun Nov 28 09:47:18 2021 @@ -81,3 +81,6 @@ Semit.c 285u0.285x17declared_used_var 286u0.286x16defined_used_var 283d0.283d8use_varsF0V +302d0.302d8compoundsT134compound_expression_in_initializer +303d-1.0d12_tmpA16PcC +305u0.305x12_tmp
CVS commit: src/tests/usr.bin/xlint/lint1
Module Name:src Committed By: rillig Date: Sun Nov 28 09:47:18 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint1: emit.c emit.exp-ln Log Message: tests/lint1: reproduce parse error for accidentally exported name Seen in usr.sbin/cpuctl/aarch64.c line 118. error: aarch64.ln:857: not alnum or _: (for '118d-1.0d12_tmpA16PcC') The name _tmp was not supposed to be exported. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/xlint/lint1/emit.c \ src/tests/usr.bin/xlint/lint1/emit.exp-ln 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 Nov 28 09:16:46 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint2: t_lint2.sh src/usr.bin/xlint/lint2: read.c Log Message: lint2: in case of parse errors, output the offending line This provides more of a clue than a simple '(not alnum or _: )', especially in the output of build.sh. While here, change the format of the error message to the standard '%s:%d'. Since these are internal errors, they are not supposed to occur often, so no need to change error(1). To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/xlint/lint2/t_lint2.sh cvs rdiff -u -r1.70 -r1.71 src/usr.bin/xlint/lint2/read.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/lint2/t_lint2.sh diff -u src/tests/usr.bin/xlint/lint2/t_lint2.sh:1.9 src/tests/usr.bin/xlint/lint2/t_lint2.sh:1.10 --- src/tests/usr.bin/xlint/lint2/t_lint2.sh:1.9 Sun Nov 28 09:10:36 2021 +++ src/tests/usr.bin/xlint/lint2/t_lint2.sh Sun Nov 28 09:16:46 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_lint2.sh,v 1.9 2021/11/28 09:10:36 rillig Exp $ +# $NetBSD: t_lint2.sh,v 1.10 2021/11/28 09:16:46 rillig Exp $ # # Copyright (c) 2021 The NetBSD Foundation, Inc. # All rights reserved. @@ -76,6 +76,7 @@ emit_lp64_body() std_emit_body 'emit_lp64' } +# usage: test_error input message-regex [input-regex] test_error() { printf '%s\n' \ @@ -86,7 +87,8 @@ test_error() "$1" \ > 'input.ln' - atf_check -s 'exit:1' -e "match:input file error: input\\.ln,3 \($2\)\$" \ + atf_check -s 'exit:1' \ + -e "match:error: input\\.ln:3: $2 \\(for '${3-$1}'\\)\$" \ "$lint2" 'input.ln' } @@ -141,9 +143,9 @@ error_cases_body() test_error '0c0.0s2"' 'trailing data: ' test_error '0c0.0s2"%' 'missing closing quote' # shellcheck disable=SC1003 - test_error '0c0.0s2"\' 'missing after \\' + test_error '0c0.0s2"\' 'missing after \\' '0c0\.0s2"\\' # shellcheck disable=SC1003 - test_error '0c0.0s2"%\' 'missing after \\' + test_error '0c0.0s2"%\' 'missing after \\' '0c0\.0s2"%\\' # declarations and definitions test_error '0d0' 'bad line number' @@ -168,6 +170,7 @@ error_cases_body() test_error '0u0.0' 'bad delim ' test_error '0u0.0_' 'bad delim _' test_error '0u0.0x' 'not a number: ' + # trailing garbage is not detected test_error_ignored '0u0.0x3var_' } Index: src/usr.bin/xlint/lint2/read.c diff -u src/usr.bin/xlint/lint2/read.c:1.70 src/usr.bin/xlint/lint2/read.c:1.71 --- src/usr.bin/xlint/lint2/read.c:1.70 Sun Nov 28 08:21:49 2021 +++ src/usr.bin/xlint/lint2/read.c Sun Nov 28 09:16:46 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: read.c,v 1.70 2021/11/28 08:21:49 rillig Exp $ */ +/* $NetBSD: read.c,v 1.71 2021/11/28 09:16:46 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: read.c,v 1.70 2021/11/28 08:21:49 rillig Exp $"); +__RCSID("$NetBSD: read.c,v 1.71 2021/11/28 09:16:46 rillig Exp $"); #endif #include @@ -90,6 +90,7 @@ static hte_t **renametab; /* index of current C source file (as specified at the command line) */ static int csrcfile; +static const char *readfile_line; static void inperr(const char *, ...) __attribute__((format(printf, 1, 2), noreturn)); @@ -228,11 +229,13 @@ readfile(const char *name) err(1, "cannot open %s", name); while ((line = fgetln(inp, &len)) != NULL) { + readfile_line = line; if (len == 0 || line[len - 1] != '\n') inperr("%s", &line[len - 1]); line[len - 1] = '\0'; read_ln_line(line, len); + readfile_line = NULL; } _destroyhash(renametab); @@ -254,8 +257,8 @@ inperr(const char *fmt, ...) (void)vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); - errx(1, "input file error: %s,%zu (%s)", - fnames[srcfile], flines[srcfile], buf); + errx(1, "error: %s:%zu: %s (for '%s')", + fnames[srcfile], flines[srcfile], buf, readfile_line); } /*
CVS commit: src
Module Name:src Committed By: rillig Date: Sun Nov 28 09:16:46 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint2: t_lint2.sh src/usr.bin/xlint/lint2: read.c Log Message: lint2: in case of parse errors, output the offending line This provides more of a clue than a simple '(not alnum or _: )', especially in the output of build.sh. While here, change the format of the error message to the standard '%s:%d'. Since these are internal errors, they are not supposed to occur often, so no need to change error(1). To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/xlint/lint2/t_lint2.sh cvs rdiff -u -r1.70 -r1.71 src/usr.bin/xlint/lint2/read.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/doc
Module Name:src Committed By: wiz Date: Sun Nov 28 09:14:21 UTC 2021 Modified Files: src/doc: 3RDPARTY Log Message: sqlite3-3.37.0 out To generate a diff of this commit: cvs rdiff -u -r1.1826 -r1.1827 src/doc/3RDPARTY Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/doc/3RDPARTY diff -u src/doc/3RDPARTY:1.1826 src/doc/3RDPARTY:1.1827 --- src/doc/3RDPARTY:1.1826 Sun Nov 7 17:16:19 2021 +++ src/doc/3RDPARTY Sun Nov 28 09:14:21 2021 @@ -1,4 +1,4 @@ -# $NetBSD: 3RDPARTY,v 1.1826 2021/11/07 17:16:19 jmcneill Exp $ +# $NetBSD: 3RDPARTY,v 1.1827 2021/11/28 09:14:21 wiz Exp $ # # This file contains a list of the software that has been integrated into # NetBSD where we are not the primary maintainer. @@ -1321,7 +1321,7 @@ original. Package: sqlite Version: 3.26.0 -Current Vers: 3.34.1 (2021-01-20) +Current Vers: 3.37.0 (2021-11-28) Maintainer: Richard Hipp Home Page: http://www.sqlite.org Date: 2021-03-01
CVS commit: src/doc
Module Name:src Committed By: wiz Date: Sun Nov 28 09:14:21 UTC 2021 Modified Files: src/doc: 3RDPARTY Log Message: sqlite3-3.37.0 out To generate a diff of this commit: cvs rdiff -u -r1.1826 -r1.1827 src/doc/3RDPARTY 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/lint2
Module Name:src Committed By: rillig Date: Sun Nov 28 09:10:36 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint2: t_lint2.sh Log Message: tests/lint2: fix regular expressions containing backslash In regular expressions, a backslash must be doubled. In this case, ATF didn't complain because the single backslashes were used in the pattern '\($2\)', where they produced '\(...\\)'. Omitting the backslash for the closing parenthesis was apparently OK; other regex implementations complain about this. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/xlint/lint2/t_lint2.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/xlint/lint2/t_lint2.sh diff -u src/tests/usr.bin/xlint/lint2/t_lint2.sh:1.8 src/tests/usr.bin/xlint/lint2/t_lint2.sh:1.9 --- src/tests/usr.bin/xlint/lint2/t_lint2.sh:1.8 Sun Sep 5 18:17:15 2021 +++ src/tests/usr.bin/xlint/lint2/t_lint2.sh Sun Nov 28 09:10:36 2021 @@ -1,4 +1,4 @@ -# $NetBSD: t_lint2.sh,v 1.8 2021/09/05 18:17:15 rillig Exp $ +# $NetBSD: t_lint2.sh,v 1.9 2021/11/28 09:10:36 rillig Exp $ # # Copyright (c) 2021 The NetBSD Foundation, Inc. # All rights reserved. @@ -141,9 +141,9 @@ error_cases_body() test_error '0c0.0s2"' 'trailing data: ' test_error '0c0.0s2"%' 'missing closing quote' # shellcheck disable=SC1003 - test_error '0c0.0s2"\' 'missing after \' + test_error '0c0.0s2"\' 'missing after \\' # shellcheck disable=SC1003 - test_error '0c0.0s2"%\' 'missing after \' + test_error '0c0.0s2"%\' 'missing after \\' # declarations and definitions test_error '0d0' 'bad line number'
CVS commit: src/tests/usr.bin/xlint/lint2
Module Name:src Committed By: rillig Date: Sun Nov 28 09:10:36 UTC 2021 Modified Files: src/tests/usr.bin/xlint/lint2: t_lint2.sh Log Message: tests/lint2: fix regular expressions containing backslash In regular expressions, a backslash must be doubled. In this case, ATF didn't complain because the single backslashes were used in the pattern '\($2\)', where they produced '\(...\\)'. Omitting the backslash for the closing parenthesis was apparently OK; other regex implementations complain about this. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/xlint/lint2/t_lint2.sh 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/lint2
Module Name:src Committed By: rillig Date: Sun Nov 28 08:21:50 UTC 2021 Modified Files: src/usr.bin/xlint/lint2: read.c Log Message: lint: move fgetln peculiarities out of read_ln_line This allows the function parameter to be a pointer to const. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 src/usr.bin/xlint/lint2/read.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/lint2/read.c diff -u src/usr.bin/xlint/lint2/read.c:1.69 src/usr.bin/xlint/lint2/read.c:1.70 --- src/usr.bin/xlint/lint2/read.c:1.69 Tue Nov 16 22:12:44 2021 +++ src/usr.bin/xlint/lint2/read.c Sun Nov 28 08:21:49 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: read.c,v 1.69 2021/11/16 22:12:44 rillig Exp $ */ +/* $NetBSD: read.c,v 1.70 2021/11/28 08:21:49 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: read.c,v 1.69 2021/11/16 22:12:44 rillig Exp $"); +__RCSID("$NetBSD: read.c,v 1.70 2021/11/28 08:21:49 rillig Exp $"); #endif #include @@ -139,7 +139,7 @@ parse_short(const char **p) } static void -read_ln_line(char *line, size_t len) +read_ln_line(const char *line, size_t len) { const char *cp; int cline, isrc, iline; @@ -148,9 +148,6 @@ read_ln_line(char *line, size_t len) flines[srcfile]++; - if (len == 0 || line[len - 1] != '\n') - inperr("%s", &line[len - 1]); - line[len - 1] = '\0'; cp = line; /* line number in csrcfile */ @@ -230,8 +227,13 @@ readfile(const char *name) if ((inp = fopen(name, "r")) == NULL) err(1, "cannot open %s", name); - while ((line = fgetln(inp, &len)) != NULL) + while ((line = fgetln(inp, &len)) != NULL) { + if (len == 0 || line[len - 1] != '\n') + inperr("%s", &line[len - 1]); + line[len - 1] = '\0'; + read_ln_line(line, len); + } _destroyhash(renametab);
CVS commit: src/usr.bin/xlint/lint2
Module Name:src Committed By: rillig Date: Sun Nov 28 08:21:50 UTC 2021 Modified Files: src/usr.bin/xlint/lint2: read.c Log Message: lint: move fgetln peculiarities out of read_ln_line This allows the function parameter to be a pointer to const. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 src/usr.bin/xlint/lint2/read.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.