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: treat 'complex' and 'imaginary' as ty...



details:   https://anonhg.NetBSD.org/src/rev/e7e5dfee6795
branches:  trunk
changeset: 376623:e7e5dfee6795
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Jun 25 19:29:57 2023 +0000

description:
indent: treat 'complex' and 'imaginary' as type modifiers, not as types

diffstat:

 tests/usr.bin/indent/lsym_storage_class.c |  17 ++++++++++++-----
 usr.bin/indent/lexi.c                     |  12 ++++++------
 2 files changed, 18 insertions(+), 11 deletions(-)

diffs (75 lines):

diff -r 6463ac055180 -r e7e5dfee6795 tests/usr.bin/indent/lsym_storage_class.c
--- a/tests/usr.bin/indent/lsym_storage_class.c Sun Jun 25 19:19:42 2023 +0000
+++ b/tests/usr.bin/indent/lsym_storage_class.c Sun Jun 25 19:29:57 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_storage_class.c,v 1.5 2023/06/04 11:45:00 rillig Exp $ */
+/* $NetBSD: lsym_storage_class.c,v 1.6 2023/06/25 19:29:57 rillig Exp $ */
 
 /*
  * Tests for the token lsym_modifier (formerly named lsym_storage_class), which
@@ -7,9 +7,16 @@
  */
 
 //indent input
-static int definition_with_internal_linkage;
-extern int declaration_with_external_linkage;
-int definition_with_external_linkage;
+static int     definition_with_internal_linkage;
+extern int     declaration_with_external_linkage;
+int            definition_with_external_linkage;
+_Complex double        cd;
+_Imaginary double id;
+complex double cd;
+imaginary double id;
+// The token after a modifier (in this case 'dc') is always interpreted as a
+// type name, therefore it is not indented by 16 but by a single space.
+double complex dc;
 //indent end
 
-//indent run-equals-input -di0
+//indent run-equals-input
diff -r 6463ac055180 -r e7e5dfee6795 usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c     Sun Jun 25 19:19:42 2023 +0000
+++ b/usr.bin/indent/lexi.c     Sun Jun 25 19:29:57 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lexi.c,v 1.234 2023/06/25 19:19:42 rillig Exp $        */
+/*     $NetBSD: lexi.c,v 1.235 2023/06/25 19:29:57 rillig Exp $        */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: lexi.c,v 1.234 2023/06/25 19:19:42 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.235 2023/06/25 19:29:57 rillig Exp $");
 
 #include <stdlib.h>
 #include <string.h>
@@ -51,14 +51,14 @@ static const struct keyword {
        lexer_symbol lsym;
 } keywords[] = {
        {"_Bool", lsym_type},
-       {"_Complex", lsym_type},
-       {"_Imaginary", lsym_type},
+       {"_Complex", lsym_modifier},
+       {"_Imaginary", lsym_modifier},
        {"auto", lsym_modifier},
        {"bool", lsym_type},
        {"break", lsym_word},
        {"case", lsym_case},
        {"char", lsym_type},
-       {"complex", lsym_type},
+       {"complex", lsym_modifier},
        {"const", lsym_modifier},
        {"continue", lsym_word},
        {"default", lsym_default},
@@ -71,7 +71,7 @@ static const struct keyword {
        {"for", lsym_for},
        {"goto", lsym_word},
        {"if", lsym_if},
-       {"imaginary", lsym_type},
+       {"imaginary", lsym_modifier},
        {"inline", lsym_modifier},
        {"int", lsym_type},
        {"long", lsym_type},



Home | Main Index | Thread Index | Old Index