Module Name:    src
Committed By:   rillig
Date:           Sat Mar 13 09:06:12 UTC 2021

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

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

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

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

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


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

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

Modified files:

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

Reply via email to