CVS commit: src/usr.bin/indent

2021-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 15:32:13 UTC 2021

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

Log Message:
indent: rename input buffer variables

>From reading the names 'save_com' and 'sc_end', it was not obvious
enough that these two variables are the limits of the same buffer, the
names were just too unrelated.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.219 -r1.220 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.87 -r1.88 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.117 -r1.118 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-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 15:32:13 UTC 2021

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

Log Message:
indent: rename input buffer variables

>From reading the names 'save_com' and 'sc_end', it was not obvious
enough that these two variables are the limits of the same buffer, the
names were just too unrelated.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.219 -r1.220 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.87 -r1.88 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.117 -r1.118 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.219 src/usr.bin/indent/indent.c:1.220
--- src/usr.bin/indent/indent.c:1.219	Fri Nov 19 15:28:32 2021
+++ src/usr.bin/indent/indent.c	Fri Nov 19 15:32:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.219 2021/11/19 15:28:32 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.220 2021/11/19 15:32:13 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.219 2021/11/19 15:28:32 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.220 2021/11/19 15:32:13 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -222,16 +222,17 @@ static void
 debug_save_com(const char *prefix)
 {
 debug_printf("%s: save_com is ", prefix);
-debug_vis_range("\"", inbuf.save_com, inbuf.sc_end, "\"\n");
+debug_vis_range("\"", inbuf.save_com_s, inbuf.save_com_e, "\"\n");
 }
 #else
 #define debug_save_com(prefix) do { } while (false)
 #endif
 
 static void
-sc_check_size(size_t n)
+save_com_check_size(size_t n)
 {
-if ((size_t)(inbuf.sc_end - inbuf.sc_buf) + n <= sc_size)
+if ((size_t)(inbuf.save_com_e - inbuf.save_com_buf) + n <=
+	array_length(inbuf.save_com_buf))
 	return;
 
 diag(1, "Internal buffer overflow - "
@@ -241,31 +242,31 @@ sc_check_size(size_t n)
 }
 
 static void
-sc_add_char(char ch)
+save_com_add_char(char ch)
 {
-sc_check_size(1);
-*inbuf.sc_end++ = ch;
+save_com_check_size(1);
+*inbuf.save_com_e++ = ch;
 }
 
 static void
-sc_add_range(const char *s, const char *e)
+save_com_add_range(const char *s, const char *e)
 {
 size_t len = (size_t)(e - s);
-sc_check_size(len);
-memcpy(inbuf.sc_end, s, len);
-inbuf.sc_end += len;
+save_com_check_size(len);
+memcpy(inbuf.save_com_e, s, len);
+inbuf.save_com_e += len;
 }
 
 static void
 search_stmt_newline(bool *force_nl)
 {
-if (inbuf.sc_end == NULL) {
-	inbuf.save_com = inbuf.sc_buf;
-	inbuf.save_com[0] = inbuf.save_com[1] = ' ';
-	inbuf.sc_end = _com[2];
+if (inbuf.save_com_e == NULL) {
+	inbuf.save_com_s = inbuf.save_com_buf;
+	inbuf.save_com_s[0] = inbuf.save_com_s[1] = ' ';
+	inbuf.save_com_e = _com_s[2];
 	debug_save_com("search_stmt_newline init");
 }
-sc_add_char('\n');
+save_com_add_char('\n');
 debug_save_com(__func__);
 
 line_no++;
@@ -284,7 +285,7 @@ search_stmt_newline(bool *force_nl)
 static void
 search_stmt_comment(void)
 {
-if (inbuf.sc_end == NULL) {
+if (inbuf.save_com_e == NULL) {
 	/*
 	 * Copy everything from the start of the line, because
 	 * process_comment() will use that to calculate the original
@@ -298,25 +299,25 @@ search_stmt_comment(void)
 	 */
 	assert((size_t)(inbuf.inp.s - inbuf.inp.buf) >= 4);
 	size_t line_len = (size_t)(inbuf.inp.s - inbuf.inp.buf) - 4;
-	assert(line_len < array_length(inbuf.sc_buf));
-	memcpy(inbuf.sc_buf, inbuf.inp.buf, line_len);
-	inbuf.save_com = inbuf.sc_buf + line_len;
-	inbuf.save_com[0] = inbuf.save_com[1] = ' ';
-	inbuf.sc_end = _com[2];
+	assert(line_len < array_length(inbuf.save_com_buf));
+	memcpy(inbuf.save_com_buf, inbuf.inp.buf, line_len);
+	inbuf.save_com_s = inbuf.save_com_buf + line_len;
+	inbuf.save_com_s[0] = inbuf.save_com_s[1] = ' ';
+	inbuf.save_com_e = _com_s[2];
 	debug_vis_range("search_stmt_comment: before save_com is \"",
-	inbuf.sc_buf, inbuf.save_com, "\"\n");
+	inbuf.save_com_buf, inbuf.save_com_s, "\"\n");
 	debug_vis_range("search_stmt_comment: save_com is \"",
-	inbuf.save_com, inbuf.sc_end, "\"\n");
+	inbuf.save_com_s, inbuf.save_com_e, "\"\n");
 }
 
-sc_add_range(token.s, token.e);
+save_com_add_range(token.s, token.e);
 if (token.e[-1] == '/') {
 	while (inbuf.inp.s[0] != '\n')
-	sc_add_char(inp_next());
+	save_com_add_char(inp_next());
 	debug_save_com("search_stmt_comment end C99");
 } else {
-	while (!(inbuf.sc_end[-2] == '*' && inbuf.sc_end[-1] == '/'))
-	sc_add_char(inp_next());
+	while (!(inbuf.save_com_e[-2] == '*' && inbuf.save_com_e[-1] == '/'))
+	save_com_add_char(inp_next());
 	

CVS commit: src/usr.bin/indent

2021-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 15:28:32 UTC 2021

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

Log Message:
indent: group variables for input handling

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.218 -r1.219 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.86 -r1.87 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.116 -r1.117 src/usr.bin/indent/io.c \
src/usr.bin/indent/pr_comment.c
cvs rdiff -u -r1.139 -r1.140 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-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 15:28:32 UTC 2021

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

Log Message:
indent: group variables for input handling

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.218 -r1.219 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.86 -r1.87 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.116 -r1.117 src/usr.bin/indent/io.c \
src/usr.bin/indent/pr_comment.c
cvs rdiff -u -r1.139 -r1.140 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.218 src/usr.bin/indent/indent.c:1.219
--- src/usr.bin/indent/indent.c:1.218	Sun Nov  7 19:18:56 2021
+++ src/usr.bin/indent/indent.c	Fri Nov 19 15:28:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.218 2021/11/07 19:18:56 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.219 2021/11/19 15:28:32 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.218 2021/11/07 19:18:56 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.219 2021/11/19 15:28:32 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -88,7 +88,7 @@ struct options opt = {
 
 struct parser_state ps;
 
-struct buffer inp;
+struct input_buffer inbuf;
 
 struct buffer token;
 
@@ -96,13 +96,6 @@ struct buffer lab;
 struct buffer code;
 struct buffer com;
 
-char sc_buf[sc_size];
-char *save_com;
-static char *sc_end;		/* pointer into save_com buffer */
-
-char *saved_inp_s;
-char *saved_inp_e;
-
 bool found_err;
 int blank_lines_to_output;
 bool blank_line_before;
@@ -229,7 +222,7 @@ static void
 debug_save_com(const char *prefix)
 {
 debug_printf("%s: save_com is ", prefix);
-debug_vis_range("\"", save_com, sc_end, "\"\n");
+debug_vis_range("\"", inbuf.save_com, inbuf.sc_end, "\"\n");
 }
 #else
 #define debug_save_com(prefix) do { } while (false)
@@ -238,7 +231,7 @@ debug_save_com(const char *prefix)
 static void
 sc_check_size(size_t n)
 {
-if ((size_t)(sc_end - sc_buf) + n <= sc_size)
+if ((size_t)(inbuf.sc_end - inbuf.sc_buf) + n <= sc_size)
 	return;
 
 diag(1, "Internal buffer overflow - "
@@ -251,7 +244,7 @@ static void
 sc_add_char(char ch)
 {
 sc_check_size(1);
-*sc_end++ = ch;
+*inbuf.sc_end++ = ch;
 }
 
 static void
@@ -259,17 +252,17 @@ sc_add_range(const char *s, const char *
 {
 size_t len = (size_t)(e - s);
 sc_check_size(len);
-memcpy(sc_end, s, len);
-sc_end += len;
+memcpy(inbuf.sc_end, s, len);
+inbuf.sc_end += len;
 }
 
 static void
 search_stmt_newline(bool *force_nl)
 {
-if (sc_end == NULL) {
-	save_com = sc_buf;
-	save_com[0] = save_com[1] = ' ';
-	sc_end = _com[2];
+if (inbuf.sc_end == NULL) {
+	inbuf.save_com = inbuf.sc_buf;
+	inbuf.save_com[0] = inbuf.save_com[1] = ' ';
+	inbuf.sc_end = _com[2];
 	debug_save_com("search_stmt_newline init");
 }
 sc_add_char('\n');
@@ -291,7 +284,7 @@ search_stmt_newline(bool *force_nl)
 static void
 search_stmt_comment(void)
 {
-if (sc_end == NULL) {
+if (inbuf.sc_end == NULL) {
 	/*
 	 * Copy everything from the start of the line, because
 	 * process_comment() will use that to calculate the original
@@ -303,26 +296,26 @@ search_stmt_comment(void)
 	 * is an additional line break before the ')', memcpy tries to copy
 	 * (size_t)-1 bytes.
 	 */
-	assert((size_t)(inp.s - inp.buf) >= 4);
-	size_t line_len = (size_t)(inp.s - inp.buf) - 4;
-	assert(line_len < array_length(sc_buf));
-	memcpy(sc_buf, inp.buf, line_len);
-	save_com = sc_buf + line_len;
-	save_com[0] = save_com[1] = ' ';
-	sc_end = _com[2];
+	assert((size_t)(inbuf.inp.s - inbuf.inp.buf) >= 4);
+	size_t line_len = (size_t)(inbuf.inp.s - inbuf.inp.buf) - 4;
+	assert(line_len < array_length(inbuf.sc_buf));
+	memcpy(inbuf.sc_buf, inbuf.inp.buf, line_len);
+	inbuf.save_com = inbuf.sc_buf + line_len;
+	inbuf.save_com[0] = inbuf.save_com[1] = ' ';
+	inbuf.sc_end = _com[2];
 	debug_vis_range("search_stmt_comment: before save_com is \"",
-	sc_buf, save_com, "\"\n");
+	inbuf.sc_buf, inbuf.save_com, "\"\n");
 	debug_vis_range("search_stmt_comment: save_com is \"",
-	save_com, sc_end, "\"\n");
+	inbuf.save_com, inbuf.sc_end, "\"\n");
 }
 
 sc_add_range(token.s, token.e);
 if (token.e[-1] == '/') {
-	while (inp.s[0] != '\n')
+	while (inbuf.inp.s[0] != '\n')
 	sc_add_char(inp_next());
 	debug_save_com("search_stmt_comment end C99");
 } else {
-	while (!(sc_end[-2] == '*' && sc_end[-1] == '/'))
+	while (!(inbuf.sc_end[-2] == '*' && inbuf.sc_end[-1] == '/'))
 	sc_add_char(inp_next());
 	debug_save_com("search_stmt_comment end block");
 }
@@ -335,17 +328,17 @@ 

CVS commit: src/usr.bin/indent

2021-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 17:11:46 UTC 2021

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

Log Message:
indent: replace direct access to the input buffer

This is a preparation for abstracting away all the low-level details of
handling the input.  The goal is to fix the current bugs regarding line
number counting, out of bounds memory access, and generally unreadable
code.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.221 -r1.222 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.88 -r1.89 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.140 -r1.141 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.118 -r1.119 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-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 17:11:46 UTC 2021

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

Log Message:
indent: replace direct access to the input buffer

This is a preparation for abstracting away all the low-level details of
handling the input.  The goal is to fix the current bugs regarding line
number counting, out of bounds memory access, and generally unreadable
code.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.221 -r1.222 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.88 -r1.89 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.140 -r1.141 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.118 -r1.119 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.221 src/usr.bin/indent/indent.c:1.222
--- src/usr.bin/indent/indent.c:1.221	Fri Nov 19 15:34:25 2021
+++ src/usr.bin/indent/indent.c	Fri Nov 19 17:11:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.221 2021/11/19 15:34:25 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.222 2021/11/19 17:11:46 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.221 2021/11/19 15:34:25 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.222 2021/11/19 17:11:46 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -344,9 +344,9 @@ search_stmt_lbrace(void)
 	 * will be moved into "the else's line", so if there was a newline
 	 * resulting from the "{" before, it must be scanned now and ignored.
 	 */
-	while (isspace((unsigned char)*inbuf.inp.s)) {
+	while (isspace((unsigned char)inp_peek())) {
 	inp_skip();
-	if (*inbuf.inp.s == '\n')
+	if (inp_peek() == '\n')
 		break;
 	}
 	debug_inbuf(__func__);
@@ -443,7 +443,7 @@ search_stmt_lookahead(lexer_symbol *lsym
  * into the buffer so that the later lexi() call will read them.
  */
 if (inbuf.save_com_e != NULL) {
-	while (ch_isblank(*inbuf.inp.s))
+	while (ch_isblank(inp_peek()))
 	save_com_add_char(inp_next());
 	debug_inbuf(__func__);
 }
@@ -1246,10 +1246,10 @@ read_preprocessing_line(void)
 state = PLAIN;
 int com_start = 0, com_end = 0;
 
-while (ch_isblank(*inbuf.inp.s))
+while (ch_isblank(inp_peek()))
 	inp_skip();
 
-while (*inbuf.inp.s != '\n' || (state == COMM && !had_eof)) {
+while (inp_peek() != '\n' || (state == COMM && !had_eof)) {
 	buf_reserve(, 2);
 	*lab.e++ = inp_next();
 	switch (lab.e[-1]) {
@@ -1258,9 +1258,9 @@ read_preprocessing_line(void)
 		*lab.e++ = inp_next();
 	break;
 	case '/':
-	if (*inbuf.inp.s == '*' && state == PLAIN) {
+	if (inp_peek() == '*' && state == PLAIN) {
 		state = COMM;
-		*lab.e++ = *inbuf.inp.s++;
+		*lab.e++ = inp_next();
 		com_start = (int)buf_len() - 2;
 	}
 	break;
@@ -1277,9 +1277,9 @@ read_preprocessing_line(void)
 		state = CHR;
 	break;
 	case '*':
-	if (*inbuf.inp.s == '/' && state == COMM) {
+	if (inp_peek() == '/' && state == COMM) {
 		state = PLAIN;
-		*lab.e++ = *inbuf.inp.s++;
+		*lab.e++ = inp_next();
 		com_end = (int)buf_len();
 	}
 	break;

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.88 src/usr.bin/indent/indent.h:1.89
--- src/usr.bin/indent/indent.h:1.88	Fri Nov 19 15:32:13 2021
+++ src/usr.bin/indent/indent.h	Fri Nov 19 17:11:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.88 2021/11/19 15:32:13 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.89 2021/11/19 17:11:46 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -377,8 +377,10 @@ int compute_code_indent(void);
 int compute_label_indent(void);
 int ind_add(int, const char *, const char *);
 
+char inp_peek(void);
 void inp_skip(void);
 char inp_next(void);
+
 lexer_symbol lexi(void);
 void diag(int, const char *, ...)__printflike(2, 3);
 void dump_line(void);

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.140 src/usr.bin/indent/lexi.c:1.141
--- src/usr.bin/indent/lexi.c:1.140	Fri Nov 19 15:28:32 2021
+++ src/usr.bin/indent/lexi.c	Fri Nov 19 17:11:46 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.140 2021/11/19 15:28:32 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.141 2021/11/19 17:11:46 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)lexi.c	8.1 (
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.140 2021/11/19 15:28:32 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.141 2021/11/19 17:11:46 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -178,7 +178,7 @@ static const unsigned 

CVS commit: src/usr.bin/indent

2021-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 17:59:16 UTC 2021

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

Log Message:
indent: move character input handling from indent.c to io.c

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.223 -r1.224 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.92 -r1.93 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.120 -r1.121 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.223 src/usr.bin/indent/indent.c:1.224
--- src/usr.bin/indent/indent.c:1.223	Fri Nov 19 17:42:45 2021
+++ src/usr.bin/indent/indent.c	Fri Nov 19 17:59:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.223 2021/11/19 17:42:45 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.224 2021/11/19 17:59:16 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.223 2021/11/19 17:42:45 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.224 2021/11/19 17:59:16 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -218,12 +218,7 @@ diag(int level, const char *msg, ...)
 static void
 search_stmt_newline(bool *force_nl)
 {
-if (inbuf.save_com_e == NULL) {
-	inbuf.save_com_s = inbuf.save_com_buf;
-	inbuf.save_com_s[0] = inbuf.save_com_s[1] = ' ';
-	inbuf.save_com_e = _com_s[2];
-	debug_inp("search_stmt_newline init");
-}
+inp_comment_init_newline();
 inp_comment_add_char('\n');
 debug_inp(__func__);
 
@@ -243,38 +238,14 @@ search_stmt_newline(bool *force_nl)
 static void
 search_stmt_comment(void)
 {
-if (inbuf.save_com_e == NULL) {
-	/*
-	 * Copy everything from the start of the line, because
-	 * process_comment() will use that to calculate the original
-	 * indentation of a boxed comment.
-	 */
-	/*
-	 * FIXME: This '4' needs an explanation. For example, in the snippet
-	 * 'if(expr)/''*comment', the 'r)' of the code is not copied. If there
-	 * is an additional line break before the ')', memcpy tries to copy
-	 * (size_t)-1 bytes.
-	 */
-	assert((size_t)(inbuf.inp.s - inbuf.inp.buf) >= 4);
-	size_t line_len = (size_t)(inbuf.inp.s - inbuf.inp.buf) - 4;
-	assert(line_len < array_length(inbuf.save_com_buf));
-	memcpy(inbuf.save_com_buf, inbuf.inp.buf, line_len);
-	inbuf.save_com_s = inbuf.save_com_buf + line_len;
-	inbuf.save_com_s[0] = inbuf.save_com_s[1] = ' ';
-	inbuf.save_com_e = _com_s[2];
-	debug_vis_range("search_stmt_comment: before save_com is \"",
-	inbuf.save_com_buf, inbuf.save_com_s, "\"\n");
-	debug_vis_range("search_stmt_comment: save_com is \"",
-	inbuf.save_com_s, inbuf.save_com_e, "\"\n");
-}
-
+inp_comment_init_comment();
 inp_comment_add_range(token.s, token.e);
 if (token.e[-1] == '/') {
-	while (inbuf.inp.s[0] != '\n')
+	while (inp_peek() != '\n')
 	inp_comment_add_char(inp_next());
 	debug_inp("search_stmt_comment end C99");
 } else {
-	while (!(inbuf.save_com_e[-2] == '*' && inbuf.save_com_e[-1] == '/'))
+	while (!inp_comment_complete_block())
 	inp_comment_add_char(inp_next());
 	debug_inp("search_stmt_comment end block");
 }
@@ -288,7 +259,7 @@ search_stmt_lbrace(void)
  * this loop in order to avoid copying the token again.
  */
 if (inbuf.save_com_e != NULL && opt.brace_same_line) {
-	assert(inbuf.save_com_s[0] == ' ');	/* see search_stmt_comment */
+	assert(inbuf.save_com_s[0] == ' ');	/* inp_comment_init_newline */
 	inbuf.save_com_s[0] = '{';
 	/*
 	 * Originally the lbrace may have been alone on its own line, but it

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.92 src/usr.bin/indent/indent.h:1.93
--- src/usr.bin/indent/indent.h:1.92	Fri Nov 19 17:42:45 2021
+++ src/usr.bin/indent/indent.h	Fri Nov 19 17:59:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.92 2021/11/19 17:42:45 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.93 2021/11/19 17:59:16 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -384,8 +384,11 @@ char inp_lookahead(size_t);
 void inp_skip(void);
 char inp_next(void);
 
+void inp_comment_init_newline(void);
+void inp_comment_init_comment(void);
 void inp_comment_add_char(char);
 void inp_comment_add_range(const char *, const char *);
+bool inp_comment_complete_block(void);
 
 void inp_from_comment(void);
 

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.120 src/usr.bin/indent/io.c:1.121
--- src/usr.bin/indent/io.c:1.120	Fri Nov 19 17:42:45 2021
+++ src/usr.bin/indent/io.c	Fri Nov 19 17:59:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.120 2021/11/19 17:42:45 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.121 2021/11/19 17:59:16 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: 

CVS commit: src/usr.bin/indent

2021-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 17:59:16 UTC 2021

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

Log Message:
indent: move character input handling from indent.c to io.c

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.223 -r1.224 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.92 -r1.93 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.120 -r1.121 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-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 18:23:59 UTC 2021

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

Log Message:
indent: use character input API from pr_comment.c

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.122 -r1.123 src/usr.bin/indent/io.c
cvs rdiff -u -r1.119 -r1.120 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.94 src/usr.bin/indent/indent.h:1.95
--- src/usr.bin/indent/indent.h:1.94	Fri Nov 19 18:14:18 2021
+++ src/usr.bin/indent/indent.h	Fri Nov 19 18:23:59 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.94 2021/11/19 18:14:18 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.95 2021/11/19 18:23:59 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -380,6 +380,7 @@ int ind_add(int, const char *, const cha
 void inp_init(void);
 
 const char *inp_p(void);
+const char *inp_line_start(void);
 const char *inp_line_end(void);
 char inp_peek(void);
 char inp_lookahead(size_t);

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.122 src/usr.bin/indent/io.c:1.123
--- src/usr.bin/indent/io.c:1.122	Fri Nov 19 18:14:18 2021
+++ src/usr.bin/indent/io.c	Fri Nov 19 18:23:59 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.122 2021/11/19 18:14:18 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.123 2021/11/19 18:23:59 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.122 2021/11/19 18:14:18 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.123 2021/11/19 18:23:59 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -79,6 +79,21 @@ inp_p(void)
 }
 
 const char *
+inp_line_start(void)
+{
+/*
+ * The comment we're about to read usually comes from inp.buf, unless
+ * it has been copied into save_com.
+ *
+ * XXX: ordered comparison between pointers from different objects
+ * invokes undefined behavior (C99 6.5.8).
+ */
+return inbuf.inp.s >= inbuf.save_com_buf &&
+	inbuf.inp.s < inbuf.save_com_buf + array_length(inbuf.save_com_buf)
+	? inbuf.save_com_buf : inbuf.inp.buf;
+}
+
+const char *
 inp_line_end(void)
 {
 return inbuf.inp.e;

Index: src/usr.bin/indent/pr_comment.c
diff -u src/usr.bin/indent/pr_comment.c:1.119 src/usr.bin/indent/pr_comment.c:1.120
--- src/usr.bin/indent/pr_comment.c:1.119	Fri Nov 19 17:11:46 2021
+++ src/usr.bin/indent/pr_comment.c	Fri Nov 19 18:23:59 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: pr_comment.c,v 1.119 2021/11/19 17:11:46 rillig Exp $	*/
+/*	$NetBSD: pr_comment.c,v 1.120 2021/11/19 18:23:59 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)pr_comment.c
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: pr_comment.c,v 1.119 2021/11/19 17:11:46 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.120 2021/11/19 18:23:59 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -86,13 +86,13 @@ com_terminate(void)
 static bool
 fits_in_one_line(int max_line_length)
 {
-for (const char *p = inbuf.inp.s; *p != '\n'; p++) {
+for (const char *p = inp_p(); *p != '\n'; p++) {
 	assert(*p != '\0');
-	assert(inbuf.inp.e - p >= 2);
+	assert(inp_line_end() - p >= 2);
 	if (!(p[0] == '*' && p[1] == '/'))
 	continue;
 
-	int len = ind_add(ps.com_ind + 3, inbuf.inp.s, p);
+	int len = ind_add(ps.com_ind + 3, inp_p(), p);
 	len += ch_isblank(p[-1]) ? 2 : 3;
 	return len <= max_line_length;
 }
@@ -152,22 +152,13 @@ analyze_comment(bool *p_may_wrap, bool *
 	/*
 	 * Find out how much indentation there was originally, because that
 	 * much will have to be ignored by dump_line().
-	 *
-	 * The comment we're about to read usually comes from inp.buf, unless
-	 * it has been copied into save_com.
-	 *
-	 * XXX: ordered comparison between pointers from different objects
-	 * invokes undefined behavior (C99 6.5.8).
 	 */
-	const char *start = inbuf.inp.s >= inbuf.save_com_buf &&
-		inbuf.inp.s <
-		inbuf.save_com_buf + array_length(inbuf.save_com_buf)
-	? inbuf.save_com_buf : inbuf.inp.buf;
-	ps.n_comment_delta = -ind_add(0, start, inbuf.inp.s - 2);
+	const char *start = inp_line_start();
+	ps.n_comment_delta = -ind_add(0, start, inp_p() - 2);
 } else {
 	ps.n_comment_delta = 0;
 	while (ch_isblank(inp_peek()))
-	inbuf.inp.s++;
+	inp_skip();
 }
 
 ps.comment_delta = 0;
@@ -213,9 +204,9 @@ copy_comment_wrap(int adj_max_line_lengt
 	dump_line_ff();
 	last_blank = -1;
 	com_add_delim();
-	inbuf.inp.s++;
+	

CVS commit: src/usr.bin/indent

2021-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 18:23:59 UTC 2021

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

Log Message:
indent: use character input API from pr_comment.c

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.122 -r1.123 src/usr.bin/indent/io.c
cvs rdiff -u -r1.119 -r1.120 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-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 18:25:50 UTC 2021

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

Log Message:
indent: unexport inbuf

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.123 -r1.124 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-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 18:25:50 UTC 2021

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

Log Message:
indent: unexport inbuf

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.123 -r1.124 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.95 src/usr.bin/indent/indent.h:1.96
--- src/usr.bin/indent/indent.h:1.95	Fri Nov 19 18:23:59 2021
+++ src/usr.bin/indent/indent.h	Fri Nov 19 18:25:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.95 2021/11/19 18:23:59 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.96 2021/11/19 18:25:50 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -143,20 +143,6 @@ struct buffer {
 char *l;			/* end of the allocated memory */
 };
 
-extern struct input_buffer {
-struct buffer inp;		/* one line of input, ready to be split into
- * tokens; occasionally this buffer switches
- * to save_com_buf */
-char save_com_buf[5000];	/* input text is saved here when looking for
- * the brace after an if, while, etc */
-char *save_com_s;		/* start of the comment in save_com_buf */
-char *save_com_e;		/* end of the comment in save_com_buf */
-
-char *saved_inp_s;		/* saved value of inp.s when taking input from
- * save_com */
-char *saved_inp_e;		/* similarly saved value of inp.e */
-} inbuf;
-
 extern FILE *input;
 extern FILE *output;
 

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.123 src/usr.bin/indent/io.c:1.124
--- src/usr.bin/indent/io.c:1.123	Fri Nov 19 18:23:59 2021
+++ src/usr.bin/indent/io.c	Fri Nov 19 18:25:50 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.123 2021/11/19 18:23:59 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.124 2021/11/19 18:25:50 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.123 2021/11/19 18:23:59 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.124 2021/11/19 18:25:50 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -57,7 +57,19 @@ __FBSDID("$FreeBSD: head/usr.bin/indent/
 
 #include "indent.h"
 
-struct input_buffer inbuf;
+static struct input_buffer {
+struct buffer inp;		/* one line of input, ready to be split into
+ * tokens; occasionally this buffer switches
+ * to save_com_buf */
+char save_com_buf[5000];	/* input text is saved here when looking for
+ * the brace after an if, while, etc */
+char *save_com_s;		/* start of the comment in save_com_buf */
+char *save_com_e;		/* end of the comment in save_com_buf */
+
+char *saved_inp_s;		/* saved value of inp.s when taking input from
+ * save_com */
+char *saved_inp_e;		/* similarly saved value of inp.e */
+} inbuf;
 
 static int paren_indent;
 static bool suppress_blanklines;



CVS commit: src/usr.bin/indent

2021-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 17:20:57 UTC 2021

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

Log Message:
indent: move character input handling from lexi.c to io.c

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.117 -r1.118 src/usr.bin/indent/io.c
cvs rdiff -u -r1.141 -r1.142 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.h
diff -u src/usr.bin/indent/indent.h:1.89 src/usr.bin/indent/indent.h:1.90
--- src/usr.bin/indent/indent.h:1.89	Fri Nov 19 17:11:46 2021
+++ src/usr.bin/indent/indent.h	Fri Nov 19 17:20:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.89 2021/11/19 17:11:46 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.90 2021/11/19 17:20:57 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -378,6 +378,7 @@ int compute_label_indent(void);
 int ind_add(int, const char *, const char *);
 
 char inp_peek(void);
+char inp_lookahead(size_t);
 void inp_skip(void);
 char inp_next(void);
 

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.117 src/usr.bin/indent/io.c:1.118
--- src/usr.bin/indent/io.c:1.117	Fri Nov 19 15:28:32 2021
+++ src/usr.bin/indent/io.c	Fri Nov 19 17:20:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.117 2021/11/19 15:28:32 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.118 2021/11/19 17:20:57 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.117 2021/11/19 15:28:32 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.118 2021/11/19 17:20:57 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -58,6 +58,36 @@ __FBSDID("$FreeBSD: head/usr.bin/indent/
 static int paren_indent;
 static bool suppress_blanklines;
 
+
+char
+inp_peek(void)
+{
+return *inbuf.inp.s;
+}
+
+char
+inp_lookahead(size_t i)
+{
+return inbuf.inp.s[i];
+}
+
+void
+inp_skip(void)
+{
+inbuf.inp.s++;
+if (inbuf.inp.s >= inbuf.inp.e)
+	inp_read_line();
+}
+
+char
+inp_next(void)
+{
+char ch = inp_peek();
+inp_skip();
+return ch;
+}
+
+
 static void
 output_char(char ch)
 {

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.141 src/usr.bin/indent/lexi.c:1.142
--- src/usr.bin/indent/lexi.c:1.141	Fri Nov 19 17:11:46 2021
+++ src/usr.bin/indent/lexi.c	Fri Nov 19 17:20:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.141 2021/11/19 17:11:46 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.142 2021/11/19 17:20:57 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,11 +43,12 @@ static char sccsid[] = "@(#)lexi.c	8.1 (
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.141 2021/11/19 17:11:46 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.142 2021/11/19 17:20:57 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
 
+#include 
 #include 
 #include 
 #include 
@@ -178,28 +179,6 @@ static const unsigned char lex_number_ro
 ['.'] = 15,
 };
 
-char
-inp_peek(void)
-{
-return *inbuf.inp.s;
-}
-
-void
-inp_skip(void)
-{
-inbuf.inp.s++;
-if (inbuf.inp.s >= inbuf.inp.e)
-	inp_read_line();
-}
-
-char
-inp_next(void)
-{
-char ch = inp_peek();
-inp_skip();
-return ch;
-}
-
 static void
 check_size_token(size_t desired_size)
 {
@@ -378,10 +357,9 @@ lex_word(void)
 	inp_peek() == '_' || inp_peek() == '$') {
 
 	if (inp_peek() == '\\') {
-	if (inbuf.inp.s[1] == '\n') {
-		inbuf.inp.s += 2;
-		if (inbuf.inp.s >= inbuf.inp.e)
-		inp_read_line();
+	if (inp_lookahead(1) == '\n') {
+		inp_skip();
+		inp_skip();
 	} else
 		break;
 	}
@@ -417,7 +395,7 @@ probably_typename(void)
 {
 if (ps.block_init || ps.in_stmt)
 	return false;
-if (inbuf.inp.s[0] == '*' && inbuf.inp.s[1] != '=')
+if (inp_peek() == '*' && inp_lookahead(1) != '=')
 	goto maybe;
 if (isalpha((unsigned char)inp_peek()))
 	goto maybe;
@@ -469,7 +447,7 @@ static lexer_symbol
 lexi_alnum(void)
 {
 if (isdigit((unsigned char)inp_peek()) ||
-	(inbuf.inp.s[0] == '.' && isdigit((unsigned char)inbuf.inp.s[1]))) {
+	(inp_peek() == '.' && isdigit((unsigned char)inp_lookahead(1 {
 	lex_number();
 } else if (isalnum((unsigned char)inp_peek()) ||
 	inp_peek() == '_' || inp_peek() == '$') {
@@ -738,8 +716,7 @@ lexi(void)
 	unary_delim = true;
 }
 
-if (inbuf.inp.s >= inbuf.inp.e)
-	inp_read_line();
+assert(inbuf.inp.s < inbuf.inp.e);
 
 ps.next_unary = unary_delim;
 



CVS commit: src/usr.bin/indent

2021-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 17:20:57 UTC 2021

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

Log Message:
indent: move character input handling from lexi.c to io.c

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.117 -r1.118 src/usr.bin/indent/io.c
cvs rdiff -u -r1.141 -r1.142 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-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 17:42:46 UTC 2021

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

Log Message:
indent: move character input from indent.c to io.c

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.222 -r1.223 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.91 -r1.92 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.119 -r1.120 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-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 17:42:46 UTC 2021

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

Log Message:
indent: move character input from indent.c to io.c

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.222 -r1.223 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.91 -r1.92 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.119 -r1.120 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.222 src/usr.bin/indent/indent.c:1.223
--- src/usr.bin/indent/indent.c:1.222	Fri Nov 19 17:11:46 2021
+++ src/usr.bin/indent/indent.c	Fri Nov 19 17:42:45 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.222 2021/11/19 17:11:46 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.223 2021/11/19 17:42:45 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.222 2021/11/19 17:11:46 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.223 2021/11/19 17:42:45 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -88,8 +88,6 @@ struct options opt = {
 
 struct parser_state ps;
 
-struct input_buffer inbuf;
-
 struct buffer token;
 
 struct buffer lab;
@@ -217,53 +215,6 @@ diag(int level, const char *msg, ...)
 va_end(ap);
 }
 
-#ifdef debug
-static void
-debug_inbuf(const char *prefix)
-{
-debug_printf("%s:", prefix);
-debug_vis_range(" inp \"", inbuf.inp.s, inbuf.inp.e, "\"");
-if (inbuf.save_com_s != NULL)
-	debug_vis_range(" save_com \"",
-	inbuf.save_com_s, inbuf.save_com_e, "\"");
-if (inbuf.saved_inp_s != NULL)
-	debug_vis_range(" saved_inp \"",
-	inbuf.saved_inp_s, inbuf.saved_inp_e, "\"");
-debug_printf("\n");
-}
-#else
-#define debug_inbuf(prefix) do { } while (false)
-#endif
-
-static void
-save_com_check_size(size_t n)
-{
-if ((size_t)(inbuf.save_com_e - inbuf.save_com_buf) + n <=
-	array_length(inbuf.save_com_buf))
-	return;
-
-diag(1, "Internal buffer overflow - "
-	"Move big comment from right after if, while, or whatever");
-fflush(output);
-exit(1);
-}
-
-static void
-save_com_add_char(char ch)
-{
-save_com_check_size(1);
-*inbuf.save_com_e++ = ch;
-}
-
-static void
-save_com_add_range(const char *s, const char *e)
-{
-size_t len = (size_t)(e - s);
-save_com_check_size(len);
-memcpy(inbuf.save_com_e, s, len);
-inbuf.save_com_e += len;
-}
-
 static void
 search_stmt_newline(bool *force_nl)
 {
@@ -271,10 +222,10 @@ search_stmt_newline(bool *force_nl)
 	inbuf.save_com_s = inbuf.save_com_buf;
 	inbuf.save_com_s[0] = inbuf.save_com_s[1] = ' ';
 	inbuf.save_com_e = _com_s[2];
-	debug_inbuf("search_stmt_newline init");
+	debug_inp("search_stmt_newline init");
 }
-save_com_add_char('\n');
-debug_inbuf(__func__);
+inp_comment_add_char('\n');
+debug_inp(__func__);
 
 line_no++;
 
@@ -317,15 +268,15 @@ search_stmt_comment(void)
 	inbuf.save_com_s, inbuf.save_com_e, "\"\n");
 }
 
-save_com_add_range(token.s, token.e);
+inp_comment_add_range(token.s, token.e);
 if (token.e[-1] == '/') {
 	while (inbuf.inp.s[0] != '\n')
-	save_com_add_char(inp_next());
-	debug_inbuf("search_stmt_comment end C99");
+	inp_comment_add_char(inp_next());
+	debug_inp("search_stmt_comment end C99");
 } else {
 	while (!(inbuf.save_com_e[-2] == '*' && inbuf.save_com_e[-1] == '/'))
-	save_com_add_char(inp_next());
-	debug_inbuf("search_stmt_comment end block");
+	inp_comment_add_char(inp_next());
+	debug_inp("search_stmt_comment end block");
 }
 }
 
@@ -349,7 +300,7 @@ search_stmt_lbrace(void)
 	if (inp_peek() == '\n')
 		break;
 	}
-	debug_inbuf(__func__);
+	debug_inp(__func__);
 	return true;
 }
 return false;
@@ -375,7 +326,7 @@ search_stmt_other(lexer_symbol lsym, boo
 	return false;
 }
 
-debug_inbuf(__func__);
+debug_inp(__func__);
 while (inbuf.save_com_e > inbuf.save_com_s && ch_isblank(inbuf.save_com_e[-1]))
 	inbuf.save_com_e--;
 
@@ -391,15 +342,15 @@ search_stmt_other(lexer_symbol lsym, boo
 	*force_nl = false;
 	--line_no;		/* this will be re-increased when the newline
  * is read from the buffer */
-	save_com_add_char('\n');
-	save_com_add_char(' ');
+	inp_comment_add_char('\n');
+	inp_comment_add_char(' ');
 	if (opt.verbose)	/* warn if the line was not already broken */
 	diag(0, "Line broken");
 }
 
 for (const char *t_ptr = token.s; *t_ptr != '\0'; ++t_ptr)
-	save_com_add_char(*t_ptr);
-debug_inbuf("search_stmt_other end");
+	inp_comment_add_char(*t_ptr);
+debug_inp("search_stmt_other end");
 return true;
 }
 
@@ -407,16 +358,8 @@ static void
 switch_buffer(void)
 {
 

CVS commit: src/usr.bin/indent

2021-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 18:14:18 UTC 2021

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

Log Message:
indent: remove all references to inbuf from indent.c

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.224 -r1.225 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.93 -r1.94 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.121 -r1.122 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-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 18:14:18 UTC 2021

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

Log Message:
indent: remove all references to inbuf from indent.c

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.224 -r1.225 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.93 -r1.94 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.121 -r1.122 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.224 src/usr.bin/indent/indent.c:1.225
--- src/usr.bin/indent/indent.c:1.224	Fri Nov 19 17:59:16 2021
+++ src/usr.bin/indent/indent.c	Fri Nov 19 18:14:18 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.224 2021/11/19 17:59:16 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.225 2021/11/19 18:14:18 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.224 2021/11/19 17:59:16 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.225 2021/11/19 18:14:18 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -258,9 +258,8 @@ search_stmt_lbrace(void)
  * Put KNF-style lbraces before the buffered up tokens and jump out of
  * this loop in order to avoid copying the token again.
  */
-if (inbuf.save_com_e != NULL && opt.brace_same_line) {
-	assert(inbuf.save_com_s[0] == ' ');	/* inp_comment_init_newline */
-	inbuf.save_com_s[0] = '{';
+if (inp_comment_seen() && opt.brace_same_line) {
+	inp_comment_insert_lbrace();
 	/*
 	 * Originally the lbrace may have been alone on its own line, but it
 	 * will be moved into "the else's line", so if there was a newline
@@ -291,21 +290,18 @@ search_stmt_other(lexer_symbol lsym, boo
 if (remove_newlines)
 	*force_nl = false;
 
-if (inbuf.save_com_e == NULL) {	/* ignore buffering if comment wasn't saved
- * up */
+if (!inp_comment_seen()) {
 	ps.search_stmt = false;
 	return false;
 }
 
 debug_inp(__func__);
-while (inbuf.save_com_e > inbuf.save_com_s && ch_isblank(inbuf.save_com_e[-1]))
-	inbuf.save_com_e--;
+inp_comment_rtrim();
 
 if (opt.swallow_optional_blanklines ||
 	(!comment_buffered && remove_newlines)) {
 	*force_nl = !remove_newlines;
-	while (inbuf.save_com_e > inbuf.save_com_s && inbuf.save_com_e[-1] == '\n')
-	inbuf.save_com_e--;
+	inp_comment_rtrim_newline();
 }
 
 if (*force_nl) {		/* if we should insert a nl here, put it into
@@ -356,7 +352,7 @@ search_stmt_lookahead(lexer_symbol *lsym
  * Work around the latter problem by copying all whitespace characters
  * into the buffer so that the later lexi() call will read them.
  */
-if (inbuf.save_com_e != NULL) {
+if (inp_comment_seen()) {
 	while (ch_isblank(inp_peek()))
 	inp_comment_add_char(inp_next());
 	debug_inp(__func__);
@@ -415,10 +411,7 @@ search_stmt(lexer_symbol *lsym, bool *fo
 static void
 main_init_globals(void)
 {
-inbuf.inp.buf = xmalloc(10);
-inbuf.inp.l = inbuf.inp.buf + 8;
-inbuf.inp.s = inbuf.inp.buf;
-inbuf.inp.e = inbuf.inp.buf;
+inp_init();
 
 buf_init();
 
@@ -545,7 +538,7 @@ main_prepare_parsing(void)
 inp_read_line();
 
 int ind = 0;
-for (const char *p = inbuf.inp.s;; p++) {
+for (const char *p = inp_p();; p++) {
 	if (*p == ' ')
 	ind++;
 	else if (*p == '\t')
@@ -1202,30 +1195,15 @@ read_preprocessing_line(void)
 
 while (lab.e > lab.s && ch_isblank(lab.e[-1]))
 	lab.e--;
-if (lab.e - lab.s == com_end && inbuf.saved_inp_s == NULL) {
+if (lab.e - lab.s == com_end && !inp_comment_seen()) {
 	/* comment on preprocessor line */
-	if (inbuf.save_com_e == NULL) {	/* if this is the first comment, we must set
- * up the buffer */
-	inbuf.save_com_s = inbuf.save_com_buf;
-	inbuf.save_com_e = inbuf.save_com_s;
-	} else {
-	inp_comment_add_char('\n');	/* add newline between comments */
-	inp_comment_add_char(' ');
-	--line_no;
-	}
+	inp_comment_init_preproc();
 	inp_comment_add_range(lab.s + com_start, lab.s + com_end);
 	lab.e = lab.s + com_start;
 	while (lab.e > lab.s && ch_isblank(lab.e[-1]))
 	lab.e--;
-	inbuf.saved_inp_s = inbuf.inp.s;	/* save current input buffer */
-	inbuf.saved_inp_e = inbuf.inp.e;
-	inbuf.inp.s = inbuf.save_com_s;	/* fix so that subsequent calls to lexi will
- * take tokens out of save_com */
 	inp_comment_add_char(' ');	/* add trailing blank, just in case */
-	debug_inp(__func__);
-	inbuf.inp.e = inbuf.save_com_e;
-	inbuf.save_com_e = NULL;
-	debug_println("switched inbuf to save_com");
+	inp_from_comment();
 }
 buf_terminate();
 }

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.93 

CVS commit: src/usr.bin/indent

2021-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 17:30:10 UTC 2021

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

Log Message:
indent: use character input API from the tokenizer

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.118 -r1.119 src/usr.bin/indent/io.c
cvs rdiff -u -r1.142 -r1.143 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-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 17:30:10 UTC 2021

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

Log Message:
indent: use character input API from the tokenizer

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.118 -r1.119 src/usr.bin/indent/io.c
cvs rdiff -u -r1.142 -r1.143 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.h
diff -u src/usr.bin/indent/indent.h:1.90 src/usr.bin/indent/indent.h:1.91
--- src/usr.bin/indent/indent.h:1.90	Fri Nov 19 17:20:57 2021
+++ src/usr.bin/indent/indent.h	Fri Nov 19 17:30:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.90 2021/11/19 17:20:57 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.91 2021/11/19 17:30:10 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -377,6 +377,8 @@ int compute_code_indent(void);
 int compute_label_indent(void);
 int ind_add(int, const char *, const char *);
 
+const char *inp_p(void);
+const char *inp_line_end(void);
 char inp_peek(void);
 char inp_lookahead(size_t);
 void inp_skip(void);

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.118 src/usr.bin/indent/io.c:1.119
--- src/usr.bin/indent/io.c:1.118	Fri Nov 19 17:20:57 2021
+++ src/usr.bin/indent/io.c	Fri Nov 19 17:30:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.118 2021/11/19 17:20:57 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.119 2021/11/19 17:30:10 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.118 2021/11/19 17:20:57 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.119 2021/11/19 17:30:10 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -59,6 +59,18 @@ static int paren_indent;
 static bool suppress_blanklines;
 
 
+const char *
+inp_p(void)
+{
+return inbuf.inp.s;
+}
+
+const char *
+inp_line_end(void)
+{
+return inbuf.inp.e;
+}
+
 char
 inp_peek(void)
 {

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.142 src/usr.bin/indent/lexi.c:1.143
--- src/usr.bin/indent/lexi.c:1.142	Fri Nov 19 17:20:57 2021
+++ src/usr.bin/indent/lexi.c	Fri Nov 19 17:30:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.142 2021/11/19 17:20:57 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.143 2021/11/19 17:30:10 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)lexi.c	8.1 (
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.142 2021/11/19 17:20:57 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.143 2021/11/19 17:30:10 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -504,7 +504,7 @@ found_typename:
 if (inp_peek() == '(' && ps.tos <= 1 && ps.ind_level == 0 &&
 	!ps.in_parameter_declaration && !ps.block_init) {
 
-	for (const char *p = inbuf.inp.s; p < inbuf.inp.e;)
+	for (const char *p = inp_p(), *e = inp_line_end(); p < e;)
 	if (*p++ == ')' && (*p == ';' || *p == ','))
 		goto no_function_definition;
 
@@ -682,14 +682,14 @@ lexi(void)
 	}
 
 	if (ps.in_decl) {
-	char *tp = inbuf.inp.s;
+	const char *tp = inp_p();
 
 	while (isalpha((unsigned char)*tp) ||
 		isspace((unsigned char)*tp)) {
-		if (++tp >= inbuf.inp.e) {
-		const char *s_before = inbuf.inp.s;
+		if (++tp >= inp_line_end()) {
+		const char *p_before = inp_p();
 		inp_read_line();
-		if (inbuf.inp.s != s_before)
+		if (inp_p() != p_before)
 			abort();
 		}
 	}
@@ -716,8 +716,6 @@ lexi(void)
 	unary_delim = true;
 }
 
-assert(inbuf.inp.s < inbuf.inp.e);
-
 ps.next_unary = unary_delim;
 
 check_size_token(1);



CVS commit: src/usr.bin/indent

2021-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 15:34:25 UTC 2021

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

Log Message:
indent: add debug logging for input buffer handling


To generate a diff of this commit:
cvs rdiff -u -r1.220 -r1.221 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-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 15:34:25 UTC 2021

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

Log Message:
indent: add debug logging for input buffer handling


To generate a diff of this commit:
cvs rdiff -u -r1.220 -r1.221 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.220 src/usr.bin/indent/indent.c:1.221
--- src/usr.bin/indent/indent.c:1.220	Fri Nov 19 15:32:13 2021
+++ src/usr.bin/indent/indent.c	Fri Nov 19 15:34:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.220 2021/11/19 15:32:13 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.221 2021/11/19 15:34:25 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.220 2021/11/19 15:32:13 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.221 2021/11/19 15:34:25 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -219,13 +219,20 @@ diag(int level, const char *msg, ...)
 
 #ifdef debug
 static void
-debug_save_com(const char *prefix)
+debug_inbuf(const char *prefix)
 {
-debug_printf("%s: save_com is ", prefix);
-debug_vis_range("\"", inbuf.save_com_s, inbuf.save_com_e, "\"\n");
+debug_printf("%s:", prefix);
+debug_vis_range(" inp \"", inbuf.inp.s, inbuf.inp.e, "\"");
+if (inbuf.save_com_s != NULL)
+	debug_vis_range(" save_com \"",
+	inbuf.save_com_s, inbuf.save_com_e, "\"");
+if (inbuf.saved_inp_s != NULL)
+	debug_vis_range(" saved_inp \"",
+	inbuf.saved_inp_s, inbuf.saved_inp_e, "\"");
+debug_printf("\n");
 }
 #else
-#define debug_save_com(prefix) do { } while (false)
+#define debug_inbuf(prefix) do { } while (false)
 #endif
 
 static void
@@ -264,10 +271,10 @@ search_stmt_newline(bool *force_nl)
 	inbuf.save_com_s = inbuf.save_com_buf;
 	inbuf.save_com_s[0] = inbuf.save_com_s[1] = ' ';
 	inbuf.save_com_e = _com_s[2];
-	debug_save_com("search_stmt_newline init");
+	debug_inbuf("search_stmt_newline init");
 }
 save_com_add_char('\n');
-debug_save_com(__func__);
+debug_inbuf(__func__);
 
 line_no++;
 
@@ -314,11 +321,11 @@ search_stmt_comment(void)
 if (token.e[-1] == '/') {
 	while (inbuf.inp.s[0] != '\n')
 	save_com_add_char(inp_next());
-	debug_save_com("search_stmt_comment end C99");
+	debug_inbuf("search_stmt_comment end C99");
 } else {
 	while (!(inbuf.save_com_e[-2] == '*' && inbuf.save_com_e[-1] == '/'))
 	save_com_add_char(inp_next());
-	debug_save_com("search_stmt_comment end block");
+	debug_inbuf("search_stmt_comment end block");
 }
 }
 
@@ -342,7 +349,7 @@ search_stmt_lbrace(void)
 	if (*inbuf.inp.s == '\n')
 		break;
 	}
-	debug_save_com(__func__);
+	debug_inbuf(__func__);
 	return true;
 }
 return false;
@@ -368,7 +375,7 @@ search_stmt_other(lexer_symbol lsym, boo
 	return false;
 }
 
-debug_save_com(__func__);
+debug_inbuf(__func__);
 while (inbuf.save_com_e > inbuf.save_com_s && ch_isblank(inbuf.save_com_e[-1]))
 	inbuf.save_com_e--;
 
@@ -392,7 +399,7 @@ search_stmt_other(lexer_symbol lsym, boo
 
 for (const char *t_ptr = token.s; *t_ptr != '\0'; ++t_ptr)
 	save_com_add_char(*t_ptr);
-debug_save_com("search_stmt_other end");
+debug_inbuf("search_stmt_other end");
 return true;
 }
 
@@ -401,7 +408,7 @@ switch_buffer(void)
 {
 ps.search_stmt = false;
 save_com_add_char(' ');		/* add trailing blank, just in case */
-debug_save_com(__func__);
+debug_inbuf(__func__);
 
 inbuf.saved_inp_s = inbuf.inp.s;
 inbuf.saved_inp_e = inbuf.inp.e;
@@ -438,7 +445,7 @@ search_stmt_lookahead(lexer_symbol *lsym
 if (inbuf.save_com_e != NULL) {
 	while (ch_isblank(*inbuf.inp.s))
 	save_com_add_char(inp_next());
-	debug_save_com(__func__);
+	debug_inbuf(__func__);
 }
 
 struct parser_state backup_ps = ps;
@@ -1301,7 +1308,7 @@ read_preprocessing_line(void)
 	inbuf.inp.s = inbuf.save_com_s;	/* fix so that subsequent calls to lexi will
  * take tokens out of save_com */
 	save_com_add_char(' ');	/* add trailing blank, just in case */
-	debug_save_com(__func__);
+	debug_inbuf(__func__);
 	inbuf.inp.e = inbuf.save_com_e;
 	inbuf.save_com_e = NULL;
 	debug_println("switched inbuf to save_com");



CVS commit: src

2021-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 18:52:33 UTC 2021

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

Log Message:
indent: fix lost function name (since 2019-04-04)

When indent searched for an identifier followed by a '(', to see whether
the identifier is a function name, it didn't care that the input buffer
could be resized due to a long line, which had made the pointer 'tp'
invalid.  Fix this by stopping the search at the end of the line.  A
better approach would be to have an unlimited lookahead buffer for
situations like these.  The code that deals with character input has
already been extracted to io.c, so it's possible to implement that now.

While here, fix another access to undefined memory, after the loop.

There is still the issue of overwriting procname[0] with a blank, which
results in inconsistent formatting depending on the function name,
probably another case of accessing undefined memory, although the
results have been reproducible, but that may have been pure luck.

The formatted code looks clearly broken, but that's still better than
losing a token and destroying the whole file.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/usr.bin/indent/fmt_decl.c
cvs rdiff -u -r1.143 -r1.144 src/usr.bin/indent/lexi.c

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



CVS commit: src

2021-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 18:52:33 UTC 2021

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

Log Message:
indent: fix lost function name (since 2019-04-04)

When indent searched for an identifier followed by a '(', to see whether
the identifier is a function name, it didn't care that the input buffer
could be resized due to a long line, which had made the pointer 'tp'
invalid.  Fix this by stopping the search at the end of the line.  A
better approach would be to have an unlimited lookahead buffer for
situations like these.  The code that deals with character input has
already been extracted to io.c, so it's possible to implement that now.

While here, fix another access to undefined memory, after the loop.

There is still the issue of overwriting procname[0] with a blank, which
results in inconsistent formatting depending on the function name,
probably another case of accessing undefined memory, although the
results have been reproducible, but that may have been pure luck.

The formatted code looks clearly broken, but that's still better than
losing a token and destroying the whole file.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/usr.bin/indent/fmt_decl.c
cvs rdiff -u -r1.143 -r1.144 src/usr.bin/indent/lexi.c

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

Modified files:

Index: src/tests/usr.bin/indent/fmt_decl.c
diff -u src/tests/usr.bin/indent/fmt_decl.c:1.15 src/tests/usr.bin/indent/fmt_decl.c:1.16
--- src/tests/usr.bin/indent/fmt_decl.c:1.15	Thu Nov 18 23:06:51 2021
+++ src/tests/usr.bin/indent/fmt_decl.c	Fri Nov 19 18:52:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: fmt_decl.c,v 1.15 2021/11/18 23:06:51 rillig Exp $	*/
+/*	$NetBSD: fmt_decl.c,v 1.16 2021/11/19 18:52:33 rillig Exp $	*/
 /* $FreeBSD: head/usr.bin/indent/tests/declarations.0 334478 2018-06-01 09:41:15Z pstef $ */
 
 /* See FreeBSD r303570 */
@@ -512,8 +512,8 @@ 
 {}
 #indent end
 
-/* FIXME: The function name is missing. */
 #indent run
-int	   *(void){
+int	   *a
+		(void){
 }
 #indent end

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.143 src/usr.bin/indent/lexi.c:1.144
--- src/usr.bin/indent/lexi.c:1.143	Fri Nov 19 17:30:10 2021
+++ src/usr.bin/indent/lexi.c	Fri Nov 19 18:52:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.143 2021/11/19 17:30:10 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.144 2021/11/19 18:52:32 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)lexi.c	8.1 (
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.143 2021/11/19 17:30:10 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.144 2021/11/19 18:52:32 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -682,19 +682,14 @@ lexi(void)
 	}
 
 	if (ps.in_decl) {
-	const char *tp = inp_p();
+	const char *tp = inp_p(), *e = inp_line_end();
 
-	while (isalpha((unsigned char)*tp) ||
-		isspace((unsigned char)*tp)) {
-		if (++tp >= inp_line_end()) {
-		const char *p_before = inp_p();
-		inp_read_line();
-		if (inp_p() != p_before)
-			abort();
-		}
-	}
-	if (*tp == '(')
-		ps.procname[0] = ' ';
+	while (tp < e && (isalpha((unsigned char)*tp) ||
+		isspace((unsigned char)*tp)))
+		tp++;
+
+	if (tp < e && *tp == '(')
+		ps.procname[0] = ' ';	/* XXX: why not '\0'? */
 	}
 
 	lsym = lsym_unary_op;



CVS commit: src/usr.bin/indent

2021-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 19:15:55 UTC 2021

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

Log Message:
indent: merge duplicate code into is_identifier_part

No functional change.


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

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

Modified files:

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.144 src/usr.bin/indent/lexi.c:1.145
--- src/usr.bin/indent/lexi.c:1.144	Fri Nov 19 18:52:32 2021
+++ src/usr.bin/indent/lexi.c	Fri Nov 19 19:15:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.144 2021/11/19 18:52:32 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.145 2021/11/19 19:15:55 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)lexi.c	8.1 (
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.144 2021/11/19 18:52:32 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.145 2021/11/19 19:15:55 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -276,7 +276,7 @@ debug_lexi(lexer_symbol lsym)
 debug_ps_bool(curr_col_1);
 debug_ps_bool(next_unary);
 if (strcmp(ps.procname, prev_ps.procname) != 0)
-	debug_println("ps.procname = '%s'", ps.procname);
+	debug_println("ps.procname = \"%s\"", ps.procname);
 debug_ps_bool(want_blank);
 debug_ps_int(paren_level);
 debug_ps_int(p_l_follow);
@@ -349,13 +349,16 @@ lex_number(void)
 }
 }
 
+static bool
+is_identifier_part(char ch)
+{
+return isalnum((unsigned char)ch) || ch == '_' || ch == '$';
+}
+
 static void
 lex_word(void)
 {
-while (isalnum((unsigned char)inp_peek()) ||
-	inp_peek() == '\\' ||
-	inp_peek() == '_' || inp_peek() == '$') {
-
+while (is_identifier_part(inp_peek()) || inp_peek() == '\\' ) {
 	if (inp_peek() == '\\') {
 	if (inp_lookahead(1) == '\n') {
 		inp_skip();
@@ -397,6 +400,7 @@ probably_typename(void)
 	return false;
 if (inp_peek() == '*' && inp_lookahead(1) != '=')
 	goto maybe;
+/* XXX: is_identifier_start */
 if (isalpha((unsigned char)inp_peek()))
 	goto maybe;
 return false;
@@ -449,8 +453,7 @@ lexi_alnum(void)
 if (isdigit((unsigned char)inp_peek()) ||
 	(inp_peek() == '.' && isdigit((unsigned char)inp_lookahead(1 {
 	lex_number();
-} else if (isalnum((unsigned char)inp_peek()) ||
-	inp_peek() == '_' || inp_peek() == '$') {
+} else if (is_identifier_part(inp_peek())) {
 	lex_word();
 } else
 	return lsym_eof;	/* just as a placeholder */
@@ -684,6 +687,7 @@ lexi(void)
 	if (ps.in_decl) {
 	const char *tp = inp_p(), *e = inp_line_end();
 
+	/* XXX: is_identifier_start */
 	while (tp < e && (isalpha((unsigned char)*tp) ||
 		isspace((unsigned char)*tp)))
 		tp++;



CVS commit: src/usr.bin/indent

2021-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 19:15:55 UTC 2021

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

Log Message:
indent: merge duplicate code into is_identifier_part

No functional change.


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

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



CVS commit: src

2021-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 19:37:13 UTC 2021

Modified Files:
src/tests/usr.bin/indent: fmt_decl.c opt_bacc.c
src/usr.bin/indent: lexi.c

Log Message:
indent: fix formatting of function definitions (since 2019-04-04)

In the definition of a function with a pointer return type, the
formatting depended on the name of the function.  Function names
matching [A-Za-z+] were formatted correctly, those containing [$0-9_]
weren't.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/tests/usr.bin/indent/fmt_decl.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/opt_bacc.c
cvs rdiff -u -r1.145 -r1.146 src/usr.bin/indent/lexi.c

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



CVS commit: src

2021-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 19:37:13 UTC 2021

Modified Files:
src/tests/usr.bin/indent: fmt_decl.c opt_bacc.c
src/usr.bin/indent: lexi.c

Log Message:
indent: fix formatting of function definitions (since 2019-04-04)

In the definition of a function with a pointer return type, the
formatting depended on the name of the function.  Function names
matching [A-Za-z+] were formatted correctly, those containing [$0-9_]
weren't.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/tests/usr.bin/indent/fmt_decl.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/opt_bacc.c
cvs rdiff -u -r1.145 -r1.146 src/usr.bin/indent/lexi.c

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

Modified files:

Index: src/tests/usr.bin/indent/fmt_decl.c
diff -u src/tests/usr.bin/indent/fmt_decl.c:1.17 src/tests/usr.bin/indent/fmt_decl.c:1.18
--- src/tests/usr.bin/indent/fmt_decl.c:1.17	Fri Nov 19 18:55:10 2021
+++ src/tests/usr.bin/indent/fmt_decl.c	Fri Nov 19 19:37:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: fmt_decl.c,v 1.17 2021/11/19 18:55:10 rillig Exp $	*/
+/*	$NetBSD: fmt_decl.c,v 1.18 2021/11/19 19:37:13 rillig Exp $	*/
 /* $FreeBSD: head/usr.bin/indent/tests/declarations.0 334478 2018-06-01 09:41:15Z pstef $ */
 
 /* See FreeBSD r303570 */
@@ -160,22 +160,6 @@ MAXALIGN(offsetof(int, test)) + MAXIMUM_
 
 
 #indent input
-int *int_create(void)
-{
-
-}
-#indent end
-
-#indent run
-int	   *
-int_create(void)
-{
-
-}
-#indent end
-
-
-#indent input
 static
 _attribute_printf(1, 2)
 void
@@ -437,6 +421,9 @@ main(void)
  * In some ancient time long before ISO C90, variable declarations with
  * initializer could be written without '='. The C Programming Language from
  * 1978 doesn't mention this form anymore.
+ *
+ * Before NetBSD lexi.c 1.123 from 2021-10-31, indent treated the '-' as a
+ * unary operator.
  */
 #indent input
 int a - 1;
@@ -454,8 +441,11 @@ int a - 1;
 
 
 /*
- * Since 2019-04-04, the indentation of the '*' depends on the function name,
- * which does not make sense.
+ * Between 2019-04-04 and before lexi.c 1.146 from 2021-11-09, the indentation
+ * of the '*' depended on the function name, which did not make sense.  For
+ * function names that matched [A-Za-z]+, the '*' was placed correctly, for
+ * all other function names (containing [$0-9_]) the '*' was right-aligned on
+ * declaration indentation, which defaults to 16.
  */
 #indent input
 int *
@@ -467,21 +457,15 @@ int *
 yy(void)
 {
 }
-#indent end
-
-/* FIXME: Both function definitions must be formatted in the same way. */
-#indent run
-int	   *
-f2(void)
-{
-}
 
 int *
-yy(void)
+int_create(void)
 {
 }
 #indent end
 
+#indent run-equals-input
+
 
 /*
  * Since 2019-04-04, the space between the '){' is missing.

Index: src/tests/usr.bin/indent/opt_bacc.c
diff -u src/tests/usr.bin/indent/opt_bacc.c:1.4 src/tests/usr.bin/indent/opt_bacc.c:1.5
--- src/tests/usr.bin/indent/opt_bacc.c:1.4	Wed Oct 20 05:14:21 2021
+++ src/tests/usr.bin/indent/opt_bacc.c	Fri Nov 19 19:37:13 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: opt_bacc.c,v 1.4 2021/10/20 05:14:21 rillig Exp $ */
+/* $NetBSD: opt_bacc.c,v 1.5 2021/11/19 19:37:13 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*
@@ -86,8 +86,7 @@ os_name(void)
 #indent end
 
 #indent run -bacc
-/* $ XXX: The '*' should not be set apart from the rest of the return type. */
-const char *
+const char *
 os_name(void)
 {
 /* $ FIXME: expecting a blank line here. */
@@ -104,14 +103,4 @@ os_name(void)
 }
 #indent end
 
-#indent run -nbacc
-const char *
-os_name(void)
-{
-#if defined(__NetBSD__) || defined(__FreeBSD__)
-	return "BSD";
-#else
-	return "unknown";
-#endif
-}
-#indent end
+#indent run-equals-input -nbacc

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.145 src/usr.bin/indent/lexi.c:1.146
--- src/usr.bin/indent/lexi.c:1.145	Fri Nov 19 19:15:55 2021
+++ src/usr.bin/indent/lexi.c	Fri Nov 19 19:37:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: lexi.c,v 1.145 2021/11/19 19:15:55 rillig Exp $	*/
+/*	$NetBSD: lexi.c,v 1.146 2021/11/19 19:37:13 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)lexi.c	8.1 (
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.145 2021/11/19 19:15:55 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.146 2021/11/19 19:37:13 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -350,6 +350,12 @@ lex_number(void)
 }
 
 static bool
+is_identifier_start(char ch)
+{
+return isalpha((unsigned char)ch) || ch == '_' || ch == '$';
+}
+
+static bool
 is_identifier_part(char ch)
 {
 return isalnum((unsigned char)ch) || ch == '_' || ch == '$';
@@ -687,10 +693,16 @@ lexi(void)
 	if (ps.in_decl) {
 	const char *tp = inp_p(), *e = inp_line_end();
 
-	/* XXX: is_identifier_start */
-	while (tp < e 

CVS commit: src/usr.bin/indent

2021-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 20:04:02 UTC 2021

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

Log Message:
indent: fix included headers


To generate a diff of this commit:
cvs rdiff -u -r1.226 -r1.227 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.126 -r1.127 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.226 src/usr.bin/indent/indent.c:1.227
--- src/usr.bin/indent/indent.c:1.226	Fri Nov 19 19:55:15 2021
+++ src/usr.bin/indent/indent.c	Fri Nov 19 20:04:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.226 2021/11/19 19:55:15 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.227 2021/11/19 20:04:02 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.226 2021/11/19 19:55:15 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.227 2021/11/19 20:04:02 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -58,6 +58,7 @@ __FBSDID("$FreeBSD: head/usr.bin/indent/
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.126 src/usr.bin/indent/io.c:1.127
--- src/usr.bin/indent/io.c:1.126	Fri Nov 19 20:01:37 2021
+++ src/usr.bin/indent/io.c	Fri Nov 19 20:04:02 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.126 2021/11/19 20:01:37 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.127 2021/11/19 20:04:02 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,14 +43,13 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.126 2021/11/19 20:01:37 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.127 2021/11/19 20:04:02 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 



CVS commit: src/usr.bin/indent

2021-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 20:04:02 UTC 2021

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

Log Message:
indent: fix included headers


To generate a diff of this commit:
cvs rdiff -u -r1.226 -r1.227 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.126 -r1.127 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-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 20:13:05 UTC 2021

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

Log Message:
indent: keep inbuf.save_com_s and inbuf.save_com_e in sync

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 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-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 20:13:05 UTC 2021

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

Log Message:
indent: keep inbuf.save_com_s and inbuf.save_com_e in sync

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.127 -r1.128 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.127 src/usr.bin/indent/io.c:1.128
--- src/usr.bin/indent/io.c:1.127	Fri Nov 19 20:04:02 2021
+++ src/usr.bin/indent/io.c	Fri Nov 19 20:13:05 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.127 2021/11/19 20:04:02 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.128 2021/11/19 20:13:05 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.127 2021/11/19 20:04:02 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.128 2021/11/19 20:13:05 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -56,7 +56,7 @@ __FBSDID("$FreeBSD: head/usr.bin/indent/
 
 #include "indent.h"
 
-static struct input_buffer {
+static struct {
 struct buffer inp;		/* one line of input, ready to be split into
  * tokens; occasionally this buffer switches
  * to save_com_buf */
@@ -67,7 +67,7 @@ static struct input_buffer {
 
 char *saved_inp_s;		/* saved value of inp.s when taking input from
  * save_com */
-char *saved_inp_e;		/* similarly saved value of inp.e */
+char *saved_inp_e;		/* saved value of inp.e */
 } inbuf;
 
 static int paren_indent;
@@ -258,7 +258,6 @@ inp_comment_complete_block(void)
 bool
 inp_comment_seen(void)
 {
-/* TODO: assert((inbuf.save_com_s != NULL) == (inbuf.save_com_e != NULL)); */
 return inbuf.save_com_e != NULL;
 }
 
@@ -284,7 +283,7 @@ inp_from_comment(void)
 
 inbuf.inp.s = inbuf.save_com_s;	/* redirect lexi input to save_com_s */
 inbuf.inp.e = inbuf.save_com_e;
-/* XXX: what about save_com_s? */
+inbuf.save_com_s = NULL;
 inbuf.save_com_e = NULL;
 debug_inp(__func__);
 }



CVS commit: src/usr.bin/indent

2021-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 20:23:17 UTC 2021

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

Log Message:
indent: reduce casts to unsigned char for character classification

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/usr.bin/indent/args.c
cvs rdiff -u -r1.227 -r1.228 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.97 -r1.98 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.128 -r1.129 src/usr.bin/indent/io.c
cvs rdiff -u -r1.147 -r1.148 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.120 -r1.121 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-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 20:23:17 UTC 2021

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

Log Message:
indent: reduce casts to unsigned char for character classification

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/usr.bin/indent/args.c
cvs rdiff -u -r1.227 -r1.228 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.97 -r1.98 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.128 -r1.129 src/usr.bin/indent/io.c
cvs rdiff -u -r1.147 -r1.148 src/usr.bin/indent/lexi.c
cvs rdiff -u -r1.120 -r1.121 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.70 src/usr.bin/indent/args.c:1.71
--- src/usr.bin/indent/args.c:1.70	Sun Nov  7 18:09:56 2021
+++ src/usr.bin/indent/args.c	Fri Nov 19 20:23:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: args.c,v 1.70 2021/11/07 18:09:56 rillig Exp $	*/
+/*	$NetBSD: args.c,v 1.71 2021/11/19 20:23:17 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,14 +43,13 @@ static char sccsid[] = "@(#)args.c	8.1 (
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: args.c,v 1.70 2021/11/07 18:09:56 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.71 2021/11/19 20:23:17 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/args.c 336318 2018-07-15 21:04:21Z pstef $");
 #endif
 
 /* Read options from profile files and from the command line. */
 
-#include 
 #include 
 #include 
 #include 
@@ -246,8 +245,7 @@ found:
 	errx(1, "%s: argument \"%s\" to option \"-%s\" must be an integer",
 	option_source, arg_arg, p->p_name);
 
-if (!(isdigit((unsigned char)*arg_arg) &&
-	p->i_min <= num && num <= p->i_max))
+if (!(ch_isdigit(*arg_arg) && p->i_min <= num && num <= p->i_max))
 	errx(1,
 	"%s: argument \"%s\" to option \"-%s\" must be between %d and %d",
 	option_source, arg_arg, p->p_name, p->i_min, p->i_max);
@@ -277,7 +275,7 @@ load_profile(const char *fname, bool mus
 		comment_ch = '*';
 	} else if (comment_ch != -1) {
 		comment_ch = ch == '/' && comment_ch == '*' ? -1 : ch;
-	} else if (isspace((unsigned char)ch)) {
+	} else if (ch_isspace((char)ch)) {
 		break;
 	} else if (n >= array_length(buf) - 5) {
 		errx(1, "buffer overflow in %s, starting with '%.10s'",

Index: src/usr.bin/indent/indent.c
diff -u src/usr.bin/indent/indent.c:1.227 src/usr.bin/indent/indent.c:1.228
--- src/usr.bin/indent/indent.c:1.227	Fri Nov 19 20:04:02 2021
+++ src/usr.bin/indent/indent.c	Fri Nov 19 20:23:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.227 2021/11/19 20:04:02 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.228 2021/11/19 20:23:17 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.227 2021/11/19 20:04:02 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.228 2021/11/19 20:23:17 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -54,7 +54,6 @@ __FBSDID("$FreeBSD: head/usr.bin/indent/
 #include 
 #endif
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -266,7 +265,7 @@ search_stmt_lbrace(void)
 	 * will be moved into "the else's line", so if there was a newline
 	 * resulting from the "{" before, it must be scanned now and ignored.
 	 */
-	while (isspace((unsigned char)inp_peek())) {
+	while (ch_isspace(inp_peek())) {
 	inp_skip();
 	if (inp_peek() == '\n')
 		break;

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.97 src/usr.bin/indent/indent.h:1.98
--- src/usr.bin/indent/indent.h:1.97	Fri Nov 19 19:55:15 2021
+++ src/usr.bin/indent/indent.h	Fri Nov 19 20:23:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.97 2021/11/19 19:55:15 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.98 2021/11/19 20:23:17 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -68,6 +68,7 @@
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.h 336333 2018-07-16 05:46:50Z pstef $");
 #endif
 
+#include 
 #include 
 #include 
 
@@ -407,11 +408,35 @@ char *xstrdup(const char *);
 void buf_expand(struct buffer *, size_t);
 
 static inline bool
+ch_isalnum(char ch)
+{
+return isalnum((unsigned char)ch) != 0;
+}
+
+static inline bool
+ch_isalpha(char ch)
+{
+return isalpha((unsigned char)ch) != 0;
+}
+
+static inline bool
 ch_isblank(char ch)
 {
 return ch == ' ' || ch == '\t';
 }
 
+static inline bool
+ch_isdigit(char ch)
+{
+return '0' <= ch && ch <= '9';
+}
+
+static inline bool
+ch_isspace(char ch)
+{
+return isspace((unsigned char)ch) != 0;
+}
+
 static inline int
 next_tab(int ind)
 {

Index: src/usr.bin/indent/io.c
diff -u 

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

2021-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 22:24:29 UTC 2021

Modified Files:
src/tests/usr.bin/indent: fmt_block.c fmt_decl.c fmt_else_comment.c
fmt_expr.c indent_off_on.c lex_char.c lex_ident.c lex_string.c
lsym_offsetof.c opt_P.c opt_T.c opt_bacc.c opt_badp.c opt_bap.c
opt_bap_sob.c opt_bbb.c opt_bc.c opt_bl_br.c opt_bs.c opt_c.c
opt_cd.c t_misc.sh

Log Message:
tests/indent: refine and extend tests


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/fmt_block.c \
src/tests/usr.bin/indent/fmt_else_comment.c \
src/tests/usr.bin/indent/fmt_expr.c src/tests/usr.bin/indent/lex_char.c \
src/tests/usr.bin/indent/lex_string.c \
src/tests/usr.bin/indent/lsym_offsetof.c src/tests/usr.bin/indent/opt_P.c \
src/tests/usr.bin/indent/opt_T.c src/tests/usr.bin/indent/opt_bap_sob.c \
src/tests/usr.bin/indent/opt_c.c src/tests/usr.bin/indent/opt_cd.c
cvs rdiff -u -r1.18 -r1.19 src/tests/usr.bin/indent/fmt_decl.c
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/indent_off_on.c \
src/tests/usr.bin/indent/opt_bap.c src/tests/usr.bin/indent/opt_bbb.c \
src/tests/usr.bin/indent/opt_bc.c
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/lex_ident.c \
src/tests/usr.bin/indent/opt_bl_br.c
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/opt_bacc.c \
src/tests/usr.bin/indent/opt_bs.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/opt_badp.c
cvs rdiff -u -r1.15 -r1.16 src/tests/usr.bin/indent/t_misc.sh

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



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

2021-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 22:24:29 UTC 2021

Modified Files:
src/tests/usr.bin/indent: fmt_block.c fmt_decl.c fmt_else_comment.c
fmt_expr.c indent_off_on.c lex_char.c lex_ident.c lex_string.c
lsym_offsetof.c opt_P.c opt_T.c opt_bacc.c opt_badp.c opt_bap.c
opt_bap_sob.c opt_bbb.c opt_bc.c opt_bl_br.c opt_bs.c opt_c.c
opt_cd.c t_misc.sh

Log Message:
tests/indent: refine and extend tests


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/indent/fmt_block.c \
src/tests/usr.bin/indent/fmt_else_comment.c \
src/tests/usr.bin/indent/fmt_expr.c src/tests/usr.bin/indent/lex_char.c \
src/tests/usr.bin/indent/lex_string.c \
src/tests/usr.bin/indent/lsym_offsetof.c src/tests/usr.bin/indent/opt_P.c \
src/tests/usr.bin/indent/opt_T.c src/tests/usr.bin/indent/opt_bap_sob.c \
src/tests/usr.bin/indent/opt_c.c src/tests/usr.bin/indent/opt_cd.c
cvs rdiff -u -r1.18 -r1.19 src/tests/usr.bin/indent/fmt_decl.c
cvs rdiff -u -r1.3 -r1.4 src/tests/usr.bin/indent/indent_off_on.c \
src/tests/usr.bin/indent/opt_bap.c src/tests/usr.bin/indent/opt_bbb.c \
src/tests/usr.bin/indent/opt_bc.c
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/indent/lex_ident.c \
src/tests/usr.bin/indent/opt_bl_br.c
cvs rdiff -u -r1.5 -r1.6 src/tests/usr.bin/indent/opt_bacc.c \
src/tests/usr.bin/indent/opt_bs.c
cvs rdiff -u -r1.4 -r1.5 src/tests/usr.bin/indent/opt_badp.c
cvs rdiff -u -r1.15 -r1.16 src/tests/usr.bin/indent/t_misc.sh

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

Modified files:

Index: src/tests/usr.bin/indent/fmt_block.c
diff -u src/tests/usr.bin/indent/fmt_block.c:1.1 src/tests/usr.bin/indent/fmt_block.c:1.2
--- src/tests/usr.bin/indent/fmt_block.c:1.1	Fri Oct 22 19:27:53 2021
+++ src/tests/usr.bin/indent/fmt_block.c	Fri Nov 19 22:24:29 2021
@@ -1,6 +1,15 @@
-/* $NetBSD: fmt_block.c,v 1.1 2021/10/22 19:27:53 rillig Exp $ */
+/* $NetBSD: fmt_block.c,v 1.2 2021/11/19 22:24:29 rillig Exp $ */
 /* $FreeBSD$ */
 
+/*
+ * Tests for formatting blocks of statements and declarations.
+ *
+ * See also:
+ *	lsym_lbrace.c
+ *	psym_stmt.c
+ *	psym_stmt_list.c
+ */
+
 #indent input
 void
 function(void)
@@ -29,3 +38,43 @@ function(void)
 	}
 }
 #indent end
+
+
+/*
+ * Two adjacent blocks must not be merged.  They are typically used in C90 and
+ * earlier to declare local variables with a limited scope.
+ */
+#indent input
+void
+function(void)
+{
+	{}{}
+}
+#indent end
+
+#indent run
+void
+function(void)
+{
+	{
+/* $ FIXME: '{' must start a new line. */
+	} {
+	}
+}
+#indent end
+
+/*
+ * The buggy behavior only occurs with the default setting '-br', which
+ * places an opening brace to the right of the preceding 'if (expr)' or
+ * similar statements.
+ */
+#indent run -bl
+void
+function(void)
+{
+	{
+	}
+	{
+	}
+}
+#indent end
Index: src/tests/usr.bin/indent/fmt_else_comment.c
diff -u src/tests/usr.bin/indent/fmt_else_comment.c:1.1 src/tests/usr.bin/indent/fmt_else_comment.c:1.2
--- src/tests/usr.bin/indent/fmt_else_comment.c:1.1	Fri Oct 22 19:27:53 2021
+++ src/tests/usr.bin/indent/fmt_else_comment.c	Fri Nov 19 22:24:29 2021
@@ -1,19 +1,51 @@
-/*	$NetBSD: fmt_else_comment.c,v 1.1 2021/10/22 19:27:53 rillig Exp $	*/
+/*	$NetBSD: fmt_else_comment.c,v 1.2 2021/11/19 22:24:29 rillig Exp $	*/
 /* $FreeBSD: head/usr.bin/indent/tests/elsecomment.0.pro 314613 2017-03-03 20:15:22Z ngie $ */
 
-/* See r303484 and r309342 */
-
+/*
+ * Tests for comments after 'if (expr)' and 'else'. If the option '-br' is
+ * given (or rather, if '-bl' is not given), indent looks ahead to the
+ * following significant token to see whether it is a '{', it then moves the
+ * comments after the '{'.
+ *
+ * See also:
+ *	FreeBSD r303484
+ *	FreeBSD r309342
+ */
+
+/*
+ * The two 'if' statements below exercise two different code paths, even
+ * though they look very similar.
+ */
 #indent input
 void t(void) {
-	/* The two if statements below excercise two different code paths. */
-
 	if (1) /* a */ int a; else /* b */ int b;
 
 	if (1) /* a */
 		int a;
 	else /* b */
 		int b;
+}
+#indent end
 
+#indent run
+void
+t(void)
+{
+	if (1)			/* a */
+		int		a;
+	else			/* b */
+		int		b;
+
+	if (1)			/* a */
+		int		a;
+	else			/* b */
+		int		b;
+}
+#indent end
+
+
+#indent input
+void t(void) {
 	if (1) {
 
 	}
@@ -50,18 +82,6 @@ void t(void) {
 void
 t(void)
 {
-	/* The two if statements below excercise two different code paths. */
-
-	if (1)			/* a */
-		int		a;
-	else			/* b */
-		int		b;
-
-	if (1)			/* a */
-		int		a;
-	else			/* b */
-		int		b;
-
 	if (1)
 	{
 
Index: src/tests/usr.bin/indent/fmt_expr.c
diff -u src/tests/usr.bin/indent/fmt_expr.c:1.1 src/tests/usr.bin/indent/fmt_expr.c:1.2
--- src/tests/usr.bin/indent/fmt_expr.c:1.1	Sat Oct 23 20:17:08 2021
+++ src/tests/usr.bin/indent/fmt_expr.c	Fri Nov 19 22:24:29 2021
@@ -1,14 +1,16 @@
-/* $NetBSD: 

CVS commit: src/usr.bin/indent

2021-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 19:55:15 UTC 2021

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

Log Message:
indent: replace ps.procname with ps.is_function_definition

Omly the first character of ps.procname was ever read, and it was only
compared to '\0'.  Using a bool for this means simpler code, less
memory and fewer wasted CPU cycles due to the removed strncpy.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.225 -r1.226 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.96 -r1.97 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.124 -r1.125 src/usr.bin/indent/io.c
cvs rdiff -u -r1.146 -r1.147 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-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 19:55:15 UTC 2021

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

Log Message:
indent: replace ps.procname with ps.is_function_definition

Omly the first character of ps.procname was ever read, and it was only
compared to '\0'.  Using a bool for this means simpler code, less
memory and fewer wasted CPU cycles due to the removed strncpy.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.225 -r1.226 src/usr.bin/indent/indent.c
cvs rdiff -u -r1.96 -r1.97 src/usr.bin/indent/indent.h
cvs rdiff -u -r1.124 -r1.125 src/usr.bin/indent/io.c
cvs rdiff -u -r1.146 -r1.147 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.225 src/usr.bin/indent/indent.c:1.226
--- src/usr.bin/indent/indent.c:1.225	Fri Nov 19 18:14:18 2021
+++ src/usr.bin/indent/indent.c	Fri Nov 19 19:55:15 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.c,v 1.225 2021/11/19 18:14:18 rillig Exp $	*/
+/*	$NetBSD: indent.c,v 1.226 2021/11/19 19:55:15 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)indent.c	5.1
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.225 2021/11/19 18:14:18 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.226 2021/11/19 19:55:15 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -671,7 +671,7 @@ process_lparen_or_lbracket(int decl_ind,
 
 if (token.s[0] == '(' && ps.in_decl
 	&& !ps.block_init && !ps.decl_indent_done &&
-	ps.procname[0] == '\0' && ps.paren_level == 0) {
+	!ps.is_function_definition && ps.paren_level == 0) {
 	/* function pointer declarations */
 	code_add_decl_indent(decl_ind, tabs_to_var);
 	ps.decl_indent_done = true;
@@ -756,7 +756,7 @@ static void
 process_unary_op(int decl_ind, bool tabs_to_var)
 {
 if (!ps.decl_indent_done && ps.in_decl && !ps.block_init &&
-	ps.procname[0] == '\0' && ps.paren_level == 0) {
+	!ps.is_function_definition && ps.paren_level == 0) {
 	/* pointer declarations */
 	code_add_decl_indent(decl_ind - (int)buf_len(), tabs_to_var);
 	ps.decl_indent_done = true;
@@ -1119,7 +1119,7 @@ process_comma(int decl_ind, bool tabs_to
 ps.want_blank = code.s != code.e;	/* only put blank after comma if comma
 	 * does not start the line */
 
-if (ps.in_decl && ps.procname[0] == '\0' && !ps.block_init &&
+if (ps.in_decl && !ps.is_function_definition && !ps.block_init &&
 	!ps.decl_indent_done && ps.paren_level == 0) {
 	/* indent leading commas and not the actual identifiers */
 	code_add_decl_indent(decl_ind - 1, tabs_to_var);

Index: src/usr.bin/indent/indent.h
diff -u src/usr.bin/indent/indent.h:1.96 src/usr.bin/indent/indent.h:1.97
--- src/usr.bin/indent/indent.h:1.96	Fri Nov 19 18:25:50 2021
+++ src/usr.bin/indent/indent.h	Fri Nov 19 19:55:15 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: indent.h,v 1.96 2021/11/19 18:25:50 rillig Exp $	*/
+/*	$NetBSD: indent.h,v 1.97 2021/11/19 19:55:15 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -256,10 +256,7 @@ extern struct parser_state {
 bool next_unary;		/* whether the following operator should be
  * unary */
 
-char procname[100];		/* The name of the current procedure; TODO:
- * document the difference between procname[0]
- * being '\0', ' ' and a real character */
-
+bool is_function_definition;
 
 bool want_blank;		/* whether the following token should be
  * prefixed by a blank. (Said prefixing is

Index: src/usr.bin/indent/io.c
diff -u src/usr.bin/indent/io.c:1.124 src/usr.bin/indent/io.c:1.125
--- src/usr.bin/indent/io.c:1.124	Fri Nov 19 18:25:50 2021
+++ src/usr.bin/indent/io.c	Fri Nov 19 19:55:15 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.124 2021/11/19 18:25:50 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.125 2021/11/19 19:55:15 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.124 2021/11/19 18:25:50 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.125 2021/11/19 19:55:15 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -449,7 +449,7 @@ output_line(char line_terminator)
 {
 static bool first_line = true;
 
-ps.procname[0] = '\0';
+ps.is_function_definition = false;
 
 if (code.s == code.e && lab.s == lab.e && com.s == com.e) {
 	if (suppress_blanklines)

Index: src/usr.bin/indent/lexi.c
diff -u src/usr.bin/indent/lexi.c:1.146 src/usr.bin/indent/lexi.c:1.147
--- src/usr.bin/indent/lexi.c:1.146	Fri Nov 19 19:37:13 2021
+++ src/usr.bin/indent/lexi.c	Fri Nov 19 19:55:15 2021
@@ 

CVS commit: src/usr.bin/indent

2021-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 20:01:37 UTC 2021

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

Log Message:
indent: clean up io.c

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 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-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 20:01:37 UTC 2021

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

Log Message:
indent: clean up io.c

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.125 -r1.126 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.125 src/usr.bin/indent/io.c:1.126
--- src/usr.bin/indent/io.c:1.125	Fri Nov 19 19:55:15 2021
+++ src/usr.bin/indent/io.c	Fri Nov 19 20:01:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: io.c,v 1.125 2021/11/19 19:55:15 rillig Exp $	*/
+/*	$NetBSD: io.c,v 1.126 2021/11/19 20:01:37 rillig Exp $	*/
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)io.c	8.1 (Be
 
 #include 
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.125 2021/11/19 19:55:15 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.126 2021/11/19 20:01:37 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -153,11 +153,8 @@ debug_inp(const char *prefix)
 			inbuf.saved_inp_s, inbuf.saved_inp_e, "\"");
 debug_printf("\n");
 }
-#else
-#define debug_inp(prefix) do { } while (false)
 #endif
 
-
 static void
 inp_comment_check_size(size_t n)
 {
@@ -200,10 +197,14 @@ inp_comment_init_comment(void)
  * input.inp.s), as that data can easily get lost.
  */
 /*
- * FIXME: This '4' needs an explanation. For example, in the snippet
+ * FIXME: The '4' below is completely wrong. For example, in the snippet
  * 'if(expr)/''*comment', the 'r)' of the code is not copied. If there
  * is an additional line break before the ')', memcpy tries to copy
  * (size_t)-1 bytes.
+ *
+ * The original author of this magic number doesn't remember its purpose
+ * anymore, so there is no point in keeping it. The existing tests must
+ * still pass though.
  */
 assert((size_t)(inbuf.inp.s - inbuf.inp.buf) >= 4);
 size_t line_len = (size_t)(inbuf.inp.s - inbuf.inp.buf) - 4;
@@ -214,9 +215,9 @@ inp_comment_init_comment(void)
 inbuf.save_com_s[1] = ' ';	/* see search_stmt_lbrace */
 inbuf.save_com_e = _com_s[2];
 debug_vis_range("search_stmt_comment: before save_com is \"",
-		inbuf.save_com_buf, inbuf.save_com_s, "\"\n");
+	inbuf.save_com_buf, inbuf.save_com_s, "\"\n");
 debug_vis_range("search_stmt_comment: save_com is \"",
-		inbuf.save_com_s, inbuf.save_com_e, "\"\n");
+	inbuf.save_com_s, inbuf.save_com_e, "\"\n");
 }
 
 void



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

2021-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 18:55:10 UTC 2021

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

Log Message:
tests/indent: update comment for the fix from the previous commit


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/tests/usr.bin/indent/fmt_decl.c

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

Modified files:

Index: src/tests/usr.bin/indent/fmt_decl.c
diff -u src/tests/usr.bin/indent/fmt_decl.c:1.16 src/tests/usr.bin/indent/fmt_decl.c:1.17
--- src/tests/usr.bin/indent/fmt_decl.c:1.16	Fri Nov 19 18:52:33 2021
+++ src/tests/usr.bin/indent/fmt_decl.c	Fri Nov 19 18:55:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: fmt_decl.c,v 1.16 2021/11/19 18:52:33 rillig Exp $	*/
+/*	$NetBSD: fmt_decl.c,v 1.17 2021/11/19 18:55:10 rillig Exp $	*/
 /* $FreeBSD: head/usr.bin/indent/tests/declarations.0 334478 2018-06-01 09:41:15Z pstef $ */
 
 /* See FreeBSD r303570 */
@@ -502,8 +502,8 @@ int	   *function_name_20
 
 
 /*
- * Since 2019-04-04, some function names are preserved and others are
- * silently discarded.
+ * Since 2019-04-04 and before lexi.c 1.144 from 2021-11-19, some function
+ * names were preserved while others were silently discarded.
  */
 #indent input
 int *



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

2021-11-19 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Nov 19 18:55:10 UTC 2021

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

Log Message:
tests/indent: update comment for the fix from the previous commit


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/tests/usr.bin/indent/fmt_decl.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-11-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Nov 19 23:46:55 UTC 2021

Modified Files:
src/sys/conf: files
src/sys/dev/ic: ahcisata_core.c ahcisatavar.h
src/sys/dev/pci: ahcisata_pci.c

Log Message:
ahcisata(4): Introduce AHCI_QUIRK_EXTRA_DELAY quirk for devices that
need extra delays as done by AHCISATA_EXTRA_DELAY option.

Enable this quirk for "C600/X79 AHCI". Also add commented out quirk
entries for "Bay Trail SATA (AHCI)" and "Mobile AHCI SATA Controller",
for which non-reproducible failures worked around by extra delays have
been reported.

500 ms of delays inserted by these option/quirk may be too much. Add
AHCISATA_EXTRA_DELAY_MS option to adjust number of delays in ms, like:


options AHCISATA_EXTRA_DELAY_MS=200


Thanks prlw1@ and jun@ for testing!


To generate a diff of this commit:
cvs rdiff -u -r1.1289 -r1.1290 src/sys/conf/files
cvs rdiff -u -r1.104 -r1.105 src/sys/dev/ic/ahcisata_core.c
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/ic/ahcisatavar.h
cvs rdiff -u -r1.60 -r1.61 src/sys/dev/pci/ahcisata_pci.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-11-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Nov 19 23:46:55 UTC 2021

Modified Files:
src/sys/conf: files
src/sys/dev/ic: ahcisata_core.c ahcisatavar.h
src/sys/dev/pci: ahcisata_pci.c

Log Message:
ahcisata(4): Introduce AHCI_QUIRK_EXTRA_DELAY quirk for devices that
need extra delays as done by AHCISATA_EXTRA_DELAY option.

Enable this quirk for "C600/X79 AHCI". Also add commented out quirk
entries for "Bay Trail SATA (AHCI)" and "Mobile AHCI SATA Controller",
for which non-reproducible failures worked around by extra delays have
been reported.

500 ms of delays inserted by these option/quirk may be too much. Add
AHCISATA_EXTRA_DELAY_MS option to adjust number of delays in ms, like:


options AHCISATA_EXTRA_DELAY_MS=200


Thanks prlw1@ and jun@ for testing!


To generate a diff of this commit:
cvs rdiff -u -r1.1289 -r1.1290 src/sys/conf/files
cvs rdiff -u -r1.104 -r1.105 src/sys/dev/ic/ahcisata_core.c
cvs rdiff -u -r1.26 -r1.27 src/sys/dev/ic/ahcisatavar.h
cvs rdiff -u -r1.60 -r1.61 src/sys/dev/pci/ahcisata_pci.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/conf/files
diff -u src/sys/conf/files:1.1289 src/sys/conf/files:1.1290
--- src/sys/conf/files:1.1289	Mon Oct 11 13:42:33 2021
+++ src/sys/conf/files	Fri Nov 19 23:46:54 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files,v 1.1289 2021/10/11 13:42:33 jmcneill Exp $
+#	$NetBSD: files,v 1.1290 2021/11/19 23:46:54 rin Exp $
 #	@(#)files.newconf	7.5 (Berkeley) 5/10/93
 
 version 	20171118
@@ -1036,6 +1036,7 @@ file	dev/ic/ninjaata32.c		njata
 
 # AHCI-compatible SATA controllers
 defflag	opt_ahcisata.h	AHCISATA_EXTRA_DELAY
+defparam opt_ahcisata.h	AHCISATA_EXTRA_DELAY_MS
 define ahcisata_core
 file dev/ic/ahcisata_core.c ahcisata_core
 device ahcisata: ata, ata_dma, ata_udma, sata, sata_fis, sata_pmp, ahcisata_core

Index: src/sys/dev/ic/ahcisata_core.c
diff -u src/sys/dev/ic/ahcisata_core.c:1.104 src/sys/dev/ic/ahcisata_core.c:1.105
--- src/sys/dev/ic/ahcisata_core.c:1.104	Wed Nov 10 17:19:30 2021
+++ src/sys/dev/ic/ahcisata_core.c	Fri Nov 19 23:46:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: ahcisata_core.c,v 1.104 2021/11/10 17:19:30 msaitoh Exp $	*/
+/*	$NetBSD: ahcisata_core.c,v 1.105 2021/11/19 23:46:55 rin Exp $	*/
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.104 2021/11/10 17:19:30 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ahcisata_core.c,v 1.105 2021/11/19 23:46:55 rin Exp $");
 
 #include 
 #include 
@@ -115,6 +115,21 @@ static const struct scsipi_bustype ahci_
 #define ATA_RESET_DELAY 31000 /* 31s for a drive reset */
 #define AHCI_RST_WAIT (ATA_RESET_DELAY / 10)
 
+#ifndef AHCISATA_EXTRA_DELAY_MS
+#define	AHCISATA_EXTRA_DELAY_MS	500	/* XXX need to adjust */
+#endif
+
+#ifdef AHCISATA_EXTRA_DELAY
+#define	AHCISATA_DO_EXTRA_DELAY(sc, chp, msg, flags)			\
+ata_delay(chp, AHCISATA_EXTRA_DELAY_MS, msg, flags)
+#else
+#define	AHCISATA_DO_EXTRA_DELAY(sc, chp, msg, flags)			\
+do {\
+	if ((sc)->sc_ahci_quirks & AHCI_QUIRK_EXTRA_DELAY)		\
+		ata_delay(chp, AHCISATA_EXTRA_DELAY_MS, msg, flags);	\
+} while (0)
+#endif
+
 const struct ata_bustype ahci_ata_bustype = {
 	.bustype_type = SCSIPI_BUSTYPE_ATA,
 	.ata_bio = ahci_ata_bio,
@@ -970,9 +985,7 @@ again:
 	AHCI_READ(sc, AHCI_P_CMD(chp->ch_channel))), DEBUG_PROBE);
 end:
 	ahci_channel_stop(sc, chp, flags);
-#ifdef AHCISATA_EXTRA_DELAY
-	ata_delay(chp, 500, "ahcirst", flags);
-#endif
+	AHCISATA_DO_EXTRA_DELAY(sc, chp, "ahcirst", flags);
 	/* clear port interrupt register */
 	AHCI_WRITE(sc, AHCI_P_IS(chp->ch_channel), 0x);
 	ahci_channel_start(sc, chp, flags,
@@ -996,9 +1009,7 @@ ahci_reset_channel(struct ata_channel *c
 		/* XXX and then ? */
 	}
 	ata_kill_active(chp, KILL_RESET, flags);
-#ifdef AHCISATA_EXTRA_DELAY
-	ata_delay(chp, 500, "ahcirst", flags);
-#endif
+	AHCISATA_DO_EXTRA_DELAY(sc, chp, "ahcirst", flags);
 	/* clear port interrupt register */
 	AHCI_WRITE(sc, AHCI_P_IS(chp->ch_channel), 0x);
 	/* clear SErrors and start operations */
@@ -1068,9 +1079,7 @@ ahci_probe_drive(struct ata_channel *chp
 	switch (sata_reset_interface(chp, sc->sc_ahcit, achp->ahcic_scontrol,
 	achp->ahcic_sstatus, AT_WAIT)) {
 	case SStatus_DET_DEV:
-#ifdef AHCISATA_EXTRA_DELAY
-		ata_delay(chp, 500, "ahcidv", AT_WAIT);
-#endif
+		AHCISATA_DO_EXTRA_DELAY(sc, chp, "ahcidv", AT_WAIT);
 
 		/* Initial value, used in case the soft reset fails */
 		sig = AHCI_READ(sc, AHCI_P_SIG(chp->ch_channel));
@@ -1109,10 +1118,11 @@ ahci_probe_drive(struct ata_channel *chp
 		AHCI_P_IX_IFS |
 		AHCI_P_IX_OFS | AHCI_P_IX_DPS | AHCI_P_IX_UFS |
 		AHCI_P_IX_PSS | AHCI_P_IX_DHRS | AHCI_P_IX_SDBS);
-#ifdef AHCISATA_EXTRA_DELAY
-		/* wait 500ms before actually starting operations */
-		ata_delay(chp, 500, "ahciprb", AT_WAIT);
-#endif
+		/*
+		 * optionally, wait 

CVS commit: src/bin/sh

2021-11-19 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat Nov 20 01:52:51 UTC 2021

Modified Files:
src/bin/sh: sh.1

Log Message:
Improve the wording of the "Argument List Processing" section (where
all the sh options, also used with "set", are listed) in response to
a discussion on icb conveyed to me by Darrin B. Jewell.
A few improvements to the description of the "set" built-in as well.

Bump Dd to cover all of this month's changes (so far).


To generate a diff of this commit:
cvs rdiff -u -r1.238 -r1.239 src/bin/sh/sh.1

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



CVS commit: src/bin/sh

2021-11-19 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Sat Nov 20 01:52:51 UTC 2021

Modified Files:
src/bin/sh: sh.1

Log Message:
Improve the wording of the "Argument List Processing" section (where
all the sh options, also used with "set", are listed) in response to
a discussion on icb conveyed to me by Darrin B. Jewell.
A few improvements to the description of the "set" built-in as well.

Bump Dd to cover all of this month's changes (so far).


To generate a diff of this commit:
cvs rdiff -u -r1.238 -r1.239 src/bin/sh/sh.1

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

Modified files:

Index: src/bin/sh/sh.1
diff -u src/bin/sh/sh.1:1.238 src/bin/sh/sh.1:1.239
--- src/bin/sh/sh.1:1.238	Tue Nov 16 23:39:34 2021
+++ src/bin/sh/sh.1	Sat Nov 20 01:52:51 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: sh.1,v 1.238 2021/11/16 23:39:34 rillig Exp $
+.\"	$NetBSD: sh.1,v 1.239 2021/11/20 01:52:51 kre Exp $
 .\" Copyright (c) 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
 .\"
@@ -31,7 +31,7 @@
 .\"
 .\"	@(#)sh.1	8.6 (Berkeley) 5/4/95
 .\"
-.Dd October 31, 2021
+.Dd November 20, 2021
 .Dt SH 1
 .\" everything except c o and s (keep them ordered)
 .ds flags abCEeFfhIiLmnpquVvXx
@@ -266,12 +266,24 @@ or
 only, either on the command line, or with the
 .Ic set
 built-in command.
+Those are listed in the table below after the options
+with a one letter, flag, equivalent.
+.Pp
 Other options described are for the command line only.
 Specifying a dash
 .Dq Cm \-
 turns the option on, while using a plus
 .Dq Cm +
 disables the option.
+This may seem counter-intuitive, but is in line with the
+common practice where
+.Ic cmd Fl x
+runs
+.Ic cmd
+with the
+.Sq x
+option set.
+.Pp
 The following options can be set from the command line and,
 unless otherwise stated, with the
 .Ic set
@@ -371,6 +383,16 @@ Ignore EOFs from input when interactive.
 (After a large number of consecutive EOFs the shell will exit anyway.)
 .It Fl i Em interactive
 Force the shell to behave interactively.
+If not set on the command line,
+this option is set automatically at shell startup if
+the shell is reading from standard input (no
+.Fl c ,
+or
+.Ar command_file
+given at invocation of
+.Nm ) ,
+and standard input and standard error refer to
+terminmal type devices.
 .It Fl L Em local_lineno
 When set, before a function is defined,
 causes the variable
@@ -389,7 +411,7 @@ For more details see the section
 .Sx LINENO
 below.
 .It Fl m Em monitor
-Turn on job control (set automatically when interactive).
+Turn on job control (set automatically at shell startup when interactive).
 .It Fl n Em noexec
 Read and parse commands, but do not execute them.
 This is useful for checking the syntax of shell scripts.
@@ -442,7 +464,7 @@ This option has no effect when set or re
 already started reading from the command_file, or from standard input.
 Note that the
 .Fl s
-flag being set does not cause the shell to be interactive.
+flag being set does not, of itself, cause the shell to be interactive.
 .It Fl u Em nounset
 Write a message to standard error when attempting to obtain a
 value from a variable that is not set,
@@ -471,7 +493,7 @@ if it had been set).
 section below.)
 .It Fl v Em verbose
 The shell writes its input to standard error as it is read.
-Useful for debugging.
+Perhaps ocassionally useful for some debugging.
 .It Fl X Em xlock
 Cause output from the
 .Ic xtrace
@@ -503,12 +525,30 @@ is set,
 means that which existed immediately before any redirections to
 be applied to the command are performed.
 Useful for debugging.
+.El
+.Pp
+The following options have no one letter variant,
+and are used only in conjunction with
+.Fl o
+or
+.Cm +o ,
+either on the command line, or via the
+.Ic set
+built-in command.
+.Bl -tag -width ".Fl L Em local_lineno" -offset indent
 .It "\ \ " Em cdprint
 Make an interactive shell always print the new directory name when
 changed by the
 .Ic cd
 command.
-In a non-interactive shell this option has no effect.
+In a non-interactive shell this option has no effect
+unless the
+.Em posix
+option is set.
+However,
+.Em cdprint
+is an extension to POSIX, so these two options should
+rarely be set at the same time.
 .It "\ \ " Em nolog
 Prevent the entry of function definitions into the command history (see
 .Ic fc
@@ -3579,12 +3619,17 @@ command instead, if you want to return f
 your shell.
 .\"
 .Pp
-.It Ic set Oo { Fl options | Cm +options | Cm \-- } Oc Ar arg ...
+.It set
+.It set { Fl o | Cm +o }
+.It Ic set Oo { Fl options | Cm +options } ... Oc Oo Cm \-\|\- Oc Oo Ar arg ... Oc
+.Pp
 The
 .Ic set
 command performs four different functions.
 .Pp
-With no arguments, it lists the values of all shell variables.
+With no arguments,
+.Ic set
+lists the names and values of all set shell variables.
 .Pp
 With a single option of either
 .Dq Fl o
@@ -3604,7 +3649,11 @@ If options are given, it sets the specif
 flags, or clears 

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

2021-11-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Nov 20 00:17:10 UTC 2021

Modified Files:
src/sys/arch/zaurus/dev: w100.c

Log Message:
- Accept anti-aliased fonts.
- Clear garbage from screen when attach.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/zaurus/dev/w100.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/zaurus/dev/w100.c
diff -u src/sys/arch/zaurus/dev/w100.c:1.3 src/sys/arch/zaurus/dev/w100.c:1.4
--- src/sys/arch/zaurus/dev/w100.c:1.3	Sat Nov 21 17:22:03 2020
+++ src/sys/arch/zaurus/dev/w100.c	Sat Nov 20 00:17:10 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: w100.c,v 1.3 2020/11/21 17:22:03 thorpej Exp $ */
+/* $NetBSD: w100.c,v 1.4 2021/11/20 00:17:10 rin Exp $ */
 /*
  * Copyright (c) 2002, 2003  Genetec Corporation.  All rights reserved.
  * Written by Hiroyuki Bessho for Genetec Corporation.
@@ -28,7 +28,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__KERNEL_RCSID(0, "$NetBSD: w100.c,v 1.3 2020/11/21 17:22:03 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: w100.c,v 1.4 2021/11/20 00:17:10 rin Exp $");
 
 #include 
 #include 
@@ -257,7 +257,7 @@ w100_setup_rasops(struct w100_softc *sc,
 struct w100_wsscreen_descr *descr, const struct w100_panel_geometry *geom)
 {
 
-	rinfo->ri_flg = descr->flags;
+	rinfo->ri_flg = descr->flags | RI_CLEAR | RI_ENABLE_ALPHA;
 	rinfo->ri_depth = descr->depth;
 	rinfo->ri_width = sc->display_width;
 	rinfo->ri_height = sc->display_height;



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

2021-11-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Nov 20 00:17:10 UTC 2021

Modified Files:
src/sys/arch/zaurus/dev: w100.c

Log Message:
- Accept anti-aliased fonts.
- Clear garbage from screen when attach.


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

2021-11-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Nov 20 00:23:51 UTC 2021

Modified Files:
src/sys/arch/hpcarm/conf: WZERO3

Log Message:
Add commented out FONT_DROID_SANS_MONO10x20 option. This enables 80x24
terminal on WVGA models, which is slightly easier on the eyes ;)


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/hpcarm/conf/WZERO3

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



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

2021-11-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Nov 20 00:23:51 UTC 2021

Modified Files:
src/sys/arch/hpcarm/conf: WZERO3

Log Message:
Add commented out FONT_DROID_SANS_MONO10x20 option. This enables 80x24
terminal on WVGA models, which is slightly easier on the eyes ;)


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/hpcarm/conf/WZERO3

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/hpcarm/conf/WZERO3
diff -u src/sys/arch/hpcarm/conf/WZERO3:1.53 src/sys/arch/hpcarm/conf/WZERO3:1.54
--- src/sys/arch/hpcarm/conf/WZERO3:1.53	Sat Apr 18 11:00:41 2020
+++ src/sys/arch/hpcarm/conf/WZERO3	Sat Nov 20 00:23:51 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: WZERO3,v 1.53 2020/04/18 11:00:41 skrll Exp $
+#	$NetBSD: WZERO3,v 1.54 2021/11/20 00:23:51 rin Exp $
 #
 #	WZERO3 -- Sharp Windows Mobile 5 based PDA
 #
@@ -8,7 +8,7 @@ include	"arch/hpcarm/conf/files.wzero3"
 
 #options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.53 $"
+#ident 		"GENERIC-$Revision: 1.54 $"
 
 # estimated number of users
 maxusers	32
@@ -122,6 +122,9 @@ options 	WS_KERNEL_FG=WSCOL_GREEN
 
 options 	FONT_VT220L8x16
 
+# 80x24 terminal on WVGA models
+#options 	FONT_DROID_SANS_MONO10x20
+
 # Alternate buffer queue strategies for better responsiveness under high
 # disk I/O load.
 #options 	BUFQ_READPRIO



CVS commit: src/lib/libc/sys

2021-11-19 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Fri Nov 19 23:51:17 UTC 2021

Modified Files:
src/lib/libc/sys: chmod.2

Log Message:
Mention that fchmod conforms to XPG 4.2. Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/lib/libc/sys/chmod.2

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



CVS commit: src/lib/libc/sys

2021-11-19 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Fri Nov 19 23:51:17 UTC 2021

Modified Files:
src/lib/libc/sys: chmod.2

Log Message:
Mention that fchmod conforms to XPG 4.2. Bump date.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/lib/libc/sys/chmod.2

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

Modified files:

Index: src/lib/libc/sys/chmod.2
diff -u src/lib/libc/sys/chmod.2:1.48 src/lib/libc/sys/chmod.2:1.49
--- src/lib/libc/sys/chmod.2:1.48	Sun Sep  1 19:13:57 2019
+++ src/lib/libc/sys/chmod.2	Fri Nov 19 23:51:16 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: chmod.2,v 1.48 2019/09/01 19:13:57 sevan Exp $
+.\"	$NetBSD: chmod.2,v 1.49 2021/11/19 23:51:16 wiz Exp $
 .\"
 .\" Copyright (c) 1980, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)chmod.2	8.1 (Berkeley) 6/4/93
 .\"
-.Dd September 1, 2019
+.Dd November 20, 2021
 .Dt CHMOD 2
 .Os
 .Sh NAME
@@ -283,6 +283,11 @@ The
 .Fn chmod
 function conforms to
 .St -p1003.1-90 .
+The
+.Fn fchmod
+function conforms to
+.St -xpg4.2 .
+The
 .Fn fchmodat
 function conforms to
 .St -p1003.1-2008 .



CVS commit: src/sys/dev/wsfont

2021-11-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Nov 19 23:50:39 UTC 2021

Modified Files:
src/sys/dev/wsfont: wsfont.c

Log Message:
wsfont_rotate(): Add missing NULL check for wsfont_find0().


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/dev/wsfont/wsfont.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/wsfont

2021-11-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Nov 19 23:50:39 UTC 2021

Modified Files:
src/sys/dev/wsfont: wsfont.c

Log Message:
wsfont_rotate(): Add missing NULL check for wsfont_find0().


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/sys/dev/wsfont/wsfont.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/wsfont/wsfont.c
diff -u src/sys/dev/wsfont/wsfont.c:1.71 src/sys/dev/wsfont/wsfont.c:1.72
--- src/sys/dev/wsfont/wsfont.c:1.71	Mon Nov 23 12:15:39 2020
+++ src/sys/dev/wsfont/wsfont.c	Fri Nov 19 23:50:39 2021
@@ -1,4 +1,4 @@
-/* 	$NetBSD: wsfont.c,v 1.71 2020/11/23 12:15:39 rin Exp $	*/
+/* 	$NetBSD: wsfont.c,v 1.72 2021/11/19 23:50:39 rin Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wsfont.c,v 1.71 2020/11/23 12:15:39 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsfont.c,v 1.72 2021/11/19 23:50:39 rin Exp $");
 
 #include "opt_wsfont.h"
 
@@ -563,6 +563,9 @@ wsfont_rotate(int cookie, int rotate)
 	origfont = wsfont_find0(cookie, 0x);
 	splx(s);
 
+	if (origfont == NULL)
+		return (-1);
+
 	switch (rotate) {
 	case WSFONT_ROTATE_CW:
 		font = wsfont_rotate_cw_internal(origfont->font);



CVS commit: src/sys/dev/wsfont

2021-11-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Nov 19 23:55:16 UTC 2021

Modified Files:
src/sys/dev/wsfont: wsfont.c

Log Message:
Add support to rotate anti-aliased fonts.

wsfont_rotate_{cw,ccw}_internal() have been cleaned up and unified into
new static function wsfont_rotate_internal().


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sys/dev/wsfont/wsfont.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/wsfont

2021-11-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Nov 19 23:55:16 UTC 2021

Modified Files:
src/sys/dev/wsfont: wsfont.c

Log Message:
Add support to rotate anti-aliased fonts.

wsfont_rotate_{cw,ccw}_internal() have been cleaned up and unified into
new static function wsfont_rotate_internal().


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sys/dev/wsfont/wsfont.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/wsfont/wsfont.c
diff -u src/sys/dev/wsfont/wsfont.c:1.72 src/sys/dev/wsfont/wsfont.c:1.73
--- src/sys/dev/wsfont/wsfont.c:1.72	Fri Nov 19 23:50:39 2021
+++ src/sys/dev/wsfont/wsfont.c	Fri Nov 19 23:55:16 2021
@@ -1,4 +1,4 @@
-/* 	$NetBSD: wsfont.c,v 1.72 2021/11/19 23:50:39 rin Exp $	*/
+/* 	$NetBSD: wsfont.c,v 1.73 2021/11/19 23:55:16 rin Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wsfont.c,v 1.72 2021/11/19 23:50:39 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsfont.c,v 1.73 2021/11/19 23:55:16 rin Exp $");
 
 #include "opt_wsfont.h"
 
@@ -418,15 +418,15 @@ wsfont_enum(void (*cb)(const char *, int
 
 #if NRASOPS_ROTATION > 0
 
-struct wsdisplay_font *wsfont_rotate_cw_internal(struct wsdisplay_font *);
-struct wsdisplay_font *wsfont_rotate_ccw_internal(struct wsdisplay_font *);
-
-struct wsdisplay_font *
-wsfont_rotate_cw_internal(struct wsdisplay_font *font)
+static struct wsdisplay_font *
+wsfont_rotate_internal(struct wsdisplay_font *font, int rotate)
 {
-	int b, n, r, namelen, newstride;
 	struct wsdisplay_font *newfont;
-	char *newname, *newbits;
+	char *newname, *newdata;
+	u_char *ch, *newch, *p, *newp;
+	int namelen, newstride, n, h, w;
+	u_char bit;
+	bool alpha = FONT_IS_ALPHA(font), cw = (rotate == WSFONT_ROTATE_CW);
 
 	/* Duplicate the existing font... */
 	newfont = malloc(sizeof(*font), M_DEVBUF, M_WAITOK);
@@ -436,103 +436,58 @@ wsfont_rotate_cw_internal(struct wsdispl
 	namelen = strlen(font->name) + 4;
 	newname = malloc(namelen, M_DEVBUF, M_WAITOK);
 	strlcpy(newname, font->name, namelen);
-	strlcat(newname, "cw", namelen);
+	strlcat(newname, cw ? "cw" : "ccw", namelen);
 	newfont->name = newname;
 
 	/* Allocate a buffer big enough for the rotated font. */
-	newstride = (font->fontheight + 7) / 8;
-	newbits = malloc(newstride * font->fontwidth * font->numchars,
+	newstride = alpha ? font->fontheight : howmany(font->fontheight, 8);
+	newdata = malloc(newstride * font->fontwidth * font->numchars,
 	M_DEVBUF, M_WAITOK|M_ZERO);
 
-	/* Rotate the font a bit at a time. */
-	for (n = 0; n < font->numchars; n++) {
-		unsigned char *ch = (unsigned char *)font->data +
-		(n * font->stride * font->fontheight);
-
-		for (r = 0; r < font->fontheight; r++) {
-			for (b = 0; b < font->fontwidth; b++) {
-unsigned char *rb;
-
-rb = ch + (font->stride * r) + (b / 8);
-if (*rb & (0x80 >> (b % 8))) {
-	unsigned char *rrb;
-
-	rrb = newbits + newstride - 1 - (r / 8)
-	+ (n * newstride * font->fontwidth)
-	+ (newstride * b);
-	*rrb |= (1 << (r % 8));
-}
-			}
-		}
-	}
-
-	newfont->data = newbits;
-
-	/* Update font sizes. */
-	newfont->stride = newstride;
-	newfont->fontwidth = font->fontheight;
-	newfont->fontheight = font->fontwidth;
-
-	if (wsfont_add(newfont, 0) != 0) {
-		/*
-		 * If we seem to have rotated this font already, drop the
-		 * new one...
-		 */
-		free(newbits, M_DEVBUF);
-		free(newfont, M_DEVBUF);
-		newfont = NULL;
-	}
-
-	return (newfont);
-}
-
-struct wsdisplay_font *
-wsfont_rotate_ccw_internal(struct wsdisplay_font *font)
-{
-	int b, n, r, namelen, newstride;
-	struct wsdisplay_font *newfont;
-	char *newname, *newbits;
-
-	/* Duplicate the existing font... */
-	newfont = malloc(sizeof(*font), M_DEVBUF, M_WAITOK);
+#define	BYTE_OFFSET(x, alpha)	((alpha) ? (x) : (x) / 8)
+#define	BIT_FROM_LEFT(x)	__BIT(7 - ((x) % 8))
+#define	BIT_FROM_RIGHT(x)	__BIT((x) % 8)
 
-	*newfont = *font;
-
-	namelen = strlen(font->name) + 4;
-	newname = malloc(namelen, M_DEVBUF, M_WAITOK);
-	strlcpy(newname, font->name, namelen);
-	strlcat(newname, "ccw", namelen);
-	newfont->name = newname;
-
-	/* Allocate a buffer big enough for the rotated font. */
-	newstride = (font->fontheight + 7) / 8;
-	newbits = malloc(newstride * font->fontwidth * font->numchars,
-	M_DEVBUF, M_WAITOK|M_ZERO);
-
-	/* Rotate the font a bit at a time. */
+	/* Rotate the font a pixel at a time. */
 	for (n = 0; n < font->numchars; n++) {
-		unsigned char *ch = (unsigned char *)font->data +
+		ch = (u_char *)font->data +
 		(n * font->stride * font->fontheight);
-
-		for (r = 0; r < font->fontheight; r++) {
-			for (b = 0; b < font->fontwidth; b++) {
-unsigned char *rb;
-
-rb = ch + (font->stride * r) + (b / 8);
-if (*rb & (0x80 >> (b % 8))) {
-	unsigned char *rrb;
-	int w = font->fontwidth;
-
-	rrb = 

CVS commit: src/sys/dev/wsfont

2021-11-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Nov 20 00:00:19 UTC 2021

Modified Files:
src/sys/dev/wsfont: files.wsfont wsfont.c

Log Message:
Sort Droid Sans Mono family fonts by size.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/wsfont/files.wsfont
cvs rdiff -u -r1.73 -r1.74 src/sys/dev/wsfont/wsfont.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/wsfont

2021-11-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Nov 20 00:00:19 UTC 2021

Modified Files:
src/sys/dev/wsfont: files.wsfont wsfont.c

Log Message:
Sort Droid Sans Mono family fonts by size.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/wsfont/files.wsfont
cvs rdiff -u -r1.73 -r1.74 src/sys/dev/wsfont/wsfont.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/wsfont/files.wsfont
diff -u src/sys/dev/wsfont/files.wsfont:1.28 src/sys/dev/wsfont/files.wsfont:1.29
--- src/sys/dev/wsfont/files.wsfont:1.28	Sat Nov 21 23:00:02 2020
+++ src/sys/dev/wsfont/files.wsfont	Sat Nov 20 00:00:19 2021
@@ -1,4 +1,4 @@
-# 	$NetBSD: files.wsfont,v 1.28 2020/11/21 23:00:02 rin Exp $
+# 	$NetBSD: files.wsfont,v 1.29 2021/11/20 00:00:19 rin Exp $
 
 defpseudo wsfont
 
@@ -25,8 +25,8 @@ defflag	opt_wsfont.h		FONT_BOLD8x16
 FONT_SONY12x24
 FONT_OMRON12x20
 FONT_DEJAVU_SANS_MONO12x22
-FONT_DROID_SANS_MONO12x22
 FONT_DROID_SANS_MONO9x18
+FONT_DROID_SANS_MONO12x22
 FONT_DROID_SANS_MONO19x36
 FONT_GO_MONO12x23
 FONT_SPLEEN5x8

Index: src/sys/dev/wsfont/wsfont.c
diff -u src/sys/dev/wsfont/wsfont.c:1.73 src/sys/dev/wsfont/wsfont.c:1.74
--- src/sys/dev/wsfont/wsfont.c:1.73	Fri Nov 19 23:55:16 2021
+++ src/sys/dev/wsfont/wsfont.c	Sat Nov 20 00:00:19 2021
@@ -1,4 +1,4 @@
-/* 	$NetBSD: wsfont.c,v 1.73 2021/11/19 23:55:16 rin Exp $	*/
+/* 	$NetBSD: wsfont.c,v 1.74 2021/11/20 00:00:19 rin Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: wsfont.c,v 1.73 2021/11/19 23:55:16 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: wsfont.c,v 1.74 2021/11/20 00:00:19 rin Exp $");
 
 #include "opt_wsfont.h"
 
@@ -130,14 +130,14 @@ __KERNEL_RCSID(0, "$NetBSD: wsfont.c,v 1
 #include 
 #endif
 
-#ifdef FONT_DROID_SANS_MONO12x22
+#ifdef FONT_DROID_SANS_MONO9x18
 #define HAVE_FONT 1
-#include 
+#include 
 #endif
 
-#ifdef FONT_DROID_SANS_MONO9x18
+#ifdef FONT_DROID_SANS_MONO12x22
 #define HAVE_FONT 1
-#include 
+#include 
 #endif
 
 #ifdef FONT_DROID_SANS_MONO19x36



CVS commit: src/sys/dev/wsfont

2021-11-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Nov 20 00:08:23 UTC 2021

Modified Files:
src/sys/dev/wsfont: files.wsfont wsfont.c
Added Files:
src/sys/dev/wsfont: Droid_Sans_Mono_10x20.h

Log Message:
Add Droid_Sans_Mono_10x20, generated by ttf2wsfont(1).

Having 10x20 in addition to 9x18 and 12x22 may seem redundant, but
this font enables nice 80x24 and 80x30 terminals on WVGA (800x480)
and SVGA (800x600) displays, respectively :)


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/dev/wsfont/Droid_Sans_Mono_10x20.h
cvs rdiff -u -r1.29 -r1.30 src/sys/dev/wsfont/files.wsfont
cvs rdiff -u -r1.74 -r1.75 src/sys/dev/wsfont/wsfont.c

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



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

2021-11-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Nov 20 00:15:04 UTC 2021

Modified Files:
src/sys/arch/arm/xscale: pxa2x0_lcd.c

Log Message:
Accept anti-aliased fonts; they are supported by rotated screen found on
hpcarm/WZERO3 and PXA270-based zaurus.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/arm/xscale/pxa2x0_lcd.c

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



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

2021-11-19 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Nov 20 00:15:04 UTC 2021

Modified Files:
src/sys/arch/arm/xscale: pxa2x0_lcd.c

Log Message:
Accept anti-aliased fonts; they are supported by rotated screen found on
hpcarm/WZERO3 and PXA270-based zaurus.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/arm/xscale/pxa2x0_lcd.c

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

Modified files:

Index: src/sys/arch/arm/xscale/pxa2x0_lcd.c
diff -u src/sys/arch/arm/xscale/pxa2x0_lcd.c:1.38 src/sys/arch/arm/xscale/pxa2x0_lcd.c:1.39
--- src/sys/arch/arm/xscale/pxa2x0_lcd.c:1.38	Fri Nov 20 18:49:45 2020
+++ src/sys/arch/arm/xscale/pxa2x0_lcd.c	Sat Nov 20 00:15:04 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: pxa2x0_lcd.c,v 1.38 2020/11/20 18:49:45 thorpej Exp $ */
+/* $NetBSD: pxa2x0_lcd.c,v 1.39 2021/11/20 00:15:04 rin Exp $ */
 
 /*
  * Copyright (c) 2002  Genetec Corporation.  All rights reserved.
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pxa2x0_lcd.c,v 1.38 2020/11/20 18:49:45 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pxa2x0_lcd.c,v 1.39 2021/11/20 00:15:04 rin Exp $");
 
 #include "opt_pxa2x0_lcd.h"
 
@@ -644,7 +644,7 @@ pxa2x0_lcd_setup_rasops(struct pxa2x0_lc
 const struct lcd_panel_geometry *geom)
 {
 
-	rinfo->ri_flg = descr->flags;
+	rinfo->ri_flg = descr->flags | RI_ENABLE_ALPHA;
 	rinfo->ri_depth = descr->depth;
 	rinfo->ri_width = geom->panel_width;
 	rinfo->ri_height = geom->panel_height;
@@ -748,7 +748,7 @@ pxa2x0_lcd_setup_wsscreen(struct pxa2x0_
 	}
 
 	/* let rasops_init calculate # of cols and rows in character */
-	rinfo.ri_flg = 0;
+	rinfo.ri_flg = RI_ENABLE_ALPHA;
 	rinfo.ri_depth = descr->depth;
 	rinfo.ri_bits = NULL;
 	rinfo.ri_width = width;
@@ -806,7 +806,7 @@ pxa2x0_lcd_alloc_screen(void *v, const s
 	/*
 	 * initialize raster operation for this screen.
 	 */
-	scr->rinfo.ri_flg = 0;
+	scr->rinfo.ri_flg = RI_ENABLE_ALPHA;
 	scr->rinfo.ri_depth = type->depth;
 	scr->rinfo.ri_bits = scr->buf_va;
 	scr->rinfo.ri_width = sc->geometry->panel_width;



Re: CVS commit: src/sys

2021-11-19 Thread Rin Okuyama

On 2021/11/20 8:46, Rin Okuyama wrote:

Enable this quirk for "C600/X79 AHCI". Also add commented out quirk
entries for "Bay Trail SATA (AHCI)" and "Mobile AHCI SATA Controller",
for which non-reproducible failures worked around by extra delays have
been reported.


Oops, I meant:

"Mobile AHCI SATA Controller" --> "82801I Mobile AHCI SATA Controller"

Thanks,
rin