Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/indent indent: remove strange debugging code that we...



details:   https://anonhg.NetBSD.org/src/rev/966c311f3c65
branches:  trunk
changeset: 953562:966c311f3c65
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Mar 13 09:06:12 2021 +0000

description:
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.

diffstat:

 usr.bin/indent/io.c |  18 +++---------------
 1 files changed, 3 insertions(+), 15 deletions(-)

diffs (53 lines):

diff -r 11f2bcb26cd0 -r 966c311f3c65 usr.bin/indent/io.c
--- a/usr.bin/indent/io.c       Sat Mar 13 00:26:56 2021 +0000
+++ b/usr.bin/indent/io.c       Sat Mar 13 09:06:12 2021 +0000
@@ -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 @@
 #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_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 @@
        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 @@
                        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 */



Home | Main Index | Thread Index | Old Index