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: use braces around multi-line statements



details:   https://anonhg.NetBSD.org/src/rev/89c90162e359
branches:  trunk
changeset: 1024022:89c90162e359
user:      rillig <rillig%NetBSD.org@localhost>
date:      Thu Oct 07 21:57:21 2021 +0000

description:
indent: use braces around multi-line statements

No functional change.

diffstat:

 usr.bin/indent/indent.c     |  11 ++++-------
 usr.bin/indent/io.c         |  10 +++++-----
 usr.bin/indent/lexi.c       |   8 ++++----
 usr.bin/indent/pr_comment.c |   7 ++++---
 4 files changed, 17 insertions(+), 19 deletions(-)

diffs (150 lines):

diff -r 5720c3059a95 -r 89c90162e359 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c   Thu Oct 07 21:52:54 2021 +0000
+++ b/usr.bin/indent/indent.c   Thu Oct 07 21:57:21 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: indent.c,v 1.119 2021/10/07 21:52:54 rillig Exp $      */
+/*     $NetBSD: indent.c,v 1.120 2021/10/07 21:57:21 rillig Exp $      */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.119 2021/10/07 21:52:54 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.120 2021/10/07 21:57:21 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
 #endif
@@ -248,9 +248,8 @@
        return false;
     }
 
-    while (sc_end > save_com && isblank((unsigned char)sc_end[-1])) {
+    while (sc_end > save_com && isblank((unsigned char)sc_end[-1]))
        sc_end--;
-    }
 
     if (opt.swallow_optional_blanklines ||
        (!comment_buffered && remove_newlines)) {
@@ -1430,9 +1429,7 @@
        }
 
        *code.e = '\0';
-       if (ttype != comment &&
-           ttype != newline &&
-           ttype != preprocessing)
+       if (ttype != comment && ttype != newline && ttype != preprocessing)
            ps.last_token = ttype;
     }
 }
diff -r 5720c3059a95 -r 89c90162e359 usr.bin/indent/io.c
--- a/usr.bin/indent/io.c       Thu Oct 07 21:52:54 2021 +0000
+++ b/usr.bin/indent/io.c       Thu Oct 07 21:57:21 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: io.c,v 1.77 2021/10/07 21:52:54 rillig Exp $   */
+/*     $NetBSD: io.c,v 1.78 2021/10/07 21:57:21 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.77 2021/10/07 21:52:54 rillig Exp $");
+__RCSID("$NetBSD: io.c,v 1.78 2021/10/07 21:57:21 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/io.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -296,13 +296,13 @@
     int target_ind = opt.indent_size * ps.ind_level;
 
     if (ps.paren_level != 0) {
-       if (!opt.lineup_to_parens)
+       if (!opt.lineup_to_parens) {
            if (2 * opt.continuation_indent == opt.indent_size)
                target_ind += opt.continuation_indent;
            else
                target_ind += opt.continuation_indent * ps.paren_level;
 
-       else if (opt.lineup_to_parens_always)
+       } else if (opt.lineup_to_parens_always) {
            /*
             * XXX: where does this '- 1' come from?  It looks strange but is
             * nevertheless needed for proper indentation, as demonstrated in
@@ -310,7 +310,7 @@
             */
            target_ind = paren_indent - 1;
 
-       else {
+       } else {
            int w;
            int t = paren_indent;
 
diff -r 5720c3059a95 -r 89c90162e359 usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c     Thu Oct 07 21:52:54 2021 +0000
+++ b/usr.bin/indent/lexi.c     Thu Oct 07 21:57:21 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lexi.c,v 1.75 2021/10/07 21:52:54 rillig Exp $ */
+/*     $NetBSD: lexi.c,v 1.76 2021/10/07 21:57:21 rillig Exp $ */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: lexi.c,v 1.75 2021/10/07 21:52:54 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.76 2021/10/07 21:57:21 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -596,11 +596,11 @@
                unary_delim = false;
            }
 
-       } else if (*buf_ptr == '=')
+       } else if (*buf_ptr == '=') {
            /* check for operator += */
            *token.e++ = *buf_ptr++;
 
-       else if (*buf_ptr == '>') {
+       } else if (*buf_ptr == '>') {
            /* check for operator -> */
            *token.e++ = *buf_ptr++;
            unary_delim = false;
diff -r 5720c3059a95 -r 89c90162e359 usr.bin/indent/pr_comment.c
--- a/usr.bin/indent/pr_comment.c       Thu Oct 07 21:52:54 2021 +0000
+++ b/usr.bin/indent/pr_comment.c       Thu Oct 07 21:57:21 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pr_comment.c,v 1.56 2021/10/07 21:52:54 rillig Exp $   */
+/*     $NetBSD: pr_comment.c,v 1.57 2021/10/07 21:57:21 rillig Exp $   */
 
 /*-
  * SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
 
 #include <sys/cdefs.h>
 #if defined(__NetBSD__)
-__RCSID("$NetBSD: pr_comment.c,v 1.56 2021/10/07 21:52:54 rillig Exp $");
+__RCSID("$NetBSD: pr_comment.c,v 1.57 2021/10/07 21:57:21 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/pr_comment.c 334927 2018-06-10 16:44:18Z pstef $");
 #endif
@@ -175,7 +175,7 @@
        *com.e++ = ' ';
 
     /* Don't put a break delimiter if this is a one-liner that won't wrap. */
-    if (break_delim)
+    if (break_delim) {
        for (t_ptr = buf_ptr; *t_ptr != '\0' && *t_ptr != '\n'; t_ptr++) {
            if (t_ptr >= buf_end)
                fill_buffer();
@@ -192,6 +192,7 @@
                break;
            }
        }
+    }
 
     if (break_delim) {
        char *t = com.e;



Home | Main Index | Thread Index | Old Index