CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 05:26:42 UTC 2021

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

Log Message:
indent: clean up check_size_comment

The additional parameter last_bl_ptr was only necessary because the last
blank was stored as a pointer into the buffer.  By storing the index in
the buffer instead, it doesn't need to be updated all the time.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 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-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 05:26:42 UTC 2021

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

Log Message:
indent: clean up check_size_comment

The additional parameter last_bl_ptr was only necessary because the last
blank was stored as a pointer into the buffer.  By storing the index in
the buffer instead, it doesn't need to be updated all the time.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 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.34 src/usr.bin/indent/pr_comment.c:1.35
--- src/usr.bin/indent/pr_comment.c:1.34	Sun Mar 14 04:52:10 2021
+++ src/usr.bin/indent/pr_comment.c	Sun Mar 14 05:26:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.34 2021/03/14 04:52:10 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.35 2021/03/14 05:26:42 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)pr_comment.c
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: pr_comment.c,v 1.34 2021/03/14 04:52:10 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.35 2021/03/14 05:26:42 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -60,22 +60,19 @@ __FBSDID("$FreeBSD: head/usr.bin/indent/
 #include "indent.h"
 
 static void
-check_size_comment(size_t desired_size, char **last_bl_ptr)
+check_size_comment(size_t desired_size)
 {
 if (e_com + (desired_size) < l_com)
 return;
 
 size_t nsize = l_com - s_com + 400 + desired_size;
 size_t com_len = e_com - s_com;
-ssize_t blank_pos = *last_bl_ptr != NULL ? *last_bl_ptr - combuf : -1;
 combuf = realloc(combuf, nsize);
 if (combuf == NULL)
 	err(1, NULL);
-e_com = combuf + com_len + 1;
-if (blank_pos > 0)
-	*last_bl_ptr = combuf + blank_pos;
-l_com = combuf + nsize - 5;
 s_com = combuf + 1;
+e_com = s_com + com_len;
+l_com = combuf + nsize - 5;
 }
 
 /*
@@ -101,15 +98,14 @@ process_comment(void)
 {
 int adj_max_line_length; /* Adjusted max_line_length for comments
  * that spill over the right margin */
-char   *last_bl;	/* points to the last blank in the output
- * buffer */
+ssize_t last_blank;		/* index of the last blank in combuf */
 char   *t_ptr;		/* used for moving string */
 int break_delim = opt.comment_delimiter_on_blankline;
 int l_just_saw_decl = ps.just_saw_decl;
 
 adj_max_line_length = opt.max_line_length;
 ps.just_saw_decl = 0;
-last_bl = NULL;		/* no blanks found so far */
+last_blank = -1;		/* no blanks found so far */
 ps.box_com = false;		/* at first, assume that we are not in
  * a boxed comment or some other
  * comment that should not be touched */
@@ -232,12 +228,12 @@ process_comment(void)
  * copied */
 	switch (*buf_ptr) {	/* this checks for various special cases */
 	case 014:		/* check for a form feed */
-	check_size_comment(3, _bl);
+	check_size_comment(3);
 	if (!ps.box_com) {	/* in a text comment, break the line here */
 		ps.use_ff = true;
 		/* fix so dump_line uses a form feed */
 		dump_line();
-		last_bl = NULL;
+		last_blank = -1;
 		if (!ps.box_com && opt.star_comment_cont)
 		*e_com++ = ' ', *e_com++ = '*', *e_com++ = ' ';
 		while (*++buf_ptr == ' ' || *buf_ptr == '\t')
@@ -259,8 +255,8 @@ process_comment(void)
 		dump_line();
 		return;
 	}
-	last_bl = NULL;
-	check_size_comment(4, _bl);
+	last_blank = -1;
+	check_size_comment(4);
 	if (ps.box_com || ps.last_nl) {	/* if this is a boxed comment,
 		 * we dont ignore the newline */
 		if (s_com == e_com)
@@ -275,16 +271,9 @@ process_comment(void)
 		*e_com++ = ' ', *e_com++ = '*', *e_com++ = ' ';
 	} else {
 		ps.last_nl = 1;
-		if (e_com[-1] == ' ' || e_com[-1] == '\t')
-		last_bl = e_com - 1;
-		/*
-		 * if there was a space at the end of the last line, remember
-		 * where it was
-		 */
-		else {		/* otherwise, insert one */
-		last_bl = e_com;
+		if (!(e_com[-1] == ' ' || e_com[-1] == '\t'))
 		*e_com++ = ' ';
-		}
+		last_blank = e_com - 1 - combuf;
 	}
 	++line_no;		/* keep track of input line number */
 	if (!ps.box_com) {
@@ -308,7 +297,7 @@ process_comment(void)
  * of comment */
 	if (++buf_ptr >= buf_end)	/* get to next char after * */
 		fill_buffer();
-	check_size_comment(4, _bl);
+	check_size_comment(4);
 	if (*buf_ptr == '/') {	/* it is the end!!! */
 	end_of_comment:
 		if (++buf_ptr >= buf_end)
@@ -335,16 +324,16 @@ process_comment(void)
 	;
 	int now_len = indentation_after_range(ps.com_col - 1, s_com, e_com);
 	do {
-		check_size_comment(1, _bl);
+		

CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 04:52:10 UTC 2021

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

Log Message:
indent: remove trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 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.33 src/usr.bin/indent/pr_comment.c:1.34
--- src/usr.bin/indent/pr_comment.c:1.33	Sun Mar 14 04:42:17 2021
+++ src/usr.bin/indent/pr_comment.c	Sun Mar 14 04:52:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.33 2021/03/14 04:42:17 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.34 2021/03/14 04:52:10 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)pr_comment.c
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: pr_comment.c,v 1.33 2021/03/14 04:42:17 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.34 2021/03/14 04:52:10 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -146,15 +146,15 @@ process_comment(void)
 		ps.com_col = 1 + !opt.format_col1_comments;
 	} else {
 	break_delim = false;
-	
+
 	int target_col;
 	if (s_code != e_code)
 		target_col = 1 + indentation_after(compute_code_indent(), s_code);
 	else if (s_lab != e_lab)
 		target_col = 1 + indentation_after(compute_label_indent(), s_lab);
-	else 
+	else
 		target_col = 1;
-	
+
 	ps.com_col = ps.decl_on_line || ps.ind_level == 0
 		? opt.decl_comment_column : opt.comment_column;
 	if (ps.com_col <= target_col)



CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 04:52:10 UTC 2021

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

Log Message:
indent: remove trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 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-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 04:42:17 UTC 2021

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

Log Message:
indent: clean up target column computation in process_comment

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 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.32 src/usr.bin/indent/pr_comment.c:1.33
--- src/usr.bin/indent/pr_comment.c:1.32	Sun Mar 14 01:34:13 2021
+++ src/usr.bin/indent/pr_comment.c	Sun Mar 14 04:42:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.32 2021/03/14 01:34:13 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.33 2021/03/14 04:42:17 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)pr_comment.c
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: pr_comment.c,v 1.32 2021/03/14 01:34:13 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.33 2021/03/14 04:42:17 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -145,15 +145,16 @@ process_comment(void)
 	if (ps.com_col <= 1)
 		ps.com_col = 1 + !opt.format_col1_comments;
 	} else {
-	int target_col;
 	break_delim = false;
+	
+	int target_col;
 	if (s_code != e_code)
 		target_col = 1 + indentation_after(compute_code_indent(), s_code);
-	else {
+	else if (s_lab != e_lab)
+		target_col = 1 + indentation_after(compute_label_indent(), s_lab);
+	else 
 		target_col = 1;
-		if (s_lab != e_lab)
-		target_col = 1 + indentation_after(compute_label_indent(), s_lab);
-	}
+	
 	ps.com_col = ps.decl_on_line || ps.ind_level == 0
 		? opt.decl_comment_column : opt.comment_column;
 	if (ps.com_col <= target_col)



CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 04:42:17 UTC 2021

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

Log Message:
indent: clean up target column computation in process_comment

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 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/sys/arch/evbppc/conf

2021-03-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Mar 14 03:35:39 UTC 2021

Modified Files:
src/sys/arch/evbppc/conf: EXPLORA451

Log Message:
Enable NFS_BOOT_UDP; on-board NIC seems to be too slow for overhead due to
NFS over TCP. Some scores of pkgsrc/benchmarks/bonnie improve nearly x2.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/arch/evbppc/conf/EXPLORA451

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



CVS commit: src/sys/arch/evbppc/conf

2021-03-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Mar 14 03:35:39 UTC 2021

Modified Files:
src/sys/arch/evbppc/conf: EXPLORA451

Log Message:
Enable NFS_BOOT_UDP; on-board NIC seems to be too slow for overhead due to
NFS over TCP. Some scores of pkgsrc/benchmarks/bonnie improve nearly x2.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/arch/evbppc/conf/EXPLORA451

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/evbppc/conf/EXPLORA451
diff -u src/sys/arch/evbppc/conf/EXPLORA451:1.70 src/sys/arch/evbppc/conf/EXPLORA451:1.71
--- src/sys/arch/evbppc/conf/EXPLORA451:1.70	Fri Mar  5 07:06:15 2021
+++ src/sys/arch/evbppc/conf/EXPLORA451	Sun Mar 14 03:35:39 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: EXPLORA451,v 1.70 2021/03/05 07:06:15 rin Exp $
+#	$NetBSD: EXPLORA451,v 1.71 2021/03/14 03:35:39 rin Exp $
 #
 #	EXPLORA451 -- NCD Explora 450 Series Thin Client
 #
@@ -121,6 +121,7 @@ options 	WS_KERNEL_FG=WSCOL_GREEN
 options 	WSDISPLAY_DEFAULTSCREENS=1
 
 # Options for netboot
+options 	NFS_BOOT_UDP		# for much better performance
 options 	NFS_BOOT_BOOTPARAM
 options 	NFS_BOOT_DHCP
 



CVS commit: src/sys/arch/mac68k/mac68k

2021-03-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Mar 14 03:25:01 UTC 2021

Modified Files:
src/sys/arch/mac68k/mac68k: locore.s

Log Message:
Fix DJMEMCMAX option for Quadra/Centris 650/800.

- Use jeq instead of jra for conditional branch.
- Use cmpl instead of cmp (= cmpw) for int variables.

Now, my Quadra 800 recognizes full 520MB memory!


To generate a diff of this commit:
cvs rdiff -u -r1.173 -r1.174 src/sys/arch/mac68k/mac68k/locore.s

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/mac68k/mac68k/locore.s
diff -u src/sys/arch/mac68k/mac68k/locore.s:1.173 src/sys/arch/mac68k/mac68k/locore.s:1.174
--- src/sys/arch/mac68k/mac68k/locore.s:1.173	Tue Jul 21 06:10:26 2020
+++ src/sys/arch/mac68k/mac68k/locore.s	Sun Mar 14 03:25:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.s,v 1.173 2020/07/21 06:10:26 rin Exp $	*/
+/*	$NetBSD: locore.s,v 1.174 2021/03/14 03:25:01 rin Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -275,16 +275,16 @@ Lstart3:
 
 #if defined(DJMEMCMAX)
 	movl	%a3,%sp@-
-	cmp	#MACH_MACC610,_C_LABEL(machineid)
-	jra	Ldjmemc610
-	cmp	#MACH_MACQ610,_C_LABEL(machineid)
-	jra	Ldjmemc610
-	cmp	#MACH_MACC650,_C_LABEL(machineid)
-	jra	Ldjmemccfg
-	cmp	#MACH_MACQ650,_C_LABEL(machineid)
-	jra	Ldjmemccfg
-	cmp	#MACH_MACQ800,_C_LABEL(machineid)
-	jra	Ldjmemccfg
+	cmpl	#MACH_MACC610,_C_LABEL(machineid)
+	jeq	Ldjmemc610
+	cmpl	#MACH_MACQ610,_C_LABEL(machineid)
+	jeq	Ldjmemc610
+	cmpl	#MACH_MACC650,_C_LABEL(machineid)
+	jeq	Ldjmemccfg
+	cmpl	#MACH_MACQ650,_C_LABEL(machineid)
+	jeq	Ldjmemccfg
+	cmpl	#MACH_MACQ800,_C_LABEL(machineid)
+	jeq	Ldjmemccfg
 
 	jra	Lnodjmemc




CVS commit: src/sys/arch/mac68k/mac68k

2021-03-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Mar 14 03:25:01 UTC 2021

Modified Files:
src/sys/arch/mac68k/mac68k: locore.s

Log Message:
Fix DJMEMCMAX option for Quadra/Centris 650/800.

- Use jeq instead of jra for conditional branch.
- Use cmpl instead of cmp (= cmpw) for int variables.

Now, my Quadra 800 recognizes full 520MB memory!


To generate a diff of this commit:
cvs rdiff -u -r1.173 -r1.174 src/sys/arch/mac68k/mac68k/locore.s

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



CVS commit: src/sys/dev/pci

2021-03-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Mar 14 03:14:42 UTC 2021

Modified Files:
src/sys/dev/pci: radeonfb.c

Log Message:
Initialize dp->rd_cmap_{red,green,blue} in radeonfb_init_palette() for 8bpp,
so that color map can be obtained by WSDISPLAYIO_GETCMAP ioctl(2).

Now, mlterm-fb from pkgsrc/x11/mlterm works just fine on radeonfb(4).


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 src/sys/dev/pci/radeonfb.c

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



CVS commit: src/sys/dev/pci

2021-03-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Mar 14 03:14:42 UTC 2021

Modified Files:
src/sys/dev/pci: radeonfb.c

Log Message:
Initialize dp->rd_cmap_{red,green,blue} in radeonfb_init_palette() for 8bpp,
so that color map can be obtained by WSDISPLAYIO_GETCMAP ioctl(2).

Now, mlterm-fb from pkgsrc/x11/mlterm works just fine on radeonfb(4).


To generate a diff of this commit:
cvs rdiff -u -r1.112 -r1.113 src/sys/dev/pci/radeonfb.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/dev/pci/radeonfb.c
diff -u src/sys/dev/pci/radeonfb.c:1.112 src/sys/dev/pci/radeonfb.c:1.113
--- src/sys/dev/pci/radeonfb.c:1.112	Fri Oct 30 15:30:43 2020
+++ src/sys/dev/pci/radeonfb.c	Sun Mar 14 03:14:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: radeonfb.c,v 1.112 2020/10/30 15:30:43 macallan Exp $ */
+/*	$NetBSD: radeonfb.c,v 1.113 2021/03/14 03:14:42 rin Exp $ */
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.112 2020/10/30 15:30:43 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: radeonfb.c,v 1.113 2021/03/14 03:14:42 rin Exp $");
 
 #include 
 #include 
@@ -2953,6 +2953,9 @@ radeonfb_init_palette(struct radeonfb_di
 			tmp |= tmp >> 4;
 			b = tmp;
 
+			dp->rd_cmap_red[i] = r;
+			dp->rd_cmap_green[i] = g;
+			dp->rd_cmap_blue[i] = b;
 			radeonfb_putpal(dp, i, r, g, b);
 		}
 	} else {



CVS commit: src/sbin/mount_nfs

2021-03-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Mar 14 02:56:51 UTC 2021

Modified Files:
src/sbin/mount_nfs: mount_nfs.8

Log Message:
Fix typo: s/--r/-r/


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sbin/mount_nfs/mount_nfs.8

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

Modified files:

Index: src/sbin/mount_nfs/mount_nfs.8
diff -u src/sbin/mount_nfs/mount_nfs.8:1.51 src/sbin/mount_nfs/mount_nfs.8:1.52
--- src/sbin/mount_nfs/mount_nfs.8:1.51	Sun Jan 24 12:51:32 2021
+++ src/sbin/mount_nfs/mount_nfs.8	Sun Mar 14 02:56:51 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: mount_nfs.8,v 1.51 2021/01/24 12:51:32 jmcneill Exp $
+.\"	$NetBSD: mount_nfs.8,v 1.52 2021/03/14 02:56:51 rin Exp $
 .\"
 .\" Copyright (c) 1992, 1993, 1994, 1995
 .\"	The Regents of the University of California.  All rights reserved.
@@ -218,7 +218,7 @@ Same as
 .Fl a Ar maxreadahead .
 .It Cm rsize Ns = Ns Aq Ar readsize
 Same as
-.Fl -r Ar readsize .
+.Fl r Ar readsize .
 .It Cm soft
 Same as
 .Fl s .



CVS commit: src/sbin/mount_nfs

2021-03-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Mar 14 02:56:51 UTC 2021

Modified Files:
src/sbin/mount_nfs: mount_nfs.8

Log Message:
Fix typo: s/--r/-r/


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sbin/mount_nfs/mount_nfs.8

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



CVS commit: src/share/man/man4

2021-03-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Mar 14 02:56:07 UTC 2021

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

Log Message:
Document NFS_BOOT_UDP instead of NFS_BOOT_TCP; We've switched to
NFS over TCP by default.

Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.517 -r1.518 src/share/man/man4/options.4

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

Modified files:

Index: src/share/man/man4/options.4
diff -u src/share/man/man4/options.4:1.517 src/share/man/man4/options.4:1.518
--- src/share/man/man4/options.4:1.517	Fri Oct  9 01:49:53 2020
+++ src/share/man/man4/options.4	Sun Mar 14 02:56:07 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: options.4,v 1.517 2020/10/09 01:49:53 gutteridge Exp $
+.\"	$NetBSD: options.4,v 1.518 2021/03/14 02:56:07 rin Exp $
 .\"
 .\" Copyright (c) 1996
 .\" 	Perry E. Metzger.  All rights reserved.
@@ -30,7 +30,7 @@
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
 .\"
-.Dd October 9, 2020
+.Dd March 14, 2021
 .Dt OPTIONS 4
 .Os
 .Sh NAME
@@ -1194,8 +1194,8 @@ for details.
 Reduce the size of the NFS client code by omitting code that's only required
 for NFSv3 and NQNFS support, leaving only that code required to use NFSv2
 servers.
-.It Cd options NFS_BOOT_TCP
-Use NFS over TCP instead of the default UDP, for mounting root.
+.It Cd options NFS_BOOT_UDP
+Use NFS over UDP instead of the default TCP, for mounting root.
 .El
 .Ss Buffer queue strategy options
 The following options enable alternative buffer queue strategies.



CVS commit: src/share/man/man4

2021-03-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Mar 14 02:56:07 UTC 2021

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

Log Message:
Document NFS_BOOT_UDP instead of NFS_BOOT_TCP; We've switched to
NFS over TCP by default.

Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.517 -r1.518 src/share/man/man4/options.4

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



CVS commit: src/sys/sys

2021-03-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Mar 14 02:53:57 UTC 2021

Modified Files:
src/sys/sys: systm.h

Log Message:
Comment on CTASSERT() in COND_SET_STRUCT(); this is a sanity check to
avoid hashing/assigning large structure. Upper-bound is arbitrary, but
be carefully for performance penalty if bumping.

Thanks christos for discussion.


To generate a diff of this commit:
cvs rdiff -u -r1.299 -r1.300 src/sys/sys/systm.h

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

Modified files:

Index: src/sys/sys/systm.h
diff -u src/sys/sys/systm.h:1.299 src/sys/sys/systm.h:1.300
--- src/sys/sys/systm.h:1.299	Wed Mar 10 13:27:51 2021
+++ src/sys/sys/systm.h	Sun Mar 14 02:53:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: systm.h,v 1.299 2021/03/10 13:27:51 simonb Exp $	*/
+/*	$NetBSD: systm.h,v 1.300 2021/03/14 02:53:57 rin Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1988, 1991, 1993
@@ -192,6 +192,11 @@ enum hashtype {
 #ifdef _KERNEL
 #define COND_SET_STRUCT(dst, src, allow) \
 	do { \
+		/* \
+		 * Make sure we don't end up hashing/assigning large \
+		 * structure for performance. Upper-bound is arbitrary, \
+		 * but consider before bumping. \
+		 */ \
 		CTASSERT(sizeof(src) < 32); \
 		if (allow) \
 			dst = src; \



CVS commit: src/sys/sys

2021-03-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Mar 14 02:53:57 UTC 2021

Modified Files:
src/sys/sys: systm.h

Log Message:
Comment on CTASSERT() in COND_SET_STRUCT(); this is a sanity check to
avoid hashing/assigning large structure. Upper-bound is arbitrary, but
be carefully for performance penalty if bumping.

Thanks christos for discussion.


To generate a diff of this commit:
cvs rdiff -u -r1.299 -r1.300 src/sys/sys/systm.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-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 01:44:37 UTC 2021

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

Log Message:
indent: make compute_code_indent more readable

The '?:' operator computing the factor was too hard to read.  When
quickly scanning the code, the 1 in the expression looked too much like
it would be added to the indentation, which would turn the indentation
length into a column number, and that again would smell like an
off-by-one error.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 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.48 src/usr.bin/indent/io.c:1.49
--- src/usr.bin/indent/io.c:1.48	Sun Mar 14 00:22:16 2021
+++ src/usr.bin/indent/io.c	Sun Mar 14 01:44:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.48 2021/03/14 00:22:16 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.49 2021/03/14 01:44:37 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.48 2021/03/14 00:22:16 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.49 2021/03/14 01:44:37 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -291,8 +291,10 @@ compute_code_indent(void)
 
 if (ps.paren_level != 0) {
 	if (!opt.lineup_to_parens)
-	target_ind += opt.continuation_indent *
-		(2 * opt.continuation_indent == opt.indent_size ? 1 : ps.paren_level);
+	if (2 * opt.continuation_indent == opt.indent_size)
+		target_ind += opt.continuation_indent;
+	else
+		target_ind += opt.continuation_indent * ps.paren_level;
 	else if (opt.lineup_to_parens_always)
 	/*
 	 * XXX: where does this '- 1' come from?  It looks strange but is



CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 01:44:37 UTC 2021

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

Log Message:
indent: make compute_code_indent more readable

The '?:' operator computing the factor was too hard to read.  When
quickly scanning the code, the 1 in the expression looked too much like
it would be added to the indentation, which would turn the indentation
length into a column number, and that again would smell like an
off-by-one error.

No functional change.


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

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



CVS commit: src

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 01:34:13 UTC 2021

Modified Files:
src/tests/usr.bin/indent: comments.0 comments.0.stdout opt-P.0.stdout
opt-bap+sob.0.stdout token-comment.0.stdout
token-keyword_do_else.0.stdout
src/usr.bin/indent: pr_comment.c

Log Message:
indent: fix off-by-one error in comment wrapping

The manual page says that the default maximum length of a comment line
is 78.  The test 'comments.0' wrongly assumed that this 78 would refer
to the maximum _column_ allowed, which is off by one.

Fix the wording in the test 'comments.0' and remove the (now satisfied)
expectation comments in the test 'token-comment.0'.

Several other tests just happened to hit that limit, fix these as well.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/comments.0 \
src/tests/usr.bin/indent/comments.0.stdout \
src/tests/usr.bin/indent/opt-bap+sob.0.stdout \
src/tests/usr.bin/indent/token-keyword_do_else.0.stdout
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/opt-P.0.stdout \
src/tests/usr.bin/indent/token-comment.0.stdout
cvs rdiff -u -r1.31 -r1.32 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/comments.0
diff -u src/tests/usr.bin/indent/comments.0:1.1 src/tests/usr.bin/indent/comments.0:1.2
--- src/tests/usr.bin/indent/comments.0:1.1	Thu Apr  4 15:27:35 2019
+++ src/tests/usr.bin/indent/comments.0	Sun Mar 14 01:34:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: comments.0,v 1.1 2019/04/04 15:27:35 kamil Exp $	*/
+/*	$NetBSD: comments.0,v 1.2 2021/03/14 01:34:13 rillig Exp $	*/
 /* $FreeBSD: head/usr.bin/indent/tests/comments.0 321383 2017-07-23 15:07:52Z pstef $ */
 typedef enum x {
 	aa = 1 << 0,	/* test a */
@@ -16,8 +16,9 @@ void t(void) {
 	 */
 	 
 	/*
-	 * Old indent did not wrap to column 78
-	 * 
+	 * The default maximum line length for comments is 78, and the 'kk' at
+	 * the end makes the line exactly 78 bytes long.
+	 *
 	 * aa bb cc dd ee ff g h i  kk
 	 */
 	
Index: src/tests/usr.bin/indent/comments.0.stdout
diff -u src/tests/usr.bin/indent/comments.0.stdout:1.1 src/tests/usr.bin/indent/comments.0.stdout:1.2
--- src/tests/usr.bin/indent/comments.0.stdout:1.1	Thu Apr  4 15:27:35 2019
+++ src/tests/usr.bin/indent/comments.0.stdout	Sun Mar 14 01:34:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: comments.0.stdout,v 1.1 2019/04/04 15:27:35 kamil Exp $	*/
+/*	$NetBSD: comments.0.stdout,v 1.2 2021/03/14 01:34:13 rillig Exp $	*/
 /* $FreeBSD: head/usr.bin/indent/tests/comments.0.stdout 334563 2018-06-03 15:28:55Z pstef $ */
 typedef enum x {
 	aa = 1 << 0,	/* test a */
@@ -18,10 +18,10 @@ t(void)
 	 */
 
 	/*
-	 * Old indent did not wrap to column 78
+	 * The default maximum line length for comments is 78, and the 'kk' at
+	 * the end makes the line exactly 78 bytes long.
 	 *
-	 * aa bb cc dd ee ff g h i 
-	 * kk
+	 * aa bb cc dd ee ff g h i  kk
 	 */
 
 	/*
Index: src/tests/usr.bin/indent/opt-bap+sob.0.stdout
diff -u src/tests/usr.bin/indent/opt-bap+sob.0.stdout:1.1 src/tests/usr.bin/indent/opt-bap+sob.0.stdout:1.2
--- src/tests/usr.bin/indent/opt-bap+sob.0.stdout:1.1	Mon Mar  8 22:13:05 2021
+++ src/tests/usr.bin/indent/opt-bap+sob.0.stdout	Sun Mar 14 01:34:13 2021
@@ -1,10 +1,10 @@
-/* $NetBSD: opt-bap+sob.0.stdout,v 1.1 2021/03/08 22:13:05 rillig Exp $ */
+/* $NetBSD: opt-bap+sob.0.stdout,v 1.2 2021/03/14 01:34:13 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
  * As of 2021-03-08, the combination of -bap and -sob, which occurs in the
- * example indent.pro from NetBSD, removes the empty line above the
- * separator.  Seen in games/cgram/cgram.c.
+ * example indent.pro from NetBSD, removes the empty line above the separator.
+ * Seen in games/cgram/cgram.c.
  */
 
 void
Index: src/tests/usr.bin/indent/token-keyword_do_else.0.stdout
diff -u src/tests/usr.bin/indent/token-keyword_do_else.0.stdout:1.1 src/tests/usr.bin/indent/token-keyword_do_else.0.stdout:1.2
--- src/tests/usr.bin/indent/token-keyword_do_else.0.stdout:1.1	Fri Mar 12 00:13:06 2021
+++ src/tests/usr.bin/indent/token-keyword_do_else.0.stdout	Sun Mar 14 01:34:13 2021
@@ -1,10 +1,10 @@
-/* $NetBSD: token-keyword_do_else.0.stdout,v 1.1 2021/03/12 00:13:06 rillig Exp $ */
+/* $NetBSD: token-keyword_do_else.0.stdout,v 1.2 2021/03/14 01:34:13 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
- * Tests for the keyword 'do' or 'else'.  These two keywords are followed by
- * a space.  In contrast to 'for', 'if' and 'while', the space is not
- * followed by a parenthesized expression.
+ * Tests for the keyword 'do' or 'else'.  These two keywords are followed by a
+ * space.  In contrast to 'for', 'if' and 'while', the space is not followed
+ * by a 

CVS commit: src

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 01:34:13 UTC 2021

Modified Files:
src/tests/usr.bin/indent: comments.0 comments.0.stdout opt-P.0.stdout
opt-bap+sob.0.stdout token-comment.0.stdout
token-keyword_do_else.0.stdout
src/usr.bin/indent: pr_comment.c

Log Message:
indent: fix off-by-one error in comment wrapping

The manual page says that the default maximum length of a comment line
is 78.  The test 'comments.0' wrongly assumed that this 78 would refer
to the maximum _column_ allowed, which is off by one.

Fix the wording in the test 'comments.0' and remove the (now satisfied)
expectation comments in the test 'token-comment.0'.

Several other tests just happened to hit that limit, fix these as well.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/comments.0 \
src/tests/usr.bin/indent/comments.0.stdout \
src/tests/usr.bin/indent/opt-bap+sob.0.stdout \
src/tests/usr.bin/indent/token-keyword_do_else.0.stdout
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/opt-P.0.stdout \
src/tests/usr.bin/indent/token-comment.0.stdout
cvs rdiff -u -r1.31 -r1.32 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/tests/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 00:50:39 UTC 2021

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

Log Message:
tests/indent: demonstrate off-by-one error in comment processing


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/token-comment.0 \
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.1 src/tests/usr.bin/indent/token-comment.0:1.2
--- src/tests/usr.bin/indent/token-comment.0:1.1	Fri Mar 12 00:13:06 2021
+++ src/tests/usr.bin/indent/token-comment.0	Sun Mar 14 00:50:39 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token-comment.0,v 1.1 2021/03/12 00:13:06 rillig Exp $ */
+/* $NetBSD: token-comment.0,v 1.2 2021/03/14 00:50:39 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -8,3 +8,9 @@
  */
 
 /* TODO: Add some code to be formatted. */
+
+/* 456789 123456789 123456789 123456789 123456789 123456789 123456789 12345 */
+/* 456789 123456789 123456789 123456789 123456789 123456789 123456789 123456 */
+/* 456789 123456789 123456789 123456789 123456789 123456789 123456789 1234567 */
+/* 456789 123456789 123456789 123456789 123456789 123456789 123456789 12345678 */
+/* 456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 */
Index: src/tests/usr.bin/indent/token-comment.0.stdout
diff -u src/tests/usr.bin/indent/token-comment.0.stdout:1.1 src/tests/usr.bin/indent/token-comment.0.stdout:1.2
--- src/tests/usr.bin/indent/token-comment.0.stdout:1.1	Fri Mar 12 00:13:06 2021
+++ src/tests/usr.bin/indent/token-comment.0.stdout	Sun Mar 14 00:50:39 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token-comment.0.stdout,v 1.1 2021/03/12 00:13:06 rillig Exp $ */
+/* $NetBSD: token-comment.0.stdout,v 1.2 2021/03/14 00:50:39 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -8,3 +8,18 @@
  */
 
 /* TODO: Add some code to be formatted. */
+
+/* 456789 123456789 123456789 123456789 123456789 123456789 123456789 12345 */
+/* 456789 123456789 123456789 123456789 123456789 123456789 123456789 123456 */
+/* 456789 123456789 123456789 123456789 123456789 123456789 123456789 1234567 */
+/* $ XXX: The '12345678' should be kept on the main line since it adds up */
+/* $ XXX: to a line length of exactly 78, which according to the manual */
+/* $ XXX: page should be ok. */
+/*
+ * 456789 123456789 123456789 123456789 123456789 123456789 123456789
+ * 12345678
+ */
+/*
+ * 456789 123456789 123456789 123456789 123456789 123456789 123456789
+ * 123456789
+ */



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

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 00:50:39 UTC 2021

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

Log Message:
tests/indent: demonstrate off-by-one error in comment processing


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

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 00:33:25 UTC 2021

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

Log Message:
indent: give indent a try at formatting its own code

Formatting indent.h required the following manual corrections
afterwards:

The first tab in the comment in line 1 was replaced with a space but
shouldn't be.

The spacing around the '...' in function prototypes was completely
wrong.  It looked like 'const char *,...)__printflike', without any
spaces.

The '*' of the return type 'const char *' was tied to the function name,
even though this declaration was only for a single function.  In such a
case, it's more appropriate to line up the function names.

The function-like macros were not indented to -di.  This is something
that I would not expect from indent, so it's ok to do that manually.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/indent/indent.h

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



CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 00:33:25 UTC 2021

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

Log Message:
indent: give indent a try at formatting its own code

Formatting indent.h required the following manual corrections
afterwards:

The first tab in the comment in line 1 was replaced with a space but
shouldn't be.

The spacing around the '...' in function prototypes was completely
wrong.  It looked like 'const char *,...)__printflike', without any
spaces.

The '*' of the return type 'const char *' was tied to the function name,
even though this declaration was only for a single function.  In such a
case, it's more appropriate to line up the function names.

The function-like macros were not indented to -di.  This is something
that I would not expect from indent, so it's ok to do that manually.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/usr.bin/indent/indent.h

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

Modified files:

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.15 src/usr.bin/indent/indent.h:1.16
--- src/usr.bin/indent/indent.h:1.15	Sat Mar 13 23:42:23 2021
+++ src/usr.bin/indent/indent.h	Sun Mar 14 00:33:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.15 2021/03/13 23:42:23 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.16 2021/03/14 00:33:25 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -41,29 +41,30 @@ __FBSDID("$FreeBSD: head/usr.bin/indent/
 #define nitems(array) (sizeof (array) / sizeof (array[0]))
 #endif
 
-void	add_typename(const char *);
-void	alloc_typenames(void);
-int	compute_code_indent(void);
-int	compute_label_indent(void);
-int	indentation_after_range(int, const char *, const char *);
-int	indentation_after(int, const char *);
-void	init_constant_tt(void);
+void		add_typename(const char *);
+void		alloc_typenames(void);
+int		compute_code_indent(void);
+int		compute_label_indent(void);
+int		indentation_after_range(int, const char *, const char *);
+int		indentation_after(int, const char *);
+void		init_constant_tt(void);
 #ifdef debug
-void	debug_vis_range(const char *, const char *, const char *, const char *);
-void	debug_printf(const char *, ...) __printflike(1, 2);
-void	debug_println(const char *, ...) __printflike(1, 2);
-const char *token_type_name(token_type);
+void		debug_vis_range(const char *, const char *, const char *,
+		const char *);
+void		debug_printf(const char *, ...) __printflike(1, 2);
+void		debug_println(const char *, ...) __printflike(1, 2);
+const char *	token_type_name(token_type);
 #else
-#define debug_printf(fmt, ...) do { } while (false)
-#define debug_println(fmt, ...) do { } while (false)
-#define debug_vis_range(prefix, s, e, suffix) do { } while (false)
+#define		debug_printf(fmt, ...) do { } while (false)
+#define		debug_println(fmt, ...) do { } while (false)
+#define		debug_vis_range(prefix, s, e, suffix) do { } while (false)
 #endif
-token_type lexi(struct parser_state *);
-void	diag(int, const char *, ...) __printflike(2, 3);
-void	dump_line(void);
-void	fill_buffer(void);
-void	parse(token_type);
-void	process_comment(void);
-void	set_defaults(void);
-void	set_option(char *);
-void	set_profile(const char *);
+token_type	lexi(struct parser_state *);
+void		diag(int, const char *, ...) __printflike(2, 3);
+void		dump_line(void);
+void		fill_buffer(void);
+void		parse(token_type);
+void		process_comment(void);
+void		set_defaults(void);
+void		set_option(char *);
+void		set_profile(const char *);



CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 00:22:16 UTC 2021

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

Log Message:
indent: fix lint warnings

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/indent/Makefile
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/indent/args.c
cvs rdiff -u -r1.58 -r1.59 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.47 -r1.48 src/usr.bin/indent/io.c
cvs rdiff -u -r1.40 -r1.41 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.30 -r1.31 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-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 14 00:22:16 UTC 2021

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

Log Message:
indent: fix lint warnings

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/indent/Makefile
cvs rdiff -u -r1.21 -r1.22 src/usr.bin/indent/args.c
cvs rdiff -u -r1.58 -r1.59 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.47 -r1.48 src/usr.bin/indent/io.c
cvs rdiff -u -r1.40 -r1.41 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.30 -r1.31 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/Makefile
diff -u src/usr.bin/indent/Makefile:1.10 src/usr.bin/indent/Makefile:1.11
--- src/usr.bin/indent/Makefile:1.10	Fri Mar 12 19:11:29 2021
+++ src/usr.bin/indent/Makefile	Sun Mar 14 00:22:16 2021
@@ -1,10 +1,13 @@
-#	$NetBSD: Makefile,v 1.10 2021/03/12 19:11:29 rillig Exp $
+#	$NetBSD: Makefile,v 1.11 2021/03/14 00:22:16 rillig Exp $
 #	from: @(#)Makefile	8.1 (Berkeley) 6/6/93
 
 PROG=	indent
 SRCS=	indent.c io.c lexi.c parse.c pr_comment.c args.c
 
 CPPFLAGS+=	${DEBUG:D-Ddebug}
-LINTFLAGS+=	-e
+LINTFLAGS+=	-e -w
+
+# bug in lint; see tests/usr.bin/lint/lint1/msg_168.c
+LINTFLAGS.lexi.c+=	-X 168
 
 .include 

Index: src/usr.bin/indent/args.c
diff -u src/usr.bin/indent/args.c:1.21 src/usr.bin/indent/args.c:1.22
--- src/usr.bin/indent/args.c:1.21	Sat Mar 13 13:51:08 2021
+++ src/usr.bin/indent/args.c	Sun Mar 14 00:22:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: args.c,v 1.21 2021/03/13 13:51:08 rillig Exp $	*/
+/*	$NetBSD: args.c,v 1.22 2021/03/14 00:22:16 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)args.c	8.1 (
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: args.c,v 1.21 2021/03/13 13:51:08 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.22 2021/03/14 00:22:16 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/args.c 336318 2018-07-15 21:04:21Z pstef $");
 #endif
@@ -212,12 +212,12 @@ scan_profile(FILE *f)
 char	*p;
 charbuf[BUFSIZ];
 
-while (1) {
+for (;;) {
 	p = buf;
 	comment_index = 0;
 	while ((i = getc(f)) != EOF) {
 	if (i == '*' && !comment_index && p > buf && p[-1] == '/') {
-		comment_index = p - buf;
+		comment_index = (int)(p - buf);
 		*p++ = i;
 	} else if (i == '/' && comment_index && p > buf && p[-1] == '*') {
 		p = buf + comment_index - 1;
@@ -314,6 +314,7 @@ found:
 	case VERSION:
 	printf("FreeBSD indent %s\n", INDENT_VERSION);
 	exit(0);
+	/*NOTREACHED*/
 
 	default:
 	errx(1, "set_option: internal error: p_special %d", p->p_special);

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.58 src/usr.bin/indent/indent.c:1.59
--- src/usr.bin/indent/indent.c:1.58	Sat Mar 13 18:46:39 2021
+++ src/usr.bin/indent/indent.c	Sun Mar 14 00:22:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.58 2021/03/13 18:46:39 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.59 2021/03/14 00:22:16 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.58 2021/03/13 18:46:39 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.59 2021/03/14 00:22:16 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -206,6 +206,7 @@ search_brace(token_type *inout_type_code
 	 * done earlier.
 	 */
 	*inout_force_nl = false;
+	break;
 	case form_feed:
 	break;
 	case comment:
@@ -215,7 +216,7 @@ search_brace(token_type *inout_type_code
 		 * process_comment() will use that to calculate original
 		 * indentation of a boxed comment.
 		 */
-		memcpy(sc_buf, in_buffer, buf_ptr - in_buffer - 4);
+		memcpy(sc_buf, in_buffer, (size_t)(buf_ptr - in_buffer) - 4);
 		save_com = sc_buf + (buf_ptr - in_buffer - 4);
 		save_com[0] = save_com[1] = ' ';
 		sc_end = _com[2];
@@ -532,7 +533,7 @@ main_prepare_parsing(void)
 char *p = buf_ptr;
 int col = 1;
 
-while (1) {
+for (;;) {
 	if (*p == ' ')
 	col++;
 	else if (*p == '\t')
@@ -585,7 +586,7 @@ process_comment_in_code(token_type type_
  * '}' */
 if (s_com != e_com) {	/* the turkey has embedded a comment
  * in a line. fix it */
-	int len = e_com - s_com;
+	size_t len = e_com - s_com;
 
 	check_size_code(len + 3);
 	*e_code++ = ' ';
@@ -724,7 +725,7 @@ process_unary_op(int dec_ind, int tabs_t
 	*e_code++ = ' ';
 
 {
-	int len = e_token - s_token;
+	size_t len = e_token - s_token;
 
 	check_size_code(len);
 	memcpy(e_code, token, len);
@@ -736,7 +737,7 @@ process_unary_op(int dec_ind, int tabs_t
 static void
 process_binary_op(void)
 {
-int len = e_token - s_token;

CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 23:42:23 UTC 2021

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

Log Message:
indent: remove disabled duplicate RCS ID from header

By convention, headers don't record their RCS ID.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/indent/indent.h

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

Modified files:

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.14 src/usr.bin/indent/indent.h:1.15
--- src/usr.bin/indent/indent.h:1.14	Sat Mar 13 13:25:23 2021
+++ src/usr.bin/indent/indent.h	Sat Mar 13 23:42:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.14 2021/03/13 13:25:23 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.15 2021/03/13 23:42:23 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -29,9 +29,7 @@
  */
 
 #if 0
-#if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.h,v 1.14 2021/03/13 13:25:23 rillig Exp $");
-#elif defined(__FreeBSD__)
+#if defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.h 336333 2018-07-16 05:46:50Z pstef $");
 #endif
 #endif



CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 23:42:23 UTC 2021

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

Log Message:
indent: remove disabled duplicate RCS ID from header

By convention, headers don't record their RCS ID.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/usr.bin/indent/indent.h

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



CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 23:36:10 UTC 2021

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

Log Message:
indent: fix documentation of parser_state.paren_indents

The column position is not the same as the indentation (off-by-one).


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 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_globs.h
diff -u src/usr.bin/indent/indent_globs.h:1.20 src/usr.bin/indent/indent_globs.h:1.21
--- src/usr.bin/indent/indent_globs.h:1.20	Sat Mar 13 13:51:08 2021
+++ src/usr.bin/indent/indent_globs.h	Sat Mar 13 23:36:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent_globs.h,v 1.20 2021/03/13 13:51:08 rillig Exp $	*/
+/*	$NetBSD: indent_globs.h,v 1.21 2021/03/13 23:36:10 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -261,7 +261,9 @@ extern struct parser_state {
  * statement */
 int paren_level;	/* parenthesization level. used to indent
  * within statements */
-short   paren_indents[20];	/* column positions of each paren */
+short   paren_indents[20]; /* indentation of the operand/argument of
+ * each level of parentheses or brackets,
+ * relative to the enclosing statement */
 int pcase;		/* set to 1 if the current line label is a
  * case.  It is printed differently from a
  * regular label */



CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 23:36:10 UTC 2021

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

Log Message:
indent: fix documentation of parser_state.paren_indents

The column position is not the same as the indentation (off-by-one).


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 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/sys/dev/sdmmc

2021-03-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Mar 13 23:26:47 UTC 2021

Modified Files:
src/sys/dev/sdmmc: sdhc.c

Log Message:
Enable block count only for count > 0.
Don't enable autostop when command sets new flag SCF_NO_STOP.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/sys/dev/sdmmc/sdhc.c

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



CVS commit: src/sys/dev/sdmmc

2021-03-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Mar 13 23:26:47 UTC 2021

Modified Files:
src/sys/dev/sdmmc: sdhc.c

Log Message:
Enable block count only for count > 0.
Don't enable autostop when command sets new flag SCF_NO_STOP.


To generate a diff of this commit:
cvs rdiff -u -r1.107 -r1.108 src/sys/dev/sdmmc/sdhc.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/dev/sdmmc/sdhc.c
diff -u src/sys/dev/sdmmc/sdhc.c:1.107 src/sys/dev/sdmmc/sdhc.c:1.108
--- src/sys/dev/sdmmc/sdhc.c:1.107	Wed Jul 15 15:57:52 2020
+++ src/sys/dev/sdmmc/sdhc.c	Sat Mar 13 23:26:47 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdhc.c,v 1.107 2020/07/15 15:57:52 msaitoh Exp $	*/
+/*	$NetBSD: sdhc.c,v 1.108 2021/03/13 23:26:47 mlelstv Exp $	*/
 /*	$OpenBSD: sdhc.c,v 1.25 2009/01/13 19:44:20 grange Exp $	*/
 
 /*
@@ -23,7 +23,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.107 2020/07/15 15:57:52 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sdhc.c,v 1.108 2021/03/13 23:26:47 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_sdmmc.h"
@@ -389,6 +389,8 @@ sdhc_host_found(struct sdhc_softc *sc, b
 		}
 	}
 
+	aprint_verbose(", caps <%08x/%08x>", caps, caps2);
+
 	const u_int retuning_mode = (caps2 >> SDHC_RETUNING_MODES_SHIFT) &
 	SDHC_RETUNING_MODES_MASK;
 	if (retuning_mode == SDHC_RETUNING_MODE_1) {
@@ -1724,14 +1726,17 @@ sdhc_start_command(struct sdhc_host *hp,
 	}
 
 	/* Prepare transfer mode register value. (2.2.5) */
-	mode = SDHC_BLOCK_COUNT_ENABLE;
+	mode = 0;
 	if (ISSET(cmd->c_flags, SCF_CMD_READ))
 		mode |= SDHC_READ_MODE;
-	if (blkcount > 1) {
-		mode |= SDHC_MULTI_BLOCK_MODE;
-		/* XXX only for memory commands? */
-		if (!ISSET(sc->sc_flags, SDHC_FLAG_NO_AUTO_STOP))
-			mode |= SDHC_AUTO_CMD12_ENABLE;
+	if (blkcount > 0) {
+		mode |= SDHC_BLOCK_COUNT_ENABLE;
+		if (blkcount > 1) {
+			mode |= SDHC_MULTI_BLOCK_MODE;
+			if (!ISSET(sc->sc_flags, SDHC_FLAG_NO_AUTO_STOP)
+			&& !ISSET(cmd->c_flags, SCF_NO_STOP))
+mode |= SDHC_AUTO_CMD12_ENABLE;
+		}
 	}
 	if (cmd->c_dmamap != NULL && cmd->c_datalen > 0 &&
 	ISSET(hp->flags,  SHF_MODE_DMAEN)) {



CVS commit: src/sys/dev/sdmmc

2021-03-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Mar 13 23:22:44 UTC 2021

Modified Files:
src/sys/dev/sdmmc: sdmmcvar.h

Log Message:
define NO_STOP flag


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/sdmmc/sdmmcvar.h

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



CVS commit: src/sys/dev/sdmmc

2021-03-13 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Mar 13 23:22:44 UTC 2021

Modified Files:
src/sys/dev/sdmmc: sdmmcvar.h

Log Message:
define NO_STOP flag


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/sdmmc/sdmmcvar.h

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

Modified files:

Index: src/sys/dev/sdmmc/sdmmcvar.h
diff -u src/sys/dev/sdmmc/sdmmcvar.h:1.35 src/sys/dev/sdmmc/sdmmcvar.h:1.36
--- src/sys/dev/sdmmc/sdmmcvar.h:1.35	Sun May 24 17:26:18 2020
+++ src/sys/dev/sdmmc/sdmmcvar.h	Sat Mar 13 23:22:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sdmmcvar.h,v 1.35 2020/05/24 17:26:18 riastradh Exp $	*/
+/*	$NetBSD: sdmmcvar.h,v 1.36 2021/03/13 23:22:44 mlelstv Exp $	*/
 /*	$OpenBSD: sdmmcvar.h,v 1.13 2009/01/09 10:55:22 jsg Exp $	*/
 
 /*
@@ -125,6 +125,7 @@ struct sdmmc_command {
 #define SCF_XFER_SDHC	(1U << 15)	/* card is SDHC */
 #define SCF_POLL	(1U << 16)	/* polling required */
 #define SCF_NEED_BOUNCE	(1U << 17)	/* (driver) transfer requires bounce buffer */
+#define SCF_NO_STOP	(1U << 18)	/* don't enable automatic stop CMD12 */
 /* response types */
 #define SCF_RSP_R0	0	/* none */
 #define SCF_RSP_R1	(SCF_RSP_PRESENT|SCF_RSP_CRC|SCF_RSP_IDX)



CVS commit: src/sys/arch/sparc64/dev

2021-03-13 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sat Mar 13 20:21:37 UTC 2021

Modified Files:
src/sys/arch/sparc64/dev: vnet.c

Log Message:
sun4v: vnet - reception and transmission of eternet frames seems to work now 
(it is possible to ping 8.8.8.8 from inside a sun4v ldom). Still cleanup of 
debug code to be done.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sparc64/dev/vnet.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/sparc64/dev

2021-03-13 Thread Palle Lyckegaard
Module Name:src
Committed By:   palle
Date:   Sat Mar 13 20:21:37 UTC 2021

Modified Files:
src/sys/arch/sparc64/dev: vnet.c

Log Message:
sun4v: vnet - reception and transmission of eternet frames seems to work now 
(it is possible to ping 8.8.8.8 from inside a sun4v ldom). Still cleanup of 
debug code to be done.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/sparc64/dev/vnet.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/sparc64/dev/vnet.c
diff -u src/sys/arch/sparc64/dev/vnet.c:1.3 src/sys/arch/sparc64/dev/vnet.c:1.4
--- src/sys/arch/sparc64/dev/vnet.c:1.3	Thu Mar 11 19:34:11 2021
+++ src/sys/arch/sparc64/dev/vnet.c	Sat Mar 13 20:21:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vnet.c,v 1.3 2021/03/11 19:34:11 palle Exp $	*/
+/*	$NetBSD: vnet.c,v 1.4 2021/03/13 20:21:37 palle Exp $	*/
 /*	$OpenBSD: vnet.c,v 1.62 2020/07/10 13:26:36 patrick Exp $	*/
 /*
  * Copyright (c) 2009, 2015 Mark Kettenis
@@ -221,6 +221,7 @@ void	vnet_rx_vio_ver_info(struct vnet_so
 void	vnet_rx_vio_attr_info(struct vnet_softc *, struct vio_msg_tag *);
 void	vnet_rx_vio_dring_reg(struct vnet_softc *, struct vio_msg_tag *);
 void	vnet_rx_vio_rdx(struct vnet_softc *sc, struct vio_msg_tag *);
+void	vnet_rx_vio_mcast_info(struct vnet_softc *sc, struct vio_msg_tag *);
 void	vnet_rx_vio_data(struct vnet_softc *sc, struct vio_msg *);
 void	vnet_rx_vio_desc_data(struct vnet_softc *sc, struct vio_msg_tag *);
 void	vnet_rx_vio_dring_data(struct vnet_softc *sc, struct vio_msg_tag *);
@@ -655,9 +656,15 @@ vnet_rx_vio_ctrl(struct vnet_softc *sc, 
 	case VIO_RDX:
 		vnet_rx_vio_rdx(sc, tag);
 		break;
+	case VNET_MCAST_INFO:
+		vnet_rx_vio_mcast_info(sc, tag);
+		break;
 	default:
 		printf("%s: CTRL/0x%02x/0x%04x FIXME\n",
  __func__, tag->stype, tag->stype_env);
+#if 0
+		Debugger();
+#endif		
 		break;
 	}
 }
@@ -739,7 +746,9 @@ vnet_rx_vio_attr_info(struct vnet_softc 
 		DPRINTF(("CTRL/INFO/ATTR_INFO\n"));
 #endif		
 		sc->sc_xfer_mode = ai->xfer_mode;
+#if 0		
 		DPRINTF(("sc_xfer_mode %d\n", sc->sc_xfer_mode));
+#endif		
 
 		ai->tag.stype = VIO_SUBTYPE_ACK;
 		ai->tag.sid = sc->sc_local_sid;
@@ -893,6 +902,40 @@ FIXME openbsd	
 }
 
 void
+vnet_rx_vio_mcast_info(struct vnet_softc *sc, struct vio_msg_tag *tag)
+{
+#if 0
+	DPRINTF(("%s: entry\n", __func__));
+#endif	
+
+	switch(tag->stype) {
+			
+		case VIO_SUBTYPE_INFO:
+#if 0
+			DPRINTF(("CTRL/INFO/MCAST_INFO\n"));
+#endif		
+			break;
+
+		case VIO_SUBTYPE_ACK:
+#if 0			
+			DPRINTF(("CTRL/ACK/MCAST_INFO\n"));
+#endif		
+			break;
+
+		case VIO_SUBTYPE_NACK:
+#if 0			
+			DPRINTF(("CTRL/NACK/MCAST_INFO\n"));
+#endif		
+			break;
+			
+		default:
+			printf("%s: CTRL/0x%02x/0x%04x\n",
+   __func__, tag->stype, tag->stype_env);
+			break;
+	}
+}
+
+void
 vnet_rx_vio_data(struct vnet_softc *sc, struct vio_msg *vm)
 {
 #if 0
@@ -1077,7 +1120,7 @@ FIXME openbsd		
 	switch(tag->stype) {
 	case VIO_SUBTYPE_INFO:
 	{
-#if 0			
+#if 0
 		DPRINTF(("%s: VIO_SUBTYPE_INFO\n", __func__));
 #endif		
 		struct vnet_desc desc;
@@ -1148,9 +1191,9 @@ FIXME openbsd			
 			m->m_len = m->m_pkthdr.len = desc.nbytes;
 #endif			
 			nbytes = roundup(desc.nbytes + VNET_ETHER_ALIGN, 8);
-#if 1
-			DPRINTF(("%s: nbytes %" PRId64 " desc.nbytes %" PRId32 "\n",
-	 __func__, nbytes, desc.nbytes));
+#if 0
+			DPRINTF(("%s: RX frame size %" PRId16 "\n",
+	 __func__, (int)nbytes));
 			uint8_t buf[ETHER_MAX_LEN];
 			pmap_extract(pmap_kernel(), (vaddr_t)buf, );
 			err = hv_ldc_copy(lc->lc_id, LDC_COPY_IN,
@@ -1161,11 +1204,12 @@ FIXME openbsd			
 			}
 			for (int i = 0; i < desc.nbytes; i++) {
 	if (i % 16 == 0) {
-		printf("\n");
+		DPRINTF(("\n"));
 	}
-	printf("%02x ", buf[i]);
+	DPRINTF(("%02x ", buf[i]));
 			}
-			printf("\n");
+			DPRINTF(("\n"));
+			DPRINTF(("\n"));
 #endif			
 #if 1
 			pmap_extract(pmap_kernel(), (vaddr_t)m->m_data, );
@@ -1176,6 +1220,7 @@ FIXME openbsd			
 goto skip;
 			}
 			m->m_data += VNET_ETHER_ALIGN;
+			m_set_rcvif(m, ifp);
 
 #if 0
 FIXME openbsd		
@@ -1224,7 +1269,7 @@ FIXME openbd		
 
 	case VIO_SUBTYPE_ACK:
 	{
-#if 0			
+#if 0
 		DPRINTF(("%s: VIO_SUBTYPE_ACK\n", __func__));
 #endif		
 		struct ldc_map *map = sc->sc_lm;
@@ -1399,6 +1444,12 @@ vnet_send_attr_info(struct vnet_softc *s
 		ai.addr |= sc->sc_macaddr[i];
 	}
 	ai.mtu = ETHER_MAX_LEN - ETHER_CRC_LEN;
+#if 0
+	DPRINTF(("%s: ai.addr %" PRIx64 "\n",
+			 __func__, ai.addr));
+	DPRINTF(("%s: ai.mtu %" PRId64 "\n",
+			 __func__, ai.mtu));
+#endif	
 	vnet_sendmsg(sc, , sizeof(ai));
 
 	sc->sc_vio_state |= VIO_SND_ATTR_INFO;
@@ -1407,7 +1458,7 @@ vnet_send_attr_info(struct vnet_softc *s
 void
 vnet_send_dring_reg(struct vnet_softc *sc)
 {
-#if 1
+#if 0
 	DPRINTF(("%s: entry\n", __func__));
 #endif	
 	
@@ -1433,7 +1484,7 @@ vnet_send_dring_reg(struct vnet_softc *s
 void
 vio_send_rdx(struct vnet_softc *sc)
 {
-#if 1
+#if 0
 	

CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 18:46:39 UTC 2021

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

Log Message:
indent: add debug logging for switching the input buffer

No functional change outside debug mode.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.46 -r1.47 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-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 18:46:39 UTC 2021

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

Log Message:
indent: add debug logging for switching the input buffer

No functional change outside debug mode.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.46 -r1.47 src/usr.bin/indent/io.c

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

Modified files:

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.57 src/usr.bin/indent/indent.c:1.58
--- src/usr.bin/indent/indent.c:1.57	Sat Mar 13 13:51:08 2021
+++ src/usr.bin/indent/indent.c	Sat Mar 13 18:46:39 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.57 2021/03/13 13:51:08 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.58 2021/03/13 18:46:39 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.57 2021/03/13 13:51:08 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.58 2021/03/13 18:46:39 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -314,6 +314,7 @@ search_brace(token_type *inout_type_code
 	*sc_end++ = ' ';	/* add trailing blank, just in case */
 	buf_end = sc_end;
 	sc_end = NULL;
+	debug_println("switched buf_ptr to save_com");
 	break;
 	}
 	}			/* end of switch */
@@ -640,11 +641,17 @@ process_lparen_or_lbracket(int dec_ind, 
 	*e_code++ = ' ';
 ps.want_blank = false;
 *e_code++ = token[0];
+
 ps.paren_indents[ps.p_l_follow - 1] =
 	indentation_after_range(0, s_code, e_code);
+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
-	&& ps.paren_indents[0] < 2 * opt.indent_size)
+	&& ps.paren_indents[0] < 2 * opt.indent_size) {
 	ps.paren_indents[0] = 2 * opt.indent_size;
+	debug_println("paren_indent[0] is now %d", ps.paren_indents[0]);
+}
 if (ps.in_or_st && *token == '(' && ps.tos <= 2) {
 	/*
 	 * this is a kluge to make sure that declarations will be
@@ -1196,12 +1203,12 @@ process_preprocessing(void)
 		e_lab--;
 	bp_save = buf_ptr;	/* save current input buffer */
 	be_save = buf_end;
-	buf_ptr = save_com;	/* fix so that subsequent calls to
-	 * lexi will take tokens out of
-	 * save_com */
+	buf_ptr = save_com;	/* fix so that subsequent calls to lexi will
+ * take tokens out of save_com */
 	*sc_end++ = ' ';	/* add trailing blank, just in case */
 	buf_end = sc_end;
 	sc_end = NULL;
+	debug_println("switched buf_ptr to save_com");
 	}
 	check_size_label(1);
 	*e_lab = '\0';	/* null terminate line */

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.46 src/usr.bin/indent/io.c:1.47
--- src/usr.bin/indent/io.c:1.46	Sat Mar 13 18:24:56 2021
+++ src/usr.bin/indent/io.c	Sat Mar 13 18:46:39 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.46 2021/03/13 18:24:56 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.47 2021/03/13 18:46:39 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.46 2021/03/13 18:24:56 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.47 2021/03/13 18:46:39 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -346,6 +346,7 @@ fill_buffer(void)
 	buf_ptr = bp_save;	/* do not read anything, just switch buffers */
 	buf_end = be_save;
 	bp_save = be_save = NULL;
+	debug_println("switched buf_ptr back to bp_save");
 	if (buf_ptr < buf_end)
 	return;		/* only return if there is really something in
  * this buffer */



CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 18:24:56 UTC 2021

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

Log Message:
indent: align comments in indent's own code

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 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.45 src/usr.bin/indent/io.c:1.46
--- src/usr.bin/indent/io.c:1.45	Sat Mar 13 13:55:42 2021
+++ src/usr.bin/indent/io.c	Sat Mar 13 18:24:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.45 2021/03/13 13:55:42 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.46 2021/03/13 18:24:56 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.45 2021/03/13 13:55:42 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.46 2021/03/13 18:24:56 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -223,7 +223,7 @@ dump_line(void)
 
 	target_col += ps.comment_delta;
 	while (*com_st == '\t')	/* consider original indentation in
- * case this is a box comment */
+ * case this is a box comment */
 		com_st++, target_col += opt.tabsize;
 	while (target_col <= 0)
 		if (*com_st == ' ')
@@ -234,7 +234,7 @@ dump_line(void)
 		} else
 		target_col = 1;
 	if (cur_col > target_col) {	/* if comment can't fit on this line,
- * put it on next line */
+ * put it on next line */
 		output_char('\n');
 		cur_col = 1;
 		++ps.out_lines;
@@ -263,14 +263,12 @@ dump_line(void)
 if (e_com - s_com > 1 && s_com[1] == '/')
 	output_range(s_token, e_token);
 
-ps.decl_on_line = ps.in_decl;	/* if we are in the middle of a
-	 * declaration, remember that fact for
-	 * proper comment indentation */
-ps.ind_stmt = ps.in_stmt & ~ps.in_decl;	/* next line should be
-		 * indented if we have not
-		 * completed this stmt and if
-		 * we are not in the middle of
-		 * a declaration */
+ps.decl_on_line = ps.in_decl; /* if we are in the middle of a declaration,
+ * remember that fact for proper comment
+ * indentation */
+ps.ind_stmt = ps.in_stmt & ~ps.in_decl; /* next line should be indented if
+ * we have not completed this stmt and if we
+ * are not in the middle of a declaration */
 ps.use_ff = false;
 ps.dumped_decl_indent = 0;
 *(e_lab = s_lab) = '\0';	/* reset buffers */



CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 18:24:56 UTC 2021

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

Log Message:
indent: align comments in indent's own code

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 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-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 18:11:31 UTC 2021

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

Log Message:
indent: remove the '+ 1' from right margin calculation in comment

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 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.29 src/usr.bin/indent/pr_comment.c:1.30
--- src/usr.bin/indent/pr_comment.c:1.29	Sat Mar 13 13:51:08 2021
+++ src/usr.bin/indent/pr_comment.c	Sat Mar 13 18:11:31 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.29 2021/03/13 13:51:08 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.30 2021/03/13 18:11:31 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)pr_comment.c
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: pr_comment.c,v 1.29 2021/03/13 13:51:08 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.30 2021/03/13 18:11:31 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -200,8 +200,9 @@ process_comment(void)
 	if (t_ptr >= buf_end)
 		fill_buffer();
 	if (t_ptr[0] == '*' && t_ptr[1] == '/') {
-	/* XXX: strange mixture between indentation, column, length */
-		if (adj_max_line_length >= 1 + indentation_after_range(ps.com_col - 1, buf_ptr, t_ptr + 2))
+		int right_margin = indentation_after_range(ps.com_col - 1,
+		buf_ptr, t_ptr + 2);
+		if (right_margin < adj_max_line_length)
 		break_delim = false;
 		break;
 	}



CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 18:11:31 UTC 2021

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

Log Message:
indent: remove the '+ 1' from right margin calculation in comment

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 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/sys

2021-03-13 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Mar 13 17:14:12 UTC 2021

Modified Files:
src/sys/arch/mips/include: pcb.h
src/sys/arch/mips/mips: trap.c
src/sys/uvm/pmap: pmap.c

Log Message:
s/pfi_faultpte// for consistency with arm / other uses of ptep


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/mips/include/pcb.h
cvs rdiff -u -r1.257 -r1.258 src/sys/arch/mips/mips/trap.c
cvs rdiff -u -r1.59 -r1.60 src/sys/uvm/pmap/pmap.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/mips/include/pcb.h
diff -u src/sys/arch/mips/include/pcb.h:1.27 src/sys/arch/mips/include/pcb.h:1.28
--- src/sys/arch/mips/include/pcb.h:1.27	Sat Sep 26 04:31:53 2020
+++ src/sys/arch/mips/include/pcb.h	Sat Mar 13 17:14:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcb.h,v 1.27 2020/09/26 04:31:53 simonb Exp $	*/
+/*	$NetBSD: pcb.h,v 1.28 2021/03/13 17:14:11 skrll Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -45,7 +45,7 @@
 #include 
 
 struct pcb_faultinfo {
-	void *pfi_faultpte;
+	void *pfi_faultptep;
 	vaddr_t pfi_faultaddr;
 	u_int pfi_repeats;
 	pid_t pfi_lastpid;

Index: src/sys/arch/mips/mips/trap.c
diff -u src/sys/arch/mips/mips/trap.c:1.257 src/sys/arch/mips/mips/trap.c:1.258
--- src/sys/arch/mips/mips/trap.c:1.257	Sun Mar  7 15:10:05 2021
+++ src/sys/arch/mips/mips/trap.c	Sat Mar 13 17:14:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: trap.c,v 1.257 2021/03/07 15:10:05 christos Exp $	*/
+/*	$NetBSD: trap.c,v 1.258 2021/03/13 17:14:11 skrll Exp $	*/
 
 /*
  * Copyright (c) 1988 University of Utah.
@@ -39,7 +39,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.257 2021/03/07 15:10:05 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.258 2021/03/13 17:14:11 skrll Exp $");
 
 #include "opt_cputype.h"	/* which mips CPU levels do we support? */
 #include "opt_ddb.h"
@@ -383,7 +383,7 @@ trap(uint32_t status, uint32_t cause, va
 		if (p->p_pid == pfi->pfi_lastpid && va == pfi->pfi_faultaddr) {
 			if (++pfi->pfi_repeats > 4) {
 tlb_asid_t asid = tlb_get_asid();
-pt_entry_t *ptep = pfi->pfi_faultpte;
+pt_entry_t *ptep = pfi->pfi_faultptep;
 printf("trap: fault #%u (%s/%s) for %#"
 PRIxVADDR" (%#"PRIxVADDR") at pc %#"
 PRIxVADDR" curpid=%u/%u ptep@%p=%#"
@@ -402,7 +402,7 @@ trap(uint32_t status, uint32_t cause, va
 			pfi->pfi_lastpid = p->p_pid;
 			pfi->pfi_faultaddr = va;
 			pfi->pfi_repeats = 0;
-			pfi->pfi_faultpte = NULL;
+			pfi->pfi_faultptep = NULL;
 			pfi->pfi_faulttype = TRAPTYPE(cause);
 		}
 #endif /* PMAP_FAULTINFO */
@@ -435,10 +435,10 @@ trap(uint32_t status, uint32_t cause, va
 		if (rv == 0) {
 #ifdef PMAP_FAULTINFO
 			if (pfi->pfi_repeats == 0) {
-pfi->pfi_faultpte =
+pfi->pfi_faultptep =
 pmap_pte_lookup(map->pmap, va);
 			}
-			KASSERT(*(pt_entry_t *)pfi->pfi_faultpte);
+			KASSERT(*(pt_entry_t *)pfi->pfi_faultptep);
 #endif
 			if (type & T_USER) {
 userret(l);

Index: src/sys/uvm/pmap/pmap.c
diff -u src/sys/uvm/pmap/pmap.c:1.59 src/sys/uvm/pmap/pmap.c:1.60
--- src/sys/uvm/pmap/pmap.c:1.59	Sat Mar 13 15:29:13 2021
+++ src/sys/uvm/pmap/pmap.c	Sat Mar 13 17:14:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.59 2021/03/13 15:29:13 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.60 2021/03/13 17:14:11 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.59 2021/03/13 15:29:13 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.60 2021/03/13 17:14:11 skrll Exp $");
 
 /*
  *	Manages physical address maps.
@@ -1027,7 +1027,7 @@ pmap_remove(pmap_t pmap, vaddr_t sva, va
 #ifdef PMAP_FAULTINFO
 	curpcb->pcb_faultinfo.pfi_faultaddr = 0;
 	curpcb->pcb_faultinfo.pfi_repeats = 0;
-	curpcb->pcb_faultinfo.pfi_faultpte = NULL;
+	curpcb->pcb_faultinfo.pfi_faultptep = NULL;
 #endif
 	kpreempt_disable();
 	pmap_addr_range_check(pmap, sva, eva, __func__);
@@ -1572,7 +1572,7 @@ pmap_remove_all(struct pmap *pmap)
 #ifdef PMAP_FAULTINFO
 	curpcb->pcb_faultinfo.pfi_faultaddr = 0;
 	curpcb->pcb_faultinfo.pfi_repeats = 0;
-	curpcb->pcb_faultinfo.pfi_faultpte = NULL;
+	curpcb->pcb_faultinfo.pfi_faultptep = NULL;
 #endif
 	kpreempt_enable();
 



CVS commit: src/sys

2021-03-13 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Mar 13 17:14:12 UTC 2021

Modified Files:
src/sys/arch/mips/include: pcb.h
src/sys/arch/mips/mips: trap.c
src/sys/uvm/pmap: pmap.c

Log Message:
s/pfi_faultpte// for consistency with arm / other uses of ptep


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/mips/include/pcb.h
cvs rdiff -u -r1.257 -r1.258 src/sys/arch/mips/mips/trap.c
cvs rdiff -u -r1.59 -r1.60 src/sys/uvm/pmap/pmap.c

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



CVS commit: src/lib/libwrap

2021-03-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar 13 16:46:49 UTC 2021

Modified Files:
src/lib/libwrap: Makefile

Log Message:
record the libblocklist dependency


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/lib/libwrap/Makefile

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



CVS commit: src/lib/libwrap

2021-03-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar 13 16:46:49 UTC 2021

Modified Files:
src/lib/libwrap: Makefile

Log Message:
record the libblocklist dependency


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/lib/libwrap/Makefile

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

Modified files:

Index: src/lib/libwrap/Makefile
diff -u src/lib/libwrap/Makefile:1.13 src/lib/libwrap/Makefile:1.14
--- src/lib/libwrap/Makefile:1.13	Sun Mar  7 15:54:41 2021
+++ src/lib/libwrap/Makefile	Sat Mar 13 11:46:49 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.13 2021/03/07 20:54:41 christos Exp $
+#	$NetBSD: Makefile,v 1.14 2021/03/13 16:46:49 christos Exp $
 
 USE_FORT?= yes	# network server
 
@@ -14,8 +14,8 @@ MLINKS+=hosts_access.3 hosts_ctl.3
 MLINKS+=hosts_access.3 request_init.3
 MLINKS+=hosts_access.3 request_set.3
 
-#LDADD+=-lblocklist
-#DPADD+=${LIBBLOCKLIST}
+LDADD+=-lblocklist
+DPADD+=${LIBBLOCKLIST}
 
 INCS= tcpd.h
 INCSDIR=/usr/include



CVS commit: src/usr.bin/sed

2021-03-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar 13 15:46:54 UTC 2021

Modified Files:
src/usr.bin/sed: compile.c

Log Message:
Handle \t too (RVP)


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/usr.bin/sed/compile.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/sed/compile.c
diff -u src/usr.bin/sed/compile.c:1.49 src/usr.bin/sed/compile.c:1.50
--- src/usr.bin/sed/compile.c:1.49	Thu Mar 11 17:31:19 2021
+++ src/usr.bin/sed/compile.c	Sat Mar 13 10:46:54 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: compile.c,v 1.49 2021/03/11 22:31:19 christos Exp $	*/
+/*	$NetBSD: compile.c,v 1.50 2021/03/13 15:46:54 christos Exp $	*/
 
 /*-
  * Copyright (c) 1992 Diomidis Spinellis.
@@ -38,7 +38,7 @@
 #endif
 
 #include 
-__RCSID("$NetBSD: compile.c,v 1.49 2021/03/11 22:31:19 christos Exp $");
+__RCSID("$NetBSD: compile.c,v 1.50 2021/03/13 15:46:54 christos Exp $");
 #ifdef __FBSDID
 __FBSDID("$FreeBSD: head/usr.bin/sed/compile.c 259132 2013-12-09 18:57:20Z eadler $");
 #endif
@@ -547,6 +547,9 @@ unescape(char **pp, char **spp)
 	case 'r':
 		*sp = '\r';
 		break;
+	case 't':
+		*sp = '\t';
+		break;
 	case 'v':
 		*sp = '\v';
 		break;



CVS commit: src/usr.bin/sed

2021-03-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Mar 13 15:46:54 UTC 2021

Modified Files:
src/usr.bin/sed: compile.c

Log Message:
Handle \t too (RVP)


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/usr.bin/sed/compile.c

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



CVS commit: src/sys/uvm

2021-03-13 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Mar 13 15:29:56 UTC 2021

Modified Files:
src/sys/uvm: uvm_amap.c uvm_aobj.c uvm_bio.c uvm_device.c uvm_km.c
uvm_map.c uvm_swap.c uvm_vnode.c
src/sys/uvm/pmap: pmap_segtab.c

Log Message:
Consistently use %#jx instead of 0x%jx or just %jx in UVMHIST_LOG formats


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/sys/uvm/uvm_amap.c
cvs rdiff -u -r1.152 -r1.153 src/sys/uvm/uvm_aobj.c
cvs rdiff -u -r1.124 -r1.125 src/sys/uvm/uvm_bio.c
cvs rdiff -u -r1.71 -r1.72 src/sys/uvm/uvm_device.c
cvs rdiff -u -r1.159 -r1.160 src/sys/uvm/uvm_km.c
cvs rdiff -u -r1.385 -r1.386 src/sys/uvm/uvm_map.c
cvs rdiff -u -r1.202 -r1.203 src/sys/uvm/uvm_swap.c
cvs rdiff -u -r1.117 -r1.118 src/sys/uvm/uvm_vnode.c
cvs rdiff -u -r1.26 -r1.27 src/sys/uvm/pmap/pmap_segtab.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/uvm_amap.c
diff -u src/sys/uvm/uvm_amap.c:1.125 src/sys/uvm/uvm_amap.c:1.126
--- src/sys/uvm/uvm_amap.c:1.125	Mon Sep 21 18:41:59 2020
+++ src/sys/uvm/uvm_amap.c	Sat Mar 13 15:29:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_amap.c,v 1.125 2020/09/21 18:41:59 chs Exp $	*/
+/*	$NetBSD: uvm_amap.c,v 1.126 2021/03/13 15:29:55 skrll Exp $	*/
 
 /*
  * Copyright (c) 1997 Charles D. Cranor and Washington University.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.125 2020/09/21 18:41:59 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_amap.c,v 1.126 2021/03/13 15:29:55 skrll Exp $");
 
 #include "opt_uvmhist.h"
 
@@ -827,7 +827,7 @@ amap_copy(struct vm_map *map, struct vm_
 	vsize_t len;
 
 	UVMHIST_FUNC(__func__);
-	UVMHIST_CALLARGS(maphist, "  (map=%#j, entry=%#j, flags=%jd)",
+	UVMHIST_CALLARGS(maphist, "  (map=%#jx, entry=%#jx, flags=%#jx)",
 	(uintptr_t)map, (uintptr_t)entry, flags, -2);
 
 	KASSERT(map != kernel_map);	/* we use nointr pool */
@@ -903,7 +903,7 @@ amap_copy(struct vm_map *map, struct vm_
 		return;
 	}
 
-	UVMHIST_LOG(maphist,"  amap=%#j, ref=%jd, must copy it",
+	UVMHIST_LOG(maphist,"  amap=%#jx, ref=%jd, must copy it",
 	(uintptr_t)srcamap, srcamap->am_ref, 0, 0);
 
 	/*

Index: src/sys/uvm/uvm_aobj.c
diff -u src/sys/uvm/uvm_aobj.c:1.152 src/sys/uvm/uvm_aobj.c:1.153
--- src/sys/uvm/uvm_aobj.c:1.152	Wed Nov  4 01:30:19 2020
+++ src/sys/uvm/uvm_aobj.c	Sat Mar 13 15:29:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_aobj.c,v 1.152 2020/11/04 01:30:19 chs Exp $	*/
+/*	$NetBSD: uvm_aobj.c,v 1.153 2021/03/13 15:29:55 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998 Chuck Silvers, Charles D. Cranor and
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_aobj.c,v 1.152 2020/11/04 01:30:19 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_aobj.c,v 1.153 2021/03/13 15:29:55 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_uvmhist.h"
@@ -810,7 +810,7 @@ uao_get(struct uvm_object *uobj, voff_t 
 	struct uvm_page_array a;
 
 	UVMHIST_FUNC(__func__);
-	UVMHIST_CALLARGS(pdhist, "aobj=%#jx offset=%jd, flags=%jd",
+	UVMHIST_CALLARGS(pdhist, "aobj=%#jx offset=%jd, flags=%#jx",
 		(uintptr_t)uobj, offset, flags,0);
 
 	/*

Index: src/sys/uvm/uvm_bio.c
diff -u src/sys/uvm/uvm_bio.c:1.124 src/sys/uvm/uvm_bio.c:1.125
--- src/sys/uvm/uvm_bio.c:1.124	Tue Nov 10 04:27:22 2020
+++ src/sys/uvm/uvm_bio.c	Sat Mar 13 15:29:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: uvm_bio.c,v 1.124 2020/11/10 04:27:22 chs Exp $	*/
+/*	$NetBSD: uvm_bio.c,v 1.125 2021/03/13 15:29:55 skrll Exp $	*/
 
 /*
  * Copyright (c) 1998 Chuck Silvers.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.124 2020/11/10 04:27:22 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uvm_bio.c,v 1.125 2021/03/13 15:29:55 skrll Exp $");
 
 #include "opt_uvmhist.h"
 #include "opt_ubc.h"
@@ -342,7 +342,7 @@ ubc_fault(struct uvm_faultinfo *ufi, vad
 	 */
 
 	access_type = umap->writelen ? VM_PROT_WRITE : VM_PROT_READ;
-	UVMHIST_LOG(ubchist, "va 0x%jx ubc_offset 0x%jx access_type %jd",
+	UVMHIST_LOG(ubchist, "va %#jx ubc_offset %#jx access_type %jd",
 	va, ubc_offset, access_type, 0);
 
 	if ((access_type & VM_PROT_WRITE) != 0) {
@@ -374,9 +374,9 @@ again:
 	memset(pgs, 0, sizeof (pgs));
 	rw_enter(uobj->vmobjlock, RW_WRITER);
 
-	UVMHIST_LOG(ubchist, "slot_offset 0x%jx writeoff 0x%jx writelen 0x%jx ",
+	UVMHIST_LOG(ubchist, "slot_offset %#jx writeoff %#jx writelen %#jx ",
 	slot_offset, umap->writeoff, umap->writelen, 0);
-	UVMHIST_LOG(ubchist, "getpages uobj %#jx offset 0x%jx npages %jd",
+	UVMHIST_LOG(ubchist, "getpages uobj %#jx offset %#jx npages %jd",
 	(uintptr_t)uobj, umap->offset + slot_offset, npages, 0);
 
 	error = (*uobj->pgops->pgo_get)(uobj, umap->offset + slot_offset, pgs,
@@ -409,7 +409,7 @@ again:
 	va = ufi->orig_rvaddr;
 	eva = ufi->orig_rvaddr + (npages << PAGE_SHIFT);
 
-	UVMHIST_LOG(ubchist, "va 0x%jx eva 0x%jx", va, eva, 0, 0);
+	UVMHIST_LOG(ubchist, "va %#jx eva %#jx", va, eva, 0, 

CVS commit: src/sys/uvm

2021-03-13 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Mar 13 15:29:56 UTC 2021

Modified Files:
src/sys/uvm: uvm_amap.c uvm_aobj.c uvm_bio.c uvm_device.c uvm_km.c
uvm_map.c uvm_swap.c uvm_vnode.c
src/sys/uvm/pmap: pmap_segtab.c

Log Message:
Consistently use %#jx instead of 0x%jx or just %jx in UVMHIST_LOG formats


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 src/sys/uvm/uvm_amap.c
cvs rdiff -u -r1.152 -r1.153 src/sys/uvm/uvm_aobj.c
cvs rdiff -u -r1.124 -r1.125 src/sys/uvm/uvm_bio.c
cvs rdiff -u -r1.71 -r1.72 src/sys/uvm/uvm_device.c
cvs rdiff -u -r1.159 -r1.160 src/sys/uvm/uvm_km.c
cvs rdiff -u -r1.385 -r1.386 src/sys/uvm/uvm_map.c
cvs rdiff -u -r1.202 -r1.203 src/sys/uvm/uvm_swap.c
cvs rdiff -u -r1.117 -r1.118 src/sys/uvm/uvm_vnode.c
cvs rdiff -u -r1.26 -r1.27 src/sys/uvm/pmap/pmap_segtab.c

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



CVS commit: src/sys/uvm/pmap

2021-03-13 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Mar 13 15:29:13 UTC 2021

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

Log Message:
Don't use %jx for 0 or 1 - just use %jd in UVMHIST_LOG format.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/uvm/pmap/pmap.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.c
diff -u src/sys/uvm/pmap/pmap.c:1.58 src/sys/uvm/pmap/pmap.c:1.59
--- src/sys/uvm/pmap/pmap.c:1.58	Sun Dec 20 16:38:26 2020
+++ src/sys/uvm/pmap/pmap.c	Sat Mar 13 15:29:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.58 2020/12/20 16:38:26 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.59 2021/03/13 15:29:13 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.58 2020/12/20 16:38:26 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.59 2021/03/13 15:29:13 skrll Exp $");
 
 /*
  *	Manages physical address maps.
@@ -950,7 +950,7 @@ pmap_update(struct pmap *pmap)
 	pmap_tlb_miss_lock_exit();
 	kpreempt_enable();
 
-	UVMHIST_LOG(pmaphist, " <-- done (kernel=%jx)",
+	UVMHIST_LOG(pmaphist, " <-- done (kernel=%jd)",
 		(pmap == pmap_kernel() ? 1 : 0), 0, 0, 0);
 }
 
@@ -969,7 +969,7 @@ pmap_pte_remove(pmap_t pmap, vaddr_t sva
 	const bool is_kernel_pmap_p = (pmap == pmap_kernel());
 
 	UVMHIST_FUNC(__func__);
-	UVMHIST_CALLARGS(pmaphist, "(pmap=%#jx kernel=%jx va=%#jx..%#jx)",
+	UVMHIST_CALLARGS(pmaphist, "(pmap=%#jx kernel=%jd va=%#jx..%#jx)",
 	(uintptr_t)pmap, (pmap == pmap_kernel() ? 1 : 0), sva, eva);
 	UVMHIST_LOG(pmaphist, "ptep=%#jx, flags(npte)=%#jx)",
 	(uintptr_t)ptep, flags, 0, 0);
@@ -1113,7 +1113,7 @@ pmap_pte_protect(pmap_t pmap, vaddr_t sv
 	const vm_prot_t prot = (flags & VM_PROT_ALL);
 
 	UVMHIST_FUNC(__func__);
-	UVMHIST_CALLARGS(pmaphist, "(pmap=%#jx kernel=%jx va=%#jx..%#jx)",
+	UVMHIST_CALLARGS(pmaphist, "(pmap=%#jx kernel=%jd va=%#jx..%#jx)",
 	(uintptr_t)pmap, (pmap == pmap_kernel() ? 1 : 0), sva, eva);
 	UVMHIST_LOG(pmaphist, "ptep=%#jx, flags(npte)=%#jx)",
 	(uintptr_t)ptep, flags, 0, 0);



CVS commit: src/sys/uvm/pmap

2021-03-13 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Mar 13 15:29:13 UTC 2021

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

Log Message:
Don't use %jx for 0 or 1 - just use %jd in UVMHIST_LOG format.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/uvm/pmap/pmap.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-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 13:55:42 UTC 2021

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

Log Message:
indent: rename local variable in dump_line

This clarifies that the variable names a column, not an indentation.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 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.44 src/usr.bin/indent/io.c:1.45
--- src/usr.bin/indent/io.c:1.44	Sat Mar 13 13:54:01 2021
+++ src/usr.bin/indent/io.c	Sat Mar 13 13:55:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.44 2021/03/13 13:54:01 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.45 2021/03/13 13:55:42 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.44 2021/03/13 13:54:01 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.45 2021/03/13 13:55:42 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -218,22 +218,22 @@ dump_line(void)
 	cur_col = 1 + indentation_after(cur_col - 1, s_code);
 	}
 	if (s_com != e_com) {		/* print comment, if any */
-	int target = ps.com_col;
+	int target_col = ps.com_col;
 	char *com_st = s_com;
 
-	target += ps.comment_delta;
+	target_col += ps.comment_delta;
 	while (*com_st == '\t')	/* consider original indentation in
  * case this is a box comment */
-		com_st++, target += opt.tabsize;
-	while (target <= 0)
+		com_st++, target_col += opt.tabsize;
+	while (target_col <= 0)
 		if (*com_st == ' ')
-		target++, com_st++;
+		target_col++, com_st++;
 		else if (*com_st == '\t') {
-		target = opt.tabsize * (1 + (target - 1) / opt.tabsize) + 1;
+		target_col = opt.tabsize * (1 + (target_col - 1) / opt.tabsize) + 1;
 		com_st++;
 		} else
-		target = 1;
-	if (cur_col > target) {	/* if comment can't fit on this line,
+		target_col = 1;
+	if (cur_col > target_col) {	/* if comment can't fit on this line,
  * put it on next line */
 		output_char('\n');
 		cur_col = 1;
@@ -241,7 +241,7 @@ dump_line(void)
 	}
 	while (e_com > com_st && isspace((unsigned char)e_com[-1]))
 		e_com--;
-	(void)output_indent(cur_col - 1, target - 1);
+	(void)output_indent(cur_col - 1, target_col - 1);
 	output_range(com_st, e_com);
 	ps.comment_delta = ps.n_comment_delta;
 	++ps.com_lines;	/* count lines with comments */



CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 13:55:42 UTC 2021

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

Log Message:
indent: rename local variable in dump_line

This clarifies that the variable names a column, not an indentation.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 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-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 13:54:01 UTC 2021

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

Log Message:
indent: in dump_line, reduce scope of local variable

This allows the variable 'target' in the lower half of the function to
get a more specific name.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 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.43 src/usr.bin/indent/io.c:1.44
--- src/usr.bin/indent/io.c:1.43	Sat Mar 13 13:51:08 2021
+++ src/usr.bin/indent/io.c	Sat Mar 13 13:54:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.43 2021/03/13 13:51:08 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.44 2021/03/13 13:54:01 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.43 2021/03/13 13:51:08 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.44 2021/03/13 13:54:01 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -115,7 +115,7 @@ output_indent(int old_ind, int new_ind)
 void
 dump_line(void)
 {
-int cur_col, target_col;
+int cur_col;
 static int  not_first_line;
 
 if (ps.procname[0]) {
@@ -195,7 +195,7 @@ dump_line(void)
 		comment_open = 0;
 		output_string(".*/\n");
 	}
-	target_col = 1 + compute_code_indent();
+	int target_col = 1 + compute_code_indent();
 	{
 		int i;
 



CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 13:54:01 UTC 2021

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

Log Message:
indent: in dump_line, reduce scope of local variable

This allows the variable 'target' in the lower half of the function to
get a more specific name.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 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-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 13:51:08 UTC 2021

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

Log Message:
indent: distinguish between 'column' and 'indentation'

column == 1 + indentation.

In addition, indentation is a relative distance while column is an
absolute position.  Therefore, don't confuse these two concepts, to
prevent off-by-one errors.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/indent/args.c
cvs rdiff -u -r1.56 -r1.57 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/indent/indent_globs.h
cvs rdiff -u -r1.42 -r1.43 src/usr.bin/indent/io.c
cvs rdiff -u -r1.28 -r1.29 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.20 src/usr.bin/indent/args.c:1.21
--- src/usr.bin/indent/args.c:1.20	Sat Mar 13 11:19:43 2021
+++ src/usr.bin/indent/args.c	Sat Mar 13 13:51:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: args.c,v 1.20 2021/03/13 11:19:43 rillig Exp $	*/
+/*	$NetBSD: args.c,v 1.21 2021/03/13 13:51:08 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)args.c	8.1 (
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: args.c,v 1.20 2021/03/13 11:19:43 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.21 2021/03/13 13:51:08 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/args.c 336318 2018-07-15 21:04:21Z pstef $");
 #endif
@@ -119,12 +119,12 @@ const struct pro {
 {"br", PRO_BOOL, true, ON, _2},
 {"bs", PRO_BOOL, false, ON, _Shannon},
 {"cdb", PRO_BOOL, true, ON, _delimiter_on_blankline},
-{"cd", PRO_INT, 0, 0, _com_ind},
+{"cd", PRO_INT, 0, 0, _comment_column},
 {"ce", PRO_BOOL, true, ON, _else},
 {"ci", PRO_INT, 0, 0, _indent},
 {"cli", PRO_SPECIAL, 0, CLI, 0},
 {"cs", PRO_BOOL, false, ON, _after_cast},
-{"c", PRO_INT, 33, 0, _ind},
+{"c", PRO_INT, 33, 0, _column},
 {"di", PRO_INT, 16, 0, _indent},
 {"dj", PRO_BOOL, false, ON, _decl},
 {"d", PRO_INT, 0, 0, _displace},
@@ -134,7 +134,7 @@ const struct pro {
 {"fc1", PRO_BOOL, true, ON, _col1_comments},
 {"fcb", PRO_BOOL, true, ON, _block_comments},
 {"ip", PRO_BOOL, true, ON, _parameters},
-{"i", PRO_INT, 8, 0, _size},
+{"i", PRO_INT, 8, 0, _size},
 {"lc", PRO_INT, 0, 0, _comment_max_line_length},
 {"ldi", PRO_INT, -1, 0, _decl_indent},
 {"lpl", PRO_BOOL, false, ON, _to_parens_always},

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.56 src/usr.bin/indent/indent.c:1.57
--- src/usr.bin/indent/indent.c:1.56	Sat Mar 13 13:25:23 2021
+++ src/usr.bin/indent/indent.c	Sat Mar 13 13:51:08 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.56 2021/03/13 13:25:23 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.57 2021/03/13 13:51:08 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.56 2021/03/13 13:25:23 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.57 2021/03/13 13:51:08 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -507,16 +507,18 @@ main_parse_command_line(int argc, char *
 	}
 }
 
-if (opt.com_ind <= 1)
-	opt.com_ind = 2;	/* don't put normal comments before column 2 */
+if (opt.comment_column <= 1)
+	opt.comment_column = 2;	/* don't put normal comments before column 2 */
 if (opt.block_comment_max_line_length <= 0)
 	opt.block_comment_max_line_length = opt.max_line_length;
 if (opt.local_decl_indent < 0) /* if not specified by user, set this */
 	opt.local_decl_indent = opt.decl_indent;
-if (opt.decl_com_ind <= 0)	/* if not specified by user, set this */
-	opt.decl_com_ind = opt.ljust_decl ? (opt.com_ind <= 10 ? 2 : opt.com_ind - 8) : opt.com_ind;
+if (opt.decl_comment_column <= 0)	/* if not specified by user, set this */
+	opt.decl_comment_column = opt.ljust_decl
+	? (opt.comment_column <= 10 ? 2 : opt.comment_column - 8)
+	: opt.comment_column;
 if (opt.continuation_indent == 0)
-	opt.continuation_indent = opt.ind_size;
+	opt.continuation_indent = opt.indent_size;
 }
 
 static void
@@ -538,8 +540,8 @@ main_prepare_parsing(void)
 	break;
 	p++;
 }
-if (col > opt.ind_size)
-	ps.ind_level = ps.i_l_follow = col / opt.ind_size;
+if (col > opt.indent_size)
+	ps.ind_level = ps.i_l_follow = col / opt.indent_size;
 }
 
 static void
@@ -641,8 +643,8 @@ process_lparen_or_lbracket(int dec_ind, 
 ps.paren_indents[ps.p_l_follow - 1] =
 	indentation_after_range(0, s_code, e_code);
 if (sp_sw && ps.p_l_follow == 1 && 

CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 13:51:08 UTC 2021

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

Log Message:
indent: distinguish between 'column' and 'indentation'

column == 1 + indentation.

In addition, indentation is a relative distance while column is an
absolute position.  Therefore, don't confuse these two concepts, to
prevent off-by-one errors.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/indent/args.c
cvs rdiff -u -r1.56 -r1.57 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/indent/indent_globs.h
cvs rdiff -u -r1.42 -r1.43 src/usr.bin/indent/io.c
cvs rdiff -u -r1.28 -r1.29 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-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 13:25:23 UTC 2021

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

Log Message:
indent: rename pr_comment to process_comment, clean up documentation

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/indent/indent_globs.h
cvs rdiff -u -r1.27 -r1.28 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.55 src/usr.bin/indent/indent.c:1.56
--- src/usr.bin/indent/indent.c:1.55	Sat Mar 13 13:14:14 2021
+++ src/usr.bin/indent/indent.c	Sat Mar 13 13:25:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.55 2021/03/13 13:14:14 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.56 2021/03/13 13:25:23 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.55 2021/03/13 13:14:14 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.56 2021/03/13 13:25:23 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -212,7 +212,7 @@ search_brace(token_type *inout_type_code
 	if (sc_end == NULL) {
 		/*
 		 * Copy everything from the start of the line, because
-		 * pr_comment() will use that to calculate original
+		 * process_comment() will use that to calculate original
 		 * indentation of a boxed comment.
 		 */
 		memcpy(sc_buf, in_buffer, buf_ptr - in_buffer - 4);
@@ -1439,8 +1439,8 @@ main_loop(void)
 	case preprocessing:	/* '#' */
 	process_preprocessing();
 	break;
-	case comment:		/* we have gotten a '/' followed by '*' */
-	pr_comment();
+	case comment:		/* the initial '/' '*' or '//' of a comment */
+	process_comment();
 	break;
 
 	default:

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.13 src/usr.bin/indent/indent.h:1.14
--- src/usr.bin/indent/indent.h:1.13	Sat Mar 13 10:32:25 2021
+++ src/usr.bin/indent/indent.h	Sat Mar 13 13:25:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.13 2021/03/13 10:32:25 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.14 2021/03/13 13:25:23 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -30,7 +30,7 @@
 
 #if 0
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.h,v 1.13 2021/03/13 10:32:25 rillig Exp $");
+__RCSID("$NetBSD: indent.h,v 1.14 2021/03/13 13:25:23 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.h 336333 2018-07-16 05:46:50Z pstef $");
 #endif
@@ -65,7 +65,7 @@ void	diag(int, const char *, ...) __prin
 void	dump_line(void);
 void	fill_buffer(void);
 void	parse(token_type);
-void	pr_comment(void);
+void	process_comment(void);
 void	set_defaults(void);
 void	set_option(char *);
 void	set_profile(const char *);

Index: src/usr.bin/indent/indent_globs.h
diff -u src/usr.bin/indent/indent_globs.h:1.18 src/usr.bin/indent/indent_globs.h:1.19
--- src/usr.bin/indent/indent_globs.h:1.18	Sat Mar 13 11:19:43 2021
+++ src/usr.bin/indent/indent_globs.h	Sat Mar 13 13:25:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent_globs.h,v 1.18 2021/03/13 11:19:43 rillig Exp $	*/
+/*	$NetBSD: indent_globs.h,v 1.19 2021/03/13 13:25:23 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -254,7 +254,7 @@ extern struct parser_state {
 int last_u_d;	/* set to true after scanning a token which
  * forces a following operator to be unary */
 int out_coms;	/* the number of comments processed, set by
- * pr_comment */
+ * process_comment */
 int out_lines;	/* the number of lines written, set by
  * dump_line */
 int p_l_follow;	/* used to remember how to indent following

Index: src/usr.bin/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.27 src/usr.bin/indent/pr_comment.c:1.28
--- src/usr.bin/indent/pr_comment.c:1.27	Sat Mar 13 11:27:01 2021
+++ src/usr.bin/indent/pr_comment.c	Sat Mar 13 13:25:23 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.27 2021/03/13 11:27:01 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.28 2021/03/13 13:25:23 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)pr_comment.c
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: pr_comment.c,v 1.27 2021/03/13 11:27:01 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.28 2021/03/13 13:25:23 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -79,38 +79,25 @@ check_size_comment(size_t desired_size, 

CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 13:25:23 UTC 2021

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

Log Message:
indent: rename pr_comment to process_comment, clean up documentation

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.18 -r1.19 src/usr.bin/indent/indent_globs.h
cvs rdiff -u -r1.27 -r1.28 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-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 13:14:14 UTC 2021

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

Log Message:
indent: fix handling of '/*' in string literal in preprocessing line

Previously, the '/*' in the string literal had been interpreted as the
beginning of a comment, which was wrong.  Because of that, the variable
declaration in the following line was still interpreted as part of the
comment.  The comment even continued until the end of the file.

Due to indent's forgiving nature, it neither complained nor even
mentioned that anything had gone wrong.  The decision of rather
producing wrong output than failing early is a dangerous one.

At least, there should have been an error message that at the end of the
file, the parser was still in a a comment, expecting the closing '*/'.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 \
src/tests/usr.bin/indent/token-preprocessing.0.stdout
cvs rdiff -u -r1.54 -r1.55 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.3 src/tests/usr.bin/indent/token-preprocessing.0.stdout:1.4
--- src/tests/usr.bin/indent/token-preprocessing.0.stdout:1.3	Sat Mar 13 13:04:13 2021
+++ src/tests/usr.bin/indent/token-preprocessing.0.stdout	Sat Mar 13 13:14:14 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token-preprocessing.0.stdout,v 1.3 2021/03/13 13:04:13 rillig Exp $ */
+/* $NetBSD: token-preprocessing.0.stdout,v 1.4 2021/03/13 13:14:14 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*-
@@ -34,6 +34,4 @@
  */ actual_value
 
 #define comment_in_string_literal "/* no comment "
-int this_is_an_ordinary_line_again;
-
-/* $ FIXME: The above empty line is wrong. */
+int		this_is_an_ordinary_line_again;

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.54 src/usr.bin/indent/indent.c:1.55
--- src/usr.bin/indent/indent.c:1.54	Sat Mar 13 12:52:24 2021
+++ src/usr.bin/indent/indent.c	Sat Mar 13 13:14:14 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.54 2021/03/13 12:52:24 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.55 2021/03/13 13:14:14 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.54 2021/03/13 12:52:24 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.55 2021/03/13 13:14:14 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -1121,7 +1121,7 @@ process_preprocessing(void)
 {
 	int in_comment = 0;
 	int com_start = 0;
-	charquote = 0;
+	charquote = '\0';
 	int com_end = 0;
 
 	while (*buf_ptr == ' ' || *buf_ptr == '\t') {
@@ -1143,7 +1143,7 @@ process_preprocessing(void)
 		}
 		break;
 	case '/':
-		if (*buf_ptr == '*' && !in_comment && !quote) {
+		if (*buf_ptr == '*' && !in_comment && quote == '\0') {
 		in_comment = 1;
 		*e_lab++ = *buf_ptr++;
 		com_start = e_lab - s_lab - 2;
@@ -1151,11 +1151,15 @@ process_preprocessing(void)
 		break;
 	case '"':
 		if (quote == '"')
-		quote = 0;
+		quote = '\0';
+		else if (quote == '\0')
+		quote = '"';
 		break;
 	case '\'':
 		if (quote == '\'')
-		quote = 0;
+		quote = '\0';
+		else if (quote == '\0')
+		quote = '\'';
 		break;
 	case '*':
 		if (*buf_ptr == '/' && in_comment) {



CVS commit: src

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 13:14:14 UTC 2021

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

Log Message:
indent: fix handling of '/*' in string literal in preprocessing line

Previously, the '/*' in the string literal had been interpreted as the
beginning of a comment, which was wrong.  Because of that, the variable
declaration in the following line was still interpreted as part of the
comment.  The comment even continued until the end of the file.

Due to indent's forgiving nature, it neither complained nor even
mentioned that anything had gone wrong.  The decision of rather
producing wrong output than failing early is a dangerous one.

At least, there should have been an error message that at the end of the
file, the parser was still in a a comment, expecting the closing '*/'.


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

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



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

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 13:04:13 UTC 2021

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

Log Message:
tests/indent: add another test case for preprocessing directives

In process_preprocessing, the variable 'quote' is not used, which makes
the code suspicious of not handling the combination of string literals
and comments properly.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/token-preprocessing.0 \
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-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 13:04:13 UTC 2021

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

Log Message:
tests/indent: add another test case for preprocessing directives

In process_preprocessing, the variable 'quote' is not used, which makes
the code suspicious of not handling the combination of string literals
and comments properly.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/token-preprocessing.0 \
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.2 src/tests/usr.bin/indent/token-preprocessing.0:1.3
--- src/tests/usr.bin/indent/token-preprocessing.0:1.2	Fri Mar 12 22:53:18 2021
+++ src/tests/usr.bin/indent/token-preprocessing.0	Sat Mar 13 13:04:13 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token-preprocessing.0,v 1.2 2021/03/12 22:53:18 rillig Exp $ */
+/* $NetBSD: token-preprocessing.0,v 1.3 2021/03/13 13:04:13 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*-
@@ -26,3 +26,11 @@
 #  else /* inner else comment */
 #  endif /* inner endif comment */
 #endif /* outer endif comment */
+
+#define multi_line_definition /* first line
+ * middle
+ * final line
+ */ actual_value
+
+#define comment_in_string_literal "/* no comment "
+int this_is_an_ordinary_line_again;
Index: src/tests/usr.bin/indent/token-preprocessing.0.stdout
diff -u src/tests/usr.bin/indent/token-preprocessing.0.stdout:1.2 src/tests/usr.bin/indent/token-preprocessing.0.stdout:1.3
--- src/tests/usr.bin/indent/token-preprocessing.0.stdout:1.2	Fri Mar 12 22:53:18 2021
+++ src/tests/usr.bin/indent/token-preprocessing.0.stdout	Sat Mar 13 13:04:13 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: token-preprocessing.0.stdout,v 1.2 2021/03/12 22:53:18 rillig Exp $ */
+/* $NetBSD: token-preprocessing.0.stdout,v 1.3 2021/03/13 13:04:13 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*-
@@ -27,3 +27,13 @@
 #else/* inner else comment */
 #endif/* inner endif comment */
 #endif/* outer endif comment */
+
+#define multi_line_definition /* first line
+ * middle
+ * final line
+ */ actual_value
+
+#define comment_in_string_literal "/* no comment "
+int this_is_an_ordinary_line_again;
+
+/* $ FIXME: The above empty line is wrong. */



CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 12:52:24 UTC 2021

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

Log Message:
indent: split 'main_loop' into several functions

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 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.53 src/usr.bin/indent/indent.c:1.54
--- src/usr.bin/indent/indent.c:1.53	Sat Mar 13 11:47:22 2021
+++ src/usr.bin/indent/indent.c	Sat Mar 13 12:52:24 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.53 2021/03/13 11:47:22 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.54 2021/03/13 12:52:24 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.53 2021/03/13 11:47:22 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.54 2021/03/13 12:52:24 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -543,6 +543,719 @@ main_prepare_parsing(void)
 }
 
 static void
+process_end_of_file(void)
+{
+if (s_lab != e_lab || s_code != e_code || s_com != e_com)
+	dump_line();
+
+if (ps.tos > 1)		/* check for balanced braces */
+	diag(1, "Stuff missing from end of file");
+
+if (opt.verbose) {
+	printf("There were %d output lines and %d comments\n",
+	   ps.out_lines, ps.out_coms);
+	printf("(Lines with comments)/(Lines with code): %6.3f\n",
+	   (1.0 * ps.com_lines) / code_lines);
+}
+
+fflush(output);
+exit(found_err);
+}
+
+static void
+process_comment_in_code(token_type type_code, int *inout_force_nl)
+{
+if (*inout_force_nl &&
+	type_code != semicolon &&
+	(type_code != lbrace || !opt.btype_2)) {
+
+	/* we should force a broken line here */
+	if (opt.verbose)
+	diag(0, "Line broken");
+	dump_line();
+	ps.want_blank = false;	/* dont insert blank at line start */
+	*inout_force_nl = false;
+}
+
+ps.in_stmt = true;		/* turn on flag which causes an extra level of
+ * indentation. this is turned off by a ; or
+ * '}' */
+if (s_com != e_com) {	/* the turkey has embedded a comment
+ * in a line. fix it */
+	int len = e_com - s_com;
+
+	check_size_code(len + 3);
+	*e_code++ = ' ';
+	memcpy(e_code, s_com, len);
+	e_code += len;
+	*e_code++ = ' ';
+	*e_code = '\0';		/* null terminate code sect */
+	ps.want_blank = false;
+	e_com = s_com;
+}
+}
+
+static void
+process_form_feed(void)
+{
+ps.use_ff = true;		/* a form feed is treated much like a newline */
+dump_line();
+ps.want_blank = false;
+}
+
+static void
+process_newline(void)
+{
+if (ps.last_token != comma || ps.p_l_follow > 0
+	|| !opt.leave_comma || ps.block_init || !break_comma || s_com != e_com) {
+	dump_line();
+	ps.want_blank = false;
+}
+++line_no;			/* keep track of input line number */
+}
+
+static void
+process_lparen_or_lbracket(int dec_ind, int tabs_to_var, int sp_sw)
+{
+/* count parens to make Healy happy */
+if (++ps.p_l_follow == nitems(ps.paren_indents)) {
+	diag(0, "Reached internal limit of %zu unclosed parens",
+	nitems(ps.paren_indents));
+	ps.p_l_follow--;
+}
+if (*token == '[')
+	/* not a function pointer declaration or a function call */;
+else if (ps.in_decl && !ps.block_init && !ps.dumped_decl_indent &&
+	ps.procname[0] == '\0' && ps.paren_level == 0) {
+	/* function pointer declarations */
+	indent_declaration(dec_ind, tabs_to_var);
+	ps.dumped_decl_indent = true;
+} else if (ps.want_blank &&
+	((ps.last_token != ident && ps.last_token != funcname) ||
+	opt.proc_calls_space ||
+	(ps.keyword == rw_sizeof ? opt.Bill_Shannon :
+	ps.keyword != rw_0 && ps.keyword != rw_offsetof)))
+	*e_code++ = ' ';
+ps.want_blank = false;
+*e_code++ = token[0];
+ps.paren_indents[ps.p_l_follow - 1] =
+	indentation_after_range(0, s_code, e_code);
+if (sp_sw && ps.p_l_follow == 1 && opt.extra_expression_indent
+	&& ps.paren_indents[0] < 2 * opt.ind_size)
+	ps.paren_indents[0] = 2 * opt.ind_size;
+if (ps.in_or_st && *token == '(' && 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 */
+}
+/* parenthesized type following sizeof or offsetof is not a cast */
+if (ps.keyword == rw_offsetof || ps.keyword == rw_sizeof)
+	ps.not_cast_mask |= 1 << ps.p_l_follow;
+}
+
+static void
+process_rparen_or_rbracket(int *inout_sp_sw, int *inout_force_nl,
+			 token_type hd_type)
+{
+if (ps.cast_mask & (1 << 

CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 12:52:24 UTC 2021

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

Log Message:
indent: split 'main_loop' into several functions

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 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-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 11:47:22 UTC 2021

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

Log Message:
indent: split 'main' into manageable parts

Since several years (maybe even decades) compilers know how to inline
static functions that are only used once.  Therefore there is no need to
have overly long functions anymore, especially not 'main', which is only
called a single time and thus does not add any noticeable performance
degradation.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 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-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 11:47:22 UTC 2021

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

Log Message:
indent: split 'main' into manageable parts

Since several years (maybe even decades) compilers know how to inline
static functions that are only used once.  Therefore there is no need to
have overly long functions anymore, especially not 'main', which is only
called a single time and thus does not add any noticeable performance
degradation.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 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.52 src/usr.bin/indent/indent.c:1.53
--- src/usr.bin/indent/indent.c:1.52	Sat Mar 13 11:27:01 2021
+++ src/usr.bin/indent/indent.c	Sat Mar 13 11:47:22 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.52 2021/03/13 11:27:01 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.53 2021/03/13 11:47:22 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.52 2021/03/13 11:27:01 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.53 2021/03/13 11:47:22 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -366,33 +366,9 @@ search_brace(token_type *inout_type_code
 *inout_last_else = 0;
 }
 
-int
-main(int argc, char **argv)
+static void
+main_init_globals(void)
 {
-int dec_ind;	/* current indentation for declarations */
-int di_stack[20];	/* a stack of structure indentation levels */
-int force_nl;	/* when true, code must be broken */
-token_type  hd_type = end_of_file; /* used to store type of stmt
- * for if (...), for (...), etc */
-int		i;		/* local loop counter */
-int scase;		/* set to true when we see a case, so we will
- * know what to do with the following colon */
-int sp_sw;		/* when true, we are in the expression of
- * if(...), while(...), etc. */
-int squest;		/* when this is positive, we have seen a ?
- * without the matching : in a ?:
- * construct */
-int		tabs_to_var;	/* true if using tabs to indent to var name */
-token_type	type_code;	/* returned by lexi */
-
-int last_else = 0;	/* true iff last keyword was an else */
-const char *profile_name = NULL;
-const char *envval = NULL;
-
-/*---*\
-|		  INITIALIZATION		  |
-\*---*/
-
 found_err = 0;
 
 ps.p_stack[0] = stmt;	/* this is the parser's stack */
@@ -433,31 +409,29 @@ main(int argc, char **argv)
 buf_ptr = buf_end = in_buffer;
 line_no = 1;
 had_eof = ps.in_decl = ps.decl_on_line = break_comma = false;
-sp_sw = force_nl = false;
 ps.in_or_st = false;
 ps.bl_line = true;
-dec_ind = 0;
-di_stack[ps.dec_nest = 0] = 0;
 ps.want_blank = ps.in_stmt = ps.ind_stmt = false;
 
-scase = ps.pcase = false;
-squest = 0;
+ps.pcase = false;
 sc_end = NULL;
 bp_save = NULL;
 be_save = NULL;
 
 output = NULL;
-tabs_to_var = 0;
 
-envval = getenv("SIMPLE_BACKUP_SUFFIX");
-if (envval)
-simple_backup_suffix = envval;
-
-/*--*\
-|			COMMAND LINE SCAN		 |
-\*--*/
+const char *suffix = getenv("SIMPLE_BACKUP_SUFFIX");
+if (suffix != NULL)
+	simple_backup_suffix = suffix;
+}
+
+static void
+main_parse_command_line(int argc, char **argv)
+{
+int i;
+const char *profile_name = NULL;
 
-#ifdef undef
+#if 0
 max_line_length = 78;	/* -l78 */
 lineup_to_parens = 1;	/* -lp */
 lineup_to_parens_always = 0; /* -nlpl */
@@ -533,10 +507,6 @@ main(int argc, char **argv)
 	}
 }
 
-#if HAVE_CAPSICUM
-init_capsicum();
-#endif
-
 if (opt.com_ind <= 1)
 	opt.com_ind = 2;	/* don't put normal comments before column 2 */
 if (opt.block_comment_max_line_length <= 0)
@@ -547,29 +517,56 @@ main(int argc, char **argv)
 	opt.decl_com_ind = opt.ljust_decl ? (opt.com_ind <= 10 ? 2 : opt.com_ind - 8) : opt.com_ind;
 if (opt.continuation_indent == 0)
 	opt.continuation_indent = opt.ind_size;
+}
+
+static void
+main_prepare_parsing(void)
+{
 fill_buffer();		/* get first batch of stuff into input buffer */
 
 parse(semicolon);
-{
-	char *p = buf_ptr;
-	int col = 1;
-
-	while (1) {
-	if (*p == ' ')
-		col++;
-	else if (*p == '\t')
-		col = opt.tabsize * (1 + (col - 1) / opt.tabsize) + 1;
-	else
-		break;
-	p++;
-	}
-	if (col > opt.ind_size)
-	ps.ind_level = 

CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 11:27:01 UTC 2021

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

Log Message:
indent: remove redundant parentheses

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.39 -r1.40 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.26 -r1.27 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-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 11:27:01 UTC 2021

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

Log Message:
indent: remove redundant parentheses

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.39 -r1.40 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.26 -r1.27 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.51 src/usr.bin/indent/indent.c:1.52
--- src/usr.bin/indent/indent.c:1.51	Sat Mar 13 11:19:43 2021
+++ src/usr.bin/indent/indent.c	Sat Mar 13 11:27:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.51 2021/03/13 11:19:43 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.52 2021/03/13 11:27:01 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.51 2021/03/13 11:19:43 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.52 2021/03/13 11:27:01 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -604,12 +604,12 @@ main(int argc, char **argv)
 	exit(found_err);
 	}
 	if (
-		(type_code != comment) &&
-		(type_code != newline) &&
-		(type_code != preprocessing) &&
-		(type_code != form_feed)) {
+		type_code != comment &&
+		type_code != newline &&
+		type_code != preprocessing &&
+		type_code != form_feed) {
 	if (force_nl &&
-		(type_code != semicolon) &&
+		type_code != semicolon &&
 		(type_code != lbrace || !opt.btype_2)) {
 		/* we should force a broken line here */
 		if (opt.verbose)
@@ -1159,9 +1159,7 @@ main(int argc, char **argv)
 	break;
 
 	case preprocessing:	/* '#' */
-	if ((s_com != e_com) ||
-		(s_lab != e_lab) ||
-		(s_code != e_code))
+	if (s_com != e_com || s_lab != e_lab || s_code != e_code)
 		dump_line();
 	check_size_label(1);
 	*e_lab++ = '#';	/* move whole line to 'label' buffer */

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.39 src/usr.bin/indent/lexi.c:1.40
--- src/usr.bin/indent/lexi.c:1.39	Sat Mar 13 09:21:57 2021
+++ src/usr.bin/indent/lexi.c	Sat Mar 13 11:27:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.39 2021/03/13 09:21:57 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.40 2021/03/13 11:27:01 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)lexi.c	8.1 (
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.39 2021/03/13 09:21:57 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.40 2021/03/13 11:27:01 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -502,14 +502,14 @@ stop_lit:
 	code = ident;
 	break;
 
-case ('('):
-case ('['):
+case '(':
+case '[':
 	unary_delim = true;
 	code = lparen;
 	break;
 
-case (')'):
-case (']'):
+case ')':
+case ']':
 	code = rparen;
 	break;
 
@@ -523,17 +523,17 @@ stop_lit:
 	code = question;
 	break;
 
-case (':'):
+case ':':
 	code = colon;
 	unary_delim = true;
 	break;
 
-case (';'):
+case ';':
 	unary_delim = true;
 	code = semicolon;
 	break;
 
-case ('{'):
+case '{':
 	unary_delim = true;
 
 	/*
@@ -543,7 +543,7 @@ stop_lit:
 	code = lbrace;
 	break;
 
-case ('}'):
+case '}':
 	unary_delim = true;
 	/* ?	code = state->block_init ? rparen : rbrace; */
 	code = rbrace;
@@ -556,7 +556,7 @@ stop_lit:
 	code = form_feed;
 	break;
 
-case (','):
+case ',':
 	unary_delim = true;
 	code = comma;
 	break;

Index: src/usr.bin/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.26 src/usr.bin/indent/pr_comment.c:1.27
--- src/usr.bin/indent/pr_comment.c:1.26	Sat Mar 13 11:19:43 2021
+++ src/usr.bin/indent/pr_comment.c	Sat Mar 13 11:27:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.26 2021/03/13 11:19:43 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.27 2021/03/13 11:27:01 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)pr_comment.c
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: pr_comment.c,v 1.26 2021/03/13 11:19:43 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.27 2021/03/13 11:27:01 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -147,7 +147,7 @@ pr_comment(void)
  * is nonzero (the default). */
 	break_delim = false;
 	}
-	if ( /* ps.bl_line && */ (s_lab == e_lab) && (s_code == e_code)) {
+	if ( /* ps.bl_line && */ s_lab == e_lab && s_code == e_code) {
 	/* klg: 

CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 11:19:43 UTC 2021

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

Log Message:
indent: fix confusing variable names

The word 'col' should only be used for the 1-based column number.  This
name is completely inappropriate for a line length since that provokes
off-by-one errors.  The name 'cols' would be acceptable although
confusing since it sounds so similar to 'col'.

Therefore, rename variables that are related to the maximum line length
to 'line_length' since that makes for obvious code and nicely relates to
the description of the option in the manual page.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/indent/args.c
cvs rdiff -u -r1.50 -r1.51 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/indent/indent_globs.h
cvs rdiff -u -r1.41 -r1.42 src/usr.bin/indent/io.c
cvs rdiff -u -r1.25 -r1.26 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-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 11:19:43 UTC 2021

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

Log Message:
indent: fix confusing variable names

The word 'col' should only be used for the 1-based column number.  This
name is completely inappropriate for a line length since that provokes
off-by-one errors.  The name 'cols' would be acceptable although
confusing since it sounds so similar to 'col'.

Therefore, rename variables that are related to the maximum line length
to 'line_length' since that makes for obvious code and nicely relates to
the description of the option in the manual page.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/usr.bin/indent/args.c
cvs rdiff -u -r1.50 -r1.51 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.17 -r1.18 src/usr.bin/indent/indent_globs.h
cvs rdiff -u -r1.41 -r1.42 src/usr.bin/indent/io.c
cvs rdiff -u -r1.25 -r1.26 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.19 src/usr.bin/indent/args.c:1.20
--- src/usr.bin/indent/args.c:1.19	Fri Mar 12 23:10:18 2021
+++ src/usr.bin/indent/args.c	Sat Mar 13 11:19:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: args.c,v 1.19 2021/03/12 23:10:18 rillig Exp $	*/
+/*	$NetBSD: args.c,v 1.20 2021/03/13 11:19:43 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)args.c	8.1 (
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: args.c,v 1.19 2021/03/12 23:10:18 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.20 2021/03/13 11:19:43 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/args.c 336318 2018-07-15 21:04:21Z pstef $");
 #endif
@@ -135,11 +135,11 @@ const struct pro {
 {"fcb", PRO_BOOL, true, ON, _block_comments},
 {"ip", PRO_BOOL, true, ON, _parameters},
 {"i", PRO_INT, 8, 0, _size},
-{"lc", PRO_INT, 0, 0, _comment_max_col},
+{"lc", PRO_INT, 0, 0, _comment_max_line_length},
 {"ldi", PRO_INT, -1, 0, _decl_indent},
 {"lpl", PRO_BOOL, false, ON, _to_parens_always},
 {"lp", PRO_BOOL, true, ON, _to_parens},
-{"l", PRO_INT, 78, 0, _col},
+{"l", PRO_INT, 78, 0, _line_length},
 {"nbacc", PRO_BOOL, false, OFF, _around_conditional_compilation},
 {"nbadp", PRO_BOOL, false, OFF, _after_declarations_at_proctop},
 {"nbad", PRO_BOOL, false, OFF, _after_declarations},

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.50 src/usr.bin/indent/indent.c:1.51
--- src/usr.bin/indent/indent.c:1.50	Sat Mar 13 10:32:25 2021
+++ src/usr.bin/indent/indent.c	Sat Mar 13 11:19:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.50 2021/03/13 10:32:25 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.51 2021/03/13 11:19:43 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.50 2021/03/13 10:32:25 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.51 2021/03/13 11:19:43 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -458,9 +458,9 @@ main(int argc, char **argv)
 \*--*/
 
 #ifdef undef
-max_col = 78;		/* -l78 */
+max_line_length = 78;	/* -l78 */
 lineup_to_parens = 1;	/* -lp */
-lineup_to_parens_always = 0;	/* -nlpl */
+lineup_to_parens_always = 0; /* -nlpl */
 ps.ljust_decl = 0;		/* -ndj */
 ps.com_ind = 33;		/* -c33 */
 star_comment_cont = 1;	/* -sc */
@@ -539,8 +539,8 @@ main(int argc, char **argv)
 
 if (opt.com_ind <= 1)
 	opt.com_ind = 2;	/* don't put normal comments before column 2 */
-if (opt.block_comment_max_col <= 0)
-	opt.block_comment_max_col = opt.max_col;
+if (opt.block_comment_max_line_length <= 0)
+	opt.block_comment_max_line_length = opt.max_line_length;
 if (opt.local_decl_indent < 0) /* if not specified by user, set this */
 	opt.local_decl_indent = opt.decl_indent;
 if (opt.decl_com_ind <= 0)	/* if not specified by user, set this */
@@ -1151,9 +1151,9 @@ main(int argc, char **argv)
 		if (ps.block_init_level <= 0)
 		ps.block_init = 0;
 		if (break_comma && (!opt.leave_comma ||
-			1 + indentation_after_range(
+			indentation_after_range(
 			compute_code_indent(), s_code, e_code)
-			> opt.max_col - opt.tabsize))
+			>= opt.max_line_length - opt.tabsize))
 		force_nl = true;
 	}
 	break;

Index: src/usr.bin/indent/indent_globs.h
diff -u src/usr.bin/indent/indent_globs.h:1.17 src/usr.bin/indent/indent_globs.h:1.18
--- src/usr.bin/indent/indent_globs.h:1.17	Mon Mar  8 20:20:11 2021
+++ 

CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 10:47:59 UTC 2021

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

Log Message:
indent: document undefined behavior in processing of comments

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 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-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 10:47:59 UTC 2021

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

Log Message:
indent: document undefined behavior in processing of comments

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 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.24 src/usr.bin/indent/pr_comment.c:1.25
--- src/usr.bin/indent/pr_comment.c:1.24	Sat Mar 13 10:32:25 2021
+++ src/usr.bin/indent/pr_comment.c	Sat Mar 13 10:47:59 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.24 2021/03/13 10:32:25 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.25 2021/03/13 10:47:59 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)pr_comment.c
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: pr_comment.c,v 1.24 2021/03/13 10:32:25 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.25 2021/03/13 10:47:59 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -186,6 +186,10 @@ pr_comment(void)
 	 */
 	char *start;
 
+	/*
+	 * XXX: ordered comparison between pointers from different objects
+	 * invokes undefined behavior (C99 6.5.8).
+	 */
 	start = buf_ptr >= save_com && buf_ptr < save_com + sc_size ?
 	sc_buf : in_buffer;
 	ps.n_comment_delta = -indentation_after_range(0, start, buf_ptr - 2);



CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 10:32:25 UTC 2021

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

Log Message:
indent: inline calls to count_spaces and count_spaces_until

These two functions operated on column numbers instead of indentation,
which required adjustments of '+ 1' and '- 1'.  Their names were
completely wrong since these functions did not count anything, instead
they computed the column.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.40 -r1.41 src/usr.bin/indent/io.c
cvs rdiff -u -r1.23 -r1.24 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.49 src/usr.bin/indent/indent.c:1.50
--- src/usr.bin/indent/indent.c:1.49	Sat Mar 13 10:06:47 2021
+++ src/usr.bin/indent/indent.c	Sat Mar 13 10:32:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.49 2021/03/13 10:06:47 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.50 2021/03/13 10:32:25 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.49 2021/03/13 10:06:47 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.50 2021/03/13 10:32:25 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -686,7 +686,8 @@ main(int argc, char **argv)
 		*e_code++ = ' ';
 	ps.want_blank = false;
 	*e_code++ = token[0];
-	ps.paren_indents[ps.p_l_follow - 1] = count_spaces_until(1, s_code, e_code) - 1;
+	ps.paren_indents[ps.p_l_follow - 1] =
+		indentation_after_range(0, s_code, e_code);
 	if (sp_sw && ps.p_l_follow == 1 && opt.extra_expression_indent
 		&& ps.paren_indents[0] < 2 * opt.ind_size)
 		ps.paren_indents[0] = 2 * opt.ind_size;
@@ -1150,8 +1151,9 @@ main(int argc, char **argv)
 		if (ps.block_init_level <= 0)
 		ps.block_init = 0;
 		if (break_comma && (!opt.leave_comma ||
-		count_spaces_until(1 + compute_code_indent(), s_code, e_code) >
-		opt.max_col - opt.tabsize))
+			1 + indentation_after_range(
+			compute_code_indent(), s_code, e_code)
+			> opt.max_col - opt.tabsize))
 		force_nl = true;
 	}
 	break;

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.12 src/usr.bin/indent/indent.h:1.13
--- src/usr.bin/indent/indent.h:1.12	Sat Mar 13 10:20:54 2021
+++ src/usr.bin/indent/indent.h	Sat Mar 13 10:32:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.12 2021/03/13 10:20:54 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.13 2021/03/13 10:32:25 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -30,7 +30,7 @@
 
 #if 0
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.h,v 1.12 2021/03/13 10:20:54 rillig Exp $");
+__RCSID("$NetBSD: indent.h,v 1.13 2021/03/13 10:32:25 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.h 336333 2018-07-16 05:46:50Z pstef $");
 #endif
@@ -47,8 +47,6 @@ void	add_typename(const char *);
 void	alloc_typenames(void);
 int	compute_code_indent(void);
 int	compute_label_indent(void);
-int	count_spaces(int, const char *);
-int	count_spaces_until(int, const char *, const char *);
 int	indentation_after_range(int, const char *, const char *);
 int	indentation_after(int, const char *);
 void	init_constant_tt(void);

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.40 src/usr.bin/indent/io.c:1.41
--- src/usr.bin/indent/io.c:1.40	Sat Mar 13 10:20:54 2021
+++ src/usr.bin/indent/io.c	Sat Mar 13 10:32:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.40 2021/03/13 10:20:54 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.41 2021/03/13 10:32:25 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.40 2021/03/13 10:20:54 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.41 2021/03/13 10:32:25 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -184,7 +184,7 @@ dump_line(void)
 		}
 	} else
 	output_range(s_lab, e_lab);
-	cur_col = count_spaces(cur_col, s_lab);
+	cur_col = 1 + indentation_after(cur_col - 1, s_lab);
 	} else
 	cur_col = 1;	/* there is no label section */
 
@@ -215,7 +215,7 @@ dump_line(void)
 	}
 	cur_col = 1 + output_indent(cur_col - 1, target_col - 1);
 	output_range(s_code, e_code);
-	cur_col = count_spaces(cur_col, s_code);
+	cur_col = 1 + indentation_after(cur_col - 1, s_code);
 	}
 	if (s_com != e_com) {		

CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 10:32:25 UTC 2021

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

Log Message:
indent: inline calls to count_spaces and count_spaces_until

These two functions operated on column numbers instead of indentation,
which required adjustments of '+ 1' and '- 1'.  Their names were
completely wrong since these functions did not count anything, instead
they computed the column.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.12 -r1.13 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.40 -r1.41 src/usr.bin/indent/io.c
cvs rdiff -u -r1.23 -r1.24 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-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 10:20:54 UTC 2021

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

Log Message:
indent: replace column computation with indentation computation

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.39 -r1.40 src/usr.bin/indent/io.c

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

Modified files:

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.11 src/usr.bin/indent/indent.h:1.12
--- src/usr.bin/indent/indent.h:1.11	Sat Mar 13 10:06:47 2021
+++ src/usr.bin/indent/indent.h	Sat Mar 13 10:20:54 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.11 2021/03/13 10:06:47 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.12 2021/03/13 10:20:54 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -30,7 +30,7 @@
 
 #if 0
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.h,v 1.11 2021/03/13 10:06:47 rillig Exp $");
+__RCSID("$NetBSD: indent.h,v 1.12 2021/03/13 10:20:54 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.h 336333 2018-07-16 05:46:50Z pstef $");
 #endif
@@ -49,6 +49,8 @@ int	compute_code_indent(void);
 int	compute_label_indent(void);
 int	count_spaces(int, const char *);
 int	count_spaces_until(int, const char *, const char *);
+int	indentation_after_range(int, const char *, const char *);
+int	indentation_after(int, const char *);
 void	init_constant_tt(void);
 #ifdef debug
 void	debug_vis_range(const char *, const char *, const char *, const char *);

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.39 src/usr.bin/indent/io.c:1.40
--- src/usr.bin/indent/io.c:1.39	Sat Mar 13 10:06:47 2021
+++ src/usr.bin/indent/io.c	Sat Mar 13 10:20:54 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.39 2021/03/13 10:06:47 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.40 2021/03/13 10:20:54 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.39 2021/03/13 10:06:47 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.40 2021/03/13 10:20:54 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -425,42 +425,38 @@ fill_buffer(void)
 }
 }
 
-/*
- * Copyright (C) 1976 by the Board of Trustees of the University of Illinois
- *
- * All rights reserved
- */
 int
-count_spaces_until(int col, const char *buffer, const char *end)
+indentation_after_range(int ind, const char *start, const char *end)
 {
-for (const char *p = buffer; *p != '\0' && p != end; ++p) {
-	switch (*p) {
-
-	case '\n':
-	case 014:		/* form feed */
-	col = 1;
-	break;
-
-	case '\t':
-	col = 1 + opt.tabsize * ((col - 1) / opt.tabsize + 1);
-	break;
+for (const char *p = start; *p != '\0' && p != end; ++p) {
+	if (*p == '\n' || *p == '\f')
+	ind = 0;
+	else if (*p == '\t')
+	ind = opt.tabsize * (ind / opt.tabsize + 1);
+	else if (*p == '\b')
+	--ind;
+	else
+	++ind;
+}
+return ind;
+}
 
-	case 010:		/* backspace */
-	--col;
-	break;
+int
+indentation_after(int ind, const char *s)
+{
+return indentation_after_range(ind, s, NULL);
+}
 
-	default:
-	++col;
-	break;
-	}			/* end of switch */
-}/* end of for loop */
-return col;
+int
+count_spaces_until(int col, const char *s, const char *e)
+{
+return 1 + indentation_after_range(col - 1, s, e);
 }
 
 int
-count_spaces(int col, const char *buffer)
+count_spaces(int col, const char *s)
 {
-return count_spaces_until(col, buffer, NULL);
+return 1 + indentation_after(col - 1, s);
 }
 
 void



CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 10:20:54 UTC 2021

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

Log Message:
indent: replace column computation with indentation computation

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.39 -r1.40 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-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 10:06:47 UTC 2021

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

Log Message:
indent: replace compute_code_column with compute_code_indent

The goal is to only ever be concerned about the _indentation_ of a
token, never the _column_ it appears in.  Having only one of these
avoids off-by-one errors.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.38 -r1.39 src/usr.bin/indent/io.c
cvs rdiff -u -r1.22 -r1.23 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.48 src/usr.bin/indent/indent.c:1.49
--- src/usr.bin/indent/indent.c:1.48	Sat Mar 13 09:21:57 2021
+++ src/usr.bin/indent/indent.c	Sat Mar 13 10:06:47 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.48 2021/03/13 09:21:57 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.49 2021/03/13 10:06:47 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.48 2021/03/13 09:21:57 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.49 2021/03/13 10:06:47 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -1150,7 +1150,7 @@ main(int argc, char **argv)
 		if (ps.block_init_level <= 0)
 		ps.block_init = 0;
 		if (break_comma && (!opt.leave_comma ||
-		count_spaces_until(compute_code_column(), s_code, e_code) >
+		count_spaces_until(1 + compute_code_indent(), s_code, e_code) >
 		opt.max_col - opt.tabsize))
 		force_nl = true;
 	}

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.10 src/usr.bin/indent/indent.h:1.11
--- src/usr.bin/indent/indent.h:1.10	Sat Mar 13 09:54:11 2021
+++ src/usr.bin/indent/indent.h	Sat Mar 13 10:06:47 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.10 2021/03/13 09:54:11 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.11 2021/03/13 10:06:47 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -30,7 +30,7 @@
 
 #if 0
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.h,v 1.10 2021/03/13 09:54:11 rillig Exp $");
+__RCSID("$NetBSD: indent.h,v 1.11 2021/03/13 10:06:47 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.h 336333 2018-07-16 05:46:50Z pstef $");
 #endif
@@ -45,7 +45,7 @@ __FBSDID("$FreeBSD: head/usr.bin/indent/
 
 void	add_typename(const char *);
 void	alloc_typenames(void);
-int	compute_code_column(void);
+int	compute_code_indent(void);
 int	compute_label_indent(void);
 int	count_spaces(int, const char *);
 int	count_spaces_until(int, const char *, const char *);

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.38 src/usr.bin/indent/io.c:1.39
--- src/usr.bin/indent/io.c:1.38	Sat Mar 13 09:54:11 2021
+++ src/usr.bin/indent/io.c	Sat Mar 13 10:06:47 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.38 2021/03/13 09:54:11 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.39 2021/03/13 10:06:47 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.38 2021/03/13 09:54:11 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.39 2021/03/13 10:06:47 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -195,7 +195,7 @@ dump_line(void)
 		comment_open = 0;
 		output_string(".*/\n");
 	}
-	target_col = compute_code_column();
+	target_col = 1 + compute_code_indent();
 	{
 		int i;
 
@@ -287,31 +287,36 @@ dump_line(void)
 }
 
 int
-compute_code_column(void)
+compute_code_indent(void)
 {
-int target_col = opt.ind_size * ps.ind_level + 1;
+int target_ind = opt.ind_size * ps.ind_level;
 
-if (ps.paren_level) {
+if (ps.paren_level != 0) {
 	if (!opt.lineup_to_parens)
-	target_col += opt.continuation_indent *
+	target_ind += opt.continuation_indent *
 		(2 * opt.continuation_indent == opt.ind_size ? 1 : ps.paren_level);
 	else if (opt.lineup_to_parens_always)
-	target_col = paren_indent;
+	/*
+	 * XXX: where does this '- 1' come from?  It looks strange but is
+	 * nevertheless needed for proper indentation, as demonstrated in
+	 * the test opt-lpl.0.
+	 */
+	target_ind = paren_indent - 1;
 	else {
 	int w;
 	int t = paren_indent;
 
 	if ((w = count_spaces(t, s_code) - opt.max_col) > 0
-		&& count_spaces(target_col, s_code) <= opt.max_col) {
+		&& count_spaces(target_ind + 1, s_code) <= 

CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 10:06:47 UTC 2021

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

Log Message:
indent: replace compute_code_column with compute_code_indent

The goal is to only ever be concerned about the _indentation_ of a
token, never the _column_ it appears in.  Having only one of these
avoids off-by-one errors.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.38 -r1.39 src/usr.bin/indent/io.c
cvs rdiff -u -r1.22 -r1.23 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-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 09:54:12 UTC 2021

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

Log Message:
indent: replace compute_label_column with compute_label_indent

Using the invariant 'column == 1 + indent'.  This removes several overly
complicated '+ 1' from the code that are not needed conceptually.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/indent/io.c
cvs rdiff -u -r1.21 -r1.22 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.9 src/usr.bin/indent/indent.h:1.10
--- src/usr.bin/indent/indent.h:1.9	Sat Mar 13 09:21:57 2021
+++ src/usr.bin/indent/indent.h	Sat Mar 13 09:54:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.9 2021/03/13 09:21:57 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.10 2021/03/13 09:54:11 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -30,7 +30,7 @@
 
 #if 0
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.h,v 1.9 2021/03/13 09:21:57 rillig Exp $");
+__RCSID("$NetBSD: indent.h,v 1.10 2021/03/13 09:54:11 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.h 336333 2018-07-16 05:46:50Z pstef $");
 #endif
@@ -46,7 +46,7 @@ __FBSDID("$FreeBSD: head/usr.bin/indent/
 void	add_typename(const char *);
 void	alloc_typenames(void);
 int	compute_code_column(void);
-int	compute_label_column(void);
+int	compute_label_indent(void);
 int	count_spaces(int, const char *);
 int	count_spaces_until(int, const char *, const char *);
 void	init_constant_tt(void);

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.37 src/usr.bin/indent/io.c:1.38
--- src/usr.bin/indent/io.c:1.37	Sat Mar 13 09:48:04 2021
+++ src/usr.bin/indent/io.c	Sat Mar 13 09:54:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.37 2021/03/13 09:48:04 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.38 2021/03/13 09:54:11 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.37 2021/03/13 09:48:04 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.38 2021/03/13 09:54:11 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -162,7 +162,7 @@ dump_line(void)
 	while (e_lab > s_lab && (e_lab[-1] == ' ' || e_lab[-1] == '\t'))
 		e_lab--;
 	*e_lab = '\0';
-	cur_col = 1 + output_indent(0, compute_label_column() - 1);
+	cur_col = 1 + output_indent(0, compute_label_indent());
 	if (s_lab[0] == '#' && (strncmp(s_lab, "#else", 5) == 0
 || strncmp(s_lab, "#endif", 6) == 0)) {
 		char *s = s_lab;
@@ -315,12 +315,13 @@ compute_code_column(void)
 }
 
 int
-compute_label_column(void)
+compute_label_indent(void)
 {
-return
-	ps.pcase ? (int) (case_ind * opt.ind_size) + 1
-	: *s_lab == '#' ? 1
-	: opt.ind_size * (ps.ind_level - label_offset) + 1;
+if (ps.pcase)
+	return (int) (case_ind * opt.ind_size);
+if (s_lab[0] == '#')
+return 0;
+return opt.ind_size * (ps.ind_level - label_offset);
 }
 
 

Index: src/usr.bin/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.21 src/usr.bin/indent/pr_comment.c:1.22
--- src/usr.bin/indent/pr_comment.c:1.21	Sat Mar 13 00:26:56 2021
+++ src/usr.bin/indent/pr_comment.c	Sat Mar 13 09:54:11 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.21 2021/03/13 00:26:56 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.22 2021/03/13 09:54:11 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)pr_comment.c
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: pr_comment.c,v 1.21 2021/03/13 00:26:56 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.22 2021/03/13 09:54:11 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -166,7 +166,7 @@ pr_comment(void)
 	else {
 		target_col = 1;
 		if (s_lab != e_lab)
-		target_col = count_spaces(compute_label_column(), s_lab);
+		target_col = count_spaces(compute_label_indent() + 1, s_lab);
 	}
 	ps.com_col = ps.decl_on_line || ps.ind_level == 0 ? opt.decl_com_ind : opt.com_ind;
 	if (ps.com_col <= target_col)



CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 09:54:12 UTC 2021

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

Log Message:
indent: replace compute_label_column with compute_label_indent

Using the invariant 'column == 1 + indent'.  This removes several overly
complicated '+ 1' from the code that are not needed conceptually.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.37 -r1.38 src/usr.bin/indent/io.c
cvs rdiff -u -r1.21 -r1.22 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-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 09:48:04 UTC 2021

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

Log Message:
indent: manually fix indentation in indent's own source code


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 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.36 src/usr.bin/indent/io.c:1.37
--- src/usr.bin/indent/io.c:1.36	Sat Mar 13 09:21:57 2021
+++ src/usr.bin/indent/io.c	Sat Mar 13 09:48:04 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.36 2021/03/13 09:21:57 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.37 2021/03/13 09:48:04 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.36 2021/03/13 09:21:57 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.37 2021/03/13 09:48:04 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -357,15 +357,15 @@ fill_buffer(void)
 	in_buffer_limit = in_buffer + size - 2;
 	}
 	if ((i = getc(f)) == EOF) {
-		*p++ = ' ';
-		*p++ = '\n';
-		had_eof = true;
-		break;
+	*p++ = ' ';
+	*p++ = '\n';
+	had_eof = true;
+	break;
 	}
 	if (i != '\0')
 	*p++ = i;
 	if (i == '\n')
-		break;
+	break;
 }
 buf_ptr = in_buffer;
 buf_end = p;
@@ -373,7 +373,7 @@ fill_buffer(void)
 	if (in_buffer[3] == 'I' && strncmp(in_buffer, "/**INDENT**", 11) == 0)
 	fill_buffer();	/* flush indent error message */
 	else {
-	int com = 0;
+	int com = 0;
 
 	p = in_buffer;
 	while (*p == ' ' || *p == '\t')



CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 09:48:04 UTC 2021

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

Log Message:
indent: manually fix indentation in indent's own source code


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 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-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 09:21:57 UTC 2021

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

Log Message:
indent: add debug logging for actually writing to the output file

Together with the results of the tokenizer and the 4 buffers for token,
label, code and comment, the debug log now provides a good high-level
view on how the indentation happens and where to look for the many
remaining bugs.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/indent/io.c
cvs rdiff -u -r1.38 -r1.39 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.47 src/usr.bin/indent/indent.c:1.48
--- src/usr.bin/indent/indent.c:1.47	Sat Mar 13 00:26:56 2021
+++ src/usr.bin/indent/indent.c	Sat Mar 13 09:21:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.47 2021/03/13 00:26:56 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.48 2021/03/13 09:21:57 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.47 2021/03/13 00:26:56 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.48 2021/03/13 09:21:57 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -1389,3 +1389,46 @@ indent_declaration(int cur_dec_ind, int 
 	ps.want_blank = false;
 }
 }
+
+#ifdef debug
+void
+debug_printf(const char *fmt, ...)
+{
+FILE *f = output == stdout ? stderr : stdout;
+va_list ap;
+
+va_start(ap, fmt);
+vfprintf(f, fmt, ap);
+va_end(ap);
+}
+
+void
+debug_println(const char *fmt, ...)
+{
+FILE *f = output == stdout ? stderr : stdout;
+va_list ap;
+
+va_start(ap, fmt);
+vfprintf(f, fmt, ap);
+va_end(ap);
+fprintf(f, "\n");
+}
+
+void
+debug_vis_range(const char *prefix, const char *s, const char *e,
+		const char *suffix)
+{
+debug_printf("%s", prefix);
+for (const char *p = s; p < e; p++) {
+	if (isprint((unsigned char)*p) && *p != '\\' && *p != '"')
+	debug_printf("%c", *p);
+	else if (*p == '\n')
+	debug_printf("\\n");
+	else if (*p == '\t')
+	debug_printf("\\t");
+	else
+	debug_printf("\\x%02x", *p);
+}
+debug_printf("%s", suffix);
+}
+#endif

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.8 src/usr.bin/indent/indent.h:1.9
--- src/usr.bin/indent/indent.h:1.8	Sat Mar 13 00:26:56 2021
+++ src/usr.bin/indent/indent.h	Sat Mar 13 09:21:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.8 2021/03/13 00:26:56 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.9 2021/03/13 09:21:57 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -30,7 +30,7 @@
 
 #if 0
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.h,v 1.8 2021/03/13 00:26:56 rillig Exp $");
+__RCSID("$NetBSD: indent.h,v 1.9 2021/03/13 09:21:57 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.h 336333 2018-07-16 05:46:50Z pstef $");
 #endif
@@ -51,7 +51,14 @@ int	count_spaces(int, const char *);
 int	count_spaces_until(int, const char *, const char *);
 void	init_constant_tt(void);
 #ifdef debug
+void	debug_vis_range(const char *, const char *, const char *, const char *);
+void	debug_printf(const char *, ...) __printflike(1, 2);
+void	debug_println(const char *, ...) __printflike(1, 2);
 const char *token_type_name(token_type);
+#else
+#define debug_printf(fmt, ...) do { } while (false)
+#define debug_println(fmt, ...) do { } while (false)
+#define debug_vis_range(prefix, s, e, suffix) do { } while (false)
 #endif
 token_type lexi(struct parser_state *);
 void	diag(int, const char *, ...) __printflike(2, 3);

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.35 src/usr.bin/indent/io.c:1.36
--- src/usr.bin/indent/io.c:1.35	Sat Mar 13 09:06:12 2021
+++ src/usr.bin/indent/io.c	Sat Mar 13 09:21:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.35 2021/03/13 09:06:12 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.36 2021/03/13 09:21:57 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.35 2021/03/13 09:06:12 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.36 2021/03/13 09:21:57 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -68,12 +68,14 @@ static void
 output_char(char ch)
 {
 fputc(ch, output);
+debug_vis_range("output_char '", ,  + 1, "'\n");
 }
 
 static void
 output_range(const char *s, const 

CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 09:21:57 UTC 2021

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

Log Message:
indent: add debug logging for actually writing to the output file

Together with the results of the tokenizer and the 4 buffers for token,
label, code and comment, the debug log now provides a good high-level
view on how the indentation happens and where to look for the many
remaining bugs.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.8 -r1.9 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.35 -r1.36 src/usr.bin/indent/io.c
cvs rdiff -u -r1.38 -r1.39 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-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 09:06:12 UTC 2021

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

Log Message:
indent: remove strange debugging code that went in the output file

Whenever the code to be output contained the magic byte 0x80, instead of
writing this byte, indent wrote the column number at the beginning of
the code snippet, times 7.  Especially the 'times 7' does not make any
sense at all.

In ISO-8859-1, this character position is not assigned.  In Microsoft
Codepage 1252 it is the Euro sign.  In UTF-8 (which was probably not on
the author's list when the code was originally written) it occurs as the
middle byte for code points like U+2026 (horizontal ellipsis) from the
block General Punctuation.

Remove this strange code, thereby fixing indent for UTF-8 code.  The
code had been there since at least 1993-04-09, when it was first
imported to NetBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 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.34 src/usr.bin/indent/io.c:1.35
--- src/usr.bin/indent/io.c:1.34	Sat Mar 13 00:26:56 2021
+++ src/usr.bin/indent/io.c	Sat Mar 13 09:06:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.34 2021/03/13 00:26:56 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.35 2021/03/13 09:06:12 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 #include 
 #ifndef lint
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.34 2021/03/13 00:26:56 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.35 2021/03/13 09:06:12 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -82,12 +82,6 @@ output_string(const char *s)
 output_range(s, s + strlen(s));
 }
 
-static void
-output_int(int i)
-{
-fprintf(output, "%d", i);
-}
-
 static int
 output_indent(int old_ind, int new_ind)
 {
@@ -194,8 +188,6 @@ dump_line(void)
 	ps.pcase = false;
 
 	if (s_code != e_code) {	/* print code section, if any */
-	char *p;
-
 	if (comment_open) {
 		comment_open = 0;
 		output_string(".*/\n");
@@ -209,11 +201,7 @@ dump_line(void)
 			ps.paren_indents[i] = -(ps.paren_indents[i] + target_col);
 	}
 	cur_col = 1 + output_indent(cur_col - 1, target_col - 1);
-	for (p = s_code; p < e_code; p++)
-		if (*p == (char) 0200)
-		output_int(target_col * 7);
-		else
-		output_char(*p);
+	output_range(s_code, e_code);
 	cur_col = count_spaces(cur_col, s_code);
 	}
 	if (s_com != e_com) {		/* print comment, if any */



CVS commit: src/usr.bin/indent

2021-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sat Mar 13 09:06:12 UTC 2021

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

Log Message:
indent: remove strange debugging code that went in the output file

Whenever the code to be output contained the magic byte 0x80, instead of
writing this byte, indent wrote the column number at the beginning of
the code snippet, times 7.  Especially the 'times 7' does not make any
sense at all.

In ISO-8859-1, this character position is not assigned.  In Microsoft
Codepage 1252 it is the Euro sign.  In UTF-8 (which was probably not on
the author's list when the code was originally written) it occurs as the
middle byte for code points like U+2026 (horizontal ellipsis) from the
block General Punctuation.

Remove this strange code, thereby fixing indent for UTF-8 code.  The
code had been there since at least 1993-04-09, when it was first
imported to NetBSD.


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