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: clean up
details: https://anonhg.NetBSD.org/src/rev/7c2af0aad841
branches: trunk
changeset: 1024721:7c2af0aad841
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Oct 31 22:38:12 2021 +0000
description:
indent: clean up
Initialize buffers in reading order, make comments more expressive,
rename add_typename to register_typename, remove unused macro.
No functional change.
diffstat:
usr.bin/indent/args.c | 8 ++++----
usr.bin/indent/indent.c | 6 +++---
usr.bin/indent/indent.h | 10 +++++-----
usr.bin/indent/lexi.c | 9 +++------
4 files changed, 15 insertions(+), 18 deletions(-)
diffs (138 lines):
diff -r 52513641ebc7 -r 7c2af0aad841 usr.bin/indent/args.c
--- a/usr.bin/indent/args.c Sun Oct 31 22:24:34 2021 +0000
+++ b/usr.bin/indent/args.c Sun Oct 31 22:38:12 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: args.c,v 1.67 2021/10/29 19:52:59 rillig Exp $ */
+/* $NetBSD: args.c,v 1.68 2021/10/31 22:38:12 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -43,7 +43,7 @@
#include <sys/cdefs.h>
#if defined(__NetBSD__)
-__RCSID("$NetBSD: args.c,v 1.67 2021/10/29 19:52:59 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.68 2021/10/31 22:38:12 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/args.c 336318 2018-07-15 21:04:21Z pstef $");
#endif
@@ -142,7 +142,7 @@
while ((fgets(line, BUFSIZ, file)) != NULL) {
/* Remove trailing whitespace */
line[strcspn(line, " \t\n\r")] = '\0';
- add_typename(line);
+ register_typename(line);
}
(void)fclose(file);
}
@@ -184,7 +184,7 @@
arg_end = arg + 1;
if (arg_end[0] == '\0')
goto need_param;
- add_typename(arg_end);
+ register_typename(arg_end);
return true;
}
diff -r 52513641ebc7 -r 7c2af0aad841 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c Sun Oct 31 22:24:34 2021 +0000
+++ b/usr.bin/indent/indent.c Sun Oct 31 22:38:12 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.202 2021/10/31 21:43:43 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.203 2021/10/31 22:38:12 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.202 2021/10/31 21:43:43 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.203 2021/10/31 22:38:12 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
#endif
@@ -507,9 +507,9 @@
buf_init(&token);
- buf_init(&com);
buf_init(&lab);
buf_init(&code);
+ buf_init(&com);
ps.s_sym[0] = psym_stmt_list;
ps.prev_token = lsym_semicolon;
diff -r 52513641ebc7 -r 7c2af0aad841 usr.bin/indent/indent.h
--- a/usr.bin/indent/indent.h Sun Oct 31 22:24:34 2021 +0000
+++ b/usr.bin/indent/indent.h Sun Oct 31 22:38:12 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.h,v 1.73 2021/10/31 20:40:42 rillig Exp $ */
+/* $NetBSD: indent.h,v 1.74 2021/10/31 22:38:12 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
@@ -76,14 +76,14 @@
lsym_preprocessing, /* '#' */
lsym_newline,
lsym_form_feed,
- lsym_comment, /* the initial '/' '*' or '//' of a comment */
+ lsym_comment, /* the initial '/ *' or '//' of a comment */
lsym_lparen_or_lbracket,
lsym_rparen_or_rbracket,
lsym_lbrace,
lsym_rbrace,
lsym_period,
- lsym_unary_op, /* e.g. '+' or '&' */
- lsym_binary_op, /* e.g. '<<' or '+' or '&&' or '/=' */
+ lsym_unary_op, /* e.g. '*', '&', '-' or leading '++' */
+ lsym_binary_op, /* e.g. '*', '&', '<<', '&&' or '/=' */
lsym_postfix_op, /* trailing '++' or '--' */
lsym_question, /* the '?' from a '?:' expression */
lsym_colon,
@@ -360,7 +360,7 @@
#define debug_vis_range(prefix, s, e, suffix) do { } while (false)
#endif
-void add_typename(const char *);
+void register_typename(const char *);
int compute_code_indent(void);
int compute_label_indent(void);
int indentation_after_range(int, const char *, const char *);
diff -r 52513641ebc7 -r 7c2af0aad841 usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c Sun Oct 31 22:24:34 2021 +0000
+++ b/usr.bin/indent/lexi.c Sun Oct 31 22:38:12 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lexi.c,v 1.127 2021/10/31 20:59:26 rillig Exp $ */
+/* $NetBSD: lexi.c,v 1.128 2021/10/31 22:38:12 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.127 2021/10/31 20:59:26 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.128 2021/10/31 22:38:12 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
#endif
@@ -272,9 +272,6 @@
#define debug_ps_int(name) \
if (ps.name != prev_ps.name) \
debug_println("%3d ps." #name, ps.name)
-#define debug_ps_keyword(name) \
- if (ps.name != kw_0) \
- debug_println(" ps." #name " = %s", kw_name(ps.name))
static void
debug_lexi(lexer_symbol lsym)
@@ -750,7 +747,7 @@
}
void
-add_typename(const char *name)
+register_typename(const char *name)
{
if (typenames.len >= typenames.cap) {
typenames.cap = 16 + 2 * typenames.cap;
Home |
Main Index |
Thread Index |
Old Index