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 code that fixes malformed prep...



details:   https://anonhg.NetBSD.org/src/rev/4b5fc6857533
branches:  trunk
changeset: 1026486:4b5fc6857533
user:      rillig <rillig%NetBSD.org@localhost>
date:      Fri Nov 26 14:27:19 2021 +0000

description:
indent: remove code that fixes malformed preprocessor directives

diffstat:

 tests/usr.bin/indent/token_preprocessing.c |  14 +++++---------
 usr.bin/indent/io.c                        |  30 +++---------------------------
 2 files changed, 8 insertions(+), 36 deletions(-)

diffs (86 lines):

diff -r fba595142d03 -r 4b5fc6857533 tests/usr.bin/indent/token_preprocessing.c
--- a/tests/usr.bin/indent/token_preprocessing.c        Fri Nov 26 14:17:01 2021 +0000
+++ b/tests/usr.bin/indent/token_preprocessing.c        Fri Nov 26 14:27:19 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: token_preprocessing.c,v 1.1 2021/10/18 22:30:34 rillig Exp $ */
+/* $NetBSD: token_preprocessing.c,v 1.2 2021/11/26 14:27:19 rillig Exp $ */
 /* $FreeBSD$ */
 
 /*-
@@ -136,8 +136,9 @@
 
 
 /*
- * Preprocessing lines that don't expect an argument but have one are fixed.
- * They are indented with a single tab.
+ * Before io.c 1.135 from 2021-11-26, indent fixed malformed preprocessing
+ * lines that had arguments even though they shouldn't. It is not the task of
+ * an indenter to fix code, that's what a linter is for.
  */
 #indent input
 #if 0
@@ -146,12 +147,7 @@
 #endif 0
 #indent end
 
-#indent run
-#if 0
-#elif 1
-#else  /* if 3 */
-#endif /* 0 */
-#indent end
+#indent run-equals-input
 
 
 /*
diff -r fba595142d03 -r 4b5fc6857533 usr.bin/indent/io.c
--- a/usr.bin/indent/io.c       Fri Nov 26 14:17:01 2021 +0000
+++ b/usr.bin/indent/io.c       Fri Nov 26 14:27:19 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: io.c,v 1.134 2021/11/26 14:17:01 rillig Exp $  */
+/*     $NetBSD: io.c,v 1.135 2021/11/26 14:27:19 rillig Exp $  */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: io.c,v 1.134 2021/11/26 14:17:01 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.135 2021/11/26 14:27:19 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -342,31 +342,7 @@
     *lab.e = '\0';
 
     ind = output_indent(0, compute_label_indent());
-
-    if (lab.s[0] == '#' && (strncmp(lab.s, "#else", 5) == 0
-           || strncmp(lab.s, "#endif", 6) == 0)) {
-       const char *s = lab.s;
-       if (lab.e[-1] == '\n')
-           lab.e--;
-       do {
-           output_char(*s++);
-       } while (s < lab.e && 'a' <= *s && *s <= 'z');
-
-       while (s < lab.e && ch_isblank(*s))
-           s++;
-
-       if (s < lab.e) {
-           if (s[0] == '/' && s[1] == '*') {
-               output_char('\t');
-               output_range(s, lab.e);
-           } else {
-               output_string("\t/* ");
-               output_range(s, lab.e);
-               output_string(" */");
-           }
-       }
-    } else
-       output_range(lab.s, lab.e);
+    output_range(lab.s, lab.e);
     ind = ind_add(ind, lab.s, lab.e);
 
     ps.is_case_label = false;



Home | Main Index | Thread Index | Old Index