Module Name: src Committed By: rillig Date: Sun Sep 26 21:05:48 UTC 2021
Modified Files: src/usr.bin/indent: args.c lexi.c Log Message: indent: unexport keyword table, clean up No functional change. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/usr.bin/indent/args.c cvs rdiff -u -r1.59 -r1.60 src/usr.bin/indent/lexi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/indent/args.c diff -u src/usr.bin/indent/args.c:1.38 src/usr.bin/indent/args.c:1.39 --- src/usr.bin/indent/args.c:1.38 Sun Sep 26 20:48:10 2021 +++ src/usr.bin/indent/args.c Sun Sep 26 21:05:48 2021 @@ -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 @@ static char sccsid[] = "@(#)args.c 8.1 ( #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 @@ static const struct pro { 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 @@ set_option(const char *arg) 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); } } Index: src/usr.bin/indent/lexi.c diff -u src/usr.bin/indent/lexi.c:1.59 src/usr.bin/indent/lexi.c:1.60 --- src/usr.bin/indent/lexi.c:1.59 Sun Sep 26 19:37:11 2021 +++ src/usr.bin/indent/lexi.c Sun Sep 26 21:05:48 2021 @@ -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 @@ static char sccsid[] = "@(#)lexi.c 8.1 ( #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 @@ __FBSDID("$FreeBSD: head/usr.bin/indent/ #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 @@ check_size_token(size_t desired_size) } 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 @@ lexi(struct parser_state *state) 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 @@ lexi(struct parser_state *state) 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 @@ lexi(struct parser_state *state) 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;