CVS commit: src/lib/libform

2021-10-24 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Mon Oct 25 06:25:19 UTC 2021

Modified Files:
src/lib/libform: internals.c

Log Message:
Fix for PR lib/47398

Move cursor to end of the currently active field and sync the cursor
location so the cursor get positioned correctly when the form window
is refreshed.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/lib/libform/internals.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libform/internals.c
diff -u src/lib/libform/internals.c:1.41 src/lib/libform/internals.c:1.42
--- src/lib/libform/internals.c:1.41	Tue Oct 19 21:22:20 2021
+++ src/lib/libform/internals.c	Mon Oct 25 06:25:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: internals.c,v 1.41 2021/10/19 21:22:20 blymn Exp $	*/
+/*	$NetBSD: internals.c,v 1.42 2021/10/25 06:25:18 blymn Exp $	*/
 
 /*-
  * Copyright (c) 1998-1999 Brett Lymn
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: internals.c,v 1.41 2021/10/19 21:22:20 blymn Exp $");
+__RCSID("$NetBSD: internals.c,v 1.42 2021/10/25 06:25:18 blymn Exp $");
 
 #include 
 #include 
@@ -1688,6 +1688,12 @@ _formi_redraw_field(FORM *form, int fiel
 	}
 
 	wattrset(form->scrwin, cur->back);
+
+	cur = form->fields[form->cur_field];
+	wmove(form->scrwin, cur->form_row + cur->cursor_ypos,
+	cur->form_col + cur->cursor_xpos);
+	wcursyncup(form->scrwin);
+
 	return;
 }
 



CVS commit: src/lib/libform

2021-10-24 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Mon Oct 25 06:25:19 UTC 2021

Modified Files:
src/lib/libform: internals.c

Log Message:
Fix for PR lib/47398

Move cursor to end of the currently active field and sync the cursor
location so the cursor get positioned correctly when the form window
is refreshed.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/lib/libform/internals.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/net

2021-10-24 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Oct 25 02:10:56 UTC 2021

Modified Files:
src/sys/net: if_spppsubr.c

Log Message:
kpreempt_disable() before sppp_get_{ip,ip6}_addrs() are unnecessary now.


To generate a diff of this commit:
cvs rdiff -u -r1.260 -r1.261 src/sys/net/if_spppsubr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/if_spppsubr.c
diff -u src/sys/net/if_spppsubr.c:1.260 src/sys/net/if_spppsubr.c:1.261
--- src/sys/net/if_spppsubr.c:1.260	Mon Oct 25 02:06:29 2021
+++ src/sys/net/if_spppsubr.c	Mon Oct 25 02:10:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_spppsubr.c,v 1.260 2021/10/25 02:06:29 knakahara Exp $	 */
+/*	$NetBSD: if_spppsubr.c,v 1.261 2021/10/25 02:10:56 knakahara Exp $	 */
 
 /*
  * Synchronous PPP/Cisco link level subroutines.
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.260 2021/10/25 02:06:29 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.261 2021/10/25 02:10:56 knakahara Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -3413,9 +3413,7 @@ sppp_ipcp_open(struct sppp *sp, void *xc
 	memset(&sp->dns_addrs, 0, sizeof sp->dns_addrs);
 
 #ifdef INET
-	kpreempt_disable();
 	sppp_get_ip_addrs(sp, &myaddr, &hisaddr, 0);
-	kpreempt_enable();
 #else
 	myaddr = hisaddr = 0;
 #endif
@@ -3967,9 +3965,7 @@ sppp_ipcp_scr(struct sppp *sp)
 		if (sp->ipcp.flags & IPCP_MYADDR_SEEN) {
 			ouraddr = sp->ipcp.req_myaddr;	/* not sure if this can ever happen */
 		} else {
-			kpreempt_disable();
 			sppp_get_ip_addrs(sp, &ouraddr, 0, 0);
-			kpreempt_enable();
 		}
 		opt[i++] = IPCP_OPT_ADDRESS;
 		opt[i++] = 6;
@@ -4039,9 +4035,7 @@ sppp_ipv6cp_open(struct sppp *sp, void *
 	sp->ipv6cp.flags &= ~IPV6CP_MYIFID_SEEN;
 #endif
 
-	kpreempt_disable();
 	sppp_get_ip6_addrs(sp, &myaddr, &hisaddr, 0);
-	kpreempt_enable();
 	/*
 	 * If we don't have our address, this probably means our
 	 * interface doesn't want to talk IPv6 at all.  (This could
@@ -4508,9 +4502,7 @@ sppp_ipv6cp_scr(struct sppp *sp)
 	KASSERT(SPPP_WLOCKED(sp));
 
 	if (ISSET(sp->ipv6cp.opts, SPPP_IPV6CP_OPT_IFID)) {
-		kpreempt_disable();
 		sppp_get_ip6_addrs(sp, &ouraddr, 0, 0);
-		kpreempt_enable();
 
 		opt[i++] = IPV6CP_OPT_IFID;
 		opt[i++] = 10;
@@ -6268,9 +6260,7 @@ sppp_params(struct sppp *sp, u_long cmd,
 		status->state = sp->scp[IDX_IPCP].state;
 		status->opts = sp->ipcp.opts;
 #ifdef INET
-		kpreempt_disable();
 		sppp_get_ip_addrs(sp, &myaddr, 0, 0);
-		kpreempt_enable();
 #else
 		myaddr = 0;
 #endif



CVS commit: src/sys/net

2021-10-24 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Oct 25 02:10:56 UTC 2021

Modified Files:
src/sys/net: if_spppsubr.c

Log Message:
kpreempt_disable() before sppp_get_{ip,ip6}_addrs() are unnecessary now.


To generate a diff of this commit:
cvs rdiff -u -r1.260 -r1.261 src/sys/net/if_spppsubr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/net

2021-10-24 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Oct 25 02:06:29 UTC 2021

Modified Files:
src/sys/net: if_spppsubr.c

Log Message:
Fix missing curlwp_bind() for ifa_release(), ok'ed by yamaguchi@n.o.

This causes the following KASSERT failure in pppoe server.
- sppp_rcr_event()
  - sppp_ipcp_confreq()
- sppp_get_ip_addrs()
  - psref_release()

After if_spppsubr.c:1.227, sppp_ipcp_confreq() is done in workqueue
instead of softint.


To generate a diff of this commit:
cvs rdiff -u -r1.259 -r1.260 src/sys/net/if_spppsubr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/if_spppsubr.c
diff -u src/sys/net/if_spppsubr.c:1.259 src/sys/net/if_spppsubr.c:1.260
--- src/sys/net/if_spppsubr.c:1.259	Mon Oct 11 05:13:11 2021
+++ src/sys/net/if_spppsubr.c	Mon Oct 25 02:06:29 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_spppsubr.c,v 1.259 2021/10/11 05:13:11 knakahara Exp $	 */
+/*	$NetBSD: if_spppsubr.c,v 1.260 2021/10/25 02:06:29 knakahara Exp $	 */
 
 /*
  * Synchronous PPP/Cisco link level subroutines.
@@ -41,7 +41,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.259 2021/10/11 05:13:11 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_spppsubr.c,v 1.260 2021/10/25 02:06:29 knakahara Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -5591,7 +5591,7 @@ sppp_get_ip_addrs(struct sppp *sp, uint3
 	struct ifaddr *ifa;
 	struct sockaddr_in *si, *sm;
 	uint32_t ssrc, ddst;
-	int s;
+	int bound, s;
 	struct psref psref;
 
 	sm = NULL;
@@ -5601,6 +5601,7 @@ sppp_get_ip_addrs(struct sppp *sp, uint3
 	 * aliases don't make any sense on a p2p link anyway.
 	 */
 	si = 0;
+	bound = curlwp_bind();
 	s = pserialize_read_enter();
 	IFADDR_READER_FOREACH(ifa, ifp) {
 		if (ifa->ifa_addr->sa_family == AF_INET) {
@@ -5625,6 +5626,7 @@ sppp_get_ip_addrs(struct sppp *sp, uint3
 			ddst = si->sin_addr.s_addr;
 		ifa_release(ifa, &psref);
 	}
+	curlwp_bindx(bound);
 
 	if (dst) *dst = ntohl(ddst);
 	if (src) *src = ntohl(ssrc);
@@ -5783,7 +5785,7 @@ sppp_get_ip6_addrs(struct sppp *sp, stru
 	struct ifaddr *ifa;
 	struct sockaddr_in6 *si, *sm;
 	struct in6_addr ssrc, ddst;
-	int s;
+	int bound, s;
 	struct psref psref;
 
 	sm = NULL;
@@ -5794,6 +5796,7 @@ sppp_get_ip6_addrs(struct sppp *sp, stru
 	 * aliases don't make any sense on a p2p link anyway.
 	 */
 	si = 0;
+	bound = curlwp_bind();
 	s = pserialize_read_enter();
 	IFADDR_READER_FOREACH(ifa, ifp) {
 		if (ifa->ifa_addr->sa_family == AF_INET6) {
@@ -5821,6 +5824,7 @@ sppp_get_ip6_addrs(struct sppp *sp, stru
 			memcpy(&ddst, &si->sin6_addr, sizeof(ddst));
 		ifa_release(ifa, &psref);
 	}
+	curlwp_bindx(bound);
 
 	if (dst)
 		memcpy(dst, &ddst, sizeof(*dst));



CVS commit: src/sys/net

2021-10-24 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Mon Oct 25 02:06:29 UTC 2021

Modified Files:
src/sys/net: if_spppsubr.c

Log Message:
Fix missing curlwp_bind() for ifa_release(), ok'ed by yamaguchi@n.o.

This causes the following KASSERT failure in pppoe server.
- sppp_rcr_event()
  - sppp_ipcp_confreq()
- sppp_get_ip_addrs()
  - psref_release()

After if_spppsubr.c:1.227, sppp_ipcp_confreq() is done in workqueue
instead of softint.


To generate a diff of this commit:
cvs rdiff -u -r1.259 -r1.260 src/sys/net/if_spppsubr.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

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Oct 25 01:06:13 UTC 2021

Modified Files:
src/usr.bin/indent: indent.c

Log Message:
indent: rename local variable sp_sw to spaced_expr

The 'sp' probably meant 'space-enclosed'; no idea what 'sw' was meant to
mean. Maybe 'switch', but that would have been rather ambiguous when
talking about control flow statements.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.156 -r1.157 src/usr.bin/indent/indent.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.156 src/usr.bin/indent/indent.c:1.157
--- src/usr.bin/indent/indent.c:1.156	Mon Oct 25 00:54:37 2021
+++ src/usr.bin/indent/indent.c	Mon Oct 25 01:06:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.156 2021/10/25 00:54:37 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.157 2021/10/25 01:06:13 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.156 2021/10/25 00:54:37 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.157 2021/10/25 01:06:13 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -713,7 +713,7 @@ want_blank_before_lparen(void)
 }
 
 static void
-process_lparen_or_lbracket(int decl_ind, bool tabs_to_var, bool sp_sw)
+process_lparen_or_lbracket(int decl_ind, bool tabs_to_var, bool spaced_expr)
 {
 if (++ps.p_l_follow == array_length(ps.paren_indents)) {
 	diag(0, "Reached internal limit of %zu unclosed parens",
@@ -737,7 +737,7 @@ process_lparen_or_lbracket(int decl_ind,
 debug_println("paren_indents[%d] is now %d",
 	ps.p_l_follow - 1, ps.paren_indents[ps.p_l_follow - 1]);
 
-if (sp_sw && ps.p_l_follow == 1 && opt.extra_expr_indent
+if (spaced_expr && ps.p_l_follow == 1 && opt.extra_expr_indent
 	&& ps.paren_indents[0] < 2 * opt.indent_size) {
 	ps.paren_indents[0] = (short)(2 * opt.indent_size);
 	debug_println("paren_indents[0] is now %d", ps.paren_indents[0]);
@@ -758,7 +758,7 @@ process_lparen_or_lbracket(int decl_ind,
 }
 
 static void
-process_rparen_or_rbracket(bool *sp_sw, bool *force_nl, stmt_head hd)
+process_rparen_or_rbracket(bool *spaced_expr, bool *force_nl, stmt_head hd)
 {
 if ((ps.cast_mask & (1 << ps.p_l_follow) & ~ps.not_cast_mask) != 0) {
 	ps.next_unary = true;
@@ -778,9 +778,9 @@ process_rparen_or_rbracket(bool *sp_sw, 
 
 *code.e++ = token.s[0];
 
-if (*sp_sw && ps.p_l_follow == 0) {	/* check for end of if (...), or some
-	 * such */
-	*sp_sw = false;
+if (*spaced_expr && ps.p_l_follow == 0) {	/* check for end of 'if
+		 * (...)', or some such */
+	*spaced_expr = false;
 	*force_nl = true;	/* must force newline after if */
 	ps.next_unary = true;
 	ps.in_stmt = false;	/* don't use stmt continuation indentation */
@@ -869,7 +869,7 @@ process_colon(int *quest_level, bool *fo
 
 static void
 process_semicolon(bool *seen_case, int *quest_level, int decl_ind,
-bool tabs_to_var, bool *sp_sw, stmt_head hd, bool *force_nl)
+bool tabs_to_var, bool *spaced_expr, stmt_head hd, bool *force_nl)
 {
 if (ps.decl_nest == 0)
 	ps.init_or_struct = false;
@@ -894,7 +894,7 @@ process_semicolon(bool *seen_case, int *
 	 * structure declaration, we aren't
 	 * anymore */
 
-if ((!*sp_sw || hd != hd_for) && ps.p_l_follow > 0) {
+if ((!*spaced_expr || hd != hd_for) && ps.p_l_follow > 0) {
 
 	/*
 	 * There were unbalanced parens in the statement. It is a bit
@@ -902,25 +902,25 @@ process_semicolon(bool *seen_case, int *
 	 */
 	diag(1, "Unbalanced parens");
 	ps.p_l_follow = 0;
-	if (*sp_sw) {		/* this is a check for an if, while, etc. with
- * unbalanced parens */
-	*sp_sw = false;
+	if (*spaced_expr) {	/* 'if', 'while', etc. with unbalanced
+ * parentheses */
+	*spaced_expr = false;
 	parse_hd(hd);	/* don't lose the 'if', or whatever */
 	}
 }
 *code.e++ = ';';
 ps.want_blank = true;
-ps.in_stmt = (ps.p_l_follow > 0);	/* we are no longer in the middle of a
+ps.in_stmt = ps.p_l_follow > 0;	/* we are no longer in the middle of a
 	 * stmt */
 
-if (!*sp_sw) {		/* if not if for (;;) */
+if (!*spaced_expr) {	/* if not if for (;;) */
 	parse(psym_semicolon);	/* let parser know about end of stmt */
 	*force_nl = true;	/* force newline after an end of stmt */
 }
 }
 
 static void
-process_lbrace(bool *force_nl, bool *sp_sw, stmt_head hd,
+process_lbrace(bool *force_nl, bool *spaced_expr, stmt_head hd,
 int *di_stack, int di_stack_cap, int *decl_ind)
 {
 ps.in_stmt = false;		/* don't indent the {} */
@@ -954,8 +954,8 @@ process_lbrace(bool *force_nl, bool *sp_
 if (ps.p_l_follow > 0) {	/* check for preceding unbalanced parens */
 	diag(1, "Unbal

CVS commit: src/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Oct 25 01:06:13 UTC 2021

Modified Files:
src/usr.bin/indent: indent.c

Log Message:
indent: rename local variable sp_sw to spaced_expr

The 'sp' probably meant 'space-enclosed'; no idea what 'sw' was meant to
mean. Maybe 'switch', but that would have been rather ambiguous when
talking about control flow statements.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.156 -r1.157 src/usr.bin/indent/indent.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Oct 25 00:54:37 UTC 2021

Modified Files:
src/usr.bin/indent: indent.c indent.h lexi.c parse.c pr_comment.c

Log Message:
indent: split type token_type into 3 separate types

Previously, token_type was used for 3 different purposes:

1. symbol types from the lexer
2. symbol types on the parser stack
3. kind of control statement for 'if (expr)' and similar statements

Splitting the 41 constants into separate types makes it immediately
clear that the parser stack never handles comments, preprocessing lines,
newlines, form feeds, the inner structure of expressions.

Previously, the constant switch_expr was especially confusing since it
was used for 3 different purposes: when returned from lexi, it
represented the keyword 'switch', in the parser stack it represented
'switch (expr)', and it was used for a statement head as well.

The only overlap between the lexer symbols and the parser symbols are
'{' and '}', and the keywords 'do' and 'else'. To increase confusion,
the constants of the previous token_type were in apparently random
order and before 2021, they had cryptic, highly abbreviated names.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.155 -r1.156 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.48 -r1.49 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.99 -r1.100 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.38 -r1.39 src/usr.bin/indent/parse.c
cvs rdiff -u -r1.83 -r1.84 src/usr.bin/indent/pr_comment.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.155 src/usr.bin/indent/indent.c:1.156
--- src/usr.bin/indent/indent.c:1.155	Sun Oct 24 22:44:13 2021
+++ src/usr.bin/indent/indent.c	Mon Oct 25 00:54:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.155 2021/10/24 22:44:13 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.156 2021/10/25 00:54:37 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.155 2021/10/24 22:44:13 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.156 2021/10/25 00:54:37 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -239,16 +239,16 @@ search_brace_lbrace(void)
 }
 
 static bool
-search_brace_other(token_type ttype, bool *force_nl,
+search_brace_other(lexer_symbol lsym, bool *force_nl,
 bool comment_buffered, bool last_else)
 {
 bool remove_newlines;
 
 remove_newlines =
 	/* "} else" */
-	(ttype == tt_lex_else && code.e != code.s && code.e[-1] == '}')
+	(lsym == lsym_else && code.e != code.s && code.e[-1] == '}')
 	/* "else if" */
-	|| (ttype == tt_lex_if && last_else && opt.else_if);
+	|| (lsym == lsym_if && last_else && opt.else_if);
 if (remove_newlines)
 	*force_nl = false;
 
@@ -301,9 +301,9 @@ switch_buffer(void)
 }
 
 static void
-search_brace_lookahead(token_type *ttype)
+search_brace_lookahead(lexer_symbol *lsym)
 {
-if (*ttype == end_of_file)
+if (*lsym == lsym_eof)
 	return;
 
 /*
@@ -335,39 +335,39 @@ search_brace_lookahead(token_type *ttype
 
 struct parser_state transient_state;
 transient_state = ps;
-*ttype = lexi(&transient_state);	/* read another token */
-if (*ttype != newline && *ttype != tt_lex_form_feed &&
-	*ttype != comment && !transient_state.search_brace) {
+*lsym = lexi(&transient_state);	/* read another token */
+if (*lsym != lsym_newline && *lsym != lsym_form_feed &&
+	*lsym != lsym_comment && !transient_state.search_brace) {
 	ps = transient_state;
 }
 }
 
 static void
-search_brace(token_type *ttype, bool *force_nl,
+search_brace(lexer_symbol *lsym, bool *force_nl,
 bool *comment_buffered, bool *last_else)
 {
 while (ps.search_brace) {
-	switch (*ttype) {
-	case newline:
+	switch (*lsym) {
+	case lsym_newline:
 	search_brace_newline(force_nl);
 	break;
-	case tt_lex_form_feed:
+	case lsym_form_feed:
 	break;
-	case comment:
+	case lsym_comment:
 	search_brace_comment(comment_buffered);
 	break;
-	case lbrace:
+	case lsym_lbrace:
 	if (search_brace_lbrace())
 		goto switch_buffer;
 	/* FALLTHROUGH */
 	default:		/* it is the start of a normal statement */
-	if (!search_brace_other(*ttype, force_nl,
+	if (!search_brace_other(*lsym, force_nl,
 		*comment_buffered, *last_else))
 		return;
 switch_buffer:
 	switch_buffer();
 	}
-	search_brace_lookahead(ttype);
+	search_brace_lookahead(lsym);
 }
 
 *last_else = false;
@@ -443,9 +443,9 @@ main_init_globals(void)
 {
 found_err = false;
 
-ps.s_ttype[0] = stmt;
+ps.s_sym[0] = psym_stmt;
 ps.last_nl = true;
-ps.last_token = semicolon;
+ps.last_token = lsym_semicolon;
 buf_init

CVS commit: src/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Mon Oct 25 00:54:37 UTC 2021

Modified Files:
src/usr.bin/indent: indent.c indent.h lexi.c parse.c pr_comment.c

Log Message:
indent: split type token_type into 3 separate types

Previously, token_type was used for 3 different purposes:

1. symbol types from the lexer
2. symbol types on the parser stack
3. kind of control statement for 'if (expr)' and similar statements

Splitting the 41 constants into separate types makes it immediately
clear that the parser stack never handles comments, preprocessing lines,
newlines, form feeds, the inner structure of expressions.

Previously, the constant switch_expr was especially confusing since it
was used for 3 different purposes: when returned from lexi, it
represented the keyword 'switch', in the parser stack it represented
'switch (expr)', and it was used for a statement head as well.

The only overlap between the lexer symbols and the parser symbols are
'{' and '}', and the keywords 'do' and 'else'. To increase confusion,
the constants of the previous token_type were in apparently random
order and before 2021, they had cryptic, highly abbreviated names.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.155 -r1.156 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.48 -r1.49 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.99 -r1.100 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.38 -r1.39 src/usr.bin/indent/parse.c
cvs rdiff -u -r1.83 -r1.84 src/usr.bin/indent/pr_comment.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 22:44:13 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_lparen.c
src/usr.bin/indent: indent.c indent.h lexi.c

Log Message:
indent: rename form_feed to tt_lex_form_feed

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/token_lparen.c
cvs rdiff -u -r1.154 -r1.155 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.47 -r1.48 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.98 -r1.99 src/usr.bin/indent/lexi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/indent/token_lparen.c
diff -u src/tests/usr.bin/indent/token_lparen.c:1.5 src/tests/usr.bin/indent/token_lparen.c:1.6
--- src/tests/usr.bin/indent/token_lparen.c:1.5	Sun Oct 24 22:28:06 2021
+++ src/tests/usr.bin/indent/token_lparen.c	Sun Oct 24 22:44:13 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token_lparen.c,v 1.5 2021/10/24 22:28:06 rillig Exp $ */
+/* $NetBSD: token_lparen.c,v 1.6 2021/10/24 22:44:13 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -130,8 +130,8 @@ void cover_want_blank_before_lparen(void
 	switch (expr) {}
 #define preprocessing
 	(preprocessing)();
-	/* $ XXX: form_feed should be skipped, just as newline. */
-	(form_feed)();		/* XXX: should be skipped */
+	/* $ XXX: tt_lex_form_feed should be skipped, just as newline. */
+	(tt_lex_form_feed)();	/* XXX: should be skipped */
 	for(;;);
 	do(tt_lex_do)=3;while(0);
 	// $ TODO: is if_expr possible?
@@ -197,7 +197,8 @@ cover_want_blank_before_lparen(void)
 #define preprocessing
 	(preprocessing)();
 
-	(form_feed)();		/* XXX: should be skipped */
+/* $ XXX: Where has the '\f' gone? It should have been preserved. */
+	(tt_lex_form_feed)();	/* XXX: should be skipped */
 	for (;;);
 	do
 		(tt_lex_do) = 3;

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.154 src/usr.bin/indent/indent.c:1.155
--- src/usr.bin/indent/indent.c:1.154	Sun Oct 24 22:38:20 2021
+++ src/usr.bin/indent/indent.c	Sun Oct 24 22:44:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.154 2021/10/24 22:38:20 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.155 2021/10/24 22:44:13 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.154 2021/10/24 22:38:20 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.155 2021/10/24 22:44:13 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -336,7 +336,7 @@ search_brace_lookahead(token_type *ttype
 struct parser_state transient_state;
 transient_state = ps;
 *ttype = lexi(&transient_state);	/* read another token */
-if (*ttype != newline && *ttype != form_feed &&
+if (*ttype != newline && *ttype != tt_lex_form_feed &&
 	*ttype != comment && !transient_state.search_brace) {
 	ps = transient_state;
 }
@@ -351,7 +351,7 @@ search_brace(token_type *ttype, bool *fo
 	case newline:
 	search_brace_newline(force_nl);
 	break;
-	case form_feed:
+	case tt_lex_form_feed:
 	break;
 	case comment:
 	search_brace_comment(comment_buffered);
@@ -1367,7 +1367,8 @@ main_loop(void)
 	/* NOTREACHED */
 	}
 
-	if (ttype == newline || ttype == form_feed || ttype == preprocessing)
+	if (ttype == newline || ttype == tt_lex_form_feed ||
+		ttype == preprocessing)
 	force_nl = false;
 	else if (ttype != comment)
 	process_comment_in_code(ttype, &force_nl);
@@ -1376,7 +1377,7 @@ main_loop(void)
 
 	switch (ttype) {
 
-	case form_feed:
+	case tt_lex_form_feed:
 	process_form_feed();
 	break;
 

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.47 src/usr.bin/indent/indent.h:1.48
--- src/usr.bin/indent/indent.h:1.47	Sun Oct 24 22:38:20 2021
+++ src/usr.bin/indent/indent.h	Sun Oct 24 22:44:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.47 2021/10/24 22:38:20 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.48 2021/10/24 22:44:13 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -89,7 +89,7 @@ typedef enum token_type {
 comment,
 switch_expr,		/* 'switch' '('  ')' */
 preprocessing,		/* '#' */
-form_feed,
+tt_lex_form_feed,
 decl,
 tt_lex_for,
 tt_lex_if,

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.98 src/usr.bin/indent/lexi.c:1.99
--- src/usr.bin/indent/lexi.c:1.98	Sun Oct 24 22:38:20 2021
+++ src/usr.bin/indent/lexi.c	Sun Oct 24 22:44:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.98 2021/10/24 22:38:20 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.99 2021/10/24 22:44:13 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)lexi.c	8.1 (
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.98 2021/10/24 22:38:20

CVS commit: src

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 22:44:13 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_lparen.c
src/usr.bin/indent: indent.c indent.h lexi.c

Log Message:
indent: rename form_feed to tt_lex_form_feed

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/token_lparen.c
cvs rdiff -u -r1.154 -r1.155 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.47 -r1.48 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.98 -r1.99 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

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 22:38:20 UTC 2021

Modified Files:
src/usr.bin/indent: indent.c indent.h lexi.c

Log Message:
indent: split kw_for_or_if_or_while into separate constants

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.153 -r1.154 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.46 -r1.47 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.97 -r1.98 src/usr.bin/indent/lexi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.153 src/usr.bin/indent/indent.c:1.154
--- src/usr.bin/indent/indent.c:1.153	Sun Oct 24 22:28:06 2021
+++ src/usr.bin/indent/indent.c	Sun Oct 24 22:38:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.153 2021/10/24 22:28:06 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.154 2021/10/24 22:38:20 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.153 2021/10/24 22:28:06 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.154 2021/10/24 22:38:20 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -248,8 +248,7 @@ search_brace_other(token_type ttype, boo
 	/* "} else" */
 	(ttype == tt_lex_else && code.e != code.s && code.e[-1] == '}')
 	/* "else if" */
-	|| (ttype == keyword_for_if_while &&
-		*token.s == 'i' && last_else && opt.else_if);
+	|| (ttype == tt_lex_if && last_else && opt.else_if);
 if (remove_newlines)
 	*force_nl = false;
 
@@ -1437,13 +1436,21 @@ main_loop(void)
 	 * expression */
 	goto copy_token;
 
-	case keyword_for_if_while:
+	case tt_lex_for:
 	sp_sw = true;	/* the interesting stuff is done after the
- * expression is scanned */
-	hd_type = *token.s == 'i' ? if_expr :
-		*token.s == 'w' ? while_expr : for_exprs;
+ * expressions are scanned */
+	hd_type = for_exprs;	/* remember the type of header for
+	 * later use by parser */
+	goto copy_token;
 
-	/* remember the type of header for later use by parser */
+	case tt_lex_if:
+	sp_sw = true;
+	hd_type = if_expr;
+	goto copy_token;
+
+	case tt_lex_while:
+	sp_sw = true;
+	hd_type = while_expr;
 	goto copy_token;
 
 	case tt_lex_do:

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.46 src/usr.bin/indent/indent.h:1.47
--- src/usr.bin/indent/indent.h:1.46	Sun Oct 24 22:28:06 2021
+++ src/usr.bin/indent/indent.h	Sun Oct 24 22:38:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.46 2021/10/24 22:28:06 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.47 2021/10/24 22:38:20 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -91,7 +91,9 @@ typedef enum token_type {
 preprocessing,		/* '#' */
 form_feed,
 decl,
-keyword_for_if_while,	/* 'for', 'if' or 'while' */
+tt_lex_for,
+tt_lex_if,
+tt_lex_while,
 tt_lex_do,
 tt_lex_else,
 if_expr,			/* 'if' '('  ')' */
@@ -225,7 +227,9 @@ enum keyword_kind {
 kw_sizeof,
 kw_struct_or_union_or_enum,
 kw_type,
-kw_for_or_if_or_while,
+kw_for,
+kw_if,
+kw_while,
 kw_do,
 kw_else,
 kw_switch,

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.97 src/usr.bin/indent/lexi.c:1.98
--- src/usr.bin/indent/lexi.c:1.97	Sun Oct 24 22:28:06 2021
+++ src/usr.bin/indent/lexi.c	Sun Oct 24 22:38:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.97 2021/10/24 22:28:06 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.98 2021/10/24 22:38:20 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)lexi.c	8.1 (
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.97 2021/10/24 22:28:06 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.98 2021/10/24 22:38:20 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -80,9 +80,9 @@ static const struct keyword {
 {"enum", kw_struct_or_union_or_enum},
 {"extern", kw_storage_class},
 {"float", kw_type},
-{"for", kw_for_or_if_or_while},
+{"for", kw_for},
 {"goto", kw_jump},
-{"if", kw_for_or_if_or_while},
+{"if", kw_if},
 {"imaginary", kw_type},
 {"inline", kw_inline_or_restrict},
 {"int", kw_type},
@@ -102,7 +102,7 @@ static const struct keyword {
 {"unsigned", kw_type},
 {"void", kw_type},
 {"volatile", kw_type},
-{"while", kw_for_or_if_or_while}
+{"while", kw_while}
 };
 
 static struct {
@@ -227,7 +227,7 @@ token_type_name(token_type ttype)
 	"case_label", "colon",
 	"semicolon", "lbrace", "rbrace", "ident", "comma",
 	"comment", "switch_expr", "preprocessing", "form_feed", "decl",
-	"keyword_for

CVS commit: src/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 22:38:20 UTC 2021

Modified Files:
src/usr.bin/indent: indent.c indent.h lexi.c

Log Message:
indent: split kw_for_or_if_or_while into separate constants

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.153 -r1.154 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.46 -r1.47 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.97 -r1.98 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

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 22:28:06 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_lparen.c
src/usr.bin/indent: indent.c indent.h lexi.c parse.c

Log Message:
indent: split kw_do_or_else into separate constants

It was unnecessarily confusing to have the token types keyword_do_else,
keyword_do and keyword_else at the same time, without any hint in what
they differed.

Some of the token types seem to be used by the lexer while others are
used in the parse stack. Maybe all token types can be partitioned into
these groups, which would suggest to use two different types for them.
And if not, it's still clearer to have this distinction in the names of
the constants.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/token_lparen.c
cvs rdiff -u -r1.152 -r1.153 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.45 -r1.46 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.96 -r1.97 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/indent/parse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/indent/token_lparen.c
diff -u src/tests/usr.bin/indent/token_lparen.c:1.4 src/tests/usr.bin/indent/token_lparen.c:1.5
--- src/tests/usr.bin/indent/token_lparen.c:1.4	Sun Oct 24 17:19:49 2021
+++ src/tests/usr.bin/indent/token_lparen.c	Sun Oct 24 22:28:06 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token_lparen.c,v 1.4 2021/10/24 17:19:49 rillig Exp $ */
+/* $NetBSD: token_lparen.c,v 1.5 2021/10/24 22:28:06 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -133,7 +133,7 @@ void cover_want_blank_before_lparen(void
 	/* $ XXX: form_feed should be skipped, just as newline. */
 	(form_feed)();		/* XXX: should be skipped */
 	for(;;);
-	do(keyword_do_else)=3;while(0);
+	do(tt_lex_do)=3;while(0);
 	// $ TODO: is if_expr possible?
 	if(cond)(if_expr)();
 	// $ TODO: is while_expr possible?
@@ -144,10 +144,10 @@ void cover_want_blank_before_lparen(void
 	(stmt);
 	// $ TODO: is stmt_list possible?
 	(stmt_list);
-	// $ TODO: is keyword_else possible? keyword_do_else is.
-	if(cond);else(keyword_else)();
-	// $ TODO: is keyword_do possible? keyword_do_else is.
-	do(keyword_do);while(0);
+	// $ TODO: is tt_ps_else possible? tt_lex_else is.
+	if(cond);else(tt_ps_else)();
+	// $ TODO: is tt_ps_do possible? tt_lex_do is.
+	do(tt_ps_do);while(0);
 	// The following line would generate 'Statement nesting error'.
 	// do stmt;(do_stmt());while(0);
 	// $ TODO: is if_expr_stmt possible?
@@ -200,7 +200,7 @@ cover_want_blank_before_lparen(void)
 	(form_feed)();		/* XXX: should be skipped */
 	for (;;);
 	do
-		(keyword_do_else) = 3;
+		(tt_lex_do) = 3;
 	while (0);
 	if (cond)
 		(if_expr)();
@@ -212,9 +212,9 @@ cover_want_blank_before_lparen(void)
 	(stmt_list);
 	if (cond);
 	else
-		(keyword_else)();
+		(tt_ps_else)();
 	do
-		(keyword_do);
+		(tt_ps_do);
 	while (0);
 	// The following line would generate 'Statement nesting error'.
 	// do stmt;(do_stmt());while(0);

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.152 src/usr.bin/indent/indent.c:1.153
--- src/usr.bin/indent/indent.c:1.152	Sun Oct 24 20:57:11 2021
+++ src/usr.bin/indent/indent.c	Sun Oct 24 22:28:06 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.152 2021/10/24 20:57:11 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.153 2021/10/24 22:28:06 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.152 2021/10/24 20:57:11 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.153 2021/10/24 22:28:06 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -246,8 +246,7 @@ search_brace_other(token_type ttype, boo
 
 remove_newlines =
 	/* "} else" */
-	(ttype == keyword_do_else && *token.s == 'e' &&
-	 code.e != code.s && code.e[-1] == '}')
+	(ttype == tt_lex_else && code.e != code.s && code.e[-1] == '}')
 	/* "else if" */
 	|| (ttype == keyword_for_if_while &&
 		*token.s == 'i' && last_else && opt.else_if);
@@ -1055,7 +1054,7 @@ process_keyword_do(bool *force_nl, bool 
 
 *force_nl = true;		/* following stuff must go onto new line */
 *last_else = false;
-parse(keyword_do);
+parse(tt_ps_do);
 }
 
 static void
@@ -1072,7 +1071,7 @@ process_keyword_else(bool *force_nl, boo
 
 *force_nl = true;		/* following stuff must go onto new line */
 *last_else = true;
-parse(keyword_else);
+parse(tt_ps_else);
 }
 
 static void
@@ -1447,11 +1446,12 @@ main_loop(void)
 	/* remember the type of header for later use by parser */
 	goto copy_token;
 
-	case keyword_do_else:
-	if (*token.s == 'd')
-		process_keyword_do(&force_nl, &last_else);
-	else
-		process_keyword_else

CVS commit: src

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 22:28:06 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_lparen.c
src/usr.bin/indent: indent.c indent.h lexi.c parse.c

Log Message:
indent: split kw_do_or_else into separate constants

It was unnecessarily confusing to have the token types keyword_do_else,
keyword_do and keyword_else at the same time, without any hint in what
they differed.

Some of the token types seem to be used by the lexer while others are
used in the parse stack. Maybe all token types can be partitioned into
these groups, which would suggest to use two different types for them.
And if not, it's still clearer to have this distinction in the names of
the constants.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/token_lparen.c
cvs rdiff -u -r1.152 -r1.153 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.45 -r1.46 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.96 -r1.97 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/indent/parse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 21:55:07 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_comment.c

Log Message:
tests/indent: document how empty lines in box comments are handled


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/token_comment.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 21:55:07 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_comment.c

Log Message:
tests/indent: document how empty lines in box comments are handled


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/token_comment.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/indent/token_comment.c
diff -u src/tests/usr.bin/indent/token_comment.c:1.6 src/tests/usr.bin/indent/token_comment.c:1.7
--- src/tests/usr.bin/indent/token_comment.c:1.6	Sun Oct 24 21:48:16 2021
+++ src/tests/usr.bin/indent/token_comment.c	Sun Oct 24 21:55:07 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token_comment.c,v 1.6 2021/10/24 21:48:16 rillig Exp $ */
+/* $NetBSD: token_comment.c,v 1.7 2021/10/24 21:55:07 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -714,3 +714,18 @@ int		decl;
 #indent end
 
 #indent run-equals-input -nfc1
+
+/*
+ * A completely empty line in a box comment must be copied unmodified to the
+ * output. This is done in process_comment by adding a space to the end of an
+ * otherwise empty comment. This space forces dump_line to add some output,
+ * but the trailing space is discarded, resulting in an empty line.
+ */
+#indent input
+/*- comment
+
+
+end */
+#indent end
+
+#indent run-equals-input -nfc1



CVS commit: src/tests/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 21:48:16 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_comment.c

Log Message:
tests/indent: test form feed in comments


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/token_comment.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/indent/token_comment.c
diff -u src/tests/usr.bin/indent/token_comment.c:1.5 src/tests/usr.bin/indent/token_comment.c:1.6
--- src/tests/usr.bin/indent/token_comment.c:1.5	Tue Oct 19 20:41:42 2021
+++ src/tests/usr.bin/indent/token_comment.c	Sun Oct 24 21:48:16 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token_comment.c,v 1.5 2021/10/19 20:41:42 rillig Exp $ */
+/* $NetBSD: token_comment.c,v 1.6 2021/10/24 21:48:16 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -678,3 +678,39 @@ int		decl;
 // end-of-line comment at the end of the file
 #indent end
 #indent run-equals-input
+
+
+/* A form feed in the middle of a comment is an ordinary character. */
+#indent input
+/*
+ * AE
+ */
+/*-AE*/
+#indent end
+#indent run-equals-input
+
+/*
+ * At the beginning of a block comment or after a '*', '\f' is special. This
+ * is an implementation detail that should not be visible from the outside.
+ * Form feeds in comments are seldom used though, so this is no problem.
+ */
+#indent input
+/* comment*/
+/*text* comment*/
+#indent end
+
+#indent run
+/* * comment */
+/* text* * comment */
+#indent end
+
+/*
+ * Without 'star_comment_cont', there is no separator between the form feed
+ * and the surrounding text.
+ */
+#indent run -nsc
+/*comment */
+/* text*comment */
+#indent end
+
+#indent run-equals-input -nfc1



CVS commit: src/tests/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 21:48:16 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_comment.c

Log Message:
tests/indent: test form feed in comments


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/token_comment.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 20:57:11 UTC 2021

Modified Files:
src/usr.bin/indent: indent.c

Log Message:
indent: rename seen_quest to quest_level

The new name aligns with other similar variables like ind_level,
case_ind_level and ifdef_level. The old name 'seen' is mainly used for
bool variables.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.151 -r1.152 src/usr.bin/indent/indent.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.151 src/usr.bin/indent/indent.c:1.152
--- src/usr.bin/indent/indent.c:1.151	Sun Oct 24 20:43:27 2021
+++ src/usr.bin/indent/indent.c	Sun Oct 24 20:57:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.151 2021/10/24 20:43:27 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.152 2021/10/24 20:57:11 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.151 2021/10/24 20:43:27 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.152 2021/10/24 20:57:11 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -831,9 +831,9 @@ process_postfix_op(void)
 }
 
 static void
-process_question(int *seen_quest)
+process_question(int *quest_level)
 {
-(*seen_quest)++;
+(*quest_level)++;
 if (ps.want_blank)
 	*code.e++ = ' ';
 *code.e++ = '?';
@@ -841,10 +841,10 @@ process_question(int *seen_quest)
 }
 
 static void
-process_colon(int *seen_quest, bool *force_nl, bool *seen_case)
+process_colon(int *quest_level, bool *force_nl, bool *seen_case)
 {
-if (*seen_quest > 0) {	/* part of a '?:' operator */
-	--*seen_quest;
+if (*quest_level > 0) {	/* part of a '?:' operator */
+	--*quest_level;
 	if (ps.want_blank)
 	*code.e++ = ' ';
 	*code.e++ = ':';
@@ -871,7 +871,7 @@ process_colon(int *seen_quest, bool *for
 }
 
 static void
-process_semicolon(bool *seen_case, int *seen_quest, int decl_ind,
+process_semicolon(bool *seen_case, int *quest_level, int decl_ind,
 bool tabs_to_var, bool *sp_sw,
 token_type hd_type,
 bool *force_nl)
@@ -879,7 +879,7 @@ process_semicolon(bool *seen_case, int *
 if (ps.decl_nest == 0)
 	ps.init_or_struct = false;
 *seen_case = false;		/* these will only need resetting in an error */
-*seen_quest = 0;
+*quest_level = 0;
 if (ps.last_token == rparen_or_rbracket)
 	ps.in_parameter_declaration = false;
 ps.cast_mask = 0;
@@ -1340,9 +1340,9 @@ main_loop(void)
  * if(...), while(...), etc. */
 token_type hd_type = end_of_file;	/* the type of statement for if (...),
  * for (...), etc */
-int seen_quest = 0;		/* when this is positive, we have seen a '?'
- * without the matching ':' in a ?:
- * construct */
+int quest_level = 0;	/* when this is positive, we have seen a '?'
+ * without the matching ':' in a '?:'
+ * expression */
 bool seen_case = false;	/* set to true when we see a 'case', so we
  * know what to do with the following colon */
 
@@ -1407,7 +1407,7 @@ main_loop(void)
 	break;
 
 	case question:
-	process_question(&seen_quest);
+	process_question(&quest_level);
 	break;
 
 	case case_label:	/* got word 'case' or 'default' */
@@ -1415,11 +1415,11 @@ main_loop(void)
 	goto copy_token;
 
 	case colon:
-	process_colon(&seen_quest, &force_nl, &seen_case);
+	process_colon(&quest_level, &force_nl, &seen_case);
 	break;
 
 	case semicolon:
-	process_semicolon(&seen_case, &seen_quest, decl_ind, tabs_to_var,
+	process_semicolon(&seen_case, &quest_level, decl_ind, tabs_to_var,
 		&sp_sw, hd_type, &force_nl);
 	break;
 



CVS commit: src/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 20:57:11 UTC 2021

Modified Files:
src/usr.bin/indent: indent.c

Log Message:
indent: rename seen_quest to quest_level

The new name aligns with other similar variables like ind_level,
case_ind_level and ifdef_level. The old name 'seen' is mainly used for
bool variables.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.151 -r1.152 src/usr.bin/indent/indent.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 20:47:00 UTC 2021

Modified Files:
src/usr.bin/indent: lexi.c

Log Message:
indent: define lexi_end as function instead of macro


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 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

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 20:47:00 UTC 2021

Modified Files:
src/usr.bin/indent: lexi.c

Log Message:
indent: define lexi_end as function instead of macro


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/usr.bin/indent/lexi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.95 src/usr.bin/indent/lexi.c:1.96
--- src/usr.bin/indent/lexi.c:1.95	Sun Oct 24 19:14:33 2021
+++ src/usr.bin/indent/lexi.c	Sun Oct 24 20:47:00 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.95 2021/10/24 19:14:33 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.96 2021/10/24 20:47:00 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)lexi.c	8.1 (
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.95 2021/10/24 19:14:33 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.96 2021/10/24 20:47:00 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -247,10 +247,12 @@ debug_print_buf(const char *name, const 
 	debug_vis_range("\"", buf->s, buf->e, "\"");
 }
 }
+#endif
 
 static token_type
 lexi_end(token_type ttype)
 {
+#ifdef debug
 debug_printf("in line %d, lexi returns '%s'",
 	line_no, token_type_name(ttype));
 debug_print_buf("token", &token);
@@ -258,12 +260,10 @@ lexi_end(token_type ttype)
 debug_print_buf("code", &code);
 debug_print_buf("comment", &com);
 debug_printf("\n");
+#endif
 
 return ttype;
 }
-#else
-#define lexi_end(tk) (tk)
-#endif
 
 static void
 lex_number(void)



CVS commit: src

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 20:43:28 UTC 2021

Modified Files:
src/tests/usr.bin/indent: opt_di.c opt_ldi.c token_semicolon.c
src/usr.bin/indent: indent.c

Log Message:
indent: fix indentation of ad-hoc tagged variables

Seen among others in usr.bin/indent/lexi.c, variable 'keywords'.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/opt_di.c
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/opt_ldi.c \
src/tests/usr.bin/indent/token_semicolon.c
cvs rdiff -u -r1.150 -r1.151 src/usr.bin/indent/indent.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 20:43:28 UTC 2021

Modified Files:
src/tests/usr.bin/indent: opt_di.c opt_ldi.c token_semicolon.c
src/usr.bin/indent: indent.c

Log Message:
indent: fix indentation of ad-hoc tagged variables

Seen among others in usr.bin/indent/lexi.c, variable 'keywords'.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/opt_di.c
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/opt_ldi.c \
src/tests/usr.bin/indent/token_semicolon.c
cvs rdiff -u -r1.150 -r1.151 src/usr.bin/indent/indent.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/indent/opt_di.c
diff -u src/tests/usr.bin/indent/opt_di.c:1.3 src/tests/usr.bin/indent/opt_di.c:1.4
--- src/tests/usr.bin/indent/opt_di.c:1.3	Sun Oct 24 19:24:22 2021
+++ src/tests/usr.bin/indent/opt_di.c	Sun Oct 24 20:43:28 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_di.c,v 1.3 2021/10/24 19:24:22 rillig Exp $ */
+/* $NetBSD: opt_di.c,v 1.4 2021/10/24 20:43:28 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -101,6 +101,15 @@ struct long_name long_name;
 #indent end
 
 
+/*
+ * A variable that has an ad-hoc struct/union/enum type does not need to be
+ * indented to the right of the keyword 'struct', it only needs a single space
+ * of indentation.
+ *
+ * Before NetBSD indent.c 1.151 from 2021-10-24, the indentation depended on
+ * the length of the keyword 'struct', 'union' or 'enum', together with type
+ * qualifiers like 'const' or the storage class like 'static'.
+ */
 #indent input
 struct {
 	int member;
@@ -109,14 +118,7 @@ struct {
 };
 #indent end
 
-/* FIXME: The variable name is indented by 6 spaces, should be 1. */
-#indent run -di0
-struct {
-	int member;
-}  var = {
-	3,
-};
-#indent end
+#indent run-equals-input -di0
 
 #indent run
 struct {

Index: src/tests/usr.bin/indent/opt_ldi.c
diff -u src/tests/usr.bin/indent/opt_ldi.c:1.1 src/tests/usr.bin/indent/opt_ldi.c:1.2
--- src/tests/usr.bin/indent/opt_ldi.c:1.1	Fri Oct 22 20:54:36 2021
+++ src/tests/usr.bin/indent/opt_ldi.c	Sun Oct 24 20:43:28 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_ldi.c,v 1.1 2021/10/22 20:54:36 rillig Exp $ */
+/* $NetBSD: opt_ldi.c,v 1.2 2021/10/24 20:43:28 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -35,3 +35,47 @@ function(void)
 	int			local;
 }
 #indent end
+
+
+/*
+ * A variable that has an ad-hoc struct/union/enum type does not need to be
+ * indented to the right of the keyword 'struct', it only needs a single space
+ * of indentation.
+ *
+ * Before NetBSD indent.c 1.151 from 2021-10-24, the indentation depended on
+ * the length of the keyword 'struct', 'union' or 'enum', together with type
+ * qualifiers like 'const' or the storage class like 'static'.
+ */
+#indent input
+{
+	struct {
+		int member;
+	} var = {
+		3,
+	};
+}
+#indent end
+
+/*
+ * Struct members use -di for indentation, no matter whether they are
+ * declared globally or locally.
+ */
+#indent run -ldi0
+{
+	struct {
+		int		member;
+	} var = {
+		3,
+	};
+}
+#indent end
+
+#indent run -ldi16
+{
+	struct {
+		int		member;
+	}		var = {
+		3,
+	};
+}
+#indent end
Index: src/tests/usr.bin/indent/token_semicolon.c
diff -u src/tests/usr.bin/indent/token_semicolon.c:1.1 src/tests/usr.bin/indent/token_semicolon.c:1.2
--- src/tests/usr.bin/indent/token_semicolon.c:1.1	Mon Oct 18 22:30:34 2021
+++ src/tests/usr.bin/indent/token_semicolon.c	Sun Oct 24 20:43:28 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token_semicolon.c,v 1.1 2021/10/18 22:30:34 rillig Exp $ */
+/* $NetBSD: token_semicolon.c,v 1.2 2021/10/24 20:43:28 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -14,7 +14,7 @@
 #indent input
 struct {
 	int member;
-}  global_var;
+} global_var;
 #indent end
 
 #indent run-equals-input -di0

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.150 src/usr.bin/indent/indent.c:1.151
--- src/usr.bin/indent/indent.c:1.150	Sun Oct 24 19:33:26 2021
+++ src/usr.bin/indent/indent.c	Sun Oct 24 20:43:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.150 2021/10/24 19:33:26 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.151 2021/10/24 20:43:27 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.150 2021/10/24 19:33:26 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.151 2021/10/24 20:43:27 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -1023,8 +1023,11 @@ process_rbrace(bool *sp_sw, int *decl_in
 
 if (ps.decl_nest > 0) { /* we are in multi-level structure declaration */
 	*decl_ind = di_stack[--ps.decl_nest];
-	if (ps.decl_nest == 0 && !ps.in_parameter_declaration)
+	if (ps.decl_nest == 0 && !ps.in_parameter_declaration) {
 	ps.just_saw_decl = 2;
+	*decl_ind = ps.ind_level == 

CVS commit: src

2021-10-24 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sun Oct 24 20:00:12 UTC 2021

Modified Files:
src/sys/arch/hpcsh/dev: psh3lcd.c
src/sys/arch/mvme68k/stand/netboot: if_iereg.h
src/sys/arch/sparc/dev: if_ie_obio.c
src/sys/arch/sun2/dev: if_ie_mbmem.c if_ie_obio.c
src/sys/arch/sun3/dev: if_ie.c if_iereg.h if_ievar.h xdreg.h
src/sys/dev/ic: i82586.c
src/sys/dev/pci: mlyreg.h
src/sys/dev/vme: if_ie_vme.c xdreg.h
src/sys/netinet: sctp.h
src/usr.sbin/acpitools/aml: aml_parse.c

Log Message:
fix various typos in comments, mainly copypasta.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/hpcsh/dev/psh3lcd.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/mvme68k/stand/netboot/if_iereg.h
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/sparc/dev/if_ie_obio.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sun2/dev/if_ie_mbmem.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sun2/dev/if_ie_obio.c
cvs rdiff -u -r1.72 -r1.73 src/sys/arch/sun3/dev/if_ie.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sun3/dev/if_iereg.h
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sun3/dev/if_ievar.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sun3/dev/xdreg.h
cvs rdiff -u -r1.89 -r1.90 src/sys/dev/ic/i82586.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pci/mlyreg.h
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/vme/if_ie_vme.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/vme/xdreg.h
cvs rdiff -u -r1.4 -r1.5 src/sys/netinet/sctp.h
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/acpitools/aml/aml_parse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/hpcsh/dev/psh3lcd.c
diff -u src/sys/arch/hpcsh/dev/psh3lcd.c:1.7 src/sys/arch/hpcsh/dev/psh3lcd.c:1.8
--- src/sys/arch/hpcsh/dev/psh3lcd.c:1.7	Sat Nov  9 02:54:11 2013
+++ src/sys/arch/hpcsh/dev/psh3lcd.c	Sun Oct 24 20:00:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: psh3lcd.c,v 1.7 2013/11/09 02:54:11 christos Exp $	*/
+/*	$NetBSD: psh3lcd.c,v 1.8 2021/10/24 20:00:11 andvar Exp $	*/
 /*
  * Copyright (c) 2005 KIYOHARA Takashi
  * All rights reserved.
@@ -59,7 +59,7 @@
 #define PSH3LCD_CONTRAST_UD		0x01
 
 /*
- * LCD brightness: controled by HG71C105FE at AREA2.
+ * LCD brightness: controlled by HG71C105FE at AREA2.
  *	: That is custom IC. We don't know spec.  X-<
  */
 #define PSH3LCD_BRIGHTNESS_REG0		0xaa72

Index: src/sys/arch/mvme68k/stand/netboot/if_iereg.h
diff -u src/sys/arch/mvme68k/stand/netboot/if_iereg.h:1.1 src/sys/arch/mvme68k/stand/netboot/if_iereg.h:1.2
--- src/sys/arch/mvme68k/stand/netboot/if_iereg.h:1.1	Fri May 17 21:18:29 1996
+++ src/sys/arch/mvme68k/stand/netboot/if_iereg.h	Sun Oct 24 20:00:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_iereg.h,v 1.1 1996/05/17 21:18:29 chuck Exp $	*/
+/*	$NetBSD: if_iereg.h,v 1.2 2021/10/24 20:00:11 andvar Exp $	*/
 
 /*
  * if_sunie.h
@@ -68,7 +68,7 @@
  *
  * 	note that the last entry of the page map maps the top of the
  * 	24 bit address space and that the SCP is supposed to be at
- * 	0xf4 (taking into account allignment).   so,
+ * 	0xf4 (taking into account alignment).   so,
  *	for multibus, that entry in the page map has to be used for the SCP.
  *
  * 	the page map effects BOTH how the ie chip sees the
@@ -99,7 +99,7 @@
  * PTE for the page map
  */
 #define IEVME_SBORDR 0x8000	/* sun byte order */
-#define IEVME_IBORDR 0x	/* intel byte ordr */
+#define IEVME_IBORDR 0x	/* intel byte order */
 
 #define IEVME_P2MEM  0x2000	/* memory is on P2 */
 #define IEVME_OBMEM  0x	/* memory is on board */

Index: src/sys/arch/sparc/dev/if_ie_obio.c
diff -u src/sys/arch/sparc/dev/if_ie_obio.c:1.42 src/sys/arch/sparc/dev/if_ie_obio.c:1.43
--- src/sys/arch/sparc/dev/if_ie_obio.c:1.42	Thu Apr 25 10:08:45 2019
+++ src/sys/arch/sparc/dev/if_ie_obio.c	Sun Oct 24 20:00:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ie_obio.c,v 1.42 2019/04/25 10:08:45 msaitoh Exp $	*/
+/*	$NetBSD: if_ie_obio.c,v 1.43 2021/10/24 20:00:11 andvar Exp $	*/
 
 /*-
  * Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -68,12 +68,12 @@
  * sun-4/200's, and VME based suns.  The byte order is all wrong for a
  * SUN, making life difficult.  Programming this chip is mostly the same,
  * but certain details differ from system to system.  This driver is
- * written so that different "ie" interfaces can be controled by the same
+ * written so that different "ie" interfaces can be controlled by the same
  * driver.
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_ie_obio.c,v 1.42 2019/04/25 10:08:45 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ie_obio.c,v 1.43 2021/10/24 20:00:11 andvar Exp $");
 
 #include 
 #include 

Index: src/sys/arch/sun2/dev/if_ie_mbmem.c
diff -u src/sys/arch/sun2/dev/if_ie_mbmem.c:1.12 src/sys/arch/sun2/dev/if_ie_mbmem.c:1.13
--- src/sys/arch/sun2/dev/if_ie_mbmem.c:1.12	Thu Apr 25 10:08:45 2019
+++ src/sys/arch/sun2/dev/if_ie_mbmem.c	Sun Oct 24 20:00:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ie_mbmem.c,v 1.12 20

CVS commit: src

2021-10-24 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sun Oct 24 20:00:12 UTC 2021

Modified Files:
src/sys/arch/hpcsh/dev: psh3lcd.c
src/sys/arch/mvme68k/stand/netboot: if_iereg.h
src/sys/arch/sparc/dev: if_ie_obio.c
src/sys/arch/sun2/dev: if_ie_mbmem.c if_ie_obio.c
src/sys/arch/sun3/dev: if_ie.c if_iereg.h if_ievar.h xdreg.h
src/sys/dev/ic: i82586.c
src/sys/dev/pci: mlyreg.h
src/sys/dev/vme: if_ie_vme.c xdreg.h
src/sys/netinet: sctp.h
src/usr.sbin/acpitools/aml: aml_parse.c

Log Message:
fix various typos in comments, mainly copypasta.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/hpcsh/dev/psh3lcd.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/mvme68k/stand/netboot/if_iereg.h
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/sparc/dev/if_ie_obio.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/sun2/dev/if_ie_mbmem.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/sun2/dev/if_ie_obio.c
cvs rdiff -u -r1.72 -r1.73 src/sys/arch/sun3/dev/if_ie.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/sun3/dev/if_iereg.h
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/sun3/dev/if_ievar.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sun3/dev/xdreg.h
cvs rdiff -u -r1.89 -r1.90 src/sys/dev/ic/i82586.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/pci/mlyreg.h
cvs rdiff -u -r1.33 -r1.34 src/sys/dev/vme/if_ie_vme.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/vme/xdreg.h
cvs rdiff -u -r1.4 -r1.5 src/sys/netinet/sctp.h
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/acpitools/aml/aml_parse.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 19:33:26 UTC 2021

Modified Files:
src/usr.bin/indent: indent.c

Log Message:
indent: initialize variables in main_loop in declaration

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 src/usr.bin/indent/indent.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.149 src/usr.bin/indent/indent.c:1.150
--- src/usr.bin/indent/indent.c:1.149	Sun Oct 24 19:14:33 2021
+++ src/usr.bin/indent/indent.c	Sun Oct 24 19:33:26 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.149 2021/10/24 19:14:33 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.150 2021/10/24 19:33:26 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.149 2021/10/24 19:14:33 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.150 2021/10/24 19:33:26 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -1328,35 +1328,30 @@ process_preprocessing(void)
 static void __attribute__((__noreturn__))
 main_loop(void)
 {
-token_type ttype;
-bool force_nl;		/* when true, code must be broken */
+bool force_nl = false;	/* when true, code must be broken */
 bool last_else = false;	/* true iff last keyword was an else */
-int decl_ind;		/* current indentation for declarations */
+int decl_ind = 0;		/* current indentation for declarations */
 int di_stack[20];		/* a stack of structure indentation levels */
-bool tabs_to_var;		/* true if using tabs to indent to var name */
-bool sp_sw;			/* when true, we are in the expression of
+bool tabs_to_var = false;	/* true if using tabs to indent to var name */
+bool sp_sw = false;		/* when true, we are in the expression of
  * if(...), while(...), etc. */
 token_type hd_type = end_of_file;	/* the type of statement for if (...),
  * for (...), etc */
-int seen_quest;		/* when this is positive, we have seen a '?'
+int seen_quest = 0;		/* when this is positive, we have seen a '?'
  * without the matching ':' in a ?:
  * construct */
-bool seen_case;		/* set to true when we see a 'case', so we
+bool seen_case = false;	/* set to true when we see a 'case', so we
  * know what to do with the following colon */
 
-sp_sw = force_nl = false;
-decl_ind = 0;
 di_stack[ps.decl_nest = 0] = 0;
-seen_case = false;
-seen_quest = 0;
-tabs_to_var = false;
 
 for (;;) {			/* this is the main loop.  it will go until we
  * reach eof */
 	bool comment_buffered = false;
 
-	ttype = lexi(&ps);	/* Read the next token.  The actual characters
- * read are stored in "token". */
+	token_type ttype = lexi(&ps);	/* Read the next token.  The actual
+	 * characters read are stored in
+	 * "token". */
 
 	/*
 	 * Move newlines and comments following an if (), while (), else, etc.



CVS commit: src/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 19:33:26 UTC 2021

Modified Files:
src/usr.bin/indent: indent.c

Log Message:
indent: initialize variables in main_loop in declaration

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.149 -r1.150 src/usr.bin/indent/indent.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 19:24:22 UTC 2021

Modified Files:
src/tests/usr.bin/indent: opt_di.c

Log Message:
tests/indent: demonstrate wrong indentation for initialized variable


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/opt_di.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 19:24:22 UTC 2021

Modified Files:
src/tests/usr.bin/indent: opt_di.c

Log Message:
tests/indent: demonstrate wrong indentation for initialized variable


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/opt_di.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/indent/opt_di.c
diff -u src/tests/usr.bin/indent/opt_di.c:1.2 src/tests/usr.bin/indent/opt_di.c:1.3
--- src/tests/usr.bin/indent/opt_di.c:1.2	Sun Oct 24 17:51:19 2021
+++ src/tests/usr.bin/indent/opt_di.c	Sun Oct 24 19:24:22 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_di.c,v 1.2 2021/10/24 17:51:19 rillig Exp $ */
+/* $NetBSD: opt_di.c,v 1.3 2021/10/24 19:24:22 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -99,3 +99,29 @@ int	tab;
 int	tab16;
 struct long_name long_name;
 #indent end
+
+
+#indent input
+struct {
+	int member;
+} var = {
+	3,
+};
+#indent end
+
+/* FIXME: The variable name is indented by 6 spaces, should be 1. */
+#indent run -di0
+struct {
+	int member;
+}  var = {
+	3,
+};
+#indent end
+
+#indent run
+struct {
+	int		member;
+}		var = {
+	3,
+};
+#indent end



CVS commit: src/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 19:14:33 UTC 2021

Modified Files:
src/usr.bin/indent: args.c indent.c lexi.c parse.c pr_comment.c

Log Message:
indent: run indent on its own source code

With manual corrections afterwards. Indent still does not get
extra_expr_indent correctly, it also indents global variables after
tagged declarations too deep.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/usr.bin/indent/args.c
cvs rdiff -u -r1.148 -r1.149 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.94 -r1.95 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.36 -r1.37 src/usr.bin/indent/parse.c
cvs rdiff -u -r1.82 -r1.83 src/usr.bin/indent/pr_comment.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/indent/args.c
diff -u src/usr.bin/indent/args.c:1.58 src/usr.bin/indent/args.c:1.59
--- src/usr.bin/indent/args.c:1.58	Sun Oct 24 11:19:25 2021
+++ src/usr.bin/indent/args.c	Sun Oct 24 19:14:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: args.c,v 1.58 2021/10/24 11:19:25 rillig Exp $	*/
+/*	$NetBSD: args.c,v 1.59 2021/10/24 19:14:33 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)args.c	8.1 (
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: args.c,v 1.58 2021/10/24 11:19:25 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.59 2021/10/24 19:14:33 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/args.c 336318 2018-07-15 21:04:21Z pstef $");
 #endif
@@ -162,7 +162,7 @@ load_profile(const char *fname, bool mus
 		break;
 	} else if (n >= array_length(buf) - 5) {
 		diag(1, "buffer overflow in %s, starting with '%.10s'",
-		 fname, buf);
+		fname, buf);
 		exit(1);
 	} else
 		buf[n++] = (char)ch;
@@ -308,7 +308,7 @@ found:
 	if (!(errno == 0 && *end == '\0' &&
 		p->i_min <= num && num <= p->i_max))
 	errx(1, "%s: invalid argument \"%s\" for option \"-%s\"",
-		 option_source, param_start, p->p_name);
+		option_source, param_start, p->p_name);
 	*(int *)p->p_var = (int)num;
 }
 }

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.148 src/usr.bin/indent/indent.c:1.149
--- src/usr.bin/indent/indent.c:1.148	Sun Oct 24 17:19:48 2021
+++ src/usr.bin/indent/indent.c	Sun Oct 24 19:14:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.148 2021/10/24 17:19:48 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.149 2021/10/24 19:14:33 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.148 2021/10/24 17:19:48 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.149 2021/10/24 19:14:33 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -309,19 +309,18 @@ search_brace_lookahead(token_type *ttype
 	return;
 
 /*
- * The only intended purpose of calling lexi() below is to categorize
- * the next token in order to decide whether to continue buffering
- * forthcoming tokens. Once the buffering is over, lexi() will be
- * called again elsewhere on all of the tokens - this time for normal
- * processing.
+ * The only intended purpose of calling lexi() below is to categorize the
+ * next token in order to decide whether to continue buffering forthcoming
+ * tokens. Once the buffering is over, lexi() will be called again
+ * elsewhere on all of the tokens - this time for normal processing.
  *
- * Calling it for this purpose is a bug, because lexi() also changes
- * the parser state and discards leading whitespace, which is needed
- * mostly for comment-related considerations.
+ * Calling it for this purpose is a bug, because lexi() also changes the
+ * parser state and discards leading whitespace, which is needed mostly
+ * for comment-related considerations.
  *
- * Work around the former problem by giving lexi() a copy of the
- * current parser state and discard it if the call turned out to be
- * just a lookahead.
+ * Work around the former problem by giving lexi() a copy of the current
+ * parser state and discard it if the call turned out to be just a
+ * lookahead.
  *
  * Work around the latter problem by copying all whitespace characters
  * into the buffer so that the later lexi() call will read them.
@@ -367,7 +366,7 @@ search_brace(token_type *ttype, bool *fo
 	if (!search_brace_other(*ttype, force_nl,
 		*comment_buffered, *last_else))
 		return;
-	switch_buffer:
+switch_buffer:
 	switch_buffer();
 	}
 	search_brace_lookahead(ttype);
@@ -490,7 +489,7 @@ bakcopy(void)
 
 const char *last_slash = strrchr(in_name, '/');
 snprintf(bakfile, sizeof(bakfile), "%s%s",
-	 last

CVS commit: src/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 19:14:33 UTC 2021

Modified Files:
src/usr.bin/indent: args.c indent.c lexi.c parse.c pr_comment.c

Log Message:
indent: run indent on its own source code

With manual corrections afterwards. Indent still does not get
extra_expr_indent correctly, it also indents global variables after
tagged declarations too deep.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/usr.bin/indent/args.c
cvs rdiff -u -r1.148 -r1.149 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.94 -r1.95 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.36 -r1.37 src/usr.bin/indent/parse.c
cvs rdiff -u -r1.82 -r1.83 src/usr.bin/indent/pr_comment.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/make

2021-10-24 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sun Oct 24 18:45:46 UTC 2021

Modified Files:
src/usr.bin/make: job.c meta.c

Log Message:
Do not ignore write failures.

We should not ignore failure to write to cmdFILE,
meta files and filemon.

Reviewed by: rillig


To generate a diff of this commit:
cvs rdiff -u -r1.435 -r1.436 src/usr.bin/make/job.c
cvs rdiff -u -r1.183 -r1.184 src/usr.bin/make/meta.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.435 src/usr.bin/make/job.c:1.436
--- src/usr.bin/make/job.c:1.435	Wed Jun 16 09:47:51 2021
+++ src/usr.bin/make/job.c	Sun Oct 24 18:45:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.435 2021/06/16 09:47:51 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.436 2021/10/24 18:45:46 sjg 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.435 2021/06/16 09:47:51 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.436 2021/10/24 18:45:46 sjg Exp $");
 
 /*
  * A shell defines how the commands are run.  All commands for a target are
@@ -765,8 +765,8 @@ ShellWriter_WriteFmt(ShellWriter *wr, co
 	DEBUG1(JOB, fmt, arg);
 
 	(void)fprintf(wr->f, fmt, arg);
-	/* XXX: Is flushing needed in any case, or only if f == stdout? */
-	(void)fflush(wr->f);
+	if (wr->f == stdout)
+		(void)fflush(wr->f);
 }
 
 static void
@@ -1163,7 +1163,9 @@ JobFinish(Job *job, int status)
 
 		JobClosePipes(job);
 		if (job->cmdFILE != NULL && job->cmdFILE != stdout) {
-			(void)fclose(job->cmdFILE);
+			if (fclose(job->cmdFILE) != 0)
+Punt("Cannot write shell script for '%s': %s",
+job->node->name, strerror(errno));
 			job->cmdFILE = NULL;
 		}
 		done = true;
@@ -1526,7 +1528,9 @@ JobExec(Job *job, char **argv)
 	watchfd(job);
 
 	if (job->cmdFILE != NULL && job->cmdFILE != stdout) {
-		(void)fclose(job->cmdFILE);
+		if (fclose(job->cmdFILE) != 0)
+			Punt("Cannot write shell script for '%s': %s",
+			job->node->name, strerror(errno));
 		job->cmdFILE = NULL;
 	}
 

Index: src/usr.bin/make/meta.c
diff -u src/usr.bin/make/meta.c:1.183 src/usr.bin/make/meta.c:1.184
--- src/usr.bin/make/meta.c:1.183	Thu Aug 19 15:50:30 2021
+++ src/usr.bin/make/meta.c	Sun Oct 24 18:45:46 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: meta.c,v 1.183 2021/08/19 15:50:30 rillig Exp $ */
+/*  $NetBSD: meta.c,v 1.184 2021/10/24 18:45:46 sjg Exp $ */
 
 /*
  * Implement 'meta' mode.
@@ -145,11 +145,11 @@ meta_open_filemon(BuildMon *pbm)
 else
 	pbm->mon_fd = mkTempFile("filemon.XX", NULL, 0);
 if ((dupfd = dup(pbm->mon_fd)) == -1) {
-	err(1, "Could not dup filemon output!");
+	Punt("Could not dup filemon output: %s", strerror(errno));
 }
 (void)fcntl(dupfd, F_SETFD, FD_CLOEXEC);
 if (filemon_setfd(pbm->filemon, dupfd) == -1) {
-	err(1, "Could not set filemon file descriptor!");
+	Punt("Could not set filemon file descriptor: %s", strerror(errno));
 }
 /* we don't need these once we exec */
 (void)fcntl(pbm->mon_fd, F_SETFD, FD_CLOEXEC);
@@ -187,7 +187,9 @@ filemon_read(FILE *mfp, int fd)
 		error = EIO;
 	}
 }
-fflush(mfp);
+if (fflush(mfp) != 0)
+	Punt("Cannot write filemon data to meta file: %s",
+	strerror(errno));
 if (close(fd) < 0)
 	error = errno;
 return error;
@@ -518,7 +520,7 @@ meta_create(BuildMon *pbm, GNode *gn)
 #endif
 
 if ((fp = fopen(fname, "w")) == NULL)
-	err(1, "Could not open meta file '%s'", fname);
+	Punt("Could not open meta file '%s': %s", fname, strerror(errno));
 
 fprintf(fp, "# Meta data file %s\n", fname);
 
@@ -536,7 +538,9 @@ meta_create(BuildMon *pbm, GNode *gn)
 }
 
 fprintf(fp, "-- command output --\n");
-fflush(fp);
+if (fflush(fp) != 0)
+	Punt("Cannot write expanded command to meta file: %s",
+	strerror(errno));
 
 Global_Append(".MAKE.META.FILES", fname);
 Global_Append(".MAKE.META.CREATED", fname);
@@ -710,7 +714,7 @@ meta_job_child(Job *job)
 
 	pid = getpid();
 	if (filemon_setpid_child(pbm->filemon, pid) == -1) {
-		err(1, "Could not set filemon pid!");
+		Punt("Could not set filemon pid: %s", strerror(errno));
 	}
 	}
 }
@@ -850,8 +854,10 @@ meta_cmd_finish(void *pbmp)
 if (pbm->filemon != NULL) {
 	while (filemon_process(pbm->filemon) > 0)
 	continue;
-	if (filemon_close(pbm->filemon) == -1)
+	if (filemon_close(pbm->filemon) == -1) {
 	error = errno;
+	Punt("filemon failed: %s", strerror(errno));
+	}
 	x = filemon_read(pbm->mfp, pbm->mon_fd);
 	if (error == 0 && x != 0)
 	error = x;



CVS commit: src/usr.bin/make

2021-10-24 Thread Simon J. Gerraty
Module Name:src
Committed By:   sjg
Date:   Sun Oct 24 18:45:46 UTC 2021

Modified Files:
src/usr.bin/make: job.c meta.c

Log Message:
Do not ignore write failures.

We should not ignore failure to write to cmdFILE,
meta files and filemon.

Reviewed by: rillig


To generate a diff of this commit:
cvs rdiff -u -r1.435 -r1.436 src/usr.bin/make/job.c
cvs rdiff -u -r1.183 -r1.184 src/usr.bin/make/meta.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 17:51:19 UTC 2021

Modified Files:
src/tests/usr.bin/indent: opt_di.c

Log Message:
tests/indent: add more tests for option '-di'


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/opt_di.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/indent/opt_di.c
diff -u src/tests/usr.bin/indent/opt_di.c:1.1 src/tests/usr.bin/indent/opt_di.c:1.2
--- src/tests/usr.bin/indent/opt_di.c:1.1	Fri Oct 22 20:54:36 2021
+++ src/tests/usr.bin/indent/opt_di.c	Sun Oct 24 17:51:19 2021
@@ -1,6 +1,11 @@
-/* $NetBSD: opt_di.c,v 1.1 2021/10/22 20:54:36 rillig Exp $ */
+/* $NetBSD: opt_di.c,v 1.2 2021/10/24 17:51:19 rillig Exp $ */
 /* $FreeBSD$ */
 
+/*
+ * Test the option '-di', which specifies the indentation of the variable
+ * declarator.
+ */
+
 #indent input
 int space;
 int	tab;
@@ -16,3 +21,81 @@ int	tab16;
 
 struct long_name long_name;
 #indent end
+
+
+/*
+ * The declarator can be a simple variable name. It can also be prefixed by
+ * asterisks, for pointer variables. These asterisks are placed to the left of
+ * the indentation line, so that the variable names are aligned.
+ *
+ * There can be multiple declarators in a single declaration, separated by
+ * commas. Only the first of them is aligned to the indentation given by
+ * '-di', the others are separated with a single space.
+ */
+#indent input
+int var;
+int *ptr, *ptr;
+#indent end
+
+#indent run -di12
+int	var;
+int	   *ptr, *ptr;
+#indent end
+
+
+/*
+ * Test the various values for indenting.
+ */
+#indent input
+int decl ;
+#indent end
+
+/*
+ * An indentation of 0 columns uses a single space between the declaration
+ * specifiers (in this case 'int') and the declarator.
+ */
+#indent run -di0
+int decl;
+#indent end
+
+/*
+ * An indentation of 7 columns uses spaces for indentation since in the
+ * default configuration, the next tab stop would be at indentation 8.
+ */
+#indent run -di7
+intdecl;
+#indent end
+
+/* The indentation consists of a single tab. */
+#indent run -di8
+int	decl;
+#indent end
+
+/* The indentation consists of a tab and a space. */
+#indent run -di9
+int	 decl;
+#indent end
+
+#indent run -di16
+int		decl;
+#indent end
+
+
+/*
+ * Ensure that all whitespace is normalized to be indented by 8 columns,
+ * which in the default configuration amounts to a single tab.
+ */
+
+#indent input
+int space;
+int	tab;
+int		tab16;
+struct long_name long_name;
+#indent end
+
+#indent run -di8
+int	space;
+int	tab;
+int	tab16;
+struct long_name long_name;
+#indent end



CVS commit: src/tests/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 17:51:19 UTC 2021

Modified Files:
src/tests/usr.bin/indent: opt_di.c

Log Message:
tests/indent: add more tests for option '-di'


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/opt_di.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/man4

2021-10-24 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sun Oct 24 17:46:06 UTC 2021

Modified Files:
src/share/man/man4: bpf.4

Log Message:
bpf.4: amend caveat about what types of links can be written to

Try to be clearer about what's supported. A peripheral issue noted in
PR pkg/55446.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/share/man/man4/bpf.4

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/share/man/man4

2021-10-24 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sun Oct 24 17:46:06 UTC 2021

Modified Files:
src/share/man/man4: bpf.4

Log Message:
bpf.4: amend caveat about what types of links can be written to

Try to be clearer about what's supported. A peripheral issue noted in
PR pkg/55446.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/share/man/man4/bpf.4

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/man4/bpf.4
diff -u src/share/man/man4/bpf.4:1.63 src/share/man/man4/bpf.4:1.64
--- src/share/man/man4/bpf.4:1.63	Fri Jun 12 20:58:43 2020
+++ src/share/man/man4/bpf.4	Sun Oct 24 17:46:06 2021
@@ -1,6 +1,6 @@
 .\" -*- nroff -*-
 .\"
-.\"	$NetBSD: bpf.4,v 1.63 2020/06/12 20:58:43 wiz Exp $
+.\"	$NetBSD: bpf.4,v 1.64 2021/10/24 17:46:06 gutteridge Exp $
 .\"
 .\" Copyright (c) 1990, 1991, 1992, 1993, 1994
 .\"	The Regents of the University of California.  All rights reserved.
@@ -24,7 +24,7 @@
 .\" This document is derived in part from the enet man page (enet.4)
 .\" distributed with 4.3BSD Unix.
 .\"
-.Dd June 11, 2020
+.Dd October 24, 2021
 .Dt BPF 4
 .Os
 .Sh NAME
@@ -75,7 +75,8 @@ A packet can be sent out on the network 
 .Nm
 file descriptor.
 The writes are unbuffered, meaning only one packet can be processed per write.
-Currently, only writes to Ethernets and SLIP links are supported.
+Currently, only writes to Ethernet-based (including Wi-Fi) and SLIP
+links are supported.
 .Sh IOCTLS
 The
 .Xr ioctl 2



CVS commit: src/lib/libc/locale

2021-10-24 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sun Oct 24 17:30:19 UTC 2021

Modified Files:
src/lib/libc/locale: setlocale.3

Log Message:
setlocale.3: minor updates to reflect the current implementation

Reflect a couple of amendments noted by John Marino on tech-userlevel:
http://mail-index.netbsd.org/tech-userlevel/2021/10/19/msg013091.html


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/lib/libc/locale/setlocale.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/locale/setlocale.3
diff -u src/lib/libc/locale/setlocale.3:1.21 src/lib/libc/locale/setlocale.3:1.22
--- src/lib/libc/locale/setlocale.3:1.21	Sat Jan 24 16:58:54 2004
+++ src/lib/libc/locale/setlocale.3	Sun Oct 24 17:30:19 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: setlocale.3,v 1.21 2004/01/24 16:58:54 wiz Exp $
+.\"	$NetBSD: setlocale.3,v 1.22 2021/10/24 17:30:19 gutteridge Exp $
 .\"
 .\" Copyright (c) 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -32,7 +32,7 @@
 .\"
 .\"	@(#)setlocale.3	8.1 (Berkeley) 6/9/93
 .\"
-.Dd May 30, 2003
+.Dd October 24, 2021
 .Dt SETLOCALE 3
 .Os
 .Sh NAME
@@ -81,9 +81,6 @@ functions.
 This controls recognition of upper and lower case,
 alphabetic or non-alphabetic characters,
 and so on.
-The real work is done by the
-.Fn setrunelocale
-function.
 .It Dv LC_MESSAGES
 Set a locale for message catalogs.
 This controls the selection of message catalogs by the
@@ -336,7 +333,9 @@ following manner before using any of the
 .Bd -literal
 	setlocale(LC_ALL, "");
 .Ed
-.\" .Sh FILES			XXX
+.Sh FILES
+The use of multibyte locales requires shared libraries located in
+.Pa /usr/lib/i18n .
 .\" .Bl -tag -width /usr/share/locale/locale/category -compact	XXX
 .\" .It Pa $PATH_LOCALE/\fIlocale\fP/\fIcategory\fP		XXX
 .\" .It Pa /usr/share/locale/\fIlocale\fP/\fIcategory\fP	XXX



CVS commit: src/lib/libc/locale

2021-10-24 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sun Oct 24 17:30:19 UTC 2021

Modified Files:
src/lib/libc/locale: setlocale.3

Log Message:
setlocale.3: minor updates to reflect the current implementation

Reflect a couple of amendments noted by John Marino on tech-userlevel:
http://mail-index.netbsd.org/tech-userlevel/2021/10/19/msg013091.html


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/lib/libc/locale/setlocale.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 17:19:49 UTC 2021

Modified Files:
src/tests/usr.bin/indent: t_errors.sh t_misc.sh token_lparen.c
src/usr.bin/indent: indent.c io.c

Log Message:
indent: clean up format of warnings and errors

Previously, warnings and errors had the form of C block comments. Before
NetBSD io.c 1.20 from 2019-10-19, this format made sense because the
diagnostics could end up in the same output stream as the formatted
output.

Since NetBSD io.c 1.20 from 2019-10-19, all diagnostics are redirected
to stderr. This change was not mentioned in the commit message back
then, it makes sense nevertheless. Since stdout and stderr now are
properly separated, there is no need anymore to keep the weird format
for warnings and errors. Switch to the standard 'error: file:line'
format.

Move the function 'diag' to indent.c to have access to the name of the
current input file.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/t_errors.sh
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/indent/t_misc.sh
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/token_lparen.c
cvs rdiff -u -r1.147 -r1.148 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.101 -r1.102 src/usr.bin/indent/io.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/indent/t_errors.sh
diff -u src/tests/usr.bin/indent/t_errors.sh:1.4 src/tests/usr.bin/indent/t_errors.sh:1.5
--- src/tests/usr.bin/indent/t_errors.sh:1.4	Sun Oct 17 18:13:00 2021
+++ src/tests/usr.bin/indent/t_errors.sh	Sun Oct 24 17:19:49 2021
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: t_errors.sh,v 1.4 2021/10/17 18:13:00 rillig Exp $
+# $NetBSD: t_errors.sh,v 1.5 2021/10/24 17:19:49 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -146,7 +146,7 @@ option_buffer_overflow_body()
 
 	# TODO: The call to 'diag' should be replaced with 'errx'.
 	expect_error \
-	'Error@1: buffer overflow in indent.pro, starting with '\''-123456781'\''' \
+	'error: Standard Input:1: buffer overflow in indent.pro, starting with '\''-123456781'\''' \
 	-Pindent.pro
 }
 
@@ -174,7 +174,7 @@ unterminated_comment_body()
 
 	atf_check -s 'exit:1' \
 	-o 'inline:/*'"$nl"' *'"$nl" \
-	-e 'inline:/**INDENT** Error@2: Unterminated comment */'"$nl" \
+	-e 'inline:error: Standard Input:2: Unterminated comment'"$nl" \
 	"$indent" -st < comment.c
 }
 
@@ -254,7 +254,7 @@ unexpected_end_of_file_body()
 	echo 'struct{' > code.c
 
 	expect_error \
-	'Error@1: Stuff missing from end of file' \
+	'error: code.c:1: Stuff missing from end of file' \
 	code.c
 
 	atf_check \
@@ -268,7 +268,7 @@ unexpected_closing_brace_top_level_body(
 	echo '}' > code.c
 
 	expect_error \
-	'Error@1: Statement nesting error' \
+	'error: code.c:1: Statement nesting error' \
 	code.c
 	atf_check \
 	-o 'inline:}'"$nl" \
@@ -281,7 +281,7 @@ unexpected_closing_brace_decl_body()
 	echo 'int i = 3};' > code.c
 
 	expect_error \
-	'Error@1: Statement nesting error' \
+	'error: code.c:1: Statement nesting error' \
 	code.c
 	# Despite the error message, the original file got overwritten with a
 	# best-effort rewrite of the code.
@@ -309,9 +309,9 @@ preprocessing_overflow_body()
 		#endif too much
 	EOF
 	cat <<-\EOF > stderr.exp
-		Error@6: #if stack overflow
-		Error@12: Unmatched #endif
-		Error@13: Unmatched #endif
+		error: code.c:6: #if stack overflow
+		error: code.c:12: Unmatched #endif
+		error: code.c:13: Unmatched #endif
 	EOF
 
 	atf_check -s 'exit:1' \
@@ -329,10 +329,10 @@ preprocessing_unrecognized_body()
 		#else
 	EOF
 	cat <<-\EOF > stderr.exp
-		Error@1: Unrecognized cpp directive
-		Error@2: Unrecognized cpp directive
-		Error@3: Unmatched #elif
-		Error@4: Unmatched #else
+		error: code.c:1: Unrecognized cpp directive
+		error: code.c:2: Unrecognized cpp directive
+		error: code.c:3: Unmatched #elif
+		error: code.c:4: Unmatched #else
 	EOF
 
 	atf_check -s 'exit:1' \

Index: src/tests/usr.bin/indent/t_misc.sh
diff -u src/tests/usr.bin/indent/t_misc.sh:1.7 src/tests/usr.bin/indent/t_misc.sh:1.8
--- src/tests/usr.bin/indent/t_misc.sh:1.7	Sun Oct 24 16:51:44 2021
+++ src/tests/usr.bin/indent/t_misc.sh	Sun Oct 24 17:19:49 2021
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: t_misc.sh,v 1.7 2021/10/24 16:51:44 rillig Exp $
+# $NetBSD: t_misc.sh,v 1.8 2021/10/24 17:19:49 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -161,11 +161,11 @@ nested_struct_declarations_body()
 		};
 	EOF
 	cat <<-\EOF > expected.err
-		/**INDENT** Warning@5: Reached internal limit of 20 struct levels */
-		/**INDENT** Warning@6: Reached internal limit of 20 struct levels */
-		/**INDENT** Warning@6: Reached internal limit of 20 struct levels */
-		/**INDENT** Warning@6: Reached internal limit of 20 struct levels */
-		/**INDENT** W

CVS commit: src

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 17:19:49 UTC 2021

Modified Files:
src/tests/usr.bin/indent: t_errors.sh t_misc.sh token_lparen.c
src/usr.bin/indent: indent.c io.c

Log Message:
indent: clean up format of warnings and errors

Previously, warnings and errors had the form of C block comments. Before
NetBSD io.c 1.20 from 2019-10-19, this format made sense because the
diagnostics could end up in the same output stream as the formatted
output.

Since NetBSD io.c 1.20 from 2019-10-19, all diagnostics are redirected
to stderr. This change was not mentioned in the commit message back
then, it makes sense nevertheless. Since stdout and stderr now are
properly separated, there is no need anymore to keep the weird format
for warnings and errors. Switch to the standard 'error: file:line'
format.

Move the function 'diag' to indent.c to have access to the name of the
current input file.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/t_errors.sh
cvs rdiff -u -r1.7 -r1.8 src/tests/usr.bin/indent/t_misc.sh
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/token_lparen.c
cvs rdiff -u -r1.147 -r1.148 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.101 -r1.102 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

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 16:51:44 UTC 2021

Modified Files:
src/tests/usr.bin/indent: t_misc.sh
src/usr.bin/indent: indent.c

Log Message:
indent: fix line number counting at beginning of function body


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/t_misc.sh
cvs rdiff -u -r1.146 -r1.147 src/usr.bin/indent/indent.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/indent/t_misc.sh
diff -u src/tests/usr.bin/indent/t_misc.sh:1.6 src/tests/usr.bin/indent/t_misc.sh:1.7
--- src/tests/usr.bin/indent/t_misc.sh:1.6	Sun Oct 24 16:46:12 2021
+++ src/tests/usr.bin/indent/t_misc.sh	Sun Oct 24 16:51:44 2021
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: t_misc.sh,v 1.6 2021/10/24 16:46:12 rillig Exp $
+# $NetBSD: t_misc.sh,v 1.7 2021/10/24 16:51:44 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -309,6 +309,9 @@ opt_U_body()
 atf_test_case 'line_no_counting'
 line_no_counting_body()
 {
+	# Before NetBSD indent.c 1.147 from 2021-10-24, indent reported the
+	# warning in line 2 instead of the correct line 3.
+
 	cat <<-\EOF > code.c
 		void line_no_counting(void)
 		{
@@ -316,9 +319,8 @@ line_no_counting_body()
 		}
 	EOF
 
-	# FIXME: the wrong ')' is in line 3, not 2.
 	cat <<-\EOF > code.err
-		/**INDENT** Warning@2: Extra ) */
+		/**INDENT** Warning@3: Extra ) */
 	EOF
 
 	atf_check -o 'ignore' -e 'file:code.err' \

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.146 src/usr.bin/indent/indent.c:1.147
--- src/usr.bin/indent/indent.c:1.146	Sun Oct 24 11:19:25 2021
+++ src/usr.bin/indent/indent.c	Sun Oct 24 16:51:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.146 2021/10/24 11:19:25 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.147 2021/10/24 16:51:44 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.146 2021/10/24 11:19:25 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.147 2021/10/24 16:51:44 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -150,6 +150,8 @@ search_brace_newline(bool *force_nl)
 }
 *sc_end++ = '\n';
 
+line_no++;
+
 /*
  * We may have inherited a force_nl == true from the previous token (like
  * a semicolon). But once we know that a newline has been scanned in this



CVS commit: src

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 16:51:44 UTC 2021

Modified Files:
src/tests/usr.bin/indent: t_misc.sh
src/usr.bin/indent: indent.c

Log Message:
indent: fix line number counting at beginning of function body


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/t_misc.sh
cvs rdiff -u -r1.146 -r1.147 src/usr.bin/indent/indent.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 16:46:12 UTC 2021

Modified Files:
src/tests/usr.bin/indent: t_misc.sh

Log Message:
indent/tests: demonstrate wrong line number counting


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/t_misc.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/indent/t_misc.sh
diff -u src/tests/usr.bin/indent/t_misc.sh:1.5 src/tests/usr.bin/indent/t_misc.sh:1.6
--- src/tests/usr.bin/indent/t_misc.sh:1.5	Sat Oct 23 21:45:14 2021
+++ src/tests/usr.bin/indent/t_misc.sh	Sun Oct 24 16:46:12 2021
@@ -1,5 +1,5 @@
 #! /bin/sh
-# $NetBSD: t_misc.sh,v 1.5 2021/10/23 21:45:14 rillig Exp $
+# $NetBSD: t_misc.sh,v 1.6 2021/10/24 16:46:12 rillig Exp $
 #
 # Copyright (c) 2021 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -306,6 +306,25 @@ opt_U_body()
 	"$indent" -Ucode.types code.c -di0 -st
 }
 
+atf_test_case 'line_no_counting'
+line_no_counting_body()
+{
+	cat <<-\EOF > code.c
+		void line_no_counting(void)
+		{
+			())
+		}
+	EOF
+
+	# FIXME: the wrong ')' is in line 3, not 2.
+	cat <<-\EOF > code.err
+		/**INDENT** Warning@2: Extra ) */
+	EOF
+
+	atf_check -o 'ignore' -e 'file:code.err' \
+	"$indent" code.c -st
+}
+
 atf_init_test_cases()
 {
 	atf_add_test_case 'in_place'
@@ -315,4 +334,5 @@ atf_init_test_cases()
 	atf_add_test_case 'opt'
 	atf_add_test_case 'opt_npro'
 	atf_add_test_case 'opt_U'
+	atf_add_test_case 'line_no_counting'
 }



CVS commit: src/tests/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 16:46:12 UTC 2021

Modified Files:
src/tests/usr.bin/indent: t_misc.sh

Log Message:
indent/tests: demonstrate wrong line number counting


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/t_misc.sh

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 16:38:00 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_lparen.c

Log Message:
tests/indent: document actually reachable token combinations with '('


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/token_lparen.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 16:38:00 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_lparen.c

Log Message:
tests/indent: document actually reachable token combinations with '('


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/token_lparen.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/token_lparen.c
diff -u src/tests/usr.bin/indent/token_lparen.c:1.2 src/tests/usr.bin/indent/token_lparen.c:1.3
--- src/tests/usr.bin/indent/token_lparen.c:1.2	Sun Oct 24 15:44:13 2021
+++ src/tests/usr.bin/indent/token_lparen.c	Sun Oct 24 16:38:00 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token_lparen.c,v 1.2 2021/10/24 15:44:13 rillig Exp $ */
+/* $NetBSD: token_lparen.c,v 1.3 2021/10/24 16:38:00 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -96,54 +96,70 @@ int array[] = {
 
 /*
  * Test want_blank_before_lparen for all possible token types.
+ *
+ * FIXME: As a side effect, this test demonstrates that line_no counting is
+ *  broken. lparen_or_lbracket is in line 5, but during debugging it is said
+ *  to be in line 4.
  */
 #indent input
 void cover_want_blank_before_lparen(void)
 {
-	int newline = (3
-	);
+	/* ps.last_token can never be 'newline'. */
+	int newline =
+	(3);
+
 	int lparen_or_lbracket = a[(3)];
 	int rparen_or_rbracket = a[3](5);
 	+(unary_op);
-	(3) + (binary_op);
+	3 + (binary_op);
 	a++(postfix_op);	/* unlikely to be seen in practice */
 	cond ? (question) : (5);
 	switch (expr) {
 	case (case_label):;
 	}
-	a ? (3) : (colon);
-	;(semicolon) = 3;
+	a ? 3 : (colon);
+	(semicolon) = 3;
 	int lbrace[] = {(3)};
 	int rbrace_in_decl = {{3}(4)};	/* syntax error */
 	{}
 	(rbrace_in_stmt)();
-	int ident = func(3);
-	int ident = int(3);	/* syntax error in C, OK in C++ */
-	int comma = func(a, (3));
-	int comment = /* comment */ (3);
+	ident(3);
+	int(decl);
+	a++, (comma)();
+	int comment = /* comment */ (3);	/* comment is skipped */
 	switch (expr) {}
 #define preprocessing
 	(preprocessing)();
-	(form_feed)();
-	int(*decl)(void);
+	/* $ XXX: form_feed should be skipped, just as newline. */
+	(form_feed)();		/* XXX: should be skipped */
 	for(;;);
 	do(keyword_do_else)=3;while(0);
+	// $ TODO: is if_expr possible?
 	if(cond)(if_expr)();
+	// $ TODO: is while_expr possible?
 	while(cond)(while_expr)();
+	// $ TODO: is for_exprs possible?
 	for(;;)(for_exprs)();
+	// $ TODO: is stmt possible?
 	(stmt);
+	// $ TODO: is stmt_list possible?
 	(stmt_list);
+	// $ TODO: is keyword_else possible? keyword_do_else is.
 	if(cond);else(keyword_else)();
+	// $ TODO: is keyword_do possible? keyword_do_else is.
 	do(keyword_do);while(0);
-	// The following line Would generate 'Statement nesting error'.
+	// The following line would generate 'Statement nesting error'.
 	// do stmt;(do_stmt());while(0);
+	// $ TODO: is if_expr_stmt possible?
 	if(cond)stmt;(if_expr_stmt)();
+	// $ TODO: is if_expr_stmt_else possible?
 	if(cond)stmt;else(if_expr_stmt_else());
 	str.(member);		/* syntax error */
-	L("string_prefix");
+	L("string_prefix");		/* impossible */
 	static (int)storage_class;	/* syntax error */
 	funcname(3);
 	typedef (type_def) new_type;
+	// $ TODO: is keyword_struct_union_enum possible?
 	struct (keyword_struct_union_enum);	/* syntax error */
 }
 #indent end
@@ -152,36 +168,36 @@ void cover_want_blank_before_lparen(void
 void
 cover_want_blank_before_lparen(void)
 {
-	int newline = (3
-	);
+	/* ps.last_token can never be 'newline'. */
+	int newline =
+	(3);
+
 	int lparen_or_lbracket = a[(3)];
 	int rparen_or_rbracket = a[3](5);
 	+(unary_op);
-	(3) + (binary_op);
+	3 + (binary_op);
 	a++ (postfix_op);	/* unlikely to be seen in practice */
 	cond ? (question) : (5);
 	switch (expr) {
 	case (case_label):;
 	}
-	a ? (3) : (colon);
-	;
+	a ? 3 : (colon);
 	(semicolon) = 3;
 	int lbrace[] = {(3)};
 	int rbrace_in_decl = {{3} (4)};	/* syntax error */
 	{
 	}
 	(rbrace_in_stmt)();
-	int ident = func(3);
-	int ident = int (3);	/* syntax error in C, OK in C++ */
-	int comma = func(a, (3));
-	int comment = /* comment */ (3);
+	ident(3);
+	int (decl);
+	a++, (comma)();
+	int comment = /* comment */ (3);	/* comment is skipped */
 	switch (expr) {
 	}
 #define preprocessing
 	(preprocessing)();
 
-	(form_feed)();
-	int (*decl)(void);
+	(form_feed)();		/* XXX: should be skipped */
 	for (;;);
 	do
 		(keyword_do_else) = 3;
@@ -200,7 +216,7 @@ cover_want_blank_before_lparen(void)
 	do
 		(keyword_do);
 	while (0);
-	// The following line Would generate 'Statement nesting error'.
+	// The following line would generate 'Statement nesting error'.
 	// do stmt;(do_stmt());while(0);
 	if (cond)
 		stmt;
@@ -210,7 +226,7 @@ cover_want_blank_before_lparen(void)
 	else
 		(if_expr_stmt_else());
 	str.(member);		/* syntax error */
-	L("string_prefix");
+	L("string_prefix");	/* impossible */
 	static (int)storage_class;	/* syntax error *

CVS commit: src/tests/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 15:44:13 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_lparen.c

Log Message:
tests/indent: test want_blank_before_lparen


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/token_lparen.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/token_lparen.c
diff -u src/tests/usr.bin/indent/token_lparen.c:1.1 src/tests/usr.bin/indent/token_lparen.c:1.2
--- src/tests/usr.bin/indent/token_lparen.c:1.1	Mon Oct 18 22:30:34 2021
+++ src/tests/usr.bin/indent/token_lparen.c	Sun Oct 24 15:44:13 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token_lparen.c,v 1.1 2021/10/18 22:30:34 rillig Exp $ */
+/* $NetBSD: token_lparen.c,v 1.2 2021/10/24 15:44:13 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -92,3 +92,128 @@ int array[] = {
 #indent end
 
 #indent run-equals-input -di0
+
+
+/*
+ * Test want_blank_before_lparen for all possible token types.
+ */
+#indent input
+void cover_want_blank_before_lparen(void)
+{
+	int newline = (3
+	);
+	int lparen_or_lbracket = a[(3)];
+	int rparen_or_rbracket = a[3](5);
+	+(unary_op);
+	(3) + (binary_op);
+	a++(postfix_op);	/* unlikely to be seen in practice */
+	cond ? (question) : (5);
+	switch (expr) {
+	case (case_label):;
+	}
+	a ? (3) : (colon);
+	;(semicolon) = 3;
+	int lbrace[] = {(3)};
+	int rbrace_in_decl = {{3}(4)};	/* syntax error */
+	{}
+	(rbrace_in_stmt)();
+	int ident = func(3);
+	int ident = int(3);	/* syntax error in C, OK in C++ */
+	int comma = func(a, (3));
+	int comment = /* comment */ (3);
+	switch (expr) {}
+#define preprocessing
+	(preprocessing)();
+	(form_feed)();
+	int(*decl)(void);
+	for(;;);
+	do(keyword_do_else)=3;while(0);
+	if(cond)(if_expr)();
+	while(cond)(while_expr)();
+	for(;;)(for_exprs)();
+	(stmt);
+	(stmt_list);
+	if(cond);else(keyword_else)();
+	do(keyword_do);while(0);
+	// The following line Would generate 'Statement nesting error'.
+	// do stmt;(do_stmt());while(0);
+	if(cond)stmt;(if_expr_stmt)();
+	if(cond)stmt;else(if_expr_stmt_else());
+	str.(member);		/* syntax error */
+	L("string_prefix");
+	static (int)storage_class;	/* syntax error */
+	funcname(3);
+	typedef (type_def) new_type;
+	struct (keyword_struct_union_enum);	/* syntax error */
+}
+#indent end
+
+#indent run -ldi0
+void
+cover_want_blank_before_lparen(void)
+{
+	int newline = (3
+	);
+	int lparen_or_lbracket = a[(3)];
+	int rparen_or_rbracket = a[3](5);
+	+(unary_op);
+	(3) + (binary_op);
+	a++ (postfix_op);	/* unlikely to be seen in practice */
+	cond ? (question) : (5);
+	switch (expr) {
+	case (case_label):;
+	}
+	a ? (3) : (colon);
+	;
+	(semicolon) = 3;
+	int lbrace[] = {(3)};
+	int rbrace_in_decl = {{3} (4)};	/* syntax error */
+	{
+	}
+	(rbrace_in_stmt)();
+	int ident = func(3);
+	int ident = int (3);	/* syntax error in C, OK in C++ */
+	int comma = func(a, (3));
+	int comment = /* comment */ (3);
+	switch (expr) {
+	}
+#define preprocessing
+	(preprocessing)();
+
+	(form_feed)();
+	int (*decl)(void);
+	for (;;);
+	do
+		(keyword_do_else) = 3;
+	while (0);
+	if (cond)
+		(if_expr)();
+	while (cond)
+		(while_expr)();
+	for (;;)
+		(for_exprs)();
+	(stmt);
+	(stmt_list);
+	if (cond);
+	else
+		(keyword_else)();
+	do
+		(keyword_do);
+	while (0);
+	// The following line Would generate 'Statement nesting error'.
+	// do stmt;(do_stmt());while(0);
+	if (cond)
+		stmt;
+	(if_expr_stmt)();
+	if (cond)
+		stmt;
+	else
+		(if_expr_stmt_else());
+	str.(member);		/* syntax error */
+	L("string_prefix");
+	static (int)storage_class;	/* syntax error */
+	funcname(3);
+	typedef (type_def) new_type;
+	struct (keyword_struct_union_enum);	/* syntax error */
+}
+#indent end



CVS commit: src/tests/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 15:44:13 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token_lparen.c

Log Message:
tests/indent: test want_blank_before_lparen


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/token_lparen.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2021-10-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 24 11:58:23 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
More SPCR cleanup:

 - For 16550 style UARTs, always honour GAS if BitWidth != 0
 - Use BitWidth instead of AccessWidth to determine register stride
 - For baud rate ID of 0, assume 115200 until we have a way of probing
   the baud rate configured by firmware.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/arm/acpi/acpi_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2021-10-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 24 11:58:23 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
More SPCR cleanup:

 - For 16550 style UARTs, always honour GAS if BitWidth != 0
 - Use BitWidth instead of AccessWidth to determine register stride
 - For baud rate ID of 0, assume 115200 until we have a way of probing
   the baud rate configured by firmware.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/arm/acpi/acpi_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_platform.c
diff -u src/sys/arch/arm/acpi/acpi_platform.c:1.31 src/sys/arch/arm/acpi/acpi_platform.c:1.32
--- src/sys/arch/arm/acpi/acpi_platform.c:1.31	Sat Oct 23 17:45:55 2021
+++ src/sys/arch/arm/acpi/acpi_platform.c	Sun Oct 24 11:58:23 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_platform.c,v 1.31 2021/10/23 17:45:55 jmcneill Exp $ */
+/* $NetBSD: acpi_platform.c,v 1.32 2021/10/24 11:58:23 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.31 2021/10/23 17:45:55 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.32 2021/10/24 11:58:23 jmcneill Exp $");
 
 #include 
 #include 
@@ -95,7 +95,20 @@ static const struct acpi_spcr_baud_rate 
 	uint8_t		id;
 	int		baud_rate;
 } acpi_spcr_baud_rates[] = {
-	{ SPCR_BAUD_DEFAULT,	-1 },
+	/*
+	 * SPCR_BAUD_DEFAULT means:
+	 *   "As is, operating system relies on the current configuration
+	 *of serial port until the full featured driver will be
+	 *initialized."
+	 *
+	 * We don't currently have a good way of telling the UART driver
+	 * to detect the currently configured baud rate, so just pick
+	 * something sensible here.
+	 *
+	 * In the past we have tried baud_rate values of 0 and -1, but
+	 * these cause problems with the com(4) driver.
+	 */
+	{ SPCR_BAUD_DEFAULT,	115200 },
 	{ SPCR_BAUD_9600,	9600 },
 	{ SPCR_BAUD_19200,	19200 },
 	{ SPCR_BAUD_57600,	57600 },
@@ -192,16 +205,27 @@ acpi_platform_attach_uart(ACPI_TABLE_SPC
 	case ACPI_DBG2_16550_SUBSET:
 	case ACPI_DBG2_16550_GAS:
 		memset(&dummy_bsh, 0, sizeof(dummy_bsh));
-		if (spcr->InterfaceType == ACPI_DBG2_16550_COMPATIBLE) {
+		switch (spcr->SerialPort.BitWidth) {
+		case 8:
 			reg_shift = 0;
-		} else if (spcr->InterfaceType == ACPI_DBG2_16550_SUBSET) {
+			break;
+		case 16:
+			reg_shift = 1;
+			break;
+		case 32:
 			reg_shift = 2;
-		} else {
-			if (ACPI_ACCESS_BIT_WIDTH(spcr->SerialPort.AccessWidth) == 8) {
+			break;
+		default:
+			/*
+			 * Bit width 0 is possible for types 0 and 1. Otherwise,
+			 * possibly buggy firmware.
+			 */
+			if (spcr->InterfaceType == ACPI_DBG2_16550_COMPATIBLE) {
 reg_shift = 0;
 			} else {
 reg_shift = 2;
 			}
+			break;
 		}
 		com_init_regs_stride(®s, &arm_generic_bs_tag, dummy_bsh,
 		le64toh(spcr->SerialPort.Address), reg_shift);



CVS commit: src/tests/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 11:42:58 UTC 2021

Modified Files:
src/tests/usr.bin/indent: opt_bs.c opt_pcs.c

Log Message:
tests/indent: test interaction between -pcs and -bs


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/opt_bs.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/opt_pcs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/indent/opt_bs.c
diff -u src/tests/usr.bin/indent/opt_bs.c:1.3 src/tests/usr.bin/indent/opt_bs.c:1.4
--- src/tests/usr.bin/indent/opt_bs.c:1.3	Sat Oct 16 21:32:10 2021
+++ src/tests/usr.bin/indent/opt_bs.c	Sun Oct 24 11:42:57 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_bs.c,v 1.3 2021/10/16 21:32:10 rillig Exp $ */
+/* $NetBSD: opt_bs.c,v 1.4 2021/10/24 11:42:57 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -60,3 +60,40 @@ example(int i)
 	print(sizeof(int));
 }
 #indent end
+
+/*
+ * The option '-bs' only affects 'sizeof', not 'offsetof', even though these
+ * two keywords are syntactically similar.
+ */
+#indent input
+int sizeof_type = sizeof   (int);
+int sizeof_type = sizeof(int);
+int sizeof_expr = sizeof   (0);
+int sizeof_expr = sizeof(0);
+int sizeof_expr = sizeof   0;
+
+int offset = offsetof(struct s, member);
+int offset = offsetof   (struct s, member);
+#indent end
+
+#indent run -pcs -di0
+int sizeof_type = sizeof (int);
+int sizeof_type = sizeof (int);
+int sizeof_expr = sizeof (0);
+int sizeof_expr = sizeof (0);
+int sizeof_expr = sizeof 0;
+
+int offset = offsetof (struct s, member);
+int offset = offsetof (struct s, member);
+#indent end
+
+#indent run -npcs -di0
+int sizeof_type = sizeof(int);
+int sizeof_type = sizeof(int);
+int sizeof_expr = sizeof(0);
+int sizeof_expr = sizeof(0);
+int sizeof_expr = sizeof 0;
+
+int offset = offsetof(struct s, member);
+int offset = offsetof(struct s, member);
+#indent end

Index: src/tests/usr.bin/indent/opt_pcs.c
diff -u src/tests/usr.bin/indent/opt_pcs.c:1.4 src/tests/usr.bin/indent/opt_pcs.c:1.5
--- src/tests/usr.bin/indent/opt_pcs.c:1.4	Sun Oct 24 11:31:37 2021
+++ src/tests/usr.bin/indent/opt_pcs.c	Sun Oct 24 11:42:57 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_pcs.c,v 1.4 2021/10/24 11:31:37 rillig Exp $ */
+/* $NetBSD: opt_pcs.c,v 1.5 2021/10/24 11:42:57 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -56,7 +56,8 @@ int offset = offsetof(struct s, member);
 int offset = offsetof   (struct s, member);
 #indent end
 
-#indent run -pcs -di0
+/* The option '-pcs' overrides '-nbs'. */
+#indent run -pcs -di0 -nbs
 int sizeof_type = sizeof (int);
 int sizeof_type = sizeof (int);
 int sizeof_expr = sizeof (0);
@@ -67,6 +68,21 @@ int offset = offsetof (struct s, member)
 int offset = offsetof (struct s, member);
 #indent end
 
+/*
+ * If the option '-npcs' is given, '-bs' can still specialize it. This only
+ * applies to 'sizeof', but not 'offsetof'.
+ */
+#indent run -npcs -di0 -bs
+int sizeof_type = sizeof (int);
+int sizeof_type = sizeof (int);
+int sizeof_expr = sizeof (0);
+int sizeof_expr = sizeof (0);
+int sizeof_expr = sizeof 0;
+
+int offset = offsetof(struct s, member);
+int offset = offsetof(struct s, member);
+#indent end
+
 #indent run -npcs -di0
 int sizeof_type = sizeof(int);
 int sizeof_type = sizeof(int);



CVS commit: src/tests/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 11:42:58 UTC 2021

Modified Files:
src/tests/usr.bin/indent: opt_bs.c opt_pcs.c

Log Message:
tests/indent: test interaction between -pcs and -bs


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/opt_bs.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/opt_pcs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/tests/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 11:31:37 UTC 2021

Modified Files:
src/tests/usr.bin/indent: opt_pcs.c

Log Message:
tests/indent: add test for sizeof and offsetof with -pcs


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/opt_pcs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/usr.bin/indent/opt_pcs.c
diff -u src/tests/usr.bin/indent/opt_pcs.c:1.3 src/tests/usr.bin/indent/opt_pcs.c:1.4
--- src/tests/usr.bin/indent/opt_pcs.c:1.3	Sat Oct 16 21:32:10 2021
+++ src/tests/usr.bin/indent/opt_pcs.c	Sun Oct 24 11:31:37 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_pcs.c,v 1.3 2021/10/16 21:32:10 rillig Exp $ */
+/* $NetBSD: opt_pcs.c,v 1.4 2021/10/24 11:31:37 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -40,3 +40,40 @@ example(void)
 	function_call(1, 2, 3);
 }
 #indent end
+
+/*
+ * The option '-pcs' also applies to 'sizeof' and 'offsetof', even though
+ * these are not functions.
+ */
+#indent input
+int sizeof_type = sizeof   (int);
+int sizeof_type = sizeof(int);
+int sizeof_expr = sizeof   (0);
+int sizeof_expr = sizeof(0);
+int sizeof_expr = sizeof   0;
+
+int offset = offsetof(struct s, member);
+int offset = offsetof   (struct s, member);
+#indent end
+
+#indent run -pcs -di0
+int sizeof_type = sizeof (int);
+int sizeof_type = sizeof (int);
+int sizeof_expr = sizeof (0);
+int sizeof_expr = sizeof (0);
+int sizeof_expr = sizeof 0;
+
+int offset = offsetof (struct s, member);
+int offset = offsetof (struct s, member);
+#indent end
+
+#indent run -npcs -di0
+int sizeof_type = sizeof(int);
+int sizeof_type = sizeof(int);
+int sizeof_expr = sizeof(0);
+int sizeof_expr = sizeof(0);
+int sizeof_expr = sizeof 0;
+
+int offset = offsetof(struct s, member);
+int offset = offsetof(struct s, member);
+#indent end



CVS commit: src/tests/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 11:31:37 UTC 2021

Modified Files:
src/tests/usr.bin/indent: opt_pcs.c

Log Message:
tests/indent: add test for sizeof and offsetof with -pcs


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/opt_pcs.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

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 11:19:25 UTC 2021

Modified Files:
src/usr.bin/indent: args.c indent.c indent.h lexi.c

Log Message:
indent: rename nitems to array_length


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/usr.bin/indent/args.c
cvs rdiff -u -r1.145 -r1.146 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.44 -r1.45 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.93 -r1.94 src/usr.bin/indent/lexi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/indent/args.c
diff -u src/usr.bin/indent/args.c:1.57 src/usr.bin/indent/args.c:1.58
--- src/usr.bin/indent/args.c:1.57	Sun Oct 24 10:54:12 2021
+++ src/usr.bin/indent/args.c	Sun Oct 24 11:19:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: args.c,v 1.57 2021/10/24 10:54:12 rillig Exp $	*/
+/*	$NetBSD: args.c,v 1.58 2021/10/24 11:19:25 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)args.c	8.1 (
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: args.c,v 1.57 2021/10/24 10:54:12 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.58 2021/10/24 11:19:25 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/args.c 336318 2018-07-15 21:04:21Z pstef $");
 #endif
@@ -160,7 +160,7 @@ load_profile(const char *fname, bool mus
 		comment_ch = ch == '/' && comment_ch == '*' ? -1 : ch;
 	} else if (isspace((unsigned char)ch)) {
 		break;
-	} else if (n >= nitems(buf) - 5) {
+	} else if (n >= array_length(buf) - 5) {
 		diag(1, "buffer overflow in %s, starting with '%.10s'",
 		 fname, buf);
 		exit(1);
@@ -286,7 +286,7 @@ set_option(const char *arg, const char *
 if (set_special_option(arg, option_source))
 	return;
 
-for (p = pro + nitems(pro); p-- != pro;) {
+for (p = pro + array_length(pro); p-- != pro;) {
 	param_start = skip_over(arg, p->p_may_negate, p->p_name);
 	if (param_start != NULL)
 	goto found;

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.145 src/usr.bin/indent/indent.c:1.146
--- src/usr.bin/indent/indent.c:1.145	Sun Oct 24 11:17:05 2021
+++ src/usr.bin/indent/indent.c	Sun Oct 24 11:19:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.145 2021/10/24 11:17:05 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.146 2021/10/24 11:19:25 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.145 2021/10/24 11:17:05 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.146 2021/10/24 11:19:25 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -700,9 +700,9 @@ want_blank_before_lparen(void)
 static void
 process_lparen_or_lbracket(int decl_ind, bool tabs_to_var, bool sp_sw)
 {
-if (++ps.p_l_follow == nitems(ps.paren_indents)) {
+if (++ps.p_l_follow == array_length(ps.paren_indents)) {
 	diag(0, "Reached internal limit of %zu unclosed parens",
-	nitems(ps.paren_indents));
+	array_length(ps.paren_indents));
 	ps.p_l_follow--;
 }
 
@@ -1266,7 +1266,7 @@ process_preprocessing(void)
 ps.is_case_label = false;
 
 if (strncmp(lab.s, "#if", 3) == 0) {	/* also ifdef, ifndef */
-	if ((size_t)ifdef_level < nitems(state_stack))
+	if ((size_t)ifdef_level < array_length(state_stack))
 	state_stack[ifdef_level++] = ps;
 	else
 	diag(1, "#if stack overflow");
@@ -1411,7 +1411,7 @@ main_loop(void)
 
 	case lbrace:
 	process_lbrace(&force_nl, &sp_sw, hd_type, di_stack,
-		(int)nitems(di_stack), &decl_ind);
+		(int)array_length(di_stack), &decl_ind);
 	break;
 
 	case rbrace:

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.44 src/usr.bin/indent/indent.h:1.45
--- src/usr.bin/indent/indent.h:1.44	Sun Oct 24 11:17:05 2021
+++ src/usr.bin/indent/indent.h	Sun Oct 24 11:19:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.44 2021/10/24 11:17:05 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.45 2021/10/24 11:19:25 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -325,9 +325,7 @@ extern struct parser_state {
 }ps;
 
 
-#ifndef nitems
-#define nitems(array) (sizeof (array) / sizeof (array[0]))
-#endif
+#define array_length(array) (sizeof (array) / sizeof (array[0]))
 
 void add_typename(const char *);
 int compute_code_indent(void);

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.93 src/usr.bin/indent/lexi.c:1.94
--- src/usr.bin/indent/lexi.c:1.93	Sun Oct 24 10:54:12 2021
+++ src/usr.bin/indent/lexi.c	Sun Oct 24 11:19:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.93 2021/10/24 10:54:12 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.94 2021/10/24 11:19:25 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[]

CVS commit: src/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 11:19:25 UTC 2021

Modified Files:
src/usr.bin/indent: args.c indent.c indent.h lexi.c

Log Message:
indent: rename nitems to array_length


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/usr.bin/indent/args.c
cvs rdiff -u -r1.145 -r1.146 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.44 -r1.45 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.93 -r1.94 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

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 11:17:05 UTC 2021

Modified Files:
src/usr.bin/indent: indent.c indent.h io.c pr_comment.c

Log Message:
indent: replace global variable use_ff with function parameter


To generate a diff of this commit:
cvs rdiff -u -r1.144 -r1.145 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.43 -r1.44 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.100 -r1.101 src/usr.bin/indent/io.c
cvs rdiff -u -r1.81 -r1.82 src/usr.bin/indent/pr_comment.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.144 src/usr.bin/indent/indent.c:1.145
--- src/usr.bin/indent/indent.c:1.144	Wed Oct 20 05:37:21 2021
+++ src/usr.bin/indent/indent.c	Sun Oct 24 11:17:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.144 2021/10/20 05:37:21 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.145 2021/10/24 11:17:05 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.144 2021/10/20 05:37:21 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.145 2021/10/24 11:17:05 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -662,8 +662,7 @@ process_comment_in_code(token_type ttype
 static void
 process_form_feed(void)
 {
-ps.use_ff = true;
-dump_line();
+dump_line_ff();
 ps.want_blank = false;
 }
 

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.43 src/usr.bin/indent/indent.h:1.44
--- src/usr.bin/indent/indent.h:1.43	Wed Oct 20 05:41:57 2021
+++ src/usr.bin/indent/indent.h	Sun Oct 24 11:17:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.43 2021/10/20 05:41:57 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.44 2021/10/24 11:17:05 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -307,8 +307,6 @@ extern struct parser_state {
 bool search_brace;		/* whether it is necessary to buffer up all
  * info up to the start of a stmt after an if,
  * while, etc */
-bool use_ff;		/* whether the current line should be
- * terminated with a form feed */
 bool want_blank;		/* whether the following token should be
  * prefixed by a blank. (Said prefixing is
  * ignored in some cases.) */
@@ -353,6 +351,7 @@ char inbuf_next(void);
 token_type lexi(struct parser_state *);
 void diag(int, const char *, ...)__printflike(2, 3);
 void dump_line(void);
+void dump_line_ff(void);
 void inbuf_read_line(void);
 void parse(token_type);
 void process_comment(void);

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.100 src/usr.bin/indent/io.c:1.101
--- src/usr.bin/indent/io.c:1.100	Sun Oct 24 10:54:12 2021
+++ src/usr.bin/indent/io.c	Sun Oct 24 11:17:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.100 2021/10/24 10:54:12 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.101 2021/10/24 11:17:05 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.100 2021/10/24 10:54:12 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.101 2021/10/24 11:17:05 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -207,8 +207,8 @@ dump_line_comment(int ind)
  * Write a line of formatted source to the output file. The line consists of a
  * label, the code and the comment.
  */
-void
-dump_line(void)
+static void
+output_line(char line_terminator)
 {
 static bool first_line = true;
 
@@ -254,10 +254,7 @@ dump_line(void)
 	if (com.e != com.s)
 	dump_line_comment(ind);
 
-	if (ps.use_ff)
-	output_char('\f');
-	else
-	output_char('\n');
+	output_char(line_terminator);
 	ps.stats.lines++;
 
 	if (ps.just_saw_decl == 1 && opt.blanklines_after_decl) {
@@ -270,7 +267,6 @@ dump_line(void)
 
 ps.decl_on_line = ps.in_decl;	/* for proper comment indentation */
 ps.ind_stmt = ps.in_stmt && !ps.in_decl;
-ps.use_ff = false;
 ps.dumped_decl_indent = false;
 
 *(lab.e = lab.s) = '\0';	/* reset buffers */
@@ -289,6 +285,18 @@ dump_line(void)
 first_line = false;
 }
 
+void
+dump_line(void)
+{
+output_line('\n');
+}
+
+void
+dump_line_ff(void)
+{
+output_line('\f');
+}
+
 int
 compute_code_indent(void)
 {

Index: src/usr.bin/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.81 src/usr.bin/indent/pr_comment.c:1.82
--- src/usr.bin/indent/pr_comment.c:1.81	Sun Oct 24 11:08:46 2021
+++ src/usr.bin/indent/pr_comment.c	Sun Oct 24 11:17:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.81 2021/10/24 11:08:46 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.82 2021/10/24 11:17:05 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identif

CVS commit: src/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 11:17:05 UTC 2021

Modified Files:
src/usr.bin/indent: indent.c indent.h io.c pr_comment.c

Log Message:
indent: replace global variable use_ff with function parameter


To generate a diff of this commit:
cvs rdiff -u -r1.144 -r1.145 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.43 -r1.44 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.100 -r1.101 src/usr.bin/indent/io.c
cvs rdiff -u -r1.81 -r1.82 src/usr.bin/indent/pr_comment.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 11:08:46 UTC 2021

Modified Files:
src/usr.bin/indent: pr_comment.c

Log Message:
indent: clean up comments


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/usr.bin/indent/pr_comment.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.80 src/usr.bin/indent/pr_comment.c:1.81
--- src/usr.bin/indent/pr_comment.c:1.80	Wed Oct 20 05:14:21 2021
+++ src/usr.bin/indent/pr_comment.c	Sun Oct 24 11:08:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.80 2021/10/20 05:14:21 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.81 2021/10/24 11:08:46 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)pr_comment.c
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: pr_comment.c,v 1.80 2021/10/20 05:14:21 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.81 2021/10/24 11:08:46 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -219,11 +219,10 @@ process_comment(void)
 	com_add_delim();
 }
 
-/* Start to copy the comment */
+/* Now copy the comment. */
 
-for (;;) {			/* this loop will go until the comment is
- * copied */
-	switch (*inp.s) {	/* this checks for various special cases */
+for (;;) {
+	switch (*inp.s) {
 	case '\f':
 	if (may_wrap) {	/* in a text comment, break the line here */
 		ps.use_ff = true;



CVS commit: src/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 11:08:46 UTC 2021

Modified Files:
src/usr.bin/indent: pr_comment.c

Log Message:
indent: clean up comments


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/usr.bin/indent/pr_comment.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 10:54:12 UTC 2021

Modified Files:
src/usr.bin/indent: args.c io.c lexi.c

Log Message:
indent: sort includes


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/usr.bin/indent/args.c
cvs rdiff -u -r1.99 -r1.100 src/usr.bin/indent/io.c
cvs rdiff -u -r1.92 -r1.93 src/usr.bin/indent/lexi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/indent/args.c
diff -u src/usr.bin/indent/args.c:1.56 src/usr.bin/indent/args.c:1.57
--- src/usr.bin/indent/args.c:1.56	Sun Oct 17 18:13:00 2021
+++ src/usr.bin/indent/args.c	Sun Oct 24 10:54:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: args.c,v 1.56 2021/10/17 18:13:00 rillig Exp $	*/
+/*	$NetBSD: args.c,v 1.57 2021/10/24 10:54:12 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)args.c	8.1 (
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: args.c,v 1.56 2021/10/17 18:13:00 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.57 2021/10/24 10:54:12 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/args.c 336318 2018-07-15 21:04:21Z pstef $");
 #endif
@@ -52,11 +52,11 @@ __FBSDID("$FreeBSD: head/usr.bin/indent/
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 
 #include "indent.h"
 

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.99 src/usr.bin/indent/io.c:1.100
--- src/usr.bin/indent/io.c:1.99	Wed Oct 20 05:14:21 2021
+++ src/usr.bin/indent/io.c	Sun Oct 24 10:54:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.99 2021/10/20 05:14:21 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.100 2021/10/24 10:54:12 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,15 +43,15 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.99 2021/10/20 05:14:21 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.100 2021/10/24 10:54:12 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
 
 #include 
+#include 
 #include 
 #include 
-#include 
 
 #include "indent.h"
 

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.92 src/usr.bin/indent/lexi.c:1.93
--- src/usr.bin/indent/lexi.c:1.92	Wed Oct 20 05:37:21 2021
+++ src/usr.bin/indent/lexi.c	Sun Oct 24 10:54:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.92 2021/10/20 05:37:21 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.93 2021/10/24 10:54:12 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,17 +43,17 @@ static char sccsid[] = "@(#)lexi.c	8.1 (
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.92 2021/10/20 05:37:21 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.93 2021/10/24 10:54:12 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
 
 #include "indent.h"
 



CVS commit: src/usr.bin/indent

2021-10-24 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Oct 24 10:54:12 UTC 2021

Modified Files:
src/usr.bin/indent: args.c io.c lexi.c

Log Message:
indent: sort includes


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/usr.bin/indent/args.c
cvs rdiff -u -r1.99 -r1.100 src/usr.bin/indent/io.c
cvs rdiff -u -r1.92 -r1.93 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: [netbsd-9] src/doc

2021-10-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 24 10:19:01 UTC 2021

Modified Files:
src/doc [netbsd-9]: CHANGES-9.3

Log Message:
Tickets #1365 - #1367


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.41 -r1.1.2.42 src/doc/CHANGES-9.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/doc/CHANGES-9.3
diff -u src/doc/CHANGES-9.3:1.1.2.41 src/doc/CHANGES-9.3:1.1.2.42
--- src/doc/CHANGES-9.3:1.1.2.41	Sat Oct 23 11:23:05 2021
+++ src/doc/CHANGES-9.3	Sun Oct 24 10:19:01 2021
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.3,v 1.1.2.41 2021/10/23 11:23:05 martin Exp $
+# $NetBSD: CHANGES-9.3,v 1.1.2.42 2021/10/24 10:19:01 martin Exp $
 
 A complete list of changes from the NetBSD 9.2 release to the NetBSD 9.3
 release:
@@ -889,3 +889,19 @@ sys/dev/usb/usbdevs_data.h			(regen)
 	urtwn(4): add Edimax N150 adapter.
 	[jnemeth, ticket #1364]
 
+usr.bin/ftp/fetch.c1.233
+
+	ftp(1): use raw write(2) instead of fwrite(3) to avoid stream
+	corruption because of the progress bar interrupts.
+	[lukem, ticket #1365]
+
+usr.bin/ftp/ftp.c1.173
+
+	ftp(1): validate address from PASV and LPSV response.
+	[lukem, ticket #1366]
+
+usr.bin/ftp/ftp.c1.174
+
+	ftp(1): cleanup after previous security fix.
+	[lukem, ticket #1367]
+



CVS commit: [netbsd-9] src/doc

2021-10-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 24 10:19:01 UTC 2021

Modified Files:
src/doc [netbsd-9]: CHANGES-9.3

Log Message:
Tickets #1365 - #1367


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.41 -r1.1.2.42 src/doc/CHANGES-9.3

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/usr.bin/ftp

2021-10-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 24 10:18:02 UTC 2021

Modified Files:
src/usr.bin/ftp [netbsd-9]: ftp.c

Log Message:
Pull up following revision(s) (requested by lukem in ticket #1367):

usr.bin/ftp/ftp.c: revision 1.174

ftp: remove unnecessary variable assignments

Remove assignment to error in initconn(); it's not tested anywhere after the
initial use, so no need to set it before goto bad.
(Looks like copypasta from the initial addition of the code in rev 1.48.)


To generate a diff of this commit:
cvs rdiff -u -r1.168.2.5 -r1.168.2.6 src/usr.bin/ftp/ftp.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/ftp/ftp.c
diff -u src/usr.bin/ftp/ftp.c:1.168.2.5 src/usr.bin/ftp/ftp.c:1.168.2.6
--- src/usr.bin/ftp/ftp.c:1.168.2.5	Sun Oct 24 10:16:05 2021
+++ src/usr.bin/ftp/ftp.c	Sun Oct 24 10:18:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ftp.c,v 1.168.2.5 2021/10/24 10:16:05 martin Exp $	*/
+/*	$NetBSD: ftp.c,v 1.168.2.6 2021/10/24 10:18:02 martin Exp $	*/
 
 /*-
  * Copyright (c) 1996-2021 The NetBSD Foundation, Inc.
@@ -92,7 +92,7 @@
 #if 0
 static char sccsid[] = "@(#)ftp.c	8.6 (Berkeley) 10/27/94";
 #else
-__RCSID("$NetBSD: ftp.c,v 1.168.2.5 2021/10/24 10:16:05 martin Exp $");
+__RCSID("$NetBSD: ftp.c,v 1.168.2.6 2021/10/24 10:18:02 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -1381,13 +1381,11 @@ initconn(void)
 			if (data_addr.su_family != AF_INET) {
 fputs(
 "Passive mode AF mismatch. Shouldn't happen!\n", ttyout);
-error = 1;
 goto bad;
 			}
 			if (code / 10 == 22 && code != 227) {
 fputs("wrong server: return code must be 227\n",
 	ttyout);
-error = 1;
 goto bad;
 			}
 			error = sscanf(pasv, "%u,%u,%u,%u,%u,%u",
@@ -1396,10 +1394,8 @@ initconn(void)
 			if (error != 6) {
 fputs(
 "Passive mode address scan failure. Shouldn't happen!\n", ttyout);
-error = 1;
 goto bad;
 			}
-			error = 0;
 			memset(&data_addr, 0, sizeof(data_addr));
 			data_addr.su_family = AF_INET;
 			data_addr.su_len = sizeof(struct sockaddr_in);
@@ -1416,7 +1412,6 @@ initconn(void)
 			if (code / 10 == 22 && code != 228) {
 fputs("wrong server: return code must be 228\n",
 	ttyout);
-error = 1;
 goto bad;
 			}
 			switch (data_addr.su_family) {
@@ -1429,17 +1424,14 @@ initconn(void)
 if (error != 9) {
 	fputs(
 "Passive mode address scan failure. Shouldn't happen!\n", ttyout);
-	error = 1;
 	goto bad;
 }
 if (af != 4 || hal != 4 || pal != 2) {
 	fputs(
 "Passive mode AF mismatch. Shouldn't happen!\n", ttyout);
-	error = 1;
 	goto bad;
 }
 
-error = 0;
 memset(&data_addr, 0, sizeof(data_addr));
 data_addr.su_family = AF_INET;
 data_addr.su_len = sizeof(struct sockaddr_in);
@@ -1467,17 +1459,14 @@ initconn(void)
 if (error != 21) {
 	fputs(
 "Passive mode address scan failure. Shouldn't happen!\n", ttyout);
-	error = 1;
 	goto bad;
 }
 if (af != 6 || hal != 16 || pal != 2) {
 	fputs(
 "Passive mode AF mismatch. Shouldn't happen!\n", ttyout);
-	error = 1;
 	goto bad;
 }
 
-error = 0;
 memset(&data_addr, 0, sizeof(data_addr));
 data_addr.su_family = AF_INET6;
 data_addr.su_len = sizeof(struct sockaddr_in6);
@@ -1500,7 +1489,8 @@ initconn(void)
 break;
 #endif
 			default:
-error = 1;
+fputs("Unknown passive mode AF.\n", ttyout);
+goto bad;
 			}
 		} else if (strcmp(pasvcmd, "EPSV") == 0) {
 			char delim[4];
@@ -1509,20 +1499,17 @@ initconn(void)
 			if (code / 10 == 22 && code != 229) {
 fputs("wrong server: return code must be 229\n",
 	ttyout);
-error = 1;
 goto bad;
 			}
 			if (sscanf(pasv, "%c%c%c%d%c", &delim[0],
 	&delim[1], &delim[2], &port[1],
 	&delim[3]) != 5) {
 fputs("parse error!\n", ttyout);
-error = 1;
 goto bad;
 			}
 			if (delim[0] != delim[1] || delim[0] != delim[2]
 			 || delim[0] != delim[3]) {
 fputs("parse error!\n", ttyout);
-error = 1;
 goto bad;
 			}
 			data_addr = hisctladdr;



CVS commit: [netbsd-9] src/usr.bin/ftp

2021-10-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 24 10:18:02 UTC 2021

Modified Files:
src/usr.bin/ftp [netbsd-9]: ftp.c

Log Message:
Pull up following revision(s) (requested by lukem in ticket #1367):

usr.bin/ftp/ftp.c: revision 1.174

ftp: remove unnecessary variable assignments

Remove assignment to error in initconn(); it's not tested anywhere after the
initial use, so no need to set it before goto bad.
(Looks like copypasta from the initial addition of the code in rev 1.48.)


To generate a diff of this commit:
cvs rdiff -u -r1.168.2.5 -r1.168.2.6 src/usr.bin/ftp/ftp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/usr.bin/ftp

2021-10-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 24 10:16:05 UTC 2021

Modified Files:
src/usr.bin/ftp [netbsd-9]: ftp.c

Log Message:
Pull up following revision(s) (requested by lukem in ticket #1366):

usr.bin/ftp/ftp.c: revision 1.173

ftp: validate address from PASV and LPSV response

Fail if the server's response to PASV or LPSV contains an IP address
that doesn't match that of the control connection.
(EPSV already only uses the port portion of the server's response,
per RFC 2428).

Previously a hostile server could cause ftp to open a data connection elsewhere.
Many other ftp implementations have had a similar change for many years,
including those in popular browsers (before they deprecated FTP ...)

Thanks to Simon Josefsson notifying me about
  https://lists.gnu.org/archive/html/bug-inetutils/2021-06/msg2.html


To generate a diff of this commit:
cvs rdiff -u -r1.168.2.4 -r1.168.2.5 src/usr.bin/ftp/ftp.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/ftp/ftp.c
diff -u src/usr.bin/ftp/ftp.c:1.168.2.4 src/usr.bin/ftp/ftp.c:1.168.2.5
--- src/usr.bin/ftp/ftp.c:1.168.2.4	Mon Jun 14 11:45:48 2021
+++ src/usr.bin/ftp/ftp.c	Sun Oct 24 10:16:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ftp.c,v 1.168.2.4 2021/06/14 11:45:48 martin Exp $	*/
+/*	$NetBSD: ftp.c,v 1.168.2.5 2021/10/24 10:16:05 martin Exp $	*/
 
 /*-
  * Copyright (c) 1996-2021 The NetBSD Foundation, Inc.
@@ -92,7 +92,7 @@
 #if 0
 static char sccsid[] = "@(#)ftp.c	8.6 (Berkeley) 10/27/94";
 #else
-__RCSID("$NetBSD: ftp.c,v 1.168.2.4 2021/06/14 11:45:48 martin Exp $");
+__RCSID("$NetBSD: ftp.c,v 1.168.2.5 2021/10/24 10:16:05 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -1406,6 +1406,12 @@ initconn(void)
 			data_addr.si_su.su_sin.sin_addr.s_addr =
 			htonl(pack4(addr, 0));
 			data_addr.su_port = htons(pack2(port, 0));
+			if (data_addr.si_su.su_sin.sin_addr.s_addr !=
+			hisctladdr.si_su.su_sin.sin_addr.s_addr) {
+fputs("Passive mode address mismatch.\n",
+ttyout);
+goto bad;
+			}
 		} else if (strcmp(pasvcmd, "LPSV") == 0) {
 			if (code / 10 == 22 && code != 228) {
 fputs("wrong server: return code must be 228\n",
@@ -1440,6 +1446,12 @@ initconn(void)
 data_addr.si_su.su_sin.sin_addr.s_addr =
 htonl(pack4(addr, 0));
 data_addr.su_port = htons(pack2(port, 0));
+if (data_addr.si_su.su_sin.sin_addr.s_addr !=
+hisctladdr.si_su.su_sin.sin_addr.s_addr) {
+	fputs("Passive mode address mismatch.\n",
+	ttyout);
+	goto bad;
+}
 break;
 #ifdef INET6
 			case AF_INET6:
@@ -1477,6 +1489,14 @@ initconn(void)
 }
 			}
 data_addr.su_port = htons(pack2(port, 0));
+if (memcmp(
+&data_addr.si_su.su_sin6.sin6_addr,
+&hisctladdr.si_su.su_sin6.sin6_addr,
+sizeof(data_addr.si_su.su_sin6.sin6_addr))) {
+	fputs("Passive mode address mismatch.\n",
+	ttyout);
+	goto bad;
+}
 break;
 #endif
 			default:



CVS commit: [netbsd-9] src/usr.bin/ftp

2021-10-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 24 10:16:05 UTC 2021

Modified Files:
src/usr.bin/ftp [netbsd-9]: ftp.c

Log Message:
Pull up following revision(s) (requested by lukem in ticket #1366):

usr.bin/ftp/ftp.c: revision 1.173

ftp: validate address from PASV and LPSV response

Fail if the server's response to PASV or LPSV contains an IP address
that doesn't match that of the control connection.
(EPSV already only uses the port portion of the server's response,
per RFC 2428).

Previously a hostile server could cause ftp to open a data connection elsewhere.
Many other ftp implementations have had a similar change for many years,
including those in popular browsers (before they deprecated FTP ...)

Thanks to Simon Josefsson notifying me about
  https://lists.gnu.org/archive/html/bug-inetutils/2021-06/msg2.html


To generate a diff of this commit:
cvs rdiff -u -r1.168.2.4 -r1.168.2.5 src/usr.bin/ftp/ftp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: [netbsd-9] src/usr.bin/ftp

2021-10-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 24 10:13:40 UTC 2021

Modified Files:
src/usr.bin/ftp [netbsd-9]: fetch.c

Log Message:
Pull up following revision(s) (requested by lukem in ticket #1365):

usr.bin/ftp/fetch.c: revision 1.233

Use raw write(2) instead of fwrite(3) to avoid stream corruption because
of the progress bar interrupts. From RVP.


To generate a diff of this commit:
cvs rdiff -u -r1.231.2.1 -r1.231.2.2 src/usr.bin/ftp/fetch.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/ftp/fetch.c
diff -u src/usr.bin/ftp/fetch.c:1.231.2.1 src/usr.bin/ftp/fetch.c:1.231.2.2
--- src/usr.bin/ftp/fetch.c:1.231.2.1	Mon Jun 14 11:34:20 2021
+++ src/usr.bin/ftp/fetch.c	Sun Oct 24 10:13:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: fetch.c,v 1.231.2.1 2021/06/14 11:34:20 martin Exp $	*/
+/*	$NetBSD: fetch.c,v 1.231.2.2 2021/10/24 10:13:40 martin Exp $	*/
 
 /*-
  * Copyright (c) 1997-2015 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: fetch.c,v 1.231.2.1 2021/06/14 11:34:20 martin Exp $");
+__RCSID("$NetBSD: fetch.c,v 1.231.2.2 2021/10/24 10:13:40 martin Exp $");
 #endif /* not lint */
 
 /*
@@ -138,6 +138,43 @@ static int	redirect_loop;
 	((urltype) == HTTP_URL_T)
 #endif
 
+/**
+ * fwrite(3) replacement that just uses write(2). Many stdio implementations
+ * don't handle interrupts properly and corrupt the output. We are taking
+ * alarm interrupts because of the progress bar.
+ *
+ * Assumes `fp' is pristine with no prior I/O calls on it.
+ */
+static size_t
+maxwrite(const void *buf, size_t size, size_t nmemb, FILE *fp)
+{
+	const char *p = buf;
+	ssize_t nwr = 0;
+	ssize_t n;
+	int fd = fileno(fp);
+
+	size *= nmemb;	/* assume no overflow */
+
+	while (size > 0) {
+		if ((n = write(fd, p, size)) == -1) {
+			switch (errno) {
+			case EINTR:
+			case EAGAIN:
+#if defined(EWOULDBLOCK) && EWOULDBLOCK != EAGAIN
+			case EWOULDBLOCK:
+#endif
+continue;
+			default:
+return nwr;
+			}
+		}
+		p += n;
+		nwr += n;
+		size -= n;
+	}
+	return nwr;
+}
+
 /*
  * Determine if token is the next word in buf (case insensitive).
  * If so, advance buf past the token and any trailing LWS, and
@@ -1650,7 +1687,7 @@ fetch_url(const char *url, const char *p
 }
 bytes += flen;
 bufrem -= flen;
-if (fwrite(xferbuf, sizeof(char), flen, fout)
+if (maxwrite(xferbuf, sizeof(char), flen, fout)
 != flen) {
 	warn("Writing `%s'", savefile);
 	goto cleanup_fetch_url;



CVS commit: [netbsd-9] src/usr.bin/ftp

2021-10-24 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Oct 24 10:13:40 UTC 2021

Modified Files:
src/usr.bin/ftp [netbsd-9]: fetch.c

Log Message:
Pull up following revision(s) (requested by lukem in ticket #1365):

usr.bin/ftp/fetch.c: revision 1.233

Use raw write(2) instead of fwrite(3) to avoid stream corruption because
of the progress bar interrupts. From RVP.


To generate a diff of this commit:
cvs rdiff -u -r1.231.2.1 -r1.231.2.2 src/usr.bin/ftp/fetch.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.