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: illustrate probably_looking_at_defini...



details:   https://anonhg.NetBSD.org/src/rev/062f253597fe
branches:  trunk
changeset: 1026522:062f253597fe
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sat Nov 27 20:58:16 2021 +0000

description:
indent: illustrate probably_looking_at_definition with examples

No functional change.

diffstat:

 usr.bin/indent/lexi.c |  22 ++++++++++++++--------
 1 files changed, 14 insertions(+), 8 deletions(-)

diffs (53 lines):

diff -r 306130ea1f12 -r 062f253597fe usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c     Sat Nov 27 20:33:39 2021 +0000
+++ b/usr.bin/indent/lexi.c     Sat Nov 27 20:58:16 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: lexi.c,v 1.165 2021/11/27 20:33:39 rillig Exp $        */
+/*     $NetBSD: lexi.c,v 1.166 2021/11/27 20:58:16 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.165 2021/11/27 20:33:39 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.166 2021/11/27 20:58:16 rillig Exp $");
 #elif defined(__FreeBSD__)
 __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
 #endif
@@ -451,7 +451,7 @@
 }
 
 /*
- * Looking at a line starting with 'function_name(something)', guess whether
+ * Looking at something like 'function_name(...)' in a line, guess whether
  * this starts a function definition or a declaration.
  */
 static bool
@@ -463,14 +463,20 @@
            paren_level++;
        if (*p == ')' && --paren_level == 0) {
            p++;
+
            while (p < e && (ch_isspace(*p) || is_identifier_part(*p)))
-               p++;
-           if (p < e && (*p == ';' || *p == ','))
+               p++;            /* '__dead' or '__unused' */
+
+           if (p == e)         /* func(...) */
+               break;
+           if (*p == ';')      /* func(...); */
                return false;
-           if (p < e && *p == '(')
-               paren_level++;
+           if (*p == ',')      /* double abs(), pi; */
+               return false;
+           if (*p == '(')      /* func(...) __attribute__((...)) */
+               paren_level++;  /* func(...) __printflike(...) */
            else
-               break;
+               break;          /* func(...) { ... */
        }
     }
 



Home | Main Index | Thread Index | Old Index