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: explain right-aligned code



details:   https://anonhg.NetBSD.org/src/rev/bee7f07f0d35
branches:  trunk
changeset: 376308:bee7f07f0d35
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Jun 10 07:05:18 2023 +0000

description:
indent: explain right-aligned code

diffstat:

 tests/usr.bin/indent/lsym_case_label.c |   8 +++++---
 usr.bin/indent/debug.c                 |  10 +++++-----
 2 files changed, 10 insertions(+), 8 deletions(-)

diffs (62 lines):

diff -r 65818020f5a4 -r bee7f07f0d35 tests/usr.bin/indent/lsym_case_label.c
--- a/tests/usr.bin/indent/lsym_case_label.c    Sat Jun 10 07:02:26 2023 +0000
+++ b/tests/usr.bin/indent/lsym_case_label.c    Sat Jun 10 07:05:18 2023 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lsym_case_label.c,v 1.9 2023/06/10 06:52:35 rillig Exp $ */
+/* $NetBSD: lsym_case_label.c,v 1.10 2023/06/10 07:05:18 rillig Exp $ */
 
 /*
  * Tests for the tokens lsym_case and lsym_default, which represent the
@@ -92,10 +92,12 @@ const char *type_name = _Generic(
 // $ XXX: It's strange to align the arguments at the parenthesis even though
 // $ XXX: the first argument is already on a separate line.
                                 ' ',
+// $ The indentation is so large that the strings would spill over the right
+// $ margin.  To prevent that, the code is right-aligned.  Since the base
+// $ indentation of this declaration is 0, the code might even start at the
+// $ beginning of the line.
                                 int: "character constants have type 'int'",
-// $ FIXME: The indentation is not sensible in any way.
                               char: "character constants have type 'char'",
-// $ FIXME: The indentation is not sensible in any way.
                         default: "character constants have some other type"
 );
 //indent end
diff -r 65818020f5a4 -r bee7f07f0d35 usr.bin/indent/debug.c
--- a/usr.bin/indent/debug.c    Sat Jun 10 07:02:26 2023 +0000
+++ b/usr.bin/indent/debug.c    Sat Jun 10 07:05:18 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: debug.c,v 1.44 2023/06/10 06:38:20 rillig Exp $        */
+/*     $NetBSD: debug.c,v 1.45 2023/06/10 07:05:18 rillig Exp $        */
 
 /*-
  * Copyright (c) 2023 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: debug.c,v 1.44 2023/06/10 06:38:20 rillig Exp $");
+__RCSID("$NetBSD: debug.c,v 1.45 2023/06/10 07:05:18 rillig Exp $");
 
 #include <stdarg.h>
 
@@ -62,7 +62,7 @@ const char *const lsym_name[] = {
        "postfix_op",
        "binary_op",
        "question",
-       "'?:' colon",
+       "question_colon",
        "comma",
        "typedef",
        "modifier",
@@ -71,8 +71,8 @@ const char *const lsym_name[] = {
        "type_in_parentheses",
        "word",
        "funcname",
-       "label colon",
-       "other colon",
+       "label_colon",
+       "other_colon",
        "semicolon",
        "case",
        "default",



Home | Main Index | Thread Index | Old Index