CVS commit: src/sys/uvm/pmap

2021-10-08 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Oct  8 07:17:32 UTC 2021

Modified Files:
src/sys/uvm/pmap: pmap_tlb.c

Log Message:
Fix a logic botch to actually apply the ASID limit returned by
pmap_md_tlb_asid_max.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/uvm/pmap/pmap_tlb.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/uvm/pmap/pmap_tlb.c
diff -u src/sys/uvm/pmap/pmap_tlb.c:1.46 src/sys/uvm/pmap/pmap_tlb.c:1.47
--- src/sys/uvm/pmap/pmap_tlb.c:1.46	Sat Oct  2 14:28:05 2021
+++ src/sys/uvm/pmap/pmap_tlb.c	Fri Oct  8 07:17:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap_tlb.c,v 1.46 2021/10/02 14:28:05 skrll Exp $	*/
+/*	$NetBSD: pmap_tlb.c,v 1.47 2021/10/08 07:17:32 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pmap_tlb.c,v 1.46 2021/10/02 14:28:05 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap_tlb.c,v 1.47 2021/10/08 07:17:32 skrll Exp $");
 
 /*
  * Manages address spaces in a TLB.
@@ -378,8 +378,9 @@ pmap_tlb_info_init(struct pmap_tlb_info 
 	kcpuset_set(ti->ti_kcpuset, cpu_index(curcpu()));
 #endif
 
-	if (ti->ti_asid_max == 0) {
-		ti->ti_asid_max = pmap_md_tlb_asid_max();
+	const tlb_asid_t asid_max = pmap_md_tlb_asid_max();
+	if (asid_max < ti->ti_asid_max) {
+		ti->ti_asid_max = asid_max;
 		ti->ti_asids_free = TLBINFO_ASID_INITIAL_FREE(ti->ti_asid_max);
 	}
 



CVS commit: src/sys/uvm/pmap

2021-10-08 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Fri Oct  8 07:17:32 UTC 2021

Modified Files:
src/sys/uvm/pmap: pmap_tlb.c

Log Message:
Fix a logic botch to actually apply the ASID limit returned by
pmap_md_tlb_asid_max.


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/uvm/pmap/pmap_tlb.c

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



CVS commit: src/bin/dd

2021-10-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct  8 14:44:49 UTC 2021

Modified Files:
src/bin/dd: dd_swab.c

Log Message:
PR/56443: RVP: dd conv=swab doesn't always work


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/bin/dd/dd_swab.c

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

Modified files:

Index: src/bin/dd/dd_swab.c
diff -u src/bin/dd/dd_swab.c:1.1 src/bin/dd/dd_swab.c:1.2
--- src/bin/dd/dd_swab.c:1.1	Fri Oct  4 04:57:38 2019
+++ src/bin/dd/dd_swab.c	Fri Oct  8 10:44:48 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: dd_swab.c,v 1.1 2019/10/04 08:57:38 mrg Exp $	*/
+/*	$NetBSD: dd_swab.c,v 1.2 2021/10/08 14:44:48 christos Exp $	*/
 
 /*
  * Copyright (c) 1988, 1993
@@ -41,7 +41,7 @@
 #if 0
 static char sccsid[] = "@(#)swab.c	8.1 (Berkeley) 6/4/93";
 #else
-__RCSID("$NetBSD: dd_swab.c,v 1.1 2019/10/04 08:57:38 mrg Exp $");
+__RCSID("$NetBSD: dd_swab.c,v 1.2 2021/10/08 14:44:48 christos Exp $");
 #endif
 #endif /* LIBC_SCCS and not lint */
 
@@ -71,7 +71,7 @@ dd_swab(const void * from, void * to, ss
 	}
 
 	/* round to multiple of 8 */
-	while ((--len % 8) != 0)
+	for (; (len % 8) != 0; --len)
 		STEP;
 	len /= 8;
 	if (len == 0)



CVS commit: src/bin/dd

2021-10-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct  8 14:44:49 UTC 2021

Modified Files:
src/bin/dd: dd_swab.c

Log Message:
PR/56443: RVP: dd conv=swab doesn't always work


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/bin/dd/dd_swab.c

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



CVS commit: src/tests/bin/dd

2021-10-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct  8 14:45:07 UTC 2021

Modified Files:
src/tests/bin/dd: t_dd.sh

Log Message:
Add swab tests from RVP.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/bin/dd/t_dd.sh

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



CVS commit: src/tests/bin/dd

2021-10-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Oct  8 14:45:07 UTC 2021

Modified Files:
src/tests/bin/dd: t_dd.sh

Log Message:
Add swab tests from RVP.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/bin/dd/t_dd.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/bin/dd/t_dd.sh
diff -u src/tests/bin/dd/t_dd.sh:1.1 src/tests/bin/dd/t_dd.sh:1.2
--- src/tests/bin/dd/t_dd.sh:1.1	Sat Mar 17 12:33:11 2012
+++ src/tests/bin/dd/t_dd.sh	Fri Oct  8 10:45:07 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_dd.sh,v 1.1 2012/03/17 16:33:11 jruoho Exp $
+# $NetBSD: t_dd.sh,v 1.2 2021/10/08 14:45:07 christos Exp $
 #
 # Copyright (c) 2007 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -122,9 +122,26 @@ seek_body() {
 	atf_check_equal $st_size 8
 }
 
+atf_test_case swab
+swab_head() {
+	atf_set "descr" "Tests conv=swab"
+}
+
+swab_body() {
+	echo -n abcdefgh > testfile
+	atf_check -s exit:0 -e ignore -o inline:badcfehg \
+	 dd if=testfile conv=swab msgfmt=quiet
+	atf_check -s exit:0 -e ignore -o inline:abcdefgh \
+	 dd if=testfile conv=swab msgfmt=quiet bs=1
+	for i in 2 4 8; do
+	atf_check -s exit:0 -e ignore -o inline:badcfehg \
+		 dd if=testfile conv=swab msgfmt=quiet bs=$i
+	done
+}
 atf_init_test_cases()
 {
 	atf_add_test_case length
 	atf_add_test_case io
 	atf_add_test_case seek
+	atf_add_test_case swab
 }



CVS commit: [netbsd-9] src/sys/kern

2021-10-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Oct  8 14:58:08 UTC 2021

Modified Files:
src/sys/kern [netbsd-9]: sys_pipe.c

Log Message:
Pull up following revision(s) (requested by hannken in ticket #1357):

sys/kern/sys_pipe.c: revision 1.157

Fix a deadlock where one thread writes to a pipe, has more data
and no space in the pipe and waits on "pipe_wcv" while the reader
is closing the pipe and waits on "pipe_draincv".

Swap the test for "PIPE_EOF" and the "cv_wait_sig()" in "pipe_write()".

PR bin/56422 "zgrep -l sometimes hangs"


To generate a diff of this commit:
cvs rdiff -u -r1.148 -r1.148.2.1 src/sys/kern/sys_pipe.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/sys/kern

2021-10-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Oct  8 14:58:08 UTC 2021

Modified Files:
src/sys/kern [netbsd-9]: sys_pipe.c

Log Message:
Pull up following revision(s) (requested by hannken in ticket #1357):

sys/kern/sys_pipe.c: revision 1.157

Fix a deadlock where one thread writes to a pipe, has more data
and no space in the pipe and waits on "pipe_wcv" while the reader
is closing the pipe and waits on "pipe_draincv".

Swap the test for "PIPE_EOF" and the "cv_wait_sig()" in "pipe_write()".

PR bin/56422 "zgrep -l sometimes hangs"


To generate a diff of this commit:
cvs rdiff -u -r1.148 -r1.148.2.1 src/sys/kern/sys_pipe.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/kern/sys_pipe.c
diff -u src/sys/kern/sys_pipe.c:1.148 src/sys/kern/sys_pipe.c:1.148.2.1
--- src/sys/kern/sys_pipe.c:1.148	Fri Apr 26 17:24:23 2019
+++ src/sys/kern/sys_pipe.c	Fri Oct  8 14:58:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_pipe.c,v 1.148 2019/04/26 17:24:23 mlelstv Exp $	*/
+/*	$NetBSD: sys_pipe.c,v 1.148.2.1 2021/10/08 14:58:08 martin Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.148 2019/04/26 17:24:23 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.148.2.1 2021/10/08 14:58:08 martin Exp $");
 
 #include 
 #include 
@@ -1006,11 +1006,6 @@ pipe_write(file_t *fp, off_t *offset, st
 break;
 			}
 
-			pipeunlock(wpipe);
-			error = cv_wait_sig(&wpipe->pipe_wcv, lock);
-			(void)pipelock(wpipe, false);
-			if (error != 0)
-break;
 			/*
 			 * If read side wants to go away, we just issue a signal
 			 * to ourselves.
@@ -1019,6 +1014,12 @@ pipe_write(file_t *fp, off_t *offset, st
 error = EPIPE;
 break;
 			}
+
+			pipeunlock(wpipe);
+			error = cv_wait_sig(&wpipe->pipe_wcv, lock);
+			(void)pipelock(wpipe, false);
+			if (error != 0)
+break;
 			wakeup_state = wpipe->pipe_state;
 		}
 	}



CVS commit: [netbsd-9] src/doc

2021-10-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Oct  8 14:59:08 UTC 2021

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

Log Message:
Ticket #1357


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.35 -r1.1.2.36 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/doc

2021-10-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Oct  8 14:59:08 UTC 2021

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

Log Message:
Ticket #1357


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.35 -r1.1.2.36 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.35 src/doc/CHANGES-9.3:1.1.2.36
--- src/doc/CHANGES-9.3:1.1.2.35	Tue Oct  5 11:08:04 2021
+++ src/doc/CHANGES-9.3	Fri Oct  8 14:59:08 2021
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.3,v 1.1.2.35 2021/10/05 11:08:04 martin Exp $
+# $NetBSD: CHANGES-9.3,v 1.1.2.36 2021/10/08 14:59:08 martin Exp $
 
 A complete list of changes from the NetBSD 9.2 release to the NetBSD 9.3
 release:
@@ -793,3 +793,8 @@ lib/libc/resolv/res_private.h			1.4
 	res_init(3): handle  kqueue close-on-fork semantics.
 	[christos, ticket #1356]
 
+sys/kern/sys_pipe.c1.157
+
+	PR 56422: fix a deadlock in "pipe_write()".
+	[hannken, ticket #1357]
+



CVS commit: [netbsd-8] src/sys/kern

2021-10-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Oct  8 14:59:59 UTC 2021

Modified Files:
src/sys/kern [netbsd-8]: sys_pipe.c

Log Message:
Pull up following revision(s) (requested by hannken in ticket #1698):

sys/kern/sys_pipe.c: revision 1.157

Fix a deadlock where one thread writes to a pipe, has more data
and no space in the pipe and waits on "pipe_wcv" while the reader
is closing the pipe and waits on "pipe_draincv".

Swap the test for "PIPE_EOF" and the "cv_wait_sig()" in "pipe_write()".

PR bin/56422 "zgrep -l sometimes hangs"


To generate a diff of this commit:
cvs rdiff -u -r1.140.12.1 -r1.140.12.2 src/sys/kern/sys_pipe.c

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



CVS commit: [netbsd-8] src/sys/kern

2021-10-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Oct  8 14:59:59 UTC 2021

Modified Files:
src/sys/kern [netbsd-8]: sys_pipe.c

Log Message:
Pull up following revision(s) (requested by hannken in ticket #1698):

sys/kern/sys_pipe.c: revision 1.157

Fix a deadlock where one thread writes to a pipe, has more data
and no space in the pipe and waits on "pipe_wcv" while the reader
is closing the pipe and waits on "pipe_draincv".

Swap the test for "PIPE_EOF" and the "cv_wait_sig()" in "pipe_write()".

PR bin/56422 "zgrep -l sometimes hangs"


To generate a diff of this commit:
cvs rdiff -u -r1.140.12.1 -r1.140.12.2 src/sys/kern/sys_pipe.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/kern/sys_pipe.c
diff -u src/sys/kern/sys_pipe.c:1.140.12.1 src/sys/kern/sys_pipe.c:1.140.12.2
--- src/sys/kern/sys_pipe.c:1.140.12.1	Wed May  1 14:51:17 2019
+++ src/sys/kern/sys_pipe.c	Fri Oct  8 14:59:59 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sys_pipe.c,v 1.140.12.1 2019/05/01 14:51:17 martin Exp $	*/
+/*	$NetBSD: sys_pipe.c,v 1.140.12.2 2021/10/08 14:59:59 martin Exp $	*/
 
 /*-
  * Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.140.12.1 2019/05/01 14:51:17 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.140.12.2 2021/10/08 14:59:59 martin Exp $");
 
 #include 
 #include 
@@ -1017,11 +1017,6 @@ pipe_write(file_t *fp, off_t *offset, st
 break;
 			}
 
-			pipeunlock(wpipe);
-			error = cv_wait_sig(&wpipe->pipe_wcv, lock);
-			(void)pipelock(wpipe, false);
-			if (error != 0)
-break;
 			/*
 			 * If read side wants to go away, we just issue a signal
 			 * to ourselves.
@@ -1030,6 +1025,12 @@ pipe_write(file_t *fp, off_t *offset, st
 error = EPIPE;
 break;
 			}
+
+			pipeunlock(wpipe);
+			error = cv_wait_sig(&wpipe->pipe_wcv, lock);
+			(void)pipelock(wpipe, false);
+			if (error != 0)
+break;
 			wakeup_state = wpipe->pipe_state;
 		}
 	}



CVS commit: [netbsd-8] src/doc

2021-10-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Oct  8 15:01:21 UTC 2021

Modified Files:
src/doc [netbsd-8]: CHANGES-8.3

Log Message:
Ticket #1698


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.103 -r1.1.2.104 src/doc/CHANGES-8.3

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



CVS commit: [netbsd-8] src/doc

2021-10-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Oct  8 15:01:21 UTC 2021

Modified Files:
src/doc [netbsd-8]: CHANGES-8.3

Log Message:
Ticket #1698


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.103 -r1.1.2.104 src/doc/CHANGES-8.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-8.3
diff -u src/doc/CHANGES-8.3:1.1.2.103 src/doc/CHANGES-8.3:1.1.2.104
--- src/doc/CHANGES-8.3:1.1.2.103	Thu Sep 23 10:08:35 2021
+++ src/doc/CHANGES-8.3	Fri Oct  8 15:01:21 2021
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-8.3,v 1.1.2.103 2021/09/23 10:08:35 martin Exp $
+# $NetBSD: CHANGES-8.3,v 1.1.2.104 2021/10/08 15:01:21 martin Exp $
 
 A complete list of changes from the NetBSD 8.2 release to the NetBSD 8.3
 release:
@@ -2116,3 +2116,8 @@ bin/mkdir/mkdir.c1.39
 	is used.
 	[kre, ticket #1697]
 
+sys/kern/sys_pipe.c1.157
+
+	PR 56422: fix a deadlock in "pipe_write()".
+	[hannken, ticket #1698]
+



CVS commit: src/usr.sbin/sysinst

2021-10-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Oct  8 15:59:56 UTC 2021

Modified Files:
src/usr.sbin/sysinst: Makefile.inc configmenu.c defs.h install.c
menus.entropy msg.entropy.de msg.entropy.en msg.entropy.es
msg.entropy.fr msg.entropy.pl util.c

Log Message:
Re-enable the entropy handling code in sysinst (only visible on machines
that do not have full entropy), but move it to the config menu
instead of enforcing it as mandatory step.

This menu is shown at the end of the setup, or if explicitly invoked
from the main menu.

Some of the input options are complex but useful in some situations
and code to support them is tiny. Most users will use the manual input
(first + default option) but some might prefer to connect a USB TRNG
or have easy setups to transfer entropy from another machine (while
copy & paste on a serial console sometimes is tricky).


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/usr.sbin/sysinst/Makefile.inc
cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/sysinst/configmenu.c
cvs rdiff -u -r1.74 -r1.75 src/usr.sbin/sysinst/defs.h
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/sysinst/install.c
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/sysinst/menus.entropy
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/sysinst/msg.entropy.de \
src/usr.sbin/sysinst/msg.entropy.en src/usr.sbin/sysinst/msg.entropy.es \
src/usr.sbin/sysinst/msg.entropy.fr src/usr.sbin/sysinst/msg.entropy.pl
cvs rdiff -u -r1.61 -r1.62 src/usr.sbin/sysinst/util.c

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



CVS commit: src/usr.sbin/sysinst

2021-10-08 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Oct  8 15:59:56 UTC 2021

Modified Files:
src/usr.sbin/sysinst: Makefile.inc configmenu.c defs.h install.c
menus.entropy msg.entropy.de msg.entropy.en msg.entropy.es
msg.entropy.fr msg.entropy.pl util.c

Log Message:
Re-enable the entropy handling code in sysinst (only visible on machines
that do not have full entropy), but move it to the config menu
instead of enforcing it as mandatory step.

This menu is shown at the end of the setup, or if explicitly invoked
from the main menu.

Some of the input options are complex but useful in some situations
and code to support them is tiny. Most users will use the manual input
(first + default option) but some might prefer to connect a USB TRNG
or have easy setups to transfer entropy from another machine (while
copy & paste on a serial console sometimes is tricky).


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/usr.sbin/sysinst/Makefile.inc
cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/sysinst/configmenu.c
cvs rdiff -u -r1.74 -r1.75 src/usr.sbin/sysinst/defs.h
cvs rdiff -u -r1.20 -r1.21 src/usr.sbin/sysinst/install.c
cvs rdiff -u -r1.1 -r1.2 src/usr.sbin/sysinst/menus.entropy
cvs rdiff -u -r1.2 -r1.3 src/usr.sbin/sysinst/msg.entropy.de \
src/usr.sbin/sysinst/msg.entropy.en src/usr.sbin/sysinst/msg.entropy.es \
src/usr.sbin/sysinst/msg.entropy.fr src/usr.sbin/sysinst/msg.entropy.pl
cvs rdiff -u -r1.61 -r1.62 src/usr.sbin/sysinst/util.c

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

Modified files:

Index: src/usr.sbin/sysinst/Makefile.inc
diff -u src/usr.sbin/sysinst/Makefile.inc:1.43 src/usr.sbin/sysinst/Makefile.inc:1.44
--- src/usr.sbin/sysinst/Makefile.inc:1.43	Sun Sep 26 15:52:40 2021
+++ src/usr.sbin/sysinst/Makefile.inc	Fri Oct  8 15:59:55 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.43 2021/09/26 15:52:40 maya Exp $
+#	$NetBSD: Makefile.inc,v 1.44 2021/10/08 15:59:55 martin Exp $
 #
 # Makefile for sysinst
 
@@ -47,7 +47,7 @@ SRCS+=	mbr.c
 CPPFLAGS+=	-DNO_CLONES
 .endif
 
-.if ${CHECK_ENTROPY:Uno} != "no"
+.if ${CHECK_ENTROPY:Uyes} != "no"
 MENUS_MI+=	menus.entropy
 CPPFLAGS+=	-DCHECK_ENTROPY=1
 .endif
@@ -209,7 +209,7 @@ msgtouch: ${DISTRIBVERDEP}
 MSG_MD+=	msg.pm.${SYSINSTLANG}
 .endif
 
-.if ${CHECK_ENTROPY:Uno} != "no"
+.if ${CHECK_ENTROPY:Uyes} != "no"
 MSG_MD+=	msg.entropy.${SYSINSTLANG}
 .endif
 

Index: src/usr.sbin/sysinst/configmenu.c
diff -u src/usr.sbin/sysinst/configmenu.c:1.12 src/usr.sbin/sysinst/configmenu.c:1.13
--- src/usr.sbin/sysinst/configmenu.c:1.12	Sun Jan 31 22:45:46 2021
+++ src/usr.sbin/sysinst/configmenu.c	Fri Oct  8 15:59:55 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: configmenu.c,v 1.12 2021/01/31 22:45:46 rillig Exp $ */
+/* $NetBSD: configmenu.c,v 1.13 2021/10/08 15:59:55 martin Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -45,6 +45,7 @@ static int set_timezone_menu(struct menu
 static int set_root_shell(struct menudesc *, void *);
 static int change_root_password(struct menudesc *, void *);
 static int add_new_user(struct menudesc *, void *);
+static int add_entropy(struct menudesc *, void *);
 static int set_binpkg(struct menudesc *, void *);
 static int set_pkgsrc(struct menudesc *, void *);
 static void config_list_init(void);
@@ -74,6 +75,7 @@ enum {
 	CONFIGOPT_LVM,
 	CONFIGOPT_RAIDFRAME,
 	CONFIGOPT_ADDUSER,
+	CONFIGOPT_ADD_ENTROPY,
 	CONFIGOPT_LAST
 };
 
@@ -102,6 +104,9 @@ configinfo config_list[] = {
 	{MSG_enable_lvm, CONFIGOPT_LVM, "lvm", toggle_rcvar, NULL},
 	{MSG_enable_raid, CONFIGOPT_RAIDFRAME, "raidframe", toggle_rcvar, NULL},
 	{MSG_add_a_user, CONFIGOPT_ADDUSER, NULL, add_new_user, ""},
+#if CHECK_ENTROPY
+	{MSG_Configure_entropy, CONFIGOPT_ADD_ENTROPY, NULL, add_entropy, ""},
+#endif
 	{NULL,		CONFIGOPT_LAST,	NULL, NULL, NULL}
 };
 
@@ -180,6 +185,10 @@ init_config_menu(configinfo *conf, menu_
 		opt = conf->opt;
 		if (opt == CONFIGOPT_LAST)
 			break;
+#if CHECK_ENTROPY
+		if (opt == CONFIGOPT_ADD_ENTROPY && entropy_needed() == 0)
+			continue;
+#endif
 		*ce = conf;
 		memset(me, 0, sizeof(*me));
 		me->opt_action = conf->action;
@@ -247,6 +256,15 @@ check_root_password(void)
 	return rval;
 }
 
+#if CHECK_ENTROPY
+static int
+add_entropy(struct menudesc *menu, void *arg)
+{
+	do_add_entropy();
+	return 0;
+}
+#endif
+
 static int
 add_new_user(struct menudesc *menu, void *arg)
 {

Index: src/usr.sbin/sysinst/defs.h
diff -u src/usr.sbin/sysinst/defs.h:1.74 src/usr.sbin/sysinst/defs.h:1.75
--- src/usr.sbin/sysinst/defs.h:1.74	Sun Sep 26 15:52:40 2021
+++ src/usr.sbin/sysinst/defs.h	Fri Oct  8 15:59:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: defs.h,v 1.74 2021/09/26 15:52:40 maya Exp $	*/
+/*	$NetBSD: defs.h,v 1.75 2021/10/08 15:59:55 martin Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -632,6 +632,10 @@ extern char dist_tgz_postfix[SSTRSIZE];
 /* needed prototypes */
 void set_menu_numo

CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 16:16:54 UTC 2021

Modified Files:
src/usr.bin/indent: indent.h
Removed Files:
src/usr.bin/indent: indent_codes.h indent_globs.h

Log Message:
indent: merge headers into a single file

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.12 -r0 src/usr.bin/indent/indent_codes.h
cvs rdiff -u -r1.48 -r0 src/usr.bin/indent/indent_globs.h

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



CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 16:16:54 UTC 2021

Modified Files:
src/usr.bin/indent: indent.h
Removed Files:
src/usr.bin/indent: indent_codes.h indent_globs.h

Log Message:
indent: merge headers into a single file

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.12 -r0 src/usr.bin/indent/indent_codes.h
cvs rdiff -u -r1.48 -r0 src/usr.bin/indent/indent_globs.h

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

Modified files:

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.30 src/usr.bin/indent/indent.h:1.31
--- src/usr.bin/indent/indent.h:1.30	Thu Oct  7 19:42:41 2021
+++ src/usr.bin/indent/indent.h	Fri Oct  8 16:16:54 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.30 2021/10/07 19:42:41 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.31 2021/10/08 16:16:54 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -27,6 +27,42 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  */
+/*-
+ * SPDX-License-Identifier: BSD-4-Clause
+ *
+ * Copyright (c) 1985 Sun Microsystems, Inc.
+ * Copyright (c) 1980, 1993
+ *	The Regents of the University of California.  All rights reserved.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *must display the following acknowledgement:
+ *	This product includes software developed by the University of
+ *	California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *may be used to endorse or promote products derived from this software
+ *without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
 
 #if 0
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.h 336333 2018-07-16 05:46:50Z pstef $");
@@ -34,8 +70,267 @@ __FBSDID("$FreeBSD: head/usr.bin/indent/
 
 #include 
 
-#include "indent_codes.h"
-#include "indent_globs.h"
+typedef enum token_type {
+end_of_file,
+newline,
+lparen,			/* '(' or '[' */
+rparen,			/* ')' or ']' */
+unary_op,			/* e.g. '+' or '&' */
+binary_op,			/* e.g. '<<' or '+' or '&&' or '/=' */
+postfix_op,			/* trailing '++' or '--' */
+question,			/* the '?' from a '?:' expression */
+case_label,
+colon,
+semicolon,
+lbrace,
+rbrace,
+ident,			/* identifier, constant or string */
+comma,
+comment,
+switch_expr,		/* 'switch' '('  ')' */
+preprocessing,		/* '#' */
+form_feed,
+decl,
+keyword_for_if_while,	/* 'for', 'if' or 'while' */
+keyword_do_else,		/* 'do' or 'else' */
+if_expr,			/* 'if' '('  ')' */
+while_expr,			/* 'while' '('  ')' */
+for_exprs,			/* 'for' '(' ... ')' */
+stmt,
+stmt_list,
+keyword_else,		/* 'else' */
+keyword_do,			/* 'do' */
+do_stmt,			/* 'do'  */
+if_expr_stmt,		/* 'if' '('  ')'  */
+if_expr_stmt_else,		/* 'if' '('  ')'  'else' */
+period,
+string_prefix,		/* 'L' */
+storage_class,
+funcname,
+type_def,
+keyword_struct_union_enum
+} token_type;
+
+#define sc_size 5000		/* size of save_com buffer */
+#define label_offset 2		/* number of levels a label is placed to left
+ * of code */
+
+
+struct buffer {
+char *buf;			/* buffer */
+char *s;			/* start */
+char *e;			/* end */
+char *l;			/* limit */
+};
+
+extern FILE   *input;		/* the fid for the input file */
+extern FILE   *output;		/* the output file */
+
+extern struct buffer lab;		/* label or preprocessor directive */
+exter

CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 16:20:33 UTC 2021

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

Log Message:
indent: rename tokens lparen and rparen to be more precise

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.31 -r1.32 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.78 -r1.79 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-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 16:20:33 UTC 2021

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

Log Message:
indent: rename tokens lparen and rparen to be more precise

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.31 -r1.32 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.78 -r1.79 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.125 src/usr.bin/indent/indent.c:1.126
--- src/usr.bin/indent/indent.c:1.125	Thu Oct  7 23:18:47 2021
+++ src/usr.bin/indent/indent.c	Fri Oct  8 16:20:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.125 2021/10/07 23:18:47 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.126 2021/10/08 16:20: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.125 2021/10/07 23:18:47 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.126 2021/10/08 16:20:33 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -621,7 +621,7 @@ want_blank_before_lparen(void)
 {
 if (!ps.want_blank)
 	return false;
-if (ps.last_token == rparen)
+if (ps.last_token == rparen_or_rbracket)
 	return false;
 if (ps.last_token != ident && ps.last_token != funcname)
 	return true;
@@ -803,7 +803,7 @@ process_semicolon(bool *seen_case, int *
  * structure declaration */
 *seen_case = false;		/* these will only need resetting in an error */
 *seen_quest = 0;
-if (ps.last_token == rparen)
+if (ps.last_token == rparen_or_rbracket)
 	ps.in_parameter_declaration = false;
 ps.cast_mask = 0;
 ps.not_cast_mask = 0;
@@ -1000,7 +1000,7 @@ process_decl(int *out_decl_ind, bool *ou
 {
 parse(decl);		/* let parser worry about indentation */
 
-if (ps.last_token == rparen && ps.tos <= 1) {
+if (ps.last_token == rparen_or_rbracket && ps.tos <= 1) {
 	if (code.s != code.e) {
 	dump_line();
 	ps.want_blank = false;
@@ -1316,11 +1316,11 @@ main_loop(void)
 	process_newline();
 	break;
 
-	case lparen:		/* got a '(' or '[' */
+	case lparen_or_lbracket:
 	process_lparen_or_lbracket(decl_ind, tabs_to_var, sp_sw);
 	break;
 
-	case rparen:		/* got a ')' or ']' */
+	case rparen_or_rbracket:
 	process_rparen_or_rbracket(&sp_sw, &force_nl, hd_type);
 	break;
 

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.31 src/usr.bin/indent/indent.h:1.32
--- src/usr.bin/indent/indent.h:1.31	Fri Oct  8 16:16:54 2021
+++ src/usr.bin/indent/indent.h	Fri Oct  8 16:20:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.31 2021/10/08 16:16:54 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.32 2021/10/08 16:20:33 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -73,8 +73,8 @@ __FBSDID("$FreeBSD: head/usr.bin/indent/
 typedef enum token_type {
 end_of_file,
 newline,
-lparen,			/* '(' or '[' */
-rparen,			/* ')' or ']' */
+lparen_or_lbracket,
+rparen_or_rbracket,
 unary_op,			/* e.g. '+' or '&' */
 binary_op,			/* e.g. '<<' or '+' or '&&' or '/=' */
 postfix_op,			/* trailing '++' or '--' */

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.78 src/usr.bin/indent/lexi.c:1.79
--- src/usr.bin/indent/lexi.c:1.78	Thu Oct  7 23:15:15 2021
+++ src/usr.bin/indent/lexi.c	Fri Oct  8 16:20:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.78 2021/10/07 23:15:15 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.79 2021/10/08 16:20:33 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.78 2021/10/07 23:15:15 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.79 2021/10/08 16:20:33 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -222,8 +222,9 @@ const char *
 token_type_name(token_type ttype)
 {
 static const char *const name[] = {
-	"end_of_file", "newline", "lparen", "rparen", "unary_op",
-	"binary_op", "postfix_op", "question", "case_label", "colon",
+	"end_of_file", "newline", "lparen_or_lbracket", "rparen_or_rbracket",
+	"unary_op", "binary_op", "postfix_op", "question",
+	"case_label", "colon",
 	"semicolon", "lbrace", "rbrace", "ident", "comma",
 	"comment", "switch_expr", "preprocessing", "form_feed", "decl",
 	"keyword_for_if_while", "keyword_do_else",
@@ -525,12 +526,12 @@ lexi(struct parser_state *state)
 case '(':
 case '[':
 	unary_delim = true;
-	ttype = lparen;
+	ttype = lparen_or_lbracket;
 	break;
 
 case ')':

CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 16:47:42 UTC 2021

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

Log Message:
indent: split process_keyword_do_else into separate functions

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 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-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 16:47:42 UTC 2021

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

Log Message:
indent: split process_keyword_do_else into separate functions

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.126 -r1.127 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.126 src/usr.bin/indent/indent.c:1.127
--- src/usr.bin/indent/indent.c:1.126	Fri Oct  8 16:20:33 2021
+++ src/usr.bin/indent/indent.c	Fri Oct  8 16:47:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.126 2021/10/08 16:20:33 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.127 2021/10/08 16:47:42 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.126 2021/10/08 16:20:33 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.127 2021/10/08 16:47:42 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -965,34 +965,37 @@ process_rbrace(bool *sp_sw, int *decl_in
 }
 
 static void
-process_keyword_do_else(bool *force_nl, bool *last_else)
+process_keyword_do(bool *force_nl, bool *last_else)
 {
 ps.in_stmt = false;
 
-if (*token.s == 'e') {
-	if (code.e != code.s && (!opt.cuddle_else || code.e[-1] != '}')) {
-	if (opt.verbose)
-		diag(0, "Line broken");
-	dump_line();	/* make sure this starts a line */
-	ps.want_blank = false;
-	}
+if (code.e != code.s) {	/* make sure this starts a line */
+	if (opt.verbose)
+	diag(0, "Line broken");
+	dump_line();
+	ps.want_blank = false;
+}
 
-	*force_nl = true;	/* following stuff must go onto new line */
-	*last_else = true;
-	parse(keyword_else);
+*force_nl = true;		/* following stuff must go onto new line */
+*last_else = false;
+parse(keyword_do);
+}
 
-} else {
-	if (code.e != code.s) {	/* make sure this starts a line */
-	if (opt.verbose)
-		diag(0, "Line broken");
-	dump_line();
-	ps.want_blank = false;
-	}
+static void
+process_keyword_else(bool *force_nl, bool *last_else)
+{
+ps.in_stmt = false;
 
-	*force_nl = true;	/* following stuff must go onto new line */
-	*last_else = false;
-	parse(keyword_do);
+if (code.e != code.s && (!opt.cuddle_else || code.e[-1] != '}')) {
+	if (opt.verbose)
+	diag(0, "Line broken");
+	dump_line();		/* make sure this starts a line */
+	ps.want_blank = false;
 }
+
+*force_nl = true;		/* following stuff must go onto new line */
+*last_else = true;
+parse(keyword_else);
 }
 
 static void
@@ -1378,7 +1381,10 @@ main_loop(void)
 	goto copy_token;
 
 	case keyword_do_else:
-	process_keyword_do_else(&force_nl, &last_else);
+	if (*token.s == 'd')
+		process_keyword_do(&force_nl, &last_else);
+	else
+		process_keyword_else(&force_nl, &last_else);
 	goto copy_token;
 
 	case type_def:



CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 17:00:21 UTC 2021

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

Log Message:
indent: reduce indentation in dump_line


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

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



CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 17:00:21 UTC 2021

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

Log Message:
indent: reduce indentation in dump_line


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

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

Modified files:

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.80 src/usr.bin/indent/io.c:1.81
--- src/usr.bin/indent/io.c:1.80	Thu Oct  7 23:18:47 2021
+++ src/usr.bin/indent/io.c	Fri Oct  8 17:00:21 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.80 2021/10/07 23:18:47 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.81 2021/10/08 17:00:21 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.80 2021/10/07 23:18:47 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.81 2021/10/08 17:00:21 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -197,21 +197,17 @@ dump_line(void)
 	}
 
 	int target_col = 1 + compute_code_indent();
-	{
-		int i;
-
-		for (i = 0; i < ps.p_l_follow; i++) {
-		if (ps.paren_indents[i] >= 0) {
-			int ind = ps.paren_indents[i];
-			/*
-			 * XXX: this mix of 'indent' and 'column' smells like
-			 * an off-by-one error.
-			 */
-			ps.paren_indents[i] = (short)-(ind + target_col);
-			debug_println(
-			"setting pi[%d] from %d to %d for column %d",
-			i, ind, ps.paren_indents[i], target_col);
-		}
+	for (int i = 0; i < ps.p_l_follow; i++) {
+		if (ps.paren_indents[i] >= 0) {
+		int ind = ps.paren_indents[i];
+		/*
+		 * XXX: this mix of 'indent' and 'column' smells like
+		 * an off-by-one error.
+		 */
+		ps.paren_indents[i] = (short)-(ind + target_col);
+		debug_println(
+			"setting pi[%d] from %d to %d for column %d",
+			i, ind, ps.paren_indents[i], target_col);
 		}
 	}
 
@@ -228,7 +224,7 @@ dump_line(void)
 	while (*com_st == '\t')	/* consider original indentation in
 	 * case this is a box comment */
 		com_st++, target_col += opt.tabsize;
-	while (target_col <= 0)
+	while (target_col <= 0) {
 		if (*com_st == ' ')
 		target_col++, com_st++;
 		else if (*com_st == '\t') {
@@ -236,6 +232,7 @@ dump_line(void)
 		com_st++;
 		} else
 		target_col = 1;
+	}
 	if (cur_col > target_col) {	/* if comment can't fit on this line,
 	 * put it on next line */
 		output_char('\n');



CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 17:04:13 UTC 2021

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

Log Message:
indent: calculate indentation instead of column

This avoids constantly adding and subtracting 1.

No functional change.


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

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



CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 17:04:13 UTC 2021

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

Log Message:
indent: calculate indentation instead of column

This avoids constantly adding and subtracting 1.

No functional change.


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

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

Modified files:

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.81 src/usr.bin/indent/io.c:1.82
--- src/usr.bin/indent/io.c:1.81	Fri Oct  8 17:00:21 2021
+++ src/usr.bin/indent/io.c	Fri Oct  8 17:04:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.81 2021/10/08 17:00:21 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.82 2021/10/08 17:04:13 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.81 2021/10/08 17:00:21 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.82 2021/10/08 17:04:13 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -110,7 +110,7 @@ output_indent(int old_ind, int new_ind)
 void
 dump_line(void)
 {
-int cur_col;
+int cur_ind;
 static bool not_first_line;
 
 if (ps.procname[0] != '\0') {
@@ -158,7 +158,7 @@ dump_line(void)
 		lab.e--;
 	*lab.e = '\0';
 
-	cur_col = 1 + output_indent(0, compute_label_indent());
+	cur_ind = output_indent(0, compute_label_indent());
 
 	if (lab.s[0] == '#' && (strncmp(lab.s, "#else", 5) == 0
 		|| strncmp(lab.s, "#endif", 6) == 0)) {
@@ -184,9 +184,9 @@ dump_line(void)
 		}
 	} else
 		output_range(lab.s, lab.e);
-	cur_col = 1 + indentation_after(cur_col - 1, lab.s);
+	cur_ind = indentation_after(cur_ind, lab.s);
 	} else
-	cur_col = 1;	/* there is no label section */
+	cur_ind = 0;	/* there is no label section */
 
 	ps.is_case_label = false;
 
@@ -211,9 +211,9 @@ dump_line(void)
 		}
 	}
 
-	cur_col = 1 + output_indent(cur_col - 1, target_col - 1);
+	cur_ind = output_indent(cur_ind, target_col - 1);
 	output_range(code.s, code.e);
-	cur_col = 1 + indentation_after(cur_col - 1, code.s);
+	cur_ind = indentation_after(cur_ind, code.s);
 	}
 
 	if (com.s != com.e) {	/* print comment, if any */
@@ -233,15 +233,15 @@ dump_line(void)
 		} else
 		target_col = 1;
 	}
-	if (cur_col > target_col) {	/* if comment can't fit on this line,
+	if (cur_ind + 1 > target_col) {	/* if comment can't fit on this line,
 	 * put it on next line */
 		output_char('\n');
-		cur_col = 1;
+		cur_ind = 0;
 		ps.stats.lines++;
 	}
 	while (com.e > com_st && isspace((unsigned char)com.e[-1]))
 		com.e--;
-	(void)output_indent(cur_col - 1, target_col - 1);
+	(void)output_indent(cur_ind, target_col - 1);
 	output_range(com_st, com.e);
 	ps.comment_delta = ps.n_comment_delta;
 	ps.stats.comment_lines++;



CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 17:07:36 UTC 2021

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

Log Message:
indent: replace column calculations with indent, part 2

No functional change.


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

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



CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 17:07:36 UTC 2021

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

Log Message:
indent: replace column calculations with indent, part 2

No functional change.


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

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

Modified files:

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.82 src/usr.bin/indent/io.c:1.83
--- src/usr.bin/indent/io.c:1.82	Fri Oct  8 17:04:13 2021
+++ src/usr.bin/indent/io.c	Fri Oct  8 17:07:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.82 2021/10/08 17:04:13 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.83 2021/10/08 17:07:36 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.82 2021/10/08 17:04:13 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.83 2021/10/08 17:07:36 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -217,23 +217,23 @@ dump_line(void)
 	}
 
 	if (com.s != com.e) {	/* print comment, if any */
-	int target_col = ps.com_col;
+	int target_ind = ps.com_col - 1;
 	char *com_st = com.s;
 
-	target_col += ps.comment_delta;
+	target_ind += ps.comment_delta;
 	while (*com_st == '\t')	/* consider original indentation in
 	 * case this is a box comment */
-		com_st++, target_col += opt.tabsize;
-	while (target_col <= 0) {
+		com_st++, target_ind += opt.tabsize;
+	while (target_ind < 0) {
 		if (*com_st == ' ')
-		target_col++, com_st++;
+		target_ind++, com_st++;
 		else if (*com_st == '\t') {
-		target_col = opt.tabsize * (1 + (target_col - 1) / opt.tabsize) + 1;
+		target_ind = opt.tabsize * (1 + target_ind / opt.tabsize);
 		com_st++;
 		} else
-		target_col = 1;
+		target_ind = 0;
 	}
-	if (cur_ind + 1 > target_col) {	/* if comment can't fit on this line,
+	if (cur_ind > target_ind) {	/* if comment can't fit on this line,
 	 * put it on next line */
 		output_char('\n');
 		cur_ind = 0;
@@ -241,7 +241,7 @@ dump_line(void)
 	}
 	while (com.e > com_st && isspace((unsigned char)com.e[-1]))
 		com.e--;
-	(void)output_indent(cur_ind, target_col - 1);
+	(void)output_indent(cur_ind, target_ind);
 	output_range(com_st, com.e);
 	ps.comment_delta = ps.n_comment_delta;
 	ps.stats.comment_lines++;



CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 17:12:08 UTC 2021

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

Log Message:
indent: replace column calculations with indent, part 3

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/usr.bin/indent/io.c
cvs rdiff -u -r1.58 -r1.59 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-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 17:12:08 UTC 2021

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

Log Message:
indent: replace column calculations with indent, part 3

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/usr.bin/indent/io.c
cvs rdiff -u -r1.58 -r1.59 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/io.c
diff -u src/usr.bin/indent/io.c:1.83 src/usr.bin/indent/io.c:1.84
--- src/usr.bin/indent/io.c:1.83	Fri Oct  8 17:07:36 2021
+++ src/usr.bin/indent/io.c	Fri Oct  8 17:12:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.83 2021/10/08 17:07:36 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.84 2021/10/08 17:12:08 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.83 2021/10/08 17:07:36 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.84 2021/10/08 17:12:08 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -196,22 +196,19 @@ dump_line(void)
 		output_string(".*/\n");
 	}
 
-	int target_col = 1 + compute_code_indent();
+	int target_ind = compute_code_indent();
 	for (int i = 0; i < ps.p_l_follow; i++) {
 		if (ps.paren_indents[i] >= 0) {
 		int ind = ps.paren_indents[i];
-		/*
-		 * XXX: this mix of 'indent' and 'column' smells like
-		 * an off-by-one error.
-		 */
-		ps.paren_indents[i] = (short)-(ind + target_col);
+		/* XXX: the '+ 1' smells like an off-by-one error. */
+		ps.paren_indents[i] = (short)-(ind + target_ind + 1);
 		debug_println(
 			"setting pi[%d] from %d to %d for column %d",
-			i, ind, ps.paren_indents[i], target_col);
+			i, ind, ps.paren_indents[i], target_ind + 1);
 		}
 	}
 
-	cur_ind = output_indent(cur_ind, target_col - 1);
+	cur_ind = output_indent(cur_ind, target_ind);
 	output_range(code.s, code.e);
 	cur_ind = indentation_after(cur_ind, code.s);
 	}

Index: src/usr.bin/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.58 src/usr.bin/indent/pr_comment.c:1.59
--- src/usr.bin/indent/pr_comment.c:1.58	Thu Oct  7 23:15:15 2021
+++ src/usr.bin/indent/pr_comment.c	Fri Oct  8 17:12:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.58 2021/10/07 23:15:15 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.59 2021/10/08 17:12:08 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.58 2021/10/07 23:15:15 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.59 2021/10/08 17:12:08 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -126,18 +126,18 @@ process_comment(void)
 	} else {
 	break_delim = false;
 
-	int target_col;
+	int target_ind;
 	if (code.s != code.e)
-		target_col = 1 + indentation_after(compute_code_indent(), code.s);
+		target_ind = indentation_after(compute_code_indent(), code.s);
 	else if (lab.s != lab.e)
-		target_col = 1 + indentation_after(compute_label_indent(), lab.s);
+		target_ind = indentation_after(compute_label_indent(), lab.s);
 	else
-		target_col = 1;
+		target_ind = 0;
 
 	ps.com_col = ps.decl_on_line || ps.ind_level == 0
 		? opt.decl_comment_column : opt.comment_column;
-	if (ps.com_col <= target_col)
-		ps.com_col = opt.tabsize * (1 + (target_col - 1) / opt.tabsize) + 1;
+	if (ps.com_col <= target_ind + 1)
+		ps.com_col = opt.tabsize * (1 + target_ind / opt.tabsize) + 1;
 	if (ps.com_col + 24 > adj_max_line_length)
 		/* XXX: mismatch between column and length */
 		adj_max_line_length = ps.com_col + 24;



CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 17:19:50 UTC 2021

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

Log Message:
indent: replace column calculations with indent, part 4/4


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.84 -r1.85 src/usr.bin/indent/io.c
cvs rdiff -u -r1.59 -r1.60 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-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 17:19:50 UTC 2021

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

Log Message:
indent: replace column calculations with indent, part 4/4


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.84 -r1.85 src/usr.bin/indent/io.c
cvs rdiff -u -r1.59 -r1.60 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.h
diff -u src/usr.bin/indent/indent.h:1.32 src/usr.bin/indent/indent.h:1.33
--- src/usr.bin/indent/indent.h:1.32	Fri Oct  8 16:20:33 2021
+++ src/usr.bin/indent/indent.h	Fri Oct  8 17:19:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.32 2021/10/08 16:20:33 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.33 2021/10/08 17:19:49 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -282,8 +282,7 @@ extern struct parser_state {
  * an initialization list */
 bool	col_1;		/* whether the last token started in
  * column 1 */
-int com_col;	/* this is the column in which the current
- * comment should start */
+int com_ind;	/* indentation of the current comment */
 int decl_nest;	/* current nesting level for structure or init */
 bool	decl_on_line;	/* whether this line of code has part
  * of a declaration on it */

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.84 src/usr.bin/indent/io.c:1.85
--- src/usr.bin/indent/io.c:1.84	Fri Oct  8 17:12:08 2021
+++ src/usr.bin/indent/io.c	Fri Oct  8 17:19:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.84 2021/10/08 17:12:08 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.85 2021/10/08 17:19:49 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.84 2021/10/08 17:12:08 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.85 2021/10/08 17:19:49 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -214,7 +214,7 @@ dump_line(void)
 	}
 
 	if (com.s != com.e) {	/* print comment, if any */
-	int target_ind = ps.com_col - 1;
+	int target_ind = ps.com_ind;
 	char *com_st = com.s;
 
 	target_ind += ps.comment_delta;

Index: src/usr.bin/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.59 src/usr.bin/indent/pr_comment.c:1.60
--- src/usr.bin/indent/pr_comment.c:1.59	Fri Oct  8 17:12:08 2021
+++ src/usr.bin/indent/pr_comment.c	Fri Oct  8 17:19:49 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.59 2021/10/08 17:12:08 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.60 2021/10/08 17:19:49 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.59 2021/10/08 17:12:08 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.60 2021/10/08 17:19:49 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -102,7 +102,7 @@ process_comment(void)
  * column 1, it should not be touched */
 	ps.box_com = true;
 	break_delim = false;
-	ps.com_col = 1;
+	ps.com_ind = 0;
 
 } else {
 	if (*inp.s == '-' || *inp.s == '*' || token.e[-1] == '/' ||
@@ -118,10 +118,10 @@ process_comment(void)
 	}
 
 	if (lab.s == lab.e && code.s == code.e) {
-	ps.com_col = (ps.ind_level - opt.unindent_displace) * opt.indent_size + 1;
+	ps.com_ind = (ps.ind_level - opt.unindent_displace) * opt.indent_size;
 	adj_max_line_length = opt.block_comment_max_line_length;
-	if (ps.com_col <= 1)
-		ps.com_col = 1 + (!opt.format_col1_comments ? 1 : 0);
+	if (ps.com_ind <= 0)
+		ps.com_ind = opt.format_col1_comments ? 0 : 1;
 
 	} else {
 	break_delim = false;
@@ -134,13 +134,13 @@ process_comment(void)
 	else
 		target_ind = 0;
 
-	ps.com_col = ps.decl_on_line || ps.ind_level == 0
-		? opt.decl_comment_column : opt.comment_column;
-	if (ps.com_col <= target_ind + 1)
-		ps.com_col = opt.tabsize * (1 + target_ind / opt.tabsize) + 1;
-	if (ps.com_col + 24 > adj_max_line_length)
-		/* XXX: mismatch between column and length */
-		adj_max_line_length = ps.com_col + 24;
+	ps.com_ind = ps.decl_on_line || ps.ind_level == 0
+		? opt.decl_comment_column - 1 : opt.comment_column - 1;
+	if (ps.com_ind <= target_ind)
+		ps.com_ind = opt.tabsize * (1 + target_ind / opt.tabsize);
+	/* XXX: the '+ 1' smells like an off-by-one error */
+	if (ps.com_ind + 1 + 24 > adj_max_line_length)
+		adj_max_line_length = ps.com_ind + 1 + 24;
 	}
 }
 
@@ -185,7 +185,7 @@ process_comment(void)
 		 * the trailing ' ' '*' '/'.  In simple cases, these cancel
 		 * out si

CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 17:26:56 UTC 2021

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

Log Message:
indent: reduce scope of t_ptr in process_comment

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 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-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 17:26:56 UTC 2021

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

Log Message:
indent: reduce scope of t_ptr in process_comment

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 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.60 src/usr.bin/indent/pr_comment.c:1.61
--- src/usr.bin/indent/pr_comment.c:1.60	Fri Oct  8 17:19:49 2021
+++ src/usr.bin/indent/pr_comment.c	Fri Oct  8 17:26:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.60 2021/10/08 17:19:49 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.61 2021/10/08 17:26:56 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.60 2021/10/08 17:19:49 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.61 2021/10/08 17:26:56 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -84,7 +84,6 @@ process_comment(void)
 int adj_max_line_length;	/* Adjusted max_line_length for comments that
  * spill over the right margin */
 ssize_t last_blank;		/* index of the last blank in com.buf */
-char *t_ptr;		/* used for moving string */
 bool break_delim = opt.comment_delimiter_on_blankline;
 int l_just_saw_decl = ps.just_saw_decl;
 
@@ -176,17 +175,17 @@ process_comment(void)
 
 /* Don't put a break delimiter if this is a one-liner that won't wrap. */
 if (break_delim) {
-	for (t_ptr = inp.s; *t_ptr != '\0' && *t_ptr != '\n'; t_ptr++) {
-	if (t_ptr >= inp.e)
+	for (const char *p = inp.s; *p != '\0' && *p != '\n'; p++) {
+	if (p >= inp.e)
 		fill_buffer();
-	if (t_ptr[0] == '*' && t_ptr[1] == '/') {
+	if (p[0] == '*' && p[1] == '/') {
 		/*
 		 * XXX: This computation ignores the leading " * ", as well as
 		 * the trailing ' ' '*' '/'.  In simple cases, these cancel
 		 * out since they are equally long.
 		 */
 		int right_margin = indentation_after_range(ps.com_ind,
-		inp.s, t_ptr + 2);
+		inp.s, p + 2);
 		if (right_margin < adj_max_line_length)
 		break_delim = false;
 		break;
@@ -340,20 +339,20 @@ process_comment(void)
 		if (!ps.box_com && opt.star_comment_cont)
 		*com.e++ = ' ', *com.e++ = '*', *com.e++ = ' ';
 
-		for (t_ptr = com.buf + last_blank + 1;
-		 is_hspace(*t_ptr); t_ptr++)
-		continue;
+		const char *p = com.buf + last_blank + 1;
+		while (is_hspace(*p))
+		p++;
 		last_blank = -1;
 
 		/*
-		 * t_ptr will be somewhere between com.e (dump_line() reset)
-		 * and com.l. So it's safe to copy byte by byte from t_ptr to
+		 * p will be somewhere between com.e (dump_line() reset)
+		 * and com.l. So it's safe to copy byte by byte from p to
 		 * com.e without any check_size_comment().
 		 */
-		while (*t_ptr != '\0') {
-		if (is_hspace(*t_ptr))
+		while (*p != '\0') {
+		if (is_hspace(*p))
 			last_blank = com.e - com.buf;
-		*com.e++ = *t_ptr++;
+		*com.e++ = *p++;
 		}
 	}
 	break;



CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 17:56:12 UTC 2021

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

Log Message:
indent: split dump_line into smaller functions

No functional change.


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

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



CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 17:56:12 UTC 2021

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

Log Message:
indent: split dump_line into smaller functions

No functional change.


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

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

Modified files:

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.85 src/usr.bin/indent/io.c:1.86
--- src/usr.bin/indent/io.c:1.85	Fri Oct  8 17:19:49 2021
+++ src/usr.bin/indent/io.c	Fri Oct  8 17:56:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.85 2021/10/08 17:19:49 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.86 2021/10/08 17:56:12 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.85 2021/10/08 17:19:49 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.86 2021/10/08 17:56:12 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -102,15 +102,123 @@ output_indent(int old_ind, int new_ind)
 return ind;
 }
 
+static int
+dump_line_label(void)
+{
+int ind;
+
+if (comment_open) {
+	comment_open = false;
+	output_string(".*/\n");
+}
+
+while (lab.e > lab.s && is_hspace(lab.e[-1]))
+	lab.e--;
+*lab.e = '\0';
+
+ind = output_indent(0, compute_label_indent());
+
+if (lab.s[0] == '#' && (strncmp(lab.s, "#else", 5) == 0
+	|| strncmp(lab.s, "#endif", 6) == 0)) {
+	const char *s = lab.s;
+	if (lab.e[-1] == '\n')
+	lab.e--;
+	do {
+	output_char(*s++);
+	} while (s < lab.e && 'a' <= *s && *s <= 'z');
+
+	while (s < lab.e && is_hspace(*s))
+	s++;
+
+	if (s < lab.e) {
+	if (s[0] == '/' && s[1] == '*') {
+		output_char('\t');
+		output_range(s, lab.e);
+	} else {
+		output_string("\t/* ");
+		output_range(s, lab.e);
+		output_string(" */");
+	}
+	}
+} else
+	output_range(lab.s, lab.e);
+ind = indentation_after(ind, lab.s);
+
+ps.is_case_label = false;
+return ind;
+}
+
+static int
+dump_line_code(int ind)
+{
+if (comment_open) {
+	comment_open = false;
+	output_string(".*/\n");
+}
+
+int target_ind = compute_code_indent();
+for (int i = 0; i < ps.p_l_follow; i++) {
+	if (ps.paren_indents[i] >= 0) {
+	int paren_ind = ps.paren_indents[i];
+	/* XXX: the '+ 1' smells like an off-by-one error. */
+	ps.paren_indents[i] = (short)-(paren_ind + target_ind + 1);
+	debug_println(
+		"setting pi[%d] from %d to %d for column %d",
+		i, paren_ind, ps.paren_indents[i], target_ind + 1);
+	}
+}
+
+ind = output_indent(ind, target_ind);
+output_range(code.s, code.e);
+return indentation_after(ind, code.s);
+}
+
+static void
+dump_line_comment(int ind)
+{
+int target_ind = ps.com_ind;
+char *com_st = com.s;
+
+target_ind += ps.comment_delta;
+
+/* consider original indentation in case this is a box comment */
+while (*com_st == '\t')
+	com_st++, target_ind += opt.tabsize;
+
+while (target_ind < 0) {
+	if (*com_st == ' ')
+	target_ind++, com_st++;
+	else if (*com_st == '\t') {
+	target_ind = opt.tabsize * (1 + target_ind / opt.tabsize);
+	com_st++;
+	} else
+	target_ind = 0;
+}
+
+/* if comment can't fit on this line, put it on next line */
+if (ind > target_ind) {
+	output_char('\n');
+	ind = 0;
+	ps.stats.lines++;
+}
+
+while (com.e > com_st && isspace((unsigned char)com.e[-1]))
+	com.e--;
+
+(void)output_indent(ind, target_ind);
+output_range(com_st, com.e);
+
+ps.comment_delta = ps.n_comment_delta;
+ps.stats.comment_lines++;
+}
+
 /*
- * dump_line is the routine that actually effects the printing of the new
- * source. It prints the label section, followed by the code section with
- * the appropriate nesting level, followed by any comments.
+ * 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)
 {
-int cur_ind;
 static bool not_first_line;
 
 if (ps.procname[0] != '\0') {
@@ -148,101 +256,13 @@ dump_line(void)
 	if (lab.e != lab.s || code.e != code.s)
 	ps.stats.code_lines++;
 
-	if (lab.e != lab.s) {	/* print lab, if any */
-	if (comment_open) {
-		comment_open = false;
-		output_string(".*/\n");
-	}
-
-	while (lab.e > lab.s && is_hspace(lab.e[-1]))
-		lab.e--;
-	*lab.e = '\0';
-
-	cur_ind = output_indent(0, compute_label_indent());
-
-	if (lab.s[0] == '#' && (strncmp(lab.s, "#else", 5) == 0
-		|| strncmp(lab.s, "#endif", 6) == 0)) {
-		char *s = lab.s;
-		if (lab.e[-1] == '\n')
-		lab.e--;
-		do {
-		output_char(*s++);
-		} while (s < lab.e && 'a' <= *s && *s <= 'z');
-
-		while (s < lab.e && is_hspace(*s))
-		s++;
-
-		if (s < lab.e) {
-		if (s[0] == '

CVS commit: src/etc

2021-10-08 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Oct  8 18:02:57 UTC 2021

Modified Files:
src/etc: master.passwd shells

Log Message:
Change the default shell of the "toor" user to /rescue/sh

toor is a backup account to be used in case of trouble.

When root's default shell was changed to from /bin/csh to /bin/sh,
toor lost its purpose.

/rescue/sh is an ideal choice here because it's a static binary,
while we've moved to dynamic linking for the rest of the system.

Discussed a few times over the years on tech-userlevel.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/etc/master.passwd
cvs rdiff -u -r1.3 -r1.4 src/etc/shells

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



CVS commit: src/etc

2021-10-08 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Oct  8 18:02:57 UTC 2021

Modified Files:
src/etc: master.passwd shells

Log Message:
Change the default shell of the "toor" user to /rescue/sh

toor is a backup account to be used in case of trouble.

When root's default shell was changed to from /bin/csh to /bin/sh,
toor lost its purpose.

/rescue/sh is an ideal choice here because it's a static binary,
while we've moved to dynamic linking for the rest of the system.

Discussed a few times over the years on tech-userlevel.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/etc/master.passwd
cvs rdiff -u -r1.3 -r1.4 src/etc/shells

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

Modified files:

Index: src/etc/master.passwd
diff -u src/etc/master.passwd:1.51 src/etc/master.passwd:1.52
--- src/etc/master.passwd:1.51	Thu Apr  2 12:35:13 2020
+++ src/etc/master.passwd	Fri Oct  8 18:02:57 2021
@@ -1,5 +1,5 @@
 root::0:0::0:0:Charlie &:/root:/bin/sh
-toor:*:0:0::0:0:Bourne-again Superuser:/root:/bin/sh
+toor:*:0:0::0:0:Bourne-again Superuser:/root:/rescue/sh
 daemon:*:1:1::0:0:The devil himself:/:/sbin/nologin
 operator:*:2:5::0:0:System &:/usr/guest/operator:/sbin/nologin
 bin:*:3:7::0:0:Binaries Commands and Source:/:/sbin/nologin

Index: src/etc/shells
diff -u src/etc/shells:1.3 src/etc/shells:1.4
--- src/etc/shells:1.3	Sun Dec 29 03:23:07 1996
+++ src/etc/shells	Fri Oct  8 18:02:57 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: shells,v 1.3 1996/12/29 03:23:07 mrg Exp $
+#	$NetBSD: shells,v 1.4 2021/10/08 18:02:57 nia Exp $
 #
 # List of acceptable shells for chpass(1).
 # Ftpd will not allow users to connect who are not using
@@ -7,3 +7,4 @@
 /bin/sh
 /bin/csh
 /bin/ksh
+/rescue/sh



CVS commit: src

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 18:29:36 UTC 2021

Modified Files:
src/tests/usr.bin/indent: comment-line-end.0.stdout
src/usr.bin/indent: io.c pr_comment.c

Log Message:
indent: fix formatting of C99 comments

The first attempt at formatting C99 comments was conceptually wrong. It
accessed the next token in dump_line, even though that function should
only ever look at the buffers for the label, the code and the current
comment. (Understanding that part of the code was difficult at that time
due to the sheer number of global variables.) The complicated and
ever-growing condition for whether to output the token was a hack and in
retrospect doesn't make sense at all, that's why it only came close to
the intended effect.

Some unintended side effects were that the C99 comments had an
additional space in front of them, and that in some cases an empty line
followed the comment, and that the comments were not aligned.

Previously, the newline that terminates the C99 comment was included in
the comment. Separating the newline from the comment fixed all these
unintended side effects. The only downside is that the multi-line
statement is not indented, but that should be easy to fix.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/indent/comment-line-end.0.stdout
cvs rdiff -u -r1.86 -r1.87 src/usr.bin/indent/io.c
cvs rdiff -u -r1.61 -r1.62 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-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 18:29:36 UTC 2021

Modified Files:
src/tests/usr.bin/indent: comment-line-end.0.stdout
src/usr.bin/indent: io.c pr_comment.c

Log Message:
indent: fix formatting of C99 comments

The first attempt at formatting C99 comments was conceptually wrong. It
accessed the next token in dump_line, even though that function should
only ever look at the buffers for the label, the code and the current
comment. (Understanding that part of the code was difficult at that time
due to the sheer number of global variables.) The complicated and
ever-growing condition for whether to output the token was a hack and in
retrospect doesn't make sense at all, that's why it only came close to
the intended effect.

Some unintended side effects were that the C99 comments had an
additional space in front of them, and that in some cases an empty line
followed the comment, and that the comments were not aligned.

Previously, the newline that terminates the C99 comment was included in
the comment. Separating the newline from the comment fixed all these
unintended side effects. The only downside is that the multi-line
statement is not indented, but that should be easy to fix.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.bin/indent/comment-line-end.0.stdout
cvs rdiff -u -r1.86 -r1.87 src/usr.bin/indent/io.c
cvs rdiff -u -r1.61 -r1.62 src/usr.bin/indent/pr_comment.c

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

Modified files:

Index: src/tests/usr.bin/indent/comment-line-end.0.stdout
diff -u src/tests/usr.bin/indent/comment-line-end.0.stdout:1.8 src/tests/usr.bin/indent/comment-line-end.0.stdout:1.9
--- src/tests/usr.bin/indent/comment-line-end.0.stdout:1.8	Thu Sep 30 22:45:34 2021
+++ src/tests/usr.bin/indent/comment-line-end.0.stdout	Fri Oct  8 18:29:36 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: comment-line-end.0.stdout,v 1.8 2021/09/30 22:45:34 rillig Exp $ */
+/* $NetBSD: comment-line-end.0.stdout,v 1.9 2021/10/08 18:29:36 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -9,11 +9,11 @@
  * unpredictable ways.
  */
 
-int		dummy // comment
- = // eq
- 1 // one
- + // plus
- 2;// two
+int		dummy		// comment
+=// eq
+1// one
++// plus
+2;// two
 
 /separator/
 
@@ -42,12 +42,7 @@ comment_at_end_of_function(void)
 {
 	if (cond)
 		statement();
-/* $ FIXME: The next line is indented with tab-space, should be tab. */
-	 // comment
- 
-/* $ FIXME: The above line has 1 trailing space. */
+	// comment
 }
 
 // end-of-line comment at the end of the file
-
-/* $ FIXME: the extra empty line above this line is wrong. */

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.86 src/usr.bin/indent/io.c:1.87
--- src/usr.bin/indent/io.c:1.86	Fri Oct  8 17:56:12 2021
+++ src/usr.bin/indent/io.c	Fri Oct  8 18:29:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.86 2021/10/08 17:56:12 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.87 2021/10/08 18:29:36 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.86 2021/10/08 17:56:12 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.87 2021/10/08 18:29:36 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -278,11 +278,6 @@ dump_line(void)
 	postfix_blankline_requested = false;
 }
 
-/* keep blank lines after '//' comments */
-if (com.e - com.s > 1 && com.s[1] == '/'
-	&& token.s < token.e && isspace((unsigned char)token.s[0]))
-	output_range(token.s, token.e);
-
 ps.decl_on_line = ps.in_decl;	/* for proper comment indentation */
 ps.ind_stmt = ps.in_stmt && !ps.in_decl;
 ps.use_ff = false;

Index: src/usr.bin/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.61 src/usr.bin/indent/pr_comment.c:1.62
--- src/usr.bin/indent/pr_comment.c:1.61	Fri Oct  8 17:26:56 2021
+++ src/usr.bin/indent/pr_comment.c	Fri Oct  8 18:29:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.61 2021/10/08 17:26:56 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.62 2021/10/08 18:29:36 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.61 2021/10/08 17:26:56 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.62 2021/10/08 18:29:36 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -228,10 +228,8 @@ process_comment(void)
 	break;
 
 	case '\n':
-	if (token.e[-1] == '/') {
-		++line_no;
-		goto end_of_comment;
-	}
+	if (token.e[-1] == '/')
+		goto end_of_line_comment;
 
 	if (had_eof) {
 		printf("Unterminated comment\n");
@@ -283,6 +281,7 

CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 19:03:34 UTC 2021

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

Log Message:
indent: run indent on indent.h

The formatting looks mostly OK.

Some struct members had excessively long names, leaving no space for
their corresponding comments. Renamed some of them using well-known
abbreviations.

The formatting for debug_vis_range is messed up, no idea why. It is
clearly a function declaration, not a function definition, so there is
no need to place the function name in column 1.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/usr.bin/indent/args.c
cvs rdiff -u -r1.127 -r1.128 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.87 -r1.88 src/usr.bin/indent/io.c
cvs rdiff -u -r1.62 -r1.63 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-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 19:03:34 UTC 2021

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

Log Message:
indent: run indent on indent.h

The formatting looks mostly OK.

Some struct members had excessively long names, leaving no space for
their corresponding comments. Renamed some of them using well-known
abbreviations.

The formatting for debug_vis_range is messed up, no idea why. It is
clearly a function declaration, not a function definition, so there is
no need to place the function name in column 1.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/usr.bin/indent/args.c
cvs rdiff -u -r1.127 -r1.128 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.87 -r1.88 src/usr.bin/indent/io.c
cvs rdiff -u -r1.62 -r1.63 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.51 src/usr.bin/indent/args.c:1.52
--- src/usr.bin/indent/args.c:1.51	Thu Oct  7 22:56:49 2021
+++ src/usr.bin/indent/args.c	Fri Oct  8 19:03:34 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: args.c,v 1.51 2021/10/07 22:56:49 rillig Exp $	*/
+/*	$NetBSD: args.c,v 1.52 2021/10/08 19:03:34 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.51 2021/10/07 22:56:49 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.52 2021/10/08 19:03:34 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/args.c 336318 2018-07-15 21:04:21Z pstef $");
 #endif
@@ -89,10 +89,10 @@ static const struct pro {
 void *p_var;		/* the associated variable */
 }   pro[] = {
 bool_options("bacc", blanklines_around_conditional_compilation),
-bool_options("bad", blanklines_after_declarations),
-bool_options("badp", blanklines_after_declarations_at_proctop),
+bool_options("bad", blanklines_after_decl),
+bool_options("badp", blanklines_after_decl_at_top),
 bool_options("bap", blanklines_after_procs),
-bool_options("bbb", blanklines_before_blockcomments),
+bool_options("bbb", blanklines_before_block_comments),
 bool_options("bc", break_after_comma),
 bool_option("bl", false, brace_same_line),
 bool_option("br", true, brace_same_line),
@@ -107,7 +107,7 @@ static const struct pro {
 int_option("d", unindent_displace),
 int_option("di", decl_indent),
 bool_options("dj", ljust_decl),
-bool_options("eei", extra_expression_indent),
+bool_options("eei", extra_expr_indent),
 bool_options("ei", else_if),
 bool_options("fbs", function_brace_split),
 bool_options("fc1", format_col1_comments),

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.127 src/usr.bin/indent/indent.c:1.128
--- src/usr.bin/indent/indent.c:1.127	Fri Oct  8 16:47:42 2021
+++ src/usr.bin/indent/indent.c	Fri Oct  8 19:03:34 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.127 2021/10/08 16:47:42 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.128 2021/10/08 19:03:34 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.127 2021/10/08 16:47:42 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.128 2021/10/08 19:03:34 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -657,7 +657,7 @@ process_lparen_or_lbracket(int decl_ind,
 debug_println("paren_indent[%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_expression_indent
+if (sp_sw && 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_indent[0] is now %d", ps.paren_indents[0]);
@@ -904,8 +904,7 @@ process_lbrace(bool *force_nl, bool *sp_
 	ps.decl_on_line = false;	/* we can't be in the middle of a
 	 * declaration, so don't do special
 	 * indentation of comments */
-	if (opt.blanklines_after_declarations_at_proctop
-	&& ps.in_parameter_declaration)
+	if (opt.blanklines_after_decl_at_top && ps.in_parameter_declaration)
 	postfix_blankline_requested = true;
 	ps.in_parameter_declaration = false;
 	ps.in_decl = false;

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.33 src/usr.bin/indent/indent.h:1.34
--- src/usr.bin/indent/indent.h:1.33	Fri Oct  8 17:19:49 2021
+++ src/usr.bin/indent/indent.h	Fri Oct  8 19:03:34 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.33 2021/10/08 17:19:49 rillig Exp $	*/
+/*	$NetBSD: indent.

CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 19:22:19 UTC 2021

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

Log Message:
indent: constify detection of function names

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 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-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 19:22:19 UTC 2021

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

Log Message:
indent: constify detection of function names

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 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.79 src/usr.bin/indent/lexi.c:1.80
--- src/usr.bin/indent/lexi.c:1.79	Fri Oct  8 16:20:33 2021
+++ src/usr.bin/indent/lexi.c	Fri Oct  8 19:22:19 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.79 2021/10/08 16:20:33 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.80 2021/10/08 19:22:19 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.79 2021/10/08 16:20:33 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.80 2021/10/08 19:22:19 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -479,8 +479,8 @@ lexi(struct parser_state *state)
 	if (*inp.s == '(' && state->tos <= 1 && state->ind_level == 0 &&
 	!state->in_parameter_declaration && !state->block_init) {
 
-	for (char *tp = inp.s; tp < inp.e;)
-		if (*tp++ == ')' && (*tp == ';' || *tp == ','))
+	for (const char *p = inp.s; p < inp.e;)
+		if (*p++ == ')' && (*p == ';' || *p == ','))
 		goto not_proc;
 
 	strncpy(state->procname, token.s, sizeof state->procname - 1);



CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 19:27:20 UTC 2021

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

Log Message:
indent: unexport add_typedefs_from_file

No functional change.


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

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

Modified files:

Index: src/usr.bin/indent/args.c
diff -u src/usr.bin/indent/args.c:1.52 src/usr.bin/indent/args.c:1.53
--- src/usr.bin/indent/args.c:1.52	Fri Oct  8 19:03:34 2021
+++ src/usr.bin/indent/args.c	Fri Oct  8 19:27:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: args.c,v 1.52 2021/10/08 19:03:34 rillig Exp $	*/
+/*	$NetBSD: args.c,v 1.53 2021/10/08 19:27:20 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.52 2021/10/08 19:03:34 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.53 2021/10/08 19:27:20 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/args.c 336318 2018-07-15 21:04:21Z pstef $");
 #endif
@@ -61,8 +61,6 @@ __FBSDID("$FreeBSD: head/usr.bin/indent/
 
 #define INDENT_VERSION	"2.0"
 
-void add_typedefs_from_file(const char *);
-
 #if __STDC_VERSION__ >= 201112L
 #define assert_type(expr, type) _Generic((expr), type : (expr))
 #else
@@ -203,6 +201,24 @@ skip_over(const char *s, bool may_negate
 return s;
 }
 
+static void
+add_typedefs_from_file(const char *fname)
+{
+FILE *file;
+char line[BUFSIZ];
+
+if ((file = fopen(fname, "r")) == NULL) {
+	fprintf(stderr, "indent: cannot open file %s\n", fname);
+	exit(1);
+}
+while ((fgets(line, BUFSIZ, file)) != NULL) {
+	/* Remove trailing whitespace */
+	line[strcspn(line, " \t\n\r")] = '\0';
+	add_typename(line);
+}
+(void)fclose(file);
+}
+
 static bool
 set_special_option(const char *arg, const char *option_source)
 {
@@ -285,21 +301,3 @@ found:
 	*(int *)p->p_var = atoi(param_start);
 }
 }
-
-void
-add_typedefs_from_file(const char *fname)
-{
-FILE *file;
-char line[BUFSIZ];
-
-if ((file = fopen(fname, "r")) == NULL) {
-	fprintf(stderr, "indent: cannot open file %s\n", fname);
-	exit(1);
-}
-while ((fgets(line, BUFSIZ, file)) != NULL) {
-	/* Remove trailing whitespace */
-	line[strcspn(line, " \t\n\r")] = '\0';
-	add_typename(line);
-}
-fclose(file);
-}



CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 19:27:20 UTC 2021

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

Log Message:
indent: unexport add_typedefs_from_file

No functional change.


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

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



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

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 20:04:26 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token-preprocessing.0
token-preprocessing.0.stdout

Log Message:
indent: demonstrate bug in parsing preprocessor lines


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/token-preprocessing.0
cvs rdiff -u -r1.4 -r1.5 \
src/tests/usr.bin/indent/token-preprocessing.0.stdout

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-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 20:04:26 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token-preprocessing.0
token-preprocessing.0.stdout

Log Message:
indent: demonstrate bug in parsing preprocessor lines


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/token-preprocessing.0
cvs rdiff -u -r1.4 -r1.5 \
src/tests/usr.bin/indent/token-preprocessing.0.stdout

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-preprocessing.0
diff -u src/tests/usr.bin/indent/token-preprocessing.0:1.3 src/tests/usr.bin/indent/token-preprocessing.0:1.4
--- src/tests/usr.bin/indent/token-preprocessing.0:1.3	Sat Mar 13 13:04:13 2021
+++ src/tests/usr.bin/indent/token-preprocessing.0	Fri Oct  8 20:04:26 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token-preprocessing.0,v 1.3 2021/03/13 13:04:13 rillig Exp $ */
+/* $NetBSD: token-preprocessing.0,v 1.4 2021/10/08 20:04:26 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*-
@@ -34,3 +34,26 @@
 
 #define comment_in_string_literal "/* no comment "
 int this_is_an_ordinary_line_again;
+
+/*
+ * Before indent.c 1.129 from 2021-10-08, indent mistakenly interpreted quotes
+ * in comments as starting a string literal. The '"' in the comment started a
+ * string, the next '"' finished the string, and the following '/' '*' was
+ * interpreted as the beginning of a comment. This comment lasted until the
+ * next '*' '/', which in this test is another preprocessor directive, solely
+ * for symmetry.
+ *
+ * The effect was that the extra space after d2 was not formatted, as that
+ * line was considered part of the comment.
+ */
+int d1 ;
+#define confuse_d /*"*/ "/*"
+int d2 ;
+#define resolve_d "*/"
+int d3 ;
+
+int s1 ;
+#define confuse_s /*'*/ '/*'
+int s2 ;
+#define resolve_s '*/'
+int s3 ;

Index: src/tests/usr.bin/indent/token-preprocessing.0.stdout
diff -u src/tests/usr.bin/indent/token-preprocessing.0.stdout:1.4 src/tests/usr.bin/indent/token-preprocessing.0.stdout:1.5
--- src/tests/usr.bin/indent/token-preprocessing.0.stdout:1.4	Sat Mar 13 13:14:14 2021
+++ src/tests/usr.bin/indent/token-preprocessing.0.stdout	Fri Oct  8 20:04:26 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token-preprocessing.0.stdout,v 1.4 2021/03/13 13:14:14 rillig Exp $ */
+/* $NetBSD: token-preprocessing.0.stdout,v 1.5 2021/10/08 20:04:26 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*-
@@ -35,3 +35,26 @@
 
 #define comment_in_string_literal "/* no comment "
 int		this_is_an_ordinary_line_again;
+
+/*
+ * Before indent.c 1.129 from 2021-10-08, indent mistakenly interpreted quotes
+ * in comments as starting a string literal. The '"' in the comment started a
+ * string, the next '"' finished the string, and the following '/' '*' was
+ * interpreted as the beginning of a comment. This comment lasted until the
+ * next '*' '/', which in this test is another preprocessor directive, solely
+ * for symmetry.
+ *
+ * The effect was that the extra space after d2 was not formatted, as that
+ * line was considered part of the comment.
+ */
+int		d1;
+#define confuse_d /*"*/ "/*"
+int d2 ;
+#define resolve_d "*/"
+int		d3;
+
+int		s1;
+#define confuse_s /*'*/ '/*'
+int s2 ;
+#define resolve_s '*/'
+int		s3;



CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 20:07:44 UTC 2021

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

Log Message:
indent: clean up argument handling

Sort the macros, remove redundancy from comment.

Remove redundant lint comment. Lint still does not recognize
__attribute__((__noreturn__)), but it also doesn't perform advanced
control flow analysis, so there is no point in having the comment, as it
doesn't suppress any warnings.

No functional change.


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

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

Modified files:

Index: src/usr.bin/indent/args.c
diff -u src/usr.bin/indent/args.c:1.53 src/usr.bin/indent/args.c:1.54
--- src/usr.bin/indent/args.c:1.53	Fri Oct  8 19:27:20 2021
+++ src/usr.bin/indent/args.c	Fri Oct  8 20:07:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: args.c,v 1.53 2021/10/08 19:27:20 rillig Exp $	*/
+/*	$NetBSD: args.c,v 1.54 2021/10/08 20:07:44 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.53 2021/10/08 19:27:20 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.54 2021/10/08 20:07:44 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/args.c 336318 2018-07-15 21:04:21Z pstef $");
 #endif
@@ -66,12 +66,13 @@ __FBSDID("$FreeBSD: head/usr.bin/indent/
 #else
 #define assert_type(expr, type) (expr)
 #endif
+
 #define bool_option(name, value, var) \
 	{name, true, value, false, assert_type(&(opt.var), bool *)}
-#define int_option(name, var) \
-	{name, false, false, false, assert_type(&(opt.var), int *)}
 #define bool_options(name, var) \
 	{name, true, false, true, assert_type(&(opt.var), bool *)}
+#define int_option(name, var) \
+	{name, false, false, false, assert_type(&(opt.var), int *)}
 
 /*
  * N.B.: an option whose name is a prefix of another option must come earlier;
@@ -80,7 +81,7 @@ __FBSDID("$FreeBSD: head/usr.bin/indent/
  * See set_special_option for special options.
  */
 static const struct pro {
-const char p_name[5];	/* name, e.g. "bl", "cli" */
+const char p_name[5];	/* e.g. "bl", "cli" */
 bool p_is_bool;
 bool p_bool_value;
 bool p_may_negate;
@@ -227,7 +228,6 @@ set_special_option(const char *arg, cons
 if (strncmp(arg, "-version", 8) == 0) {
 	printf("FreeBSD indent %s\n", INDENT_VERSION);
 	exit(0);
-	/* NOTREACHED */
 }
 
 if (arg[0] == 'P' || strncmp(arg, "npro", 4) == 0)



CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 20:07:44 UTC 2021

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

Log Message:
indent: clean up argument handling

Sort the macros, remove redundancy from comment.

Remove redundant lint comment. Lint still does not recognize
__attribute__((__noreturn__)), but it also doesn't perform advanced
control flow analysis, so there is no point in having the comment, as it
doesn't suppress any warnings.

No functional change.


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

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



CVS commit: src

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 20:14:52 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token-preprocessing.0.stdout
src/usr.bin/indent: indent.c

Log Message:
indent: fix parsing of preprocessor lines with comments and strings


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/tests/usr.bin/indent/token-preprocessing.0.stdout
cvs rdiff -u -r1.128 -r1.129 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-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 20:14:52 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token-preprocessing.0.stdout
src/usr.bin/indent: indent.c

Log Message:
indent: fix parsing of preprocessor lines with comments and strings


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 \
src/tests/usr.bin/indent/token-preprocessing.0.stdout
cvs rdiff -u -r1.128 -r1.129 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/token-preprocessing.0.stdout
diff -u src/tests/usr.bin/indent/token-preprocessing.0.stdout:1.5 src/tests/usr.bin/indent/token-preprocessing.0.stdout:1.6
--- src/tests/usr.bin/indent/token-preprocessing.0.stdout:1.5	Fri Oct  8 20:04:26 2021
+++ src/tests/usr.bin/indent/token-preprocessing.0.stdout	Fri Oct  8 20:14:52 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token-preprocessing.0.stdout,v 1.5 2021/10/08 20:04:26 rillig Exp $ */
+/* $NetBSD: token-preprocessing.0.stdout,v 1.6 2021/10/08 20:14:52 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*-
@@ -49,12 +49,12 @@ int		this_is_an_ordinary_line_again;
  */
 int		d1;
 #define confuse_d /*"*/ "/*"
-int d2 ;
+int		d2;
 #define resolve_d "*/"
 int		d3;
 
 int		s1;
 #define confuse_s /*'*/ '/*'
-int s2 ;
+int		s2;
 #define resolve_s '*/'
 int		s3;

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.128 src/usr.bin/indent/indent.c:1.129
--- src/usr.bin/indent/indent.c:1.128	Fri Oct  8 19:03:34 2021
+++ src/usr.bin/indent/indent.c	Fri Oct  8 20:14:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.128 2021/10/08 19:03:34 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.129 2021/10/08 20:14:52 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.128 2021/10/08 19:03:34 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.129 2021/10/08 20:14:52 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -1117,45 +1117,48 @@ process_comma(int decl_ind, bool tabs_to
 static void
 read_preprocessing_line(void)
 {
+enum {
+	PLAIN, STR, CHR, COMM
+} state;
+
 buf_add_char(&lab, '#');
 
-bool in_comment = false;
+state = PLAIN;
 int com_start = 0, com_end = 0;
-char quote = '\0';
 
 while (is_hspace(*inp.s))
 	inbuf_skip();
 
-while (*inp.s != '\n' || (in_comment && !had_eof)) {
+while (*inp.s != '\n' || (state == COMM && !had_eof)) {
 	buf_reserve(&lab, 2);
 	*lab.e++ = inbuf_next();
 	switch (lab.e[-1]) {
 	case '\\':
-	if (!in_comment)
+	if (state != COMM)
 		*lab.e++ = inbuf_next();
 	break;
 	case '/':
-	if (*inp.s == '*' && !in_comment && quote == '\0') {
-		in_comment = true;
+	if (*inp.s == '*' && state == PLAIN) {
+		state = COMM;
 		*lab.e++ = *inp.s++;
 		com_start = (int)buf_len(&lab) - 2;
 	}
 	break;
 	case '"':
-	if (quote == '"')
-		quote = '\0';
-	else if (quote == '\0')
-		quote = '"';
+	if (state == STR)
+		state = PLAIN;
+	else if (state == PLAIN)
+		state = STR;
 	break;
 	case '\'':
-	if (quote == '\'')
-		quote = '\0';
-	else if (quote == '\0')
-		quote = '\'';
+	if (state == CHR)
+		state = PLAIN;
+	else if (state == PLAIN)
+		state = CHR;
 	break;
 	case '*':
-	if (*inp.s == '/' && in_comment) {
-		in_comment = false;
+	if (*inp.s == '/' && state == COMM) {
+		state = PLAIN;
 		*lab.e++ = *inp.s++;
 		com_end = (int)buf_len(&lab);
 	}



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

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 20:23:23 UTC 2021

Modified Files:
src/tests/usr.bin/indent: opt-v.0 opt-v.0.stdout

Log Message:
tests/indent: demonstrate uncounted comments


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/opt-v.0 \
src/tests/usr.bin/indent/opt-v.0.stdout

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-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 20:23:23 UTC 2021

Modified Files:
src/tests/usr.bin/indent: opt-v.0 opt-v.0.stdout

Log Message:
tests/indent: demonstrate uncounted comments


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/opt-v.0 \
src/tests/usr.bin/indent/opt-v.0.stdout

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-v.0
diff -u src/tests/usr.bin/indent/opt-v.0:1.2 src/tests/usr.bin/indent/opt-v.0:1.3
--- src/tests/usr.bin/indent/opt-v.0:1.2	Sun Mar  7 10:12:18 2021
+++ src/tests/usr.bin/indent/opt-v.0	Fri Oct  8 20:23:23 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: opt-v.0,v 1.2 2021/03/07 10:12:18 rillig Exp $ */
+/* $NetBSD: opt-v.0,v 1.3 2021/10/08 20:23:23 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -9,3 +9,9 @@ example(void)
 {
 	printf("A very long message template with %d arguments: %s, %s, %s", 3, "first", "second", "third");
 }
+
+/* $ This comment is neither counted nor formatted. */
+#define macro1 /* prefix */ suffix
+
+/* $ This comment is formatted and counted. */
+#define macro2 prefix /* suffix */
Index: src/tests/usr.bin/indent/opt-v.0.stdout
diff -u src/tests/usr.bin/indent/opt-v.0.stdout:1.2 src/tests/usr.bin/indent/opt-v.0.stdout:1.3
--- src/tests/usr.bin/indent/opt-v.0.stdout:1.2	Sun Mar  7 10:12:18 2021
+++ src/tests/usr.bin/indent/opt-v.0.stdout	Fri Oct  8 20:23:23 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: opt-v.0.stdout,v 1.2 2021/03/07 10:12:18 rillig Exp $ */
+/* $NetBSD: opt-v.0.stdout,v 1.3 2021/10/08 20:23:23 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -9,5 +9,9 @@ example(void)
 {
 	printf("A very long message template with %d arguments: %s, %s, %s", 3, "first", "second", "third");
 }
-There were 8 output lines and 1 comments
-(Lines with comments)/(Lines with code):  0.600
+
+#define macro1 /* prefix */ suffix
+
+#define macro2 prefix		/* suffix */
+There were 10 output lines and 2 comments
+(Lines with comments)/(Lines with code):  0.571



CVS commit: src/distrib/amd64

2021-10-08 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Fri Oct  8 20:24:06 UTC 2021

Modified Files:
src/distrib/amd64: Makefile
Added Files:
src/distrib/amd64/installimage-bios: Makefile boot.cfg.in etc.rc
etc.ttys install.sh spec.inst

Log Message:
Restore having a BIOS-only amd64 USB image.

Several people reported having hardware that struggles booting the mix
EFI+BIOS image, and it's better to offer them a working image.

Keeping the EFI image as having the obvious name, this is going to become
more likely to work by default as newer hardware may not support BIOS boot.

(XXX pullup-9)


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/distrib/amd64/Makefile
cvs rdiff -u -r0 -r1.1 src/distrib/amd64/installimage-bios/Makefile \
src/distrib/amd64/installimage-bios/boot.cfg.in \
src/distrib/amd64/installimage-bios/etc.rc \
src/distrib/amd64/installimage-bios/etc.ttys \
src/distrib/amd64/installimage-bios/install.sh \
src/distrib/amd64/installimage-bios/spec.inst

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



CVS commit: src/distrib/amd64

2021-10-08 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Fri Oct  8 20:24:06 UTC 2021

Modified Files:
src/distrib/amd64: Makefile
Added Files:
src/distrib/amd64/installimage-bios: Makefile boot.cfg.in etc.rc
etc.ttys install.sh spec.inst

Log Message:
Restore having a BIOS-only amd64 USB image.

Several people reported having hardware that struggles booting the mix
EFI+BIOS image, and it's better to offer them a working image.

Keeping the EFI image as having the obvious name, this is going to become
more likely to work by default as newer hardware may not support BIOS boot.

(XXX pullup-9)


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/distrib/amd64/Makefile
cvs rdiff -u -r0 -r1.1 src/distrib/amd64/installimage-bios/Makefile \
src/distrib/amd64/installimage-bios/boot.cfg.in \
src/distrib/amd64/installimage-bios/etc.rc \
src/distrib/amd64/installimage-bios/etc.ttys \
src/distrib/amd64/installimage-bios/install.sh \
src/distrib/amd64/installimage-bios/spec.inst

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

Modified files:

Index: src/distrib/amd64/Makefile
diff -u src/distrib/amd64/Makefile:1.14 src/distrib/amd64/Makefile:1.15
--- src/distrib/amd64/Makefile:1.14	Wed May 27 22:27:58 2020
+++ src/distrib/amd64/Makefile	Fri Oct  8 20:24:06 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.14 2020/05/27 22:27:58 maya Exp $
+#	$NetBSD: Makefile,v 1.15 2021/10/08 20:24:06 maya Exp $
 
 .include 
 
@@ -14,6 +14,7 @@ SUBDIR+=	.WAIT
 SUBDIR+=	cdroms
 SUBDIR+=	liveimage
 SUBDIR+=	installimage
+SUBDIR+=	installimage-bios
 TARGETS+=	release 
 
 iso_image:
@@ -24,5 +25,6 @@ live_image:
 
 install_image:
 	${MAKEDIRTARGET} installimage install_image
+	${MAKEDIRTARGET} installimage-bios install_image
 
 .include 

Added files:

Index: src/distrib/amd64/installimage-bios/Makefile
diff -u /dev/null src/distrib/amd64/installimage-bios/Makefile:1.1
--- /dev/null	Fri Oct  8 20:24:06 2021
+++ src/distrib/amd64/installimage-bios/Makefile	Fri Oct  8 20:24:06 2021
@@ -0,0 +1,38 @@
+#	$NetBSD: Makefile,v 1.1 2021/10/08 20:24:06 maya Exp $
+
+.include 
+
+INSTIMGBASE=	NetBSD-${DISTRIBVER}-amd64-bios-install	# gives ${IMGBASE}.img
+
+INSTIMAGEMB?=	1800			# for all installation binaries
+
+PRIMARY_BOOT=		bootxx_ffsv1
+SECONDARY_BOOT=		boot
+SECONDARY_BOOT_ARG=	# unnecessary
+
+USE_MBR=		yes
+
+CLEANFILES+=	boot.cfg
+
+prepare_md_post:
+	${TOOL_SED}			\
+	-e "s/@@MACHINE@@/${MACHINE}/"\
+	-e "s/@@VERSION@@/${DISTRIBVER}/"\
+	< ${.CURDIR}/boot.cfg.in > boot.cfg
+
+DISTRIBDIR!= cd ${.CURDIR}/../.. ; pwd
+SYSINSTDIR!= cd ${.CURDIR}/../../../usr.sbin/sysinst/arch/${MACHINE} && ${PRINTOBJDIR}
+
+SPEC_EXTRA=		${.CURDIR}/spec.inst
+IMGFILE_EXTRA=\
+	${.CURDIR}/etc.ttys		etc/ttys			\
+	${.CURDIR}/etc.rc		etc/rc\
+	${.CURDIR}/install.sh		.\
+	${.OBJDIR}/boot.cfg		.\
+	${SYSINSTDIR}/sysinstmsgs.de	.\
+	${SYSINSTDIR}/sysinstmsgs.es	.\
+	${SYSINSTDIR}/sysinstmsgs.fr	.\
+	${SYSINSTDIR}/sysinstmsgs.pl	.\
+	${SYSINSTDIR}/sysinst		.
+
+.include "${NETBSDSRCDIR}/distrib/common/bootimage//Makefile.installimage"
Index: src/distrib/amd64/installimage-bios/boot.cfg.in
diff -u /dev/null src/distrib/amd64/installimage-bios/boot.cfg.in:1.1
--- /dev/null	Fri Oct  8 20:24:06 2021
+++ src/distrib/amd64/installimage-bios/boot.cfg.in	Fri Oct  8 20:24:06 2021
@@ -0,0 +1,9 @@
+banner=Welcome to the NetBSD/@@MACHINE@@ @@VERSION@@ installation image
+banner
+banner=
+banner=If you encounter a problem while booting, report a bug at
+banner=https://www.NetBSD.org/.
+menu=Install NetBSD:boot netbsd
+menu=Drop to boot prompt:prompt
+timeout=30
+clear=1
Index: src/distrib/amd64/installimage-bios/etc.rc
diff -u /dev/null src/distrib/amd64/installimage-bios/etc.rc:1.1
--- /dev/null	Fri Oct  8 20:24:06 2021
+++ src/distrib/amd64/installimage-bios/etc.rc	Fri Oct  8 20:24:06 2021
@@ -0,0 +1,49 @@
+# $NetBSD: etc.rc,v 1.1 2021/10/08 20:24:06 maya Exp $
+#
+# Copyright (c) 1997 Perry E. Metzger
+# Copyright (c) 1994 Christopher G. Demetriou
+# All rights reserved.
+# 
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+#notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+#notice, this list of conditions and the following disclaimer in the
+#documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+#must display the following acknowledgement:
+#  This product includes software developed for the
+#  NetBSD Project.  See http://www.NetBSD.org/ for
+

CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 20:28:56 UTC 2021

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

Log Message:
indent: reduce negations in main_loop

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 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-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 20:28:56 UTC 2021

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

Log Message:
indent: reduce negations in main_loop

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.129 -r1.130 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.129 src/usr.bin/indent/indent.c:1.130
--- src/usr.bin/indent/indent.c:1.129	Fri Oct  8 20:14:52 2021
+++ src/usr.bin/indent/indent.c	Fri Oct  8 20:28:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.129 2021/10/08 20:14:52 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.130 2021/10/08 20:28:56 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.129 2021/10/08 20:14:52 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.130 2021/10/08 20:28:56 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -1298,17 +1298,11 @@ main_loop(void)
 	/* NOTREACHED */
 	}
 
-	if (
-		ttype != comment &&
-		ttype != newline &&
-		ttype != preprocessing &&
-		ttype != form_feed) {
+	if (ttype == newline || ttype == form_feed || ttype == preprocessing)
+	force_nl = false;
+	else if (ttype != comment)
 	process_comment_in_code(ttype, &force_nl);
 
-	} else if (ttype != comment)	/* preserve force_nl through a comment */
-	force_nl = false;	/* cancel forced newline after newline, form
- * feed, etc */
-
 	buf_reserve(&code, 3);	/* space for 2 characters plus '\0' */
 
 	switch (ttype) {



CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 20:33:18 UTC 2021

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

Log Message:
indent: remove unnecessary forward declarations

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 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-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 20:33:18 UTC 2021

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

Log Message:
indent: remove unnecessary forward declarations

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.130 -r1.131 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.130 src/usr.bin/indent/indent.c:1.131
--- src/usr.bin/indent/indent.c:1.130	Fri Oct  8 20:28:56 2021
+++ src/usr.bin/indent/indent.c	Fri Oct  8 20:33:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.130 2021/10/08 20:28:56 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.131 2021/10/08 20:33:18 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.130 2021/10/08 20:28:56 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.131 2021/10/08 20:33:18 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -117,9 +117,6 @@ static struct parser_state state_stack[5
 FILE *input;
 FILE *output;
 
-static void bakcopy(void);
-static void indent_declaration(int, bool);
-
 static const char *in_name = "Standard Input";
 static const char *out_name = "Standard Output";
 static const char *backup_suffix = ".BAK";
@@ -461,6 +458,47 @@ main_init_globals(void)
 	backup_suffix = suffix;
 }
 
+/*
+ * Copy the input file to the backup file, then make the backup file the input
+ * and the original input file the output.
+ */
+static void
+bakcopy(void)
+{
+ssize_t n;
+int bak_fd;
+char buff[8 * 1024];
+
+const char *last_slash = strrchr(in_name, '/');
+snprintf(bakfile, sizeof(bakfile), "%s%s",
+	 last_slash != NULL ? last_slash + 1 : in_name, backup_suffix);
+
+/* copy in_name to backup file */
+bak_fd = creat(bakfile, 0600);
+if (bak_fd < 0)
+	err(1, "%s", bakfile);
+
+while ((n = read(fileno(input), buff, sizeof(buff))) > 0)
+	if (write(bak_fd, buff, (size_t)n) != n)
+	err(1, "%s", bakfile);
+if (n < 0)
+	err(1, "%s", in_name);
+
+close(bak_fd);
+(void)fclose(input);
+
+/* re-open backup file as the input file */
+input = fopen(bakfile, "r");
+if (input == NULL)
+	err(1, "%s", bakfile);
+/* now the original input file will be the output */
+output = fopen(in_name, "w");
+if (output == NULL) {
+	unlink(bakfile);
+	err(1, "%s", in_name);
+}
+}
+
 static void
 main_parse_command_line(int argc, char **argv)
 {
@@ -549,6 +587,41 @@ main_prepare_parsing(void)
 	ps.ind_level = ps.ind_level_follow = ind / opt.indent_size;
 }
 
+static void
+indent_declaration(int cur_decl_ind, bool tabs_to_var)
+{
+int pos = (int)buf_len(&code);
+char *orig_code_e = code.e;
+
+/*
+ * get the tab math right for indentations that are not multiples of
+ * tabsize
+ */
+if ((ps.ind_level * opt.indent_size) % opt.tabsize != 0) {
+	pos += (ps.ind_level * opt.indent_size) % opt.tabsize;
+	cur_decl_ind += (ps.ind_level * opt.indent_size) % opt.tabsize;
+}
+
+if (tabs_to_var) {
+	int tpos;
+
+	while ((tpos = opt.tabsize * (1 + pos / opt.tabsize)) <= cur_decl_ind) {
+	buf_add_char(&code, '\t');
+	pos = tpos;
+	}
+}
+
+while (pos < cur_decl_ind) {
+	buf_add_char(&code, ' ');
+	pos++;
+}
+
+if (code.e == orig_code_e && ps.want_blank) {
+	*code.e++ = ' ';
+	ps.want_blank = false;
+}
+}
+
 static void __attribute__((__noreturn__))
 process_end_of_file(void)
 {
@@ -1448,82 +1521,6 @@ main(int argc, char **argv)
 main_loop();
 }
 
-/*
- * Copy the input file to the backup file, then make the backup file the input
- * and the original input file the output.
- */
-static void
-bakcopy(void)
-{
-ssize_t n;
-int bak_fd;
-char buff[8 * 1024];
-
-const char *last_slash = strrchr(in_name, '/');
-snprintf(bakfile, sizeof(bakfile), "%s%s",
-	last_slash != NULL ? last_slash + 1 : in_name, backup_suffix);
-
-/* copy in_name to backup file */
-bak_fd = creat(bakfile, 0600);
-if (bak_fd < 0)
-	err(1, "%s", bakfile);
-
-while ((n = read(fileno(input), buff, sizeof(buff))) > 0)
-	if (write(bak_fd, buff, (size_t)n) != n)
-	err(1, "%s", bakfile);
-if (n < 0)
-	err(1, "%s", in_name);
-
-close(bak_fd);
-(void)fclose(input);
-
-/* re-open backup file as the input file */
-input = fopen(bakfile, "r");
-if (input == NULL)
-	err(1, "%s", bakfile);
-/* now the original input file will be the output */
-output = fopen(in_name, "w");
-if (output == NULL) {
-	unlink(bakfile);
-	err(1, "%s", in_name);
-}
-}
-
-static void
-indent_declaration(int cur_decl_ind, bool tabs_to_var)
-{
-int pos = (int)(code.e - code.s);
-char *start

CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 20:45:22 UTC 2021

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

Log Message:
indent: clean up process_decl, replace unnecessary strlen

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 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-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 20:45:22 UTC 2021

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

Log Message:
indent: clean up process_decl, replace unnecessary strlen

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.131 -r1.132 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.131 src/usr.bin/indent/indent.c:1.132
--- src/usr.bin/indent/indent.c:1.131	Fri Oct  8 20:33:18 2021
+++ src/usr.bin/indent/indent.c	Fri Oct  8 20:45:22 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.131 2021/10/08 20:33:18 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.132 2021/10/08 20:45:22 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.131 2021/10/08 20:33:18 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.132 2021/10/08 20:45:22 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -797,7 +797,7 @@ process_unary_op(int decl_ind, bool tabs
 if (!ps.dumped_decl_indent && ps.in_decl && !ps.block_init &&
 	ps.procname[0] == '\0' && ps.paren_level == 0) {
 	/* pointer declarations */
-	indent_declaration(decl_ind - (int)strlen(token.s), tabs_to_var);
+	indent_declaration(decl_ind - (int)buf_len(&token), tabs_to_var);
 	ps.dumped_decl_indent = true;
 } else if (ps.want_blank)
 	*code.e++ = ' ';
@@ -1071,7 +1071,7 @@ process_keyword_else(bool *force_nl, boo
 }
 
 static void
-process_decl(int *out_decl_ind, bool *out_tabs_to_var)
+process_decl(int *decl_ind, bool *tabs_to_var)
 {
 parse(decl);		/* let parser worry about indentation */
 
@@ -1096,12 +1096,12 @@ process_decl(int *out_decl_ind, bool *ou
 
 prefix_blankline_requested = false;
 
-int len = (int)strlen(token.s) + 1;
+int len = (int)buf_len(&token) + 1;
 int ind = ps.ind_level == 0 || ps.decl_nest > 0
 	? opt.decl_indent		/* global variable or local member */
 	: opt.local_decl_indent;	/* local variable */
-*out_decl_ind = ind > 0 ? ind : len;
-*out_tabs_to_var = opt.use_tabs ? ind > 0 : false;
+*decl_ind = ind > 0 ? ind : len;
+*tabs_to_var = opt.use_tabs && ind > 0;
 }
 
 static void



CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 21:13:58 UTC 2021

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

Log Message:
indent: rename fill_buffer to inbuf_read_line

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.88 -r1.89 src/usr.bin/indent/io.c
cvs rdiff -u -r1.80 -r1.81 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.63 -r1.64 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-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 21:13:58 UTC 2021

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

Log Message:
indent: rename fill_buffer to inbuf_read_line

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.88 -r1.89 src/usr.bin/indent/io.c
cvs rdiff -u -r1.80 -r1.81 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.63 -r1.64 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.132 src/usr.bin/indent/indent.c:1.133
--- src/usr.bin/indent/indent.c:1.132	Fri Oct  8 20:45:22 2021
+++ src/usr.bin/indent/indent.c	Fri Oct  8 21:13:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.132 2021/10/08 20:45:22 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.133 2021/10/08 21:13:58 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.132 2021/10/08 20:45:22 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.133 2021/10/08 21:13:58 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -314,7 +314,7 @@ search_brace_lookahead(token_type *ttype
 		errx(1, "input too long");
 	}
 	if (inp.s >= inp.e)
-	fill_buffer();
+	inbuf_read_line();
 }
 
 struct parser_state transient_state;
@@ -567,7 +567,7 @@ main_parse_command_line(int argc, char *
 static void
 main_prepare_parsing(void)
 {
-fill_buffer();		/* get first batch of stuff into input buffer */
+inbuf_read_line();
 
 parse(semicolon);
 

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.34 src/usr.bin/indent/indent.h:1.35
--- src/usr.bin/indent/indent.h:1.34	Fri Oct  8 19:03:34 2021
+++ src/usr.bin/indent/indent.h	Fri Oct  8 21:13:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.34 2021/10/08 19:03:34 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.35 2021/10/08 21:13:58 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -353,7 +353,7 @@ char inbuf_next(void);
 token_type lexi(struct parser_state *);
 void diag(int, const char *, ...)__printflike(2, 3);
 void dump_line(void);
-void fill_buffer(void);
+void inbuf_read_line(void);
 void parse(token_type);
 void process_comment(void);
 void set_option(const char *, const char *);

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.88 src/usr.bin/indent/io.c:1.89
--- src/usr.bin/indent/io.c:1.88	Fri Oct  8 19:03:34 2021
+++ src/usr.bin/indent/io.c	Fri Oct  8 21:13:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.88 2021/10/08 19:03:34 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.89 2021/10/08 21:13:58 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.88 2021/10/08 19:03:34 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.89 2021/10/08 21:13:58 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -408,13 +408,10 @@ parse_indent_comment(void)
  * Copyright (C) 1976 by the Board of Trustees of the University of Illinois
  *
  * All rights reserved
- *
- * FUNCTION: Reads one block of input into the input buffer
  */
 void
-fill_buffer(void)
+inbuf_read_line(void)
 {
-/* this routine reads stuff from the input */
 char *p;
 int ch;
 FILE *f = input;
@@ -454,9 +451,9 @@ fill_buffer(void)
 inp.s = inp.buf;
 inp.e = p;
 
-if (p - inp.buf > 2 && p[-2] == '/' && p[-3] == '*') {
-	if (inp.buf[3] == 'I' && strncmp(inp.buf, "/**INDENT**", 11) == 0)
-	fill_buffer();	/* flush indent error message */
+if (p - inp.buf >= 3 && p[-3] == '*' && p[-2] == '/') {
+	if (strncmp(inp.buf, "/**INDENT**", 11) == 0)
+	inbuf_read_line();	/* flush indent error message */
 	else
 	parse_indent_comment();
 }

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.80 src/usr.bin/indent/lexi.c:1.81
--- src/usr.bin/indent/lexi.c:1.80	Fri Oct  8 19:22:19 2021
+++ src/usr.bin/indent/lexi.c	Fri Oct  8 21:13:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.80 2021/10/08 19:22:19 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.81 2021/10/08 21:13:58 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.80 2021/10/08 19:22:19 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.81 2021/10/08 21:13:58 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.

CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 21:16:23 UTC 2021

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

Log Message:
indent: improve local variable names

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/usr.bin/indent/io.c
cvs rdiff -u -r1.81 -r1.82 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-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 21:16:23 UTC 2021

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

Log Message:
indent: improve local variable names

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/usr.bin/indent/io.c
cvs rdiff -u -r1.81 -r1.82 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/io.c
diff -u src/usr.bin/indent/io.c:1.89 src/usr.bin/indent/io.c:1.90
--- src/usr.bin/indent/io.c:1.89	Fri Oct  8 21:13:58 2021
+++ src/usr.bin/indent/io.c	Fri Oct  8 21:16:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.89 2021/10/08 21:13:58 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.90 2021/10/08 21:16:23 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.89 2021/10/08 21:13:58 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.90 2021/10/08 21:16:23 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -219,7 +219,7 @@ dump_line_comment(int ind)
 void
 dump_line(void)
 {
-static bool not_first_line;
+static bool first_line = true;
 
 if (ps.procname[0] != '\0') {
 	ps.ind_level = 0;
@@ -234,7 +234,7 @@ dump_line(void)
 
 } else if (!inhibit_formatting) {
 	suppress_blanklines = 0;
-	if (prefix_blankline_requested && not_first_line) {
+	if (prefix_blankline_requested && !first_line) {
 	if (opt.swallow_optional_blanklines) {
 		if (next_blank_lines == 1)
 		next_blank_lines = 0;
@@ -296,7 +296,7 @@ dump_line(void)
 	debug_println("paren_indent is now %d", paren_indent);
 }
 
-not_first_line = true;
+first_line = false;
 }
 
 int
@@ -369,7 +369,7 @@ skip_string(const char **pp, const char 
 static void
 parse_indent_comment(void)
 {
-bool on_off;
+bool on;
 
 const char *p = inp.buf;
 
@@ -382,9 +382,9 @@ parse_indent_comment(void)
 skip_hspace(&p);
 
 if (*p == '*' || skip_string(&p, "ON"))
-	on_off = true;
+	on = true;
 else if (skip_string(&p, "OFF"))
-	on_off = false;
+	on = false;
 else
 	return;
 
@@ -395,8 +395,8 @@ parse_indent_comment(void)
 if (com.s != com.e || lab.s != lab.e || code.s != code.e)
 	dump_line();
 
-inhibit_formatting = !on_off;
-if (on_off) {
+inhibit_formatting = !on;
+if (on) {
 	next_blank_lines = 0;
 	postfix_blankline_requested = false;
 	prefix_blankline_requested = false;

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.81 src/usr.bin/indent/lexi.c:1.82
--- src/usr.bin/indent/lexi.c:1.81	Fri Oct  8 21:13:58 2021
+++ src/usr.bin/indent/lexi.c	Fri Oct  8 21:16:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.81 2021/10/08 21:13:58 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.82 2021/10/08 21:16:23 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.81 2021/10/08 21:13:58 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.82 2021/10/08 21:16:23 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -129,7 +129,7 @@ struct {
  * HP H+ "."P  FS  -> $float;BP B+   IS? -> $int;
  */
 /* INDENT OFF */
-static const unsigned char num_lex_state[][26] = {
+static const unsigned char lex_number_state[][26] = {
 /*examples:
  00
  s  0xx
@@ -158,7 +158,7 @@ static const unsigned char num_lex_state
 };
 /* INDENT ON */
 
-static const uint8_t num_lex_row[] = {
+static const uint8_t lex_number_row[] = {
 ['0'] = 1,
 ['1'] = 2,
 ['2'] = 3, ['3'] = 3, ['4'] = 3, ['5'] = 3, ['6'] = 3, ['7'] = 3,
@@ -270,19 +270,19 @@ lex_number(void)
 {
 for (uint8_t s = 'A'; s != 'f' && s != 'i' && s != 'u';) {
 	uint8_t ch = (uint8_t)*inp.s;
-	if (ch >= nitems(num_lex_row) || num_lex_row[ch] == 0)
+	if (ch >= nitems(lex_number_row) || lex_number_row[ch] == 0)
 	break;
 
-	uint8_t row = num_lex_row[ch];
-	if (num_lex_state[row][s - 'A'] == ' ') {
+	uint8_t row = lex_number_row[ch];
+	if (lex_number_state[row][s - 'A'] == ' ') {
 	/*-
-	 * num_lex_state[0][s - 'A'] now indicates the type:
+	 * lex_number_state[0][s - 'A'] now indicates the type:
 	 * f = floating, i = integer, u = unknown
 	 */
 	break;
 	}
 
-	s = num_lex_state[row][s - 'A'];
+	s = lex_number_state[row][s - 'A'];
 	check_size_token(1);
 	*token.e++ = inbuf_next();
 }



CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 21:18:43 UTC 2021

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

Log Message:
indent: enhance comments for lex_number state machine

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 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-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 21:18:43 UTC 2021

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

Log Message:
indent: enhance comments for lex_number state machine

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 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.82 src/usr.bin/indent/lexi.c:1.83
--- src/usr.bin/indent/lexi.c:1.82	Fri Oct  8 21:16:23 2021
+++ src/usr.bin/indent/lexi.c	Fri Oct  8 21:18:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.82 2021/10/08 21:16:23 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.83 2021/10/08 21:18:43 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.82 2021/10/08 21:16:23 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.83 2021/10/08 21:18:43 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -138,22 +138,22 @@ static const unsigned char lex_number_st
  r   11ee0001101lbuuxx.a.pp
  t.01.e+008bLuxll0Ll.aa.p+0
 states:  ABCDEFGHIJKLMNOPQRSTUVWXYZ */
-[0] =   "uuiifuufiuuiiuiuiu",
-[1] =   "CEIDEHHHIJQ  U  Q  VUVVZZZ",
-[2] =   "DEIDEHHHIJQ  U  Q  VUVVZZZ",
-[3] =   "DEIDEHHHIJ   U VUVVZZZ",
-[4] =   "DEJDEHHHJJ   U VUVVZZZ",
-[5] =   " U VUVV   ",
-[6] =   "  K  U VUVV   ",
-[7] =   "  FFF   FF   U VUVV   ",
-[8] =   "f  f U VUVV  f",
-[9] =   "  LLf  fL  PR   Li  Lf",
-[10] =  "  OOf  fO   S P O i Of",
-[11] =  "FFX   ",
-[12] =  "  MMM  i  iiM   M ",
-[13] =  "  N   ",
-[14] =  " G Y  ",
-[15] =  "B EEEE   T  W ",
+[0] =   "uuiifuufiuuiiuiuiu",	/* (other) */
+[1] =   "CEIDEHHHIJQ  U  Q  VUVVZZZ",	/* 0 */
+[2] =   "DEIDEHHHIJQ  U  Q  VUVVZZZ",	/* 1 */
+[3] =   "DEIDEHHHIJ   U VUVVZZZ",	/* 2 3 4 5 6 7 */
+[4] =   "DEJDEHHHJJ   U VUVVZZZ",	/* 8 9 */
+[5] =   " U VUVV   ",	/* A a C c D d */
+[6] =   "  K  U VUVV   ",	/* B b */
+[7] =   "  FFF   FF   U VUVV   ",	/* E e */
+[8] =   "f  f U VUVV  f",	/* F f */
+[9] =   "  LLf  fL  PR   Li  Lf",	/* L */
+[10] =  "  OOf  fO   S P O i Of",	/* l */
+[11] =  "FFX   ",	/* P p */
+[12] =  "  MMM  i  iiM   M ",	/* U u */
+[13] =  "  N   ",	/* X x */
+[14] =  " G Y  ",	/* + - */
+[15] =  "B EEEE   T  W ",	/* . */
 /*   ABCDEFGHIJKLMNOPQRSTUVWXYZ */
 };
 /* INDENT ON */



CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 21:24:41 UTC 2021

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

Log Message:
indent: clean up typename handling

Unexport typenames list.

Replace standard binary search with custom binary search that returns
the inserting position.

In is_typename, take advantage of the buffer type instead of using
the standard C recipe for str_ends_with.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 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-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 21:24:41 UTC 2021

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

Log Message:
indent: clean up typename handling

Unexport typenames list.

Replace standard binary search with custom binary search that returns
the inserting position.

In is_typename, take advantage of the buffer type instead of using
the standard C recipe for str_ends_with.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 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.83 src/usr.bin/indent/lexi.c:1.84
--- src/usr.bin/indent/lexi.c:1.83	Fri Oct  8 21:18:43 2021
+++ src/usr.bin/indent/lexi.c	Fri Oct  8 21:24:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.83 2021/10/08 21:18:43 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.84 2021/10/08 21:24:40 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.83 2021/10/08 21:18:43 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.84 2021/10/08 21:24:40 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -106,7 +106,7 @@ static const struct keyword {
 {"while", kw_for_or_if_or_while}
 };
 
-struct {
+static struct {
 const char **items;
 unsigned int len;
 unsigned int cap;
@@ -211,12 +211,6 @@ cmp_keyword_by_name(const void *key, con
 return strcmp(key, ((const struct keyword *)elem)->name);
 }
 
-static int
-cmp_type_by_name(const void *key, const void *elem)
-{
-return strcmp(key, *((const char *const *)elem));
-}
-
 #ifdef debug
 const char *
 token_type_name(token_type ttype)
@@ -331,12 +325,9 @@ lex_char_or_string(void)
 }
 }
 
-/*
- * This hack attempts to guess whether the current token is in fact a
- * declaration keyword -- one that has been defined by typedef.
- */
+/* Guess whether the current token is a declared type. */
 static bool
-probably_typedef(const struct parser_state *state)
+probably_typename(const struct parser_state *state)
 {
 if (state->p_l_follow != 0)
 	return false;
@@ -353,19 +344,34 @@ maybe:
 	state->last_token == rbrace;
 }
 
+static int
+bsearch_typenames(const char *key)
+{
+const char **arr = typenames.items;
+int lo = 0;
+int hi = (int)typenames.len - 1;
+
+while (lo <= hi) {
+	int mid = (int)((unsigned)(lo + hi) >> 1);
+	int cmp = strcmp(arr[mid], key);
+	if (cmp < 0)
+	lo = mid + 1;
+	else if (cmp > 0)
+	hi = mid - 1;
+	else
+	return mid;
+}
+return -(lo + 1);
+}
+
 static bool
 is_typename(void)
 {
-if (opt.auto_typedefs) {
-	const char *u;
-	if ((u = strrchr(token.s, '_')) != NULL && strcmp(u, "_t") == 0)
-	return true;
-}
+if (opt.auto_typedefs &&
+	token.e - token.s >= 2 && memcmp(token.e - 2, "_t", 2) == 0)
+	return true;
 
-if (typenames.len == 0)
-	return false;
-return bsearch(token.s, typenames.items, (size_t)typenames.len,
-	sizeof(typenames.items[0]), cmp_type_by_name) != NULL;
+return bsearch_typenames(token.s) >= 0;
 }
 
 /* Reads the next token, placing it in the global variable "token". */
@@ -488,7 +494,7 @@ lexi(struct parser_state *state)
 	return lexi_end(funcname);
 not_proc:;
 
-	} else if (probably_typedef(state)) {
+	} else if (probably_typename(state)) {
 	state->keyword = kw_type;
 	state->last_u_d = true;
 	return lexi_end(decl);
@@ -697,25 +703,6 @@ lexi(struct parser_state *state)
 return lexi_end(ttype);
 }
 
-static int
-insert_pos(const char *key, const char **arr, unsigned int len)
-{
-int lo = 0;
-int hi = (int)len - 1;
-
-while (lo <= hi) {
-	int mid = (int)((unsigned)(lo + hi) >> 1);
-	int cmp = strcmp(arr[mid], key);
-	if (cmp < 0)
-	lo = mid + 1;
-	else if (cmp > 0)
-	hi = mid - 1;
-	else
-	return mid;
-}
-return -(lo + 1);
-}
-
 void
 add_typename(const char *name)
 {
@@ -725,7 +712,7 @@ add_typename(const char *name)
 	sizeof(typenames.items[0]) * typenames.cap);
 }
 
-int pos = insert_pos(name, typenames.items, typenames.len);
+int pos = bsearch_typenames(name);
 if (pos >= 0)
 	return;			/* already in the list */
 



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

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 21:32:28 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token-preprocessing.0
token-preprocessing.0.stdout

Log Message:
tests/indent: test that indent remembers unary/binary operators


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/token-preprocessing.0
cvs rdiff -u -r1.6 -r1.7 \
src/tests/usr.bin/indent/token-preprocessing.0.stdout

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-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 21:32:28 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token-preprocessing.0
token-preprocessing.0.stdout

Log Message:
tests/indent: test that indent remembers unary/binary operators


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/token-preprocessing.0
cvs rdiff -u -r1.6 -r1.7 \
src/tests/usr.bin/indent/token-preprocessing.0.stdout

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-preprocessing.0
diff -u src/tests/usr.bin/indent/token-preprocessing.0:1.4 src/tests/usr.bin/indent/token-preprocessing.0:1.5
--- src/tests/usr.bin/indent/token-preprocessing.0:1.4	Fri Oct  8 20:04:26 2021
+++ src/tests/usr.bin/indent/token-preprocessing.0	Fri Oct  8 21:32:28 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token-preprocessing.0,v 1.4 2021/10/08 20:04:26 rillig Exp $ */
+/* $NetBSD: token-preprocessing.0,v 1.5 2021/10/08 21:32:28 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*-
@@ -57,3 +57,14 @@ int s1 ;
 int s2 ;
 #define resolve_s '*/'
 int s3 ;
+
+/*
+ * A preprocessing directive inside an expression keeps the state about
+ * whether the next operator is unary or binary.
+ */
+int binary_plus = 3
+#define intermediate 1
+	+4;
+int unary_plus =
+#define intermediate 1
+	+ 4;

Index: src/tests/usr.bin/indent/token-preprocessing.0.stdout
diff -u src/tests/usr.bin/indent/token-preprocessing.0.stdout:1.6 src/tests/usr.bin/indent/token-preprocessing.0.stdout:1.7
--- src/tests/usr.bin/indent/token-preprocessing.0.stdout:1.6	Fri Oct  8 20:14:52 2021
+++ src/tests/usr.bin/indent/token-preprocessing.0.stdout	Fri Oct  8 21:32:28 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token-preprocessing.0.stdout,v 1.6 2021/10/08 20:14:52 rillig Exp $ */
+/* $NetBSD: token-preprocessing.0.stdout,v 1.7 2021/10/08 21:32:28 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*-
@@ -58,3 +58,14 @@ int		s1;
 int		s2;
 #define resolve_s '*/'
 int		s3;
+
+/*
+ * A preprocessing directive inside an expression keeps the state about
+ * whether the next operator is unary or binary.
+ */
+int		binary_plus = 3
+#define intermediate 1
++ 4;
+int		unary_plus =
+#define intermediate 1
++4;



CVS commit: src/sys/arch/aarch64/aarch64

2021-10-08 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Oct  8 21:41:29 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: aarch64_machdep.c

Log Message:
Use BOOT_FLAG() to recognize standard boot options.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/arch/aarch64/aarch64/aarch64_machdep.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/aarch64/aarch64

2021-10-08 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Fri Oct  8 21:41:29 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: aarch64_machdep.c

Log Message:
Use BOOT_FLAG() to recognize standard boot options.


To generate a diff of this commit:
cvs rdiff -u -r1.61 -r1.62 src/sys/arch/aarch64/aarch64/aarch64_machdep.c

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/aarch64_machdep.c
diff -u src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.61 src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.62
--- src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.61	Thu Jun  3 07:02:59 2021
+++ src/sys/arch/aarch64/aarch64/aarch64_machdep.c	Fri Oct  8 21:41:29 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: aarch64_machdep.c,v 1.61 2021/06/03 07:02:59 skrll Exp $ */
+/* $NetBSD: aarch64_machdep.c,v 1.62 2021/10/08 21:41:29 ryo Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.61 2021/06/03 07:02:59 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.62 2021/10/08 21:41:29 ryo Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_cpuoptions.h"
@@ -42,6 +42,7 @@ __KERNEL_RCSID(1, "$NetBSD: aarch64_mach
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -537,24 +538,26 @@ SYSCTL_SETUP(sysctl_machdep_setup, "sysc
 void
 parse_mi_bootargs(char *args)
 {
-	int val;
+	const char *p = args;
 
-	if (get_bootconf_option(args, "-1", BOOTOPT_TYPE_BOOLEAN, &val) && val)
-		boothowto |= RB_MD1;
-	if (get_bootconf_option(args, "-s", BOOTOPT_TYPE_BOOLEAN, &val) && val)
-		boothowto |= RB_SINGLE;
-	if (get_bootconf_option(args, "-d", BOOTOPT_TYPE_BOOLEAN, &val) && val)
-		boothowto |= RB_KDB;
-	if (get_bootconf_option(args, "-a", BOOTOPT_TYPE_BOOLEAN, &val) && val)
-		boothowto |= RB_ASKNAME;
-	if (get_bootconf_option(args, "-q", BOOTOPT_TYPE_BOOLEAN, &val) && val)
-		boothowto |= AB_QUIET;
-	if (get_bootconf_option(args, "-v", BOOTOPT_TYPE_BOOLEAN, &val) && val)
-		boothowto |= AB_VERBOSE;
-	if (get_bootconf_option(args, "-x", BOOTOPT_TYPE_BOOLEAN, &val) && val)
-		boothowto |= AB_DEBUG;
-	if (get_bootconf_option(args, "-z", BOOTOPT_TYPE_BOOLEAN, &val) && val)
-		boothowto |= AB_SILENT;
+	while (*p != '\0') {
+		while (isspace(*p))
+			p++;
+
+		/* parse single dash (`-') options */
+		if (*p == '-') {
+			p++;
+			while (!isspace(*p) && *p != '\0') {
+BOOT_FLAG(*p, boothowto);
+p++;
+			}
+			continue;
+		}
+
+		/* skip normal argument */
+		while (!isspace(*p) && *p != '\0')
+			p++;
+	}
 }
 
 void



CVS commit: src

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 21:48:33 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token-keyword_else.0
token-keyword_else.0.stdout
src/usr.bin/indent: parse.c

Log Message:
indent: clean up 'parse', add test for dangling else

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/token-keyword_else.0 \
src/tests/usr.bin/indent/token-keyword_else.0.stdout
cvs rdiff -u -r1.33 -r1.34 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

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 21:48:33 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token-keyword_else.0
token-keyword_else.0.stdout
src/usr.bin/indent: parse.c

Log Message:
indent: clean up 'parse', add test for dangling else

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/token-keyword_else.0 \
src/tests/usr.bin/indent/token-keyword_else.0.stdout
cvs rdiff -u -r1.33 -r1.34 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-keyword_else.0
diff -u src/tests/usr.bin/indent/token-keyword_else.0:1.1 src/tests/usr.bin/indent/token-keyword_else.0:1.2
--- src/tests/usr.bin/indent/token-keyword_else.0:1.1	Fri Mar 12 00:13:06 2021
+++ src/tests/usr.bin/indent/token-keyword_else.0	Fri Oct  8 21:48:33 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token-keyword_else.0,v 1.1 2021/03/12 00:13:06 rillig Exp $ */
+/* $NetBSD: token-keyword_else.0,v 1.2 2021/10/08 21:48:33 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -9,4 +9,21 @@
  * innermost incomplete 'if' statement.
  */
 
-/* TODO: Add some code to be formatted. */
+/*
+ * In 'parse', an if_expr_stmt is reduced to a simple statement, unless the
+ * next token is 'else'. The comment does not influence this since it never
+ * reaches 'parse'.
+ */
+void
+example(bool cond)
+{
+	if (cond)
+	if (cond)
+	if (cond)
+	stmt();
+	else
+	stmt();
+	/* comment */
+	else
+	stmt();
+}
Index: src/tests/usr.bin/indent/token-keyword_else.0.stdout
diff -u src/tests/usr.bin/indent/token-keyword_else.0.stdout:1.1 src/tests/usr.bin/indent/token-keyword_else.0.stdout:1.2
--- src/tests/usr.bin/indent/token-keyword_else.0.stdout:1.1	Fri Mar 12 00:13:06 2021
+++ src/tests/usr.bin/indent/token-keyword_else.0.stdout	Fri Oct  8 21:48:33 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token-keyword_else.0.stdout,v 1.1 2021/03/12 00:13:06 rillig Exp $ */
+/* $NetBSD: token-keyword_else.0.stdout,v 1.2 2021/10/08 21:48:33 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -9,4 +9,21 @@
  * innermost incomplete 'if' statement.
  */
 
-/* TODO: Add some code to be formatted. */
+/*
+ * In 'parse', an if_expr_stmt is reduced to a simple statement, unless the
+ * next token is 'else'. The comment does not influence this since it never
+ * reaches 'parse'.
+ */
+void
+example(bool cond)
+{
+	if (cond)
+		if (cond)
+			if (cond)
+stmt();
+			else
+stmt();
+	/* comment */
+		else
+			stmt();
+}

Index: src/usr.bin/indent/parse.c
diff -u src/usr.bin/indent/parse.c:1.33 src/usr.bin/indent/parse.c:1.34
--- src/usr.bin/indent/parse.c:1.33	Thu Oct  7 22:56:49 2021
+++ src/usr.bin/indent/parse.c	Fri Oct  8 21:48:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.33 2021/10/07 22:56:49 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.34 2021/10/08 21:48:33 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -62,16 +62,14 @@ static void reduce(void);
 void
 parse(token_type ttype)
 {
+debug_println("parse token: '%s' \"%s\"",
+	token_type_name(ttype), token.s);
 
-#ifdef debug
-printf("parse token: '%s' \"%s\"\n", token_type_name(ttype), token.s);
-#endif
-
-while (ps.p_stack[ps.tos] == if_expr_stmt && ttype != keyword_else) {
-	/* true if we have an if without an else */
-	ps.p_stack[ps.tos] = stmt;	/* apply the if(..) stmt ::= stmt
-	 * reduction */
-	reduce();		/* see if this allows any reduction */
+if (ttype != keyword_else) {
+	while (ps.p_stack[ps.tos] == if_expr_stmt) {
+	ps.p_stack[ps.tos] = stmt;
+	reduce();
+	}
 }
 
 switch (ttype) {



CVS commit: src/usr.sbin/sysinst

2021-10-08 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Oct  8 22:07:11 UTC 2021

Modified Files:
src/usr.sbin/sysinst: msg.entropy.es msg.entropy.fr msg.entropy.pl

Log Message:
Fix accidental word duplication


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/sysinst/msg.entropy.es \
src/usr.sbin/sysinst/msg.entropy.fr src/usr.sbin/sysinst/msg.entropy.pl

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



CVS commit: src/usr.sbin/sysinst

2021-10-08 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Fri Oct  8 22:07:11 UTC 2021

Modified Files:
src/usr.sbin/sysinst: msg.entropy.es msg.entropy.fr msg.entropy.pl

Log Message:
Fix accidental word duplication


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/sysinst/msg.entropy.es \
src/usr.sbin/sysinst/msg.entropy.fr src/usr.sbin/sysinst/msg.entropy.pl

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

Modified files:

Index: src/usr.sbin/sysinst/msg.entropy.es
diff -u src/usr.sbin/sysinst/msg.entropy.es:1.3 src/usr.sbin/sysinst/msg.entropy.es:1.4
--- src/usr.sbin/sysinst/msg.entropy.es:1.3	Fri Oct  8 15:59:55 2021
+++ src/usr.sbin/sysinst/msg.entropy.es	Fri Oct  8 22:07:11 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: msg.entropy.es,v 1.3 2021/10/08 15:59:55 martin Exp $  */
+/*  $NetBSD: msg.entropy.es,v 1.4 2021/10/08 22:07:11 nia Exp $  */
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@ If you own a USB random number device, c
 the "Re-test" option.}
 
 message entropy_add_manually		{Manual input of random data}
-message entropy_download_raw		{Load raw binary random random data}
+message entropy_download_raw		{Load raw binary random data}
 message	entropy_download_seed		{Import a NetBSD entropy file}
 message entropy_retry			{Re-test}
 
Index: src/usr.sbin/sysinst/msg.entropy.fr
diff -u src/usr.sbin/sysinst/msg.entropy.fr:1.3 src/usr.sbin/sysinst/msg.entropy.fr:1.4
--- src/usr.sbin/sysinst/msg.entropy.fr:1.3	Fri Oct  8 15:59:55 2021
+++ src/usr.sbin/sysinst/msg.entropy.fr	Fri Oct  8 22:07:11 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: msg.entropy.fr,v 1.3 2021/10/08 15:59:55 martin Exp $  */
+/*  $NetBSD: msg.entropy.fr,v 1.4 2021/10/08 22:07:11 nia Exp $  */
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@ If you own a USB random number device, c
 the "Re-test" option.}
 
 message entropy_add_manually		{Manual input of random data}
-message entropy_download_raw		{Load raw binary random random data}
+message entropy_download_raw		{Load raw binary random data}
 message	entropy_download_seed		{Import a NetBSD entropy file}
 message entropy_retry			{Re-test}
 
Index: src/usr.sbin/sysinst/msg.entropy.pl
diff -u src/usr.sbin/sysinst/msg.entropy.pl:1.3 src/usr.sbin/sysinst/msg.entropy.pl:1.4
--- src/usr.sbin/sysinst/msg.entropy.pl:1.3	Fri Oct  8 15:59:55 2021
+++ src/usr.sbin/sysinst/msg.entropy.pl	Fri Oct  8 22:07:11 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: msg.entropy.pl,v 1.3 2021/10/08 15:59:55 martin Exp $  */
+/*  $NetBSD: msg.entropy.pl,v 1.4 2021/10/08 22:07:11 nia Exp $  */
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@ If you own a USB random number device, c
 the "Re-test" option.}
 
 message entropy_add_manually		{Manual input of random data}
-message entropy_download_raw		{Load raw binary random random data}
+message entropy_download_raw		{Load raw binary random data}
 message	entropy_download_seed		{Import a NetBSD entropy file}
 message entropy_retry			{Re-test}
 



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

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 22:11:26 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token-comment.0 token-comment.0.stdout

Log Message:
tests/indent: test formatting of a chaotic boxed comment


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/token-comment.0
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/token-comment.0.stdout

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-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 22:11:26 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token-comment.0 token-comment.0.stdout

Log Message:
tests/indent: test formatting of a chaotic boxed comment


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/token-comment.0
cvs rdiff -u -r1.6 -r1.7 src/tests/usr.bin/indent/token-comment.0.stdout

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.0
diff -u src/tests/usr.bin/indent/token-comment.0:1.5 src/tests/usr.bin/indent/token-comment.0:1.6
--- src/tests/usr.bin/indent/token-comment.0:1.5	Tue Oct  5 21:01:10 2021
+++ src/tests/usr.bin/indent/token-comment.0	Fri Oct  8 22:11:26 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token-comment.0,v 1.5 2021/10/05 21:01:10 rillig Exp $ */
+/* $NetBSD: token-comment.0,v 1.6 2021/10/08 22:11:26 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -139,3 +139,15 @@ void indent_on ( void ) ;
 void indent_still_on ( void ) ;	/* due to the colon in the middle */
 /* INDENT OFF */		/* extra comment */
 void indent_still_on ( void ) ;	/* due to the extra comment to the right */
+
+/*
+	 * this
+		 * is a boxed
+			 * staircase.
+*
+* Its paragraphs get wrapped.
+
+There may also be
+		lines without asterisks.
+
+ */

Index: src/tests/usr.bin/indent/token-comment.0.stdout
diff -u src/tests/usr.bin/indent/token-comment.0.stdout:1.6 src/tests/usr.bin/indent/token-comment.0.stdout:1.7
--- src/tests/usr.bin/indent/token-comment.0.stdout:1.6	Tue Oct  5 21:01:10 2021
+++ src/tests/usr.bin/indent/token-comment.0.stdout	Fri Oct  8 22:11:26 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token-comment.0.stdout,v 1.6 2021/10/05 21:01:10 rillig Exp $ */
+/* $NetBSD: token-comment.0.stdout,v 1.7 2021/10/08 22:11:26 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -151,3 +151,12 @@ indent_still_on(void);		/* due to the co
 /* INDENT OFF *//* extra comment */
 void
 indent_still_on(void);		/* due to the extra comment to the right */
+
+/*
+ * this is a boxed staircase.
+ *
+ * Its paragraphs get wrapped.
+ *
+ * There may also be lines without asterisks.
+ *
+ */



CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 22:17:36 UTC 2021

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

Log Message:
indent: convert ps.box_com to local variable

This variable is only used in a single function, and that function does
not call any other function that could replace the parser state or
install a temporary parser state.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.64 -r1.65 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-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 22:17:36 UTC 2021

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

Log Message:
indent: convert ps.box_com to local variable

This variable is only used in a single function, and that function does
not call any other function that could replace the parser state or
install a temporary parser state.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.64 -r1.65 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.h
diff -u src/usr.bin/indent/indent.h:1.35 src/usr.bin/indent/indent.h:1.36
--- src/usr.bin/indent/indent.h:1.35	Fri Oct  8 21:13:58 2021
+++ src/usr.bin/indent/indent.h	Fri Oct  8 22:17:35 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.35 2021/10/08 21:13:58 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.36 2021/10/08 22:17:35 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -254,9 +254,6 @@ extern struct parser_state {
 token_type p_stack[STACKSIZE];
 int il[STACKSIZE];		/* this stack stores indentation levels */
 float cstk[STACKSIZE];	/* used to store case stmt indentation levels */
-bool box_com;		/* whether we are in a "boxed" comment. In
- * that case, the first non-blank char should
- * be lined up with the '/' in '/' + '*' */
 int comment_delta;		/* used to set up indentation for all lines of
  * a boxed comment after the first one */
 int n_comment_delta;	/* remembers how many columns there were

Index: src/usr.bin/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.64 src/usr.bin/indent/pr_comment.c:1.65
--- src/usr.bin/indent/pr_comment.c:1.64	Fri Oct  8 21:13:58 2021
+++ src/usr.bin/indent/pr_comment.c	Fri Oct  8 22:17:35 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.64 2021/10/08 21:13:58 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.65 2021/10/08 22:17:35 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.64 2021/10/08 21:13:58 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.65 2021/10/08 22:17:35 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -90,7 +90,7 @@ process_comment(void)
 adj_max_line_length = opt.max_line_length;
 ps.just_saw_decl = 0;
 last_blank = -1;		/* no blanks found so far */
-ps.box_com = false;		/* at first, assume that we are not in a boxed
+bool box_com = false;	/* at first, assume that we are not in a boxed
  * comment or some other comment that should
  * not be touched */
 ps.stats.comments++;
@@ -99,20 +99,14 @@ process_comment(void)
 
 if (ps.col_1 && !opt.format_col1_comments) { /* if the comment starts in
  * column 1, it should not be touched */
-	ps.box_com = true;
+	box_com = true;
 	break_delim = false;
 	ps.com_ind = 0;
 
 } else {
 	if (*inp.s == '-' || *inp.s == '*' || token.e[-1] == '/' ||
 	(*inp.s == '\n' && !opt.format_block_comments)) {
-	ps.box_com = true;	/* A comment with a '-' or '*' immediately
- * after the /+* is assumed to be a boxed
- * comment. A comment with a newline
- * immediately after the /+* is assumed to be
- * a block comment and is treated as a box
- * comment unless format_block_comments is
- * nonzero (the default). */
+	box_com = true;
 	break_delim = false;
 	}
 
@@ -143,7 +137,7 @@ process_comment(void)
 	}
 }
 
-if (ps.box_com) {
+if (box_com) {
 	/*
 	 * Find out how much indentation there was originally, because that
 	 * much will have to be ignored by dump_line(). This is a box comment,
@@ -170,7 +164,7 @@ process_comment(void)
 ps.comment_delta = 0;
 *com.e++ = '/';
 *com.e++ = token.e[-1];
-if (*inp.s != ' ' && !ps.box_com)
+if (*inp.s != ' ' && !box_com)
 	*com.e++ = ' ';
 
 /* Don't put a break delimiter if this is a one-liner that won't wrap. */
@@ -201,7 +195,7 @@ process_comment(void)
 	prefix_blankline_requested = true;
 	dump_line();
 	com.e = com.s = t;
-	if (!ps.box_com && opt.star_comment_cont)
+	if (!box_com && opt.star_comment_cont)
 	*com.e++ = ' ', *com.e++ = '*', *com.e++ = ' ';
 }
 
@@ -212,11 +206,11 @@ process_comment(void)
 	switch (*inp.s) {	/* this checks for various special cases */
 	case '\f':
 	check_size_comment(3);
-	if (!ps.box_com) {	/* in a text comment, break the line here */
+	if (!box_com) {	/* in a text comment, break the line here */
 		ps.use_ff = true;
 		dump_line();
 		last_blank = -1;
-		if (!ps.box_com && opt.star_comment_cont)
+		if (!box_com && opt.star_comment_cont)
 		*com.e++ = ' ', *com.e++ = '*', *c

CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 22:22:14 UTC 2021

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

Log Message:
indent: remove redundant conditions

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 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.65 src/usr.bin/indent/pr_comment.c:1.66
--- src/usr.bin/indent/pr_comment.c:1.65	Fri Oct  8 22:17:35 2021
+++ src/usr.bin/indent/pr_comment.c	Fri Oct  8 22:22:14 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.65 2021/10/08 22:17:35 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.66 2021/10/08 22:22:14 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.65 2021/10/08 22:17:35 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.66 2021/10/08 22:22:14 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -210,7 +210,7 @@ process_comment(void)
 		ps.use_ff = true;
 		dump_line();
 		last_blank = -1;
-		if (!box_com && opt.star_comment_cont)
+		if (opt.star_comment_cont)
 		*com.e++ = ' ', *com.e++ = '*', *com.e++ = ' ';
 		inp.s++;
 		while (is_hspace(*inp.s))
@@ -320,7 +320,7 @@ process_comment(void)
 		/* the comment is too long, it must be broken up */
 		if (last_blank == -1) {
 		dump_line();
-		if (!box_com && opt.star_comment_cont)
+		if (opt.star_comment_cont)
 			*com.e++ = ' ', *com.e++ = '*', *com.e++ = ' ';
 		break;
 		}
@@ -329,7 +329,7 @@ process_comment(void)
 		com.e = com.buf + last_blank;
 		dump_line();
 
-		if (!box_com && opt.star_comment_cont)
+		if (opt.star_comment_cont)
 		*com.e++ = ' ', *com.e++ = '*', *com.e++ = ' ';
 
 		const char *p = com.buf + last_blank + 1;



CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 22:22:14 UTC 2021

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

Log Message:
indent: remove redundant conditions

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 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-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 22:27:52 UTC 2021

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

Log Message:
indent: use standard error handling for unterminated comment

Just writing it to stdout is bad, especially when indent is used in
filter mode. Silently continuing after such an error is bad as well.

echo '/*' | indent


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 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-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 22:27:52 UTC 2021

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

Log Message:
indent: use standard error handling for unterminated comment

Just writing it to stdout is bad, especially when indent is used in
filter mode. Silently continuing after such an error is bad as well.

echo '/*' | indent


To generate a diff of this commit:
cvs rdiff -u -r1.66 -r1.67 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.66 src/usr.bin/indent/pr_comment.c:1.67
--- src/usr.bin/indent/pr_comment.c:1.66	Fri Oct  8 22:22:14 2021
+++ src/usr.bin/indent/pr_comment.c	Fri Oct  8 22:27:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.66 2021/10/08 22:22:14 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.67 2021/10/08 22:27:52 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.66 2021/10/08 22:22:14 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.67 2021/10/08 22:27:52 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -226,7 +226,7 @@ process_comment(void)
 		goto end_of_line_comment;
 
 	if (had_eof) {
-		printf("Unterminated comment\n");
+		diag(1, "Unterminated comment");
 		dump_line();
 		return;
 	}



CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 22:37:34 UTC 2021

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

Log Message:
indent: replace unreachable code with assertions

The input buffer is always supposed to be terminated with a newline. The
function inbuf_read_line silently skips null characters. Since the input
buffer is redirected to a temporary buffer in some cases, do not simply
remove this supposed dead code, but replace it with assertions.

In any case, if the code for calling inbuf_read_line had been reachable
and actually allocated a different buffer, continuing to use the pointer
p would have invoked undefined behavior anyway.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 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-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 22:37:34 UTC 2021

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

Log Message:
indent: replace unreachable code with assertions

The input buffer is always supposed to be terminated with a newline. The
function inbuf_read_line silently skips null characters. Since the input
buffer is redirected to a temporary buffer in some cases, do not simply
remove this supposed dead code, but replace it with assertions.

In any case, if the code for calling inbuf_read_line had been reachable
and actually allocated a different buffer, continuing to use the pointer
p would have invoked undefined behavior anyway.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 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.67 src/usr.bin/indent/pr_comment.c:1.68
--- src/usr.bin/indent/pr_comment.c:1.67	Fri Oct  8 22:27:52 2021
+++ src/usr.bin/indent/pr_comment.c	Fri Oct  8 22:37:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.67 2021/10/08 22:27:52 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.68 2021/10/08 22:37:33 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,11 +43,12 @@ static char sccsid[] = "@(#)pr_comment.c
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: pr_comment.c,v 1.67 2021/10/08 22:27:52 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.68 2021/10/08 22:37:33 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
 
+#include 
 #include 
 #include 
 
@@ -169,9 +170,9 @@ process_comment(void)
 
 /* Don't put a break delimiter if this is a one-liner that won't wrap. */
 if (break_delim) {
-	for (const char *p = inp.s; *p != '\0' && *p != '\n'; p++) {
-	if (p >= inp.e)
-		inbuf_read_line();
+	for (const char *p = inp.s; *p != '\n'; p++) {
+	assert(*p != '\0');
+	assert(p < inp.e);
 	if (p[0] == '*' && p[1] == '/') {
 		/*
 		 * XXX: This computation ignores the leading " * ", as well as



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

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 23:04:02 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token-colon.0 token-colon.0.stdout

Log Message:
tests/indent: test formatting of the token ':'


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/token-colon.0 \
src/tests/usr.bin/indent/token-colon.0.stdout

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-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 23:04:02 UTC 2021

Modified Files:
src/tests/usr.bin/indent: token-colon.0 token-colon.0.stdout

Log Message:
tests/indent: test formatting of the token ':'


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/token-colon.0 \
src/tests/usr.bin/indent/token-colon.0.stdout

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-colon.0
diff -u src/tests/usr.bin/indent/token-colon.0:1.1 src/tests/usr.bin/indent/token-colon.0:1.2
--- src/tests/usr.bin/indent/token-colon.0:1.1	Fri Mar 12 00:13:06 2021
+++ src/tests/usr.bin/indent/token-colon.0	Fri Oct  8 23:04:02 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token-colon.0,v 1.1 2021/03/12 00:13:06 rillig Exp $ */
+/* $NetBSD: token-colon.0,v 1.2 2021/10/08 23:04:02 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -14,4 +14,21 @@
  * In the declaration of a struct member that is a bit-field.
  */
 
-/* TODO: Add some code to be formatted. */
+void endless(void)
+{
+label1:
+goto label2;
+
+if (true)if (true)if (true)if (true)label2 :goto label1;
+}
+
+int constant_expression = true?4:12345;
+
+struct bit_field {
+bool flag:1;
+int maybe_signed : 4;
+signed int definitely_signed:3;
+signed int : 0;/* finish the storage unit for the bit-field */
+unsigned int definitely_unsigned:3;
+unsigned int:0;/* finish the storage unit for the bit-field */
+};
Index: src/tests/usr.bin/indent/token-colon.0.stdout
diff -u src/tests/usr.bin/indent/token-colon.0.stdout:1.1 src/tests/usr.bin/indent/token-colon.0.stdout:1.2
--- src/tests/usr.bin/indent/token-colon.0.stdout:1.1	Fri Mar 12 00:13:06 2021
+++ src/tests/usr.bin/indent/token-colon.0.stdout	Fri Oct  8 23:04:02 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token-colon.0.stdout,v 1.1 2021/03/12 00:13:06 rillig Exp $ */
+/* $NetBSD: token-colon.0.stdout,v 1.2 2021/10/08 23:04:02 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -14,4 +14,28 @@
  * In the declaration of a struct member that is a bit-field.
  */
 
-/* TODO: Add some code to be formatted. */
+void
+endless(void)
+{
+label1:
+	goto label2;
+
+	if (true)
+		if (true)
+			if (true)
+if (true)
+			label2:		goto label1;
+}
+
+int		constant_expression = true ? 4 : 12345;
+
+struct bit_field {
+	bool		flag:1;
+	int		maybe_signed:4;
+	signed int	definitely_signed:3;
+/* $ XXX: Placing the colon directly at the type looks inconsistent. */
+	signed int:	0;	/* finish the storage unit for the bit-field */
+	unsigned int	definitely_unsigned:3;
+/* $ XXX: Placing the colon directly at the type looks inconsistent. */
+	unsigned int:	0;	/* finish the storage unit for the bit-field */
+};



CVS commit: src/sys/external/bsd/gnu-efi/dist/gnuefi

2021-10-08 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct  8 23:08:06 UTC 2021

Modified Files:
src/sys/external/bsd/gnu-efi/dist/gnuefi: reloc_x86_64.c

Log Message:
gnu-efi: x86_64 build fixes for NetBSD


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2 -r1.2 \
src/sys/external/bsd/gnu-efi/dist/gnuefi/reloc_x86_64.c

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



CVS commit: src/sys/external/bsd/gnu-efi/dist/gnuefi

2021-10-08 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Oct  8 23:08:06 UTC 2021

Modified Files:
src/sys/external/bsd/gnu-efi/dist/gnuefi: reloc_x86_64.c

Log Message:
gnu-efi: x86_64 build fixes for NetBSD


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2 -r1.2 \
src/sys/external/bsd/gnu-efi/dist/gnuefi/reloc_x86_64.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/external/bsd/gnu-efi/dist/gnuefi/reloc_x86_64.c
diff -u src/sys/external/bsd/gnu-efi/dist/gnuefi/reloc_x86_64.c:1.1.1.2 src/sys/external/bsd/gnu-efi/dist/gnuefi/reloc_x86_64.c:1.2
--- src/sys/external/bsd/gnu-efi/dist/gnuefi/reloc_x86_64.c:1.1.1.2	Thu Aug 16 18:17:47 2018
+++ src/sys/external/bsd/gnu-efi/dist/gnuefi/reloc_x86_64.c	Fri Oct  8 23:08:06 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: reloc_x86_64.c,v 1.1.1.2 2018/08/16 18:17:47 jmcneill Exp $	*/
+/*	$NetBSD: reloc_x86_64.c,v 1.2 2021/10/08 23:08:06 jmcneill Exp $	*/
 
 /* reloc_x86_64.c - position independent x86_64 ELF shared object relocator
Copyright (C) 1999 Hewlett-Packard Co.
@@ -40,7 +40,14 @@
 #include 
 #include 
 
+#ifdef __NetBSD__
+#include 
+#include 
+#else
 #include 
+#endif
+
+EFI_STATUS _relocate (long, Elf64_Dyn *, EFI_HANDLE, EFI_SYSTEM_TABLE *);
 
 EFI_STATUS _relocate (long ldbase, Elf64_Dyn *dyn,
 		  EFI_HANDLE image EFI_UNUSED,



CVS commit: xsrc/external/mit/xf86-input-ws/dist/src

2021-10-08 Thread Nia Alarie
Module Name:xsrc
Committed By:   nia
Date:   Fri Oct  8 23:30:17 UTC 2021

Modified Files:
xsrc/external/mit/xf86-input-ws/dist/src: ws.c ws.h

Log Message:
xf86-input-ws: Port auto-calibration bits from xf86-input-mouse.

Needed for absolute input devices where pointer coordinates do not
match the display size.

Tested by jmcneill.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 xsrc/external/mit/xf86-input-ws/dist/src/ws.c
cvs rdiff -u -r1.4 -r1.5 xsrc/external/mit/xf86-input-ws/dist/src/ws.h

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



CVS commit: xsrc/external/mit/xf86-input-ws/dist/src

2021-10-08 Thread Nia Alarie
Module Name:xsrc
Committed By:   nia
Date:   Fri Oct  8 23:30:17 UTC 2021

Modified Files:
xsrc/external/mit/xf86-input-ws/dist/src: ws.c ws.h

Log Message:
xf86-input-ws: Port auto-calibration bits from xf86-input-mouse.

Needed for absolute input devices where pointer coordinates do not
match the display size.

Tested by jmcneill.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 xsrc/external/mit/xf86-input-ws/dist/src/ws.c
cvs rdiff -u -r1.4 -r1.5 xsrc/external/mit/xf86-input-ws/dist/src/ws.h

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

Modified files:

Index: xsrc/external/mit/xf86-input-ws/dist/src/ws.c
diff -u xsrc/external/mit/xf86-input-ws/dist/src/ws.c:1.13 xsrc/external/mit/xf86-input-ws/dist/src/ws.c:1.14
--- xsrc/external/mit/xf86-input-ws/dist/src/ws.c:1.13	Fri Oct  1 07:14:37 2021
+++ xsrc/external/mit/xf86-input-ws/dist/src/ws.c	Fri Oct  8 23:30:17 2021
@@ -219,6 +219,10 @@ wsPreInit12(InputDriverPtr drv, InputInf
 		buttons_from = X_CONFIG;
 	}
 
+	priv->autoCalibrate = xf86SetBoolOption(pInfo->options, "AutoCalibrate", TRUE);
+	xf86Msg(X_CONFIG, "%s: auto calibration %sabled\n",
+	pInfo->name, priv->autoCalibrate ? "en" : "dis"); 
+
 	priv->screen_no = xf86SetIntOption(pInfo->options, "ScreenNo", 0);
 	xf86Msg(X_CONFIG, "%s associated screen: %d\n",
 	pInfo->name, priv->screen_no);
@@ -602,6 +606,45 @@ wsDeviceOff(DeviceIntPtr pWS)
 }
 
 static void
+wsAutoCalibrate(InputInfoPtr pInfo)
+{
+	WSDevicePtr priv;
+	int width, height;
+	struct wsmouse_calibcoords cal;
+
+	priv = pInfo->private;
+	width = screenInfo.screens[priv->screen_no]->width;
+	height = screenInfo.screens[priv->screen_no]->height;
+
+	if (width != priv->lastScreenWidth ||
+	height != priv->lastScreenHeight) {
+		if (ioctl(pInfo->fd, WSMOUSEIO_GCALIBCOORDS, &cal) == 0 &&
+		cal.minx != cal.maxy && cal.miny != cal.maxy) {
+
+			xf86Msg(X_INFO, "%s: auto-calibrating abs pointer for %dx%d screen\n",
+			pInfo->name, width, height);
+
+			priv->min_x = cal.minx;
+			priv->min_y = cal.miny;
+			priv->max_x = cal.maxx;
+			priv->max_y = cal.maxy;
+
+			priv->translateAbs =
+			cal.samplelen == WSMOUSE_CALIBCOORDS_RESET;
+		}
+		priv->lastScreenWidth = width;
+		priv->lastScreenHeight = height;
+	}
+}
+
+static int
+wsTranslate(InputInfoPtr pInfo, int scrRange,
+int rawMin, int rawMax, int rawVal)
+{
+	return ((rawVal - rawMin) * scrRange) / (rawMax - rawMin);
+}
+
+static void
 wsReadInput(InputInfoPtr pInfo)
 {
 	WSDevicePtr priv;
@@ -613,6 +656,9 @@ wsReadInput(InputInfoPtr pInfo)
 
 	priv = pInfo->private;
 
+	if (priv->autoCalibrate)
+		wsAutoCalibrate(pInfo);
+
 	XisbBlockDuration(priv->buffer, -1);
 	pBuf = (unsigned char *)eventList;
 	n = 0;
@@ -658,12 +704,19 @@ wsReadInput(InputInfoPtr pInfo)
 			if (event->value == 4095) 
 break;
 			ax = event->value;
+			if (priv->translateAbs)
+ax = wsTranslate(pInfo,
+priv->lastScreenWidth,
+priv->min_x, priv->max_x, ax);
 			if (priv->inv_x)
 ax = priv->max_x - ax + priv->min_x;
 			break;
 		case WSCONS_EVENT_MOUSE_ABSOLUTE_Y:
 			DBG(4, ErrorF("Absolute Y %d\n", event->value));
 			ay = event->value;
+			if (priv->translateAbs)
+ay = wsTranslate(pInfo, priv->lastScreenWidth,
+priv->min_y, priv->max_y, ay);
 			if (priv->inv_y)
 ay = priv->max_y - ay + priv->min_y;
 			break;

Index: xsrc/external/mit/xf86-input-ws/dist/src/ws.h
diff -u xsrc/external/mit/xf86-input-ws/dist/src/ws.h:1.4 xsrc/external/mit/xf86-input-ws/dist/src/ws.h:1.5
--- xsrc/external/mit/xf86-input-ws/dist/src/ws.h:1.4	Tue Sep 28 06:17:15 2021
+++ xsrc/external/mit/xf86-input-ws/dist/src/ws.h	Fri Oct  8 23:30:17 2021
@@ -47,6 +47,9 @@ typedef struct WSDevice {
 	int screen_no;
 	int num, den, threshold; /* relative accel params */
 	pointer buffer;
+	int autoCalibrate;
+	int translateAbs;
+	int lastScreenWidth, lastScreenHeight;
 	int negativeZ, positiveZ; /* mappings for Z axis */
 	int negativeW, positiveW; /* mappings for W axis */
 	struct wsmouse_calibcoords coords; /* mirror of the kernel values */



CVS commit: src

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 23:40:08 UTC 2021

Modified Files:
src/tests/usr.bin/indent: opt-ldi.0 opt-ldi.0.stdout
src/usr.bin/indent: lexi.c

Log Message:
indent: remove 'global' from the list of keywords

Since 1978, 'global' has not been a keyword in C. Moreover, it was
declared as a type while its name would rather suggest a storage class.

Removing the keyword fixes the formatting of variables named 'global'.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/opt-ldi.0 \
src/tests/usr.bin/indent/opt-ldi.0.stdout
cvs rdiff -u -r1.84 -r1.85 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-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 23:40:08 UTC 2021

Modified Files:
src/tests/usr.bin/indent: opt-ldi.0 opt-ldi.0.stdout
src/usr.bin/indent: lexi.c

Log Message:
indent: remove 'global' from the list of keywords

Since 1978, 'global' has not been a keyword in C. Moreover, it was
declared as a type while its name would rather suggest a storage class.

Removing the keyword fixes the formatting of variables named 'global'.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/opt-ldi.0 \
src/tests/usr.bin/indent/opt-ldi.0.stdout
cvs rdiff -u -r1.84 -r1.85 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/opt-ldi.0
diff -u src/tests/usr.bin/indent/opt-ldi.0:1.2 src/tests/usr.bin/indent/opt-ldi.0:1.3
--- src/tests/usr.bin/indent/opt-ldi.0:1.2	Sat Mar  6 22:10:40 2021
+++ src/tests/usr.bin/indent/opt-ldi.0	Fri Oct  8 23:40:08 2021
@@ -1,7 +1,6 @@
-/* $NetBSD: opt-ldi.0,v 1.2 2021/03/06 22:10:40 rillig Exp $ */
+/* $NetBSD: opt-ldi.0,v 1.3 2021/10/08 23:40:08 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* FIXME: Why does -ldi affect global variables? */
 int global;
 
 void
Index: src/tests/usr.bin/indent/opt-ldi.0.stdout
diff -u src/tests/usr.bin/indent/opt-ldi.0.stdout:1.2 src/tests/usr.bin/indent/opt-ldi.0.stdout:1.3
--- src/tests/usr.bin/indent/opt-ldi.0.stdout:1.2	Sat Mar  6 22:10:40 2021
+++ src/tests/usr.bin/indent/opt-ldi.0.stdout	Fri Oct  8 23:40:08 2021
@@ -1,8 +1,7 @@
-/* $NetBSD: opt-ldi.0.stdout,v 1.2 2021/03/06 22:10:40 rillig Exp $ */
+/* $NetBSD: opt-ldi.0.stdout,v 1.3 2021/10/08 23:40:08 rillig Exp $ */
 /* $FreeBSD$ */
 
-/* FIXME: Why does -ldi affect global variables? */
-int global;
+int		global;
 
 void
 function(void)

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.84 src/usr.bin/indent/lexi.c:1.85
--- src/usr.bin/indent/lexi.c:1.84	Fri Oct  8 21:24:40 2021
+++ src/usr.bin/indent/lexi.c	Fri Oct  8 23:40:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.84 2021/10/08 21:24:40 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.85 2021/10/08 23:40:08 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.84 2021/10/08 21:24:40 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.85 2021/10/08 23:40:08 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -81,7 +81,6 @@ static const struct keyword {
 {"extern", kw_storage_class},
 {"float", kw_type},
 {"for", kw_for_or_if_or_while},
-{"global", kw_type},
 {"goto", kw_jump},
 {"if", kw_for_or_if_or_while},
 {"imaginary", kw_type},



CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 23:43:33 UTC 2021

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

Log Message:
indent: rename in_or_st to init_or_struct

This makes a few comments redundant.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.133 -r1.134 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.36 -r1.37 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.85 -r1.86 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-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 23:43:33 UTC 2021

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

Log Message:
indent: rename in_or_st to init_or_struct

This makes a few comments redundant.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.133 -r1.134 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.36 -r1.37 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.85 -r1.86 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.133 src/usr.bin/indent/indent.c:1.134
--- src/usr.bin/indent/indent.c:1.133	Fri Oct  8 21:13:58 2021
+++ src/usr.bin/indent/indent.c	Fri Oct  8 23:43:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.133 2021/10/08 21:13:58 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.134 2021/10/08 23:43: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.133 2021/10/08 21:13:58 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.134 2021/10/08 23:43:33 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -443,7 +443,7 @@ main_init_globals(void)
 line_no = 1;
 had_eof = ps.in_decl = ps.decl_on_line = break_comma = false;
 
-ps.in_or_st = false;
+ps.init_or_struct = false;
 ps.want_blank = ps.in_stmt = ps.ind_stmt = false;
 ps.is_case_label = false;
 
@@ -736,14 +736,13 @@ process_lparen_or_lbracket(int decl_ind,
 	debug_println("paren_indent[0] is now %d", ps.paren_indents[0]);
 }
 
-if (ps.in_or_st && *token.s == '(' && ps.tos <= 2) {
+if (ps.init_or_struct && *token.s == '(' && ps.tos <= 2) {
 	/*
 	 * this is a kluge to make sure that declarations will be aligned
 	 * right if proc decl has an explicit type on it, i.e. "int a(x) {..."
 	 */
 	parse(semicolon);	/* I said this was a kluge... */
-	ps.in_or_st = false;	/* turn off flag for structure decl or
- * initialization */
+	ps.init_or_struct = false;
 }
 
 /* parenthesized type following sizeof or offsetof is not a cast */
@@ -847,7 +846,7 @@ process_colon(int *seen_quest, bool *for
 	return;
 }
 
-if (ps.in_or_st) {		/* bit-field */
+if (ps.init_or_struct) {		/* bit-field */
 	*code.e++ = ':';
 	ps.want_blank = false;
 	return;
@@ -872,8 +871,8 @@ process_semicolon(bool *seen_case, int *
 bool *force_nl)
 {
 if (ps.decl_nest == 0)
-	ps.in_or_st = false;	/* we are not in an initialization or
- * structure declaration */
+	ps.init_or_struct = false;	/* we are not in an initialization or
+	 * structure declaration */
 *seen_case = false;		/* these will only need resetting in an error */
 *seen_quest = 0;
 if (ps.last_token == rparen_or_rbracket)
@@ -939,7 +938,7 @@ process_lbrace(bool *force_nl, bool *sp_
 	if (!opt.brace_same_line) {
 	dump_line();
 	ps.want_blank = false;
-	} else if (ps.in_parameter_declaration && !ps.in_or_st) {
+	} else if (ps.in_parameter_declaration && !ps.init_or_struct) {
 	ps.ind_level_follow = 0;
 	if (opt.function_brace_split) {	/* dump the line prior to the
 		 * brace ... */
@@ -965,8 +964,7 @@ process_lbrace(bool *force_nl, bool *sp_
 
 if (code.s == code.e)
 	ps.ind_stmt = false;	/* don't indent the '{' itself */
-if (ps.in_decl && ps.in_or_st) {	/* this is either a structure
-	 * declaration or an init */
+if (ps.in_decl && ps.init_or_struct) {
 	di_stack[ps.decl_nest] = *decl_ind;
 	if (++ps.decl_nest == di_stack_cap) {
 	diag(0, "Reached internal limit of %d struct levels",
@@ -1088,10 +1086,9 @@ process_decl(int *decl_ind, bool *tabs_t
 	ps.ind_stmt = false;
 }
 
-ps.in_or_st = true;		/* this might be a structure or initialization
- * declaration */
+ps.init_or_struct = /* maybe */ true;
 ps.in_decl = ps.decl_on_line = ps.last_token != type_def;
-if ( /* !ps.in_or_st && */ ps.decl_nest <= 0)
+if (ps.decl_nest <= 0)
 	ps.just_saw_decl = 2;
 
 prefix_blankline_requested = false;

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.36 src/usr.bin/indent/indent.h:1.37
--- src/usr.bin/indent/indent.h:1.36	Fri Oct  8 22:17:35 2021
+++ src/usr.bin/indent/indent.h	Fri Oct  8 23:43:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.36 2021/10/08 22:17:35 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.37 2021/10/08 23:43:33 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -269,9 +269,9 @@ extern struct parser_state {
  * initialization */
 bool last_nl;		/* whether the last thing scanned was a
  * newline */
-bool in_or_st;		/* true iff there has been a declarator (e.g.
- * int or char) and no left paren since the
- * last sem

CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 23:47:41 UTC 2021

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

Log Message:
indent: clean up comments, parentheses, debug messages, boolean operator

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/indent/parse.c

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



CVS commit: src/usr.bin/indent

2021-10-08 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Oct  8 23:47:41 UTC 2021

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

Log Message:
indent: clean up comments, parentheses, debug messages, boolean operator

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.34 -r1.35 src/usr.bin/indent/parse.c

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

Modified files:

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.134 src/usr.bin/indent/indent.c:1.135
--- src/usr.bin/indent/indent.c:1.134	Fri Oct  8 23:43:33 2021
+++ src/usr.bin/indent/indent.c	Fri Oct  8 23:47:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.134 2021/10/08 23:43:33 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.135 2021/10/08 23:47:40 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.134 2021/10/08 23:43:33 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.135 2021/10/08 23:47:40 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -264,6 +264,7 @@ search_brace_other(token_type ttype, boo
 	diag(0, "Line broken");
 }
 
+/* XXX: buffer overflow? This is essentially a strcpy. */
 for (const char *t_ptr = token.s; *t_ptr != '\0'; ++t_ptr)
 	*sc_end++ = *t_ptr;
 return true;
@@ -727,13 +728,13 @@ process_lparen_or_lbracket(int decl_ind,
 
 ps.paren_indents[ps.p_l_follow - 1] =
 	(short)indentation_after_range(0, code.s, code.e);
-debug_println("paren_indent[%d] is now %d",
+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
 	&& ps.paren_indents[0] < 2 * opt.indent_size) {
 	ps.paren_indents[0] = (short)(2 * opt.indent_size);
-	debug_println("paren_indent[0] is now %d", ps.paren_indents[0]);
+	debug_println("paren_indents[0] is now %d", ps.paren_indents[0]);
 }
 
 if (ps.init_or_struct && *token.s == '(' && ps.tos <= 2) {
@@ -772,8 +773,8 @@ 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 */
+if (*sp_sw && ps.p_l_follow == 0) {	/* check for end of if (...), or some
+	 * such */
 	*sp_sw = false;
 	*force_nl = true;	/* must force newline after if */
 	ps.last_u_d = true;	/* inform lexi that a following operator is
@@ -825,9 +826,7 @@ process_postfix_op(void)
 static void
 process_question(int *seen_quest)
 {
-(*seen_quest)++;		/* this will be used when a later colon
- * appears, so we can distinguish the
- * ?: construct */
+(*seen_quest)++;
 if (ps.want_blank)
 	*code.e++ = ' ';
 *code.e++ = '?';
@@ -871,8 +870,7 @@ process_semicolon(bool *seen_case, int *
 bool *force_nl)
 {
 if (ps.decl_nest == 0)
-	ps.init_or_struct = false;	/* we are not in an initialization or
-	 * structure declaration */
+	ps.init_or_struct = false;
 *seen_case = false;		/* these will only need resetting in an error */
 *seen_quest = 0;
 if (ps.last_token == rparen_or_rbracket)
@@ -890,16 +888,15 @@ process_semicolon(bool *seen_case, int *
 	ps.dumped_decl_indent = true;
 }
 
-ps.in_decl = (ps.decl_nest > 0);	/* if we were in a first level
+ps.in_decl = ps.decl_nest > 0;	/* if we were in a first level
 	 * structure declaration, we aren't
 	 * anymore */
 
 if ((!*sp_sw || hd_type != for_exprs) && ps.p_l_follow > 0) {
 
 	/*
-	 * This should be true iff there were unbalanced parens in the stmt.
-	 * It is a bit complicated, because the semicolon might be in a for
-	 * stmt
+	 * There were unbalanced parens in the statement. It is a bit
+	 * complicated, because the semicolon might be in a for statement.
 	 */
 	diag(1, "Unbalanced parens");
 	ps.p_l_follow = 0;
@@ -1160,7 +1157,7 @@ process_period(void)
 static void
 process_comma(int decl_ind, bool tabs_to_var, bool *force_nl)
 {
-ps.want_blank = (code.s != code.e);	/* only put blank after comma if comma
+ps.want_blank = code.s != code.e;	/* only put blank after comma if comma
 	 * does not start the line */
 
 if (ps.in_decl && ps.procname[0] == '\0' && !ps.block_init &&
@@ -1333,8 +1330,8 @@ main_loop(void)
 bool tabs_to_var;		/* true if using tabs to indent to var name */
 bool sp_sw;			/* when true, we are in the expression of
  * if(...), while(...), etc. */
-token_type hd_type = end_of_file;	/* used to store type of stmt for if
-	 * (...), for (...), etc */
+token_type hd_type = end_of_file;	/* the type of statement for if (...),
+ * for (...), etc */
 int seen_quest;		/* when this is positive

  1   2   >