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.
This commit is contained in:
rillig 2021-03-13 09:06:12 +00:00
parent 689a1f7922
commit 6892e0dc50

View File

@ -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 (Berkeley) 6/6/93";
#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 */