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: unexport keyword table, clean up
details: https://anonhg.NetBSD.org/src/rev/562324457e7e
branches: trunk
changeset: 1023820:562324457e7e
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Sep 26 21:05:48 2021 +0000
description:
indent: unexport keyword table, clean up
No functional change.
diffstat:
usr.bin/indent/args.c | 10 +++++-----
usr.bin/indent/lexi.c | 34 +++++++++++-----------------------
2 files changed, 16 insertions(+), 28 deletions(-)
diffs (129 lines):
diff -r 6e8354992310 -r 562324457e7e usr.bin/indent/args.c
--- a/usr.bin/indent/args.c Sun Sep 26 20:55:15 2021 +0000
+++ b/usr.bin/indent/args.c Sun Sep 26 21:05:48 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: args.c,v 1.38 2021/09/26 20:48:10 rillig Exp $ */
+/* $NetBSD: args.c,v 1.39 2021/09/26 21:05:48 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.38 2021/09/26 20:48:10 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.39 2021/09/26 21:05:48 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/args.c 336318 2018-07-15 21:04:21Z pstef $");
#endif
@@ -92,7 +92,7 @@
bool p_is_bool;
bool p_bool_value;
bool p_may_negate;
- void *p_obj; /* the associated variable (bool, int) */
+ void *p_var; /* the associated variable */
} pro[] = {
bool_options("bacc", blanklines_around_conditional_compilation),
bool_options("bad", blanklines_after_declarations),
@@ -285,12 +285,12 @@
found:
if (p->p_is_bool)
- *(bool *)p->p_obj = p->p_may_negate ? arg[0] != 'n' : p->p_bool_value;
+ *(bool *)p->p_var = p->p_may_negate ? arg[0] != 'n' : p->p_bool_value;
else {
if (!isdigit((unsigned char)*param_start))
errx(1, "%s: ``%s'' requires a parameter",
option_source, p->p_name);
- *(int *)p->p_obj = atoi(param_start);
+ *(int *)p->p_var = atoi(param_start);
}
}
diff -r 6e8354992310 -r 562324457e7e usr.bin/indent/lexi.c
--- a/usr.bin/indent/lexi.c Sun Sep 26 20:55:15 2021 +0000
+++ b/usr.bin/indent/lexi.c Sun Sep 26 21:05:48 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lexi.c,v 1.59 2021/09/26 19:37:11 rillig Exp $ */
+/* $NetBSD: lexi.c,v 1.60 2021/09/26 21:05:48 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.59 2021/09/26 19:37:11 rillig Exp $");
+__RCSID("$NetBSD: lexi.c,v 1.60 2021/09/26 21:05:48 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $");
#endif
@@ -59,17 +59,11 @@
#include "indent.h"
-struct templ {
+/* must be sorted alphabetically, is used in binary search */
+static const struct special {
const char *rwd;
enum rwcode rwcode;
-};
-
-/*
- * This table has to be sorted alphabetically, because it'll be used in binary
- * search.
- */
-const struct templ specials[] =
-{
+} specials[] = {
{"_Bool", rw_type},
{"_Complex", rw_type},
{"_Imaginary", rw_type},
@@ -210,9 +204,9 @@
}
static int
-compare_templ_array(const void *key, const void *elem)
+compare_special_array(const void *key, const void *elem)
{
- return strcmp(key, ((const struct templ *)elem)->rwd);
+ return strcmp(key, ((const struct special *)elem)->rwd);
}
static int
@@ -368,10 +362,7 @@
if (isalnum((unsigned char)*buf_ptr) ||
*buf_ptr == '_' || *buf_ptr == '$' ||
(buf_ptr[0] == '.' && isdigit((unsigned char)buf_ptr[1]))) {
- /*
- * we have a letter or number
- */
- struct templ *p;
+ struct special *p;
if (isdigit((unsigned char)*buf_ptr) ||
(buf_ptr[0] == '.' && isdigit((unsigned char)buf_ptr[1]))) {
@@ -388,12 +379,9 @@
while (*buf_ptr == ' ' || *buf_ptr == '\t') /* get rid of blanks */
inbuf_next();
state->keyword = rw_0;
+
if (state->last_token == keyword_struct_union_enum &&
- state->p_l_follow == 0) {
- /*
- * if last token was 'struct' and we're not in parentheses, then
- * this token should be treated as a declaration
- */
+ state->p_l_follow == 0) {
state->last_u_d = true;
return lexi_end(decl);
}
@@ -403,7 +391,7 @@
state->last_u_d = (state->last_token == keyword_struct_union_enum);
p = bsearch(token.s, specials, sizeof specials / sizeof specials[0],
- sizeof specials[0], compare_templ_array);
+ sizeof specials[0], compare_special_array);
if (p == NULL) { /* not a special keyword... */
char *u;
Home |
Main Index |
Thread Index |
Old Index