Module Name: src Committed By: rillig Date: Sat Sep 25 07:59:52 UTC 2021
Modified Files: src/usr.bin/indent: indent.c indent_globs.h lexi.c parse.c Log Message: indent: inline macro 'token' No functional change. To generate a diff of this commit: cvs rdiff -u -r1.65 -r1.66 src/usr.bin/indent/indent.c cvs rdiff -u -r1.24 -r1.25 src/usr.bin/indent/indent_globs.h cvs rdiff -u -r1.48 -r1.49 src/usr.bin/indent/lexi.c cvs rdiff -u -r1.20 -r1.21 src/usr.bin/indent/parse.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/indent.c diff -u src/usr.bin/indent/indent.c:1.65 src/usr.bin/indent/indent.c:1.66 --- src/usr.bin/indent/indent.c:1.65 Sat Sep 25 07:55:24 2021 +++ src/usr.bin/indent/indent.c Sat Sep 25 07:59:52 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: indent.c,v 1.65 2021/09/25 07:55:24 rillig Exp $ */ +/* $NetBSD: indent.c,v 1.66 2021/09/25 07:59:52 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -46,7 +46,7 @@ static char sccsid[] = "@(#)indent.c 5.1 #include <sys/cdefs.h> #ifndef lint #if defined(__NetBSD__) -__RCSID("$NetBSD: indent.c,v 1.65 2021/09/25 07:55:24 rillig Exp $"); +__RCSID("$NetBSD: indent.c,v 1.66 2021/09/25 07:59:52 rillig Exp $"); #elif defined(__FreeBSD__) __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $"); #endif @@ -259,11 +259,11 @@ search_brace(token_type *inout_ttype, in remove_newlines = /* "} else" */ - (*inout_ttype == keyword_do_else && *token == 'e' && + (*inout_ttype == keyword_do_else && *s_token == 'e' && code.e != code.s && code.e[-1] == '}') /* "else if" */ || (*inout_ttype == keyword_for_if_while && - *token == 'i' && *inout_last_else && opt.else_if); + *s_token == 'i' && *inout_last_else && opt.else_if); if (remove_newlines) *inout_force_nl = false; if (sc_end == NULL) { /* ignore buffering if @@ -292,7 +292,7 @@ search_brace(token_type *inout_ttype, in * not already broken */ diag(0, "Line broken"); } - for (const char *t_ptr = token; *t_ptr; ++t_ptr) + for (const char *t_ptr = s_token; *t_ptr; ++t_ptr) *sc_end++ = *t_ptr; sw_buffer: @@ -616,7 +616,7 @@ process_lparen_or_lbracket(int dec_ind, nitems(ps.paren_indents)); ps.p_l_follow--; } - if (*token == '[') + if (*s_token == '[') /* not a function pointer declaration or a function call */; else if (ps.in_decl && !ps.block_init && !ps.dumped_decl_indent && ps.procname[0] == '\0' && ps.paren_level == 0) { @@ -630,7 +630,7 @@ process_lparen_or_lbracket(int dec_ind, ps.keyword != rw_0 && ps.keyword != rw_offsetof))) *code.e++ = ' '; ps.want_blank = false; - *code.e++ = token[0]; + *code.e++ = s_token[0]; ps.paren_indents[ps.p_l_follow - 1] = indentation_after_range(0, code.s, code.e); @@ -642,7 +642,7 @@ process_lparen_or_lbracket(int dec_ind, ps.paren_indents[0] = 2 * opt.indent_size; debug_println("paren_indent[0] is now %d", ps.paren_indents[0]); } - if (ps.in_or_st && *token == '(' && ps.tos <= 2) { + if (ps.in_or_st && *s_token == '(' && ps.tos <= 2) { /* * this is a kluge to make sure that declarations will be * aligned right if proc decl has an explicit type on it, i.e. @@ -671,13 +671,13 @@ process_rparen_or_rbracket(int *inout_sp if (--ps.p_l_follow < 0) { ps.p_l_follow = 0; - diag(0, "Extra %c", *token); + diag(0, "Extra %c", *s_token); } if (code.e == code.s) /* if the paren starts the line */ ps.paren_level = ps.p_l_follow; /* then indent it */ - *code.e++ = token[0]; + *code.e++ = s_token[0]; if (*inout_sp_sw && (ps.p_l_follow == 0)) { /* check for end of if * (...), or some such */ @@ -706,7 +706,7 @@ process_unary_op(int dec_ind, int tabs_t * this token */ int i; - for (i = 0; token[i]; ++i) + for (i = 0; s_token[i]; ++i) /* find length of token */; indent_declaration(dec_ind - i, tabs_to_var); ps.dumped_decl_indent = true; @@ -717,7 +717,7 @@ process_unary_op(int dec_ind, int tabs_t size_t len = e_token - s_token; check_size_code(len); - memcpy(code.e, token, len); + memcpy(code.e, s_token, len); code.e += len; } ps.want_blank = false; @@ -731,7 +731,7 @@ process_binary_op(void) check_size_code(len + 1); if (ps.want_blank) *code.e++ = ' '; - memcpy(code.e, token, len); + memcpy(code.e, s_token, len); code.e += len; ps.want_blank = true; @@ -740,8 +740,8 @@ process_binary_op(void) static void process_postfix_op(void) { - *code.e++ = token[0]; - *code.e++ = token[1]; + *code.e++ = s_token[0]; + *code.e++ = s_token[1]; ps.want_blank = true; } @@ -966,7 +966,7 @@ static void process_keyword_do_else(int *inout_force_nl, int *inout_last_else) { ps.in_stmt = false; - if (*token == 'e') { + if (*s_token == 'e') { if (code.e != code.s && (!opt.cuddle_else || code.e[-1] != '}')) { if (opt.verbose) diag(0, "Line broken"); @@ -1010,7 +1010,7 @@ process_decl(int *out_dec_ind, int *out_ ps.just_saw_decl = 2; prefix_blankline_requested = 0; int i; - for (i = 0; token[i++];); /* get length of token */ + for (i = 0; s_token[i++];); /* get length of token */ if (ps.ind_level == 0 || ps.dec_nest > 0) { /* global variable or struct member in local variable */ @@ -1073,7 +1073,7 @@ process_string_prefix(void) check_size_code(len + 1); if (ps.want_blank) *code.e++ = ' '; - memcpy(code.e, token, len); + memcpy(code.e, s_token, len); code.e += len; ps.want_blank = false; @@ -1379,8 +1379,8 @@ main_loop(void) case keyword_for_if_while: sp_sw = true; /* the interesting stuff is done after the * expression is scanned */ - hd_type = (*token == 'i' ? if_expr : - (*token == 'w' ? while_expr : for_exprs)); + hd_type = (*s_token == 'i' ? if_expr : + (*s_token == 'w' ? while_expr : for_exprs)); /* remember the type of header for later use by parser */ goto copy_id; /* copy the token into line */ Index: src/usr.bin/indent/indent_globs.h diff -u src/usr.bin/indent/indent_globs.h:1.24 src/usr.bin/indent/indent_globs.h:1.25 --- src/usr.bin/indent/indent_globs.h:1.24 Sat Sep 25 07:55:24 2021 +++ src/usr.bin/indent/indent_globs.h Sat Sep 25 07:59:52 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: indent_globs.h,v 1.24 2021/09/25 07:55:24 rillig Exp $ */ +/* $NetBSD: indent_globs.h,v 1.25 2021/09/25 07:59:52 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -63,7 +63,6 @@ extern struct buffer lab; /* label or p extern struct buffer code; /* code */ extern struct buffer com; /* comment */ -#define token s_token extern char *tokenbuf; /* the last token scanned */ extern char *s_token; extern char *e_token; Index: src/usr.bin/indent/lexi.c diff -u src/usr.bin/indent/lexi.c:1.48 src/usr.bin/indent/lexi.c:1.49 --- src/usr.bin/indent/lexi.c:1.48 Sat Sep 25 07:55:24 2021 +++ src/usr.bin/indent/lexi.c Sat Sep 25 07:59:52 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: lexi.c,v 1.48 2021/09/25 07:55:24 rillig Exp $ */ +/* $NetBSD: lexi.c,v 1.49 2021/09/25 07:59:52 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -46,7 +46,7 @@ static char sccsid[] = "@(#)lexi.c 8.1 ( #include <sys/cdefs.h> #ifndef lint #if defined(__NetBSD__) -__RCSID("$NetBSD: lexi.c,v 1.48 2021/09/25 07:55:24 rillig Exp $"); +__RCSID("$NetBSD: lexi.c,v 1.49 2021/09/25 07:59:52 rillig Exp $"); #elif defined(__FreeBSD__) __FBSDID("$FreeBSD: head/usr.bin/indent/lexi.c 337862 2018-08-15 18:19:45Z pstef $"); #endif @@ -323,7 +323,7 @@ lex_char_or_string(void) { char delim; - delim = *token; + delim = *s_token; do { /* copy the string */ for (;;) { /* move one character or [/<char>]<char> */ if (*buf_ptr == '\n') { @@ -463,7 +463,7 @@ lexi(struct parser_state *state) while (tp < buf_end) if (*tp++ == ')' && (*tp == ';' || *tp == ',')) goto not_proc; - strncpy(state->procname, token, sizeof state->procname - 1); + strncpy(state->procname, s_token, sizeof state->procname - 1); if (state->in_decl) state->in_parameter_declaration = 1; return lexi_end(funcname); @@ -497,7 +497,7 @@ lexi(struct parser_state *state) * moved here */ *e_token = '\0'; - switch (*token) { + switch (*s_token) { case '\n': unary_delim = state->last_u_d; state->last_nl = true; /* remember that we just had a newline */ @@ -574,7 +574,7 @@ lexi(struct parser_state *state) ttype = state->last_u_d ? unary_op : binary_op; unary_delim = true; - if (*buf_ptr == token[0]) { + if (*buf_ptr == s_token[0]) { /* check for doubled character */ *e_token++ = *buf_ptr++; /* buffer overflow will be checked at end of loop */ @@ -650,7 +650,7 @@ lexi(struct parser_state *state) break; default: - if (token[0] == '/' && (*buf_ptr == '*' || *buf_ptr == '/')) { + if (s_token[0] == '/' && (*buf_ptr == '*' || *buf_ptr == '/')) { /* it is start of comment */ *e_token++ = inbuf_next(); Index: src/usr.bin/indent/parse.c diff -u src/usr.bin/indent/parse.c:1.20 src/usr.bin/indent/parse.c:1.21 --- src/usr.bin/indent/parse.c:1.20 Sat Sep 25 07:55:24 2021 +++ src/usr.bin/indent/parse.c Sat Sep 25 07:59:52 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.20 2021/09/25 07:55:24 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.21 2021/09/25 07:59:52 rillig Exp $ */ /*- * SPDX-License-Identifier: BSD-4-Clause @@ -65,7 +65,7 @@ parse(token_type ttype) int i; #ifdef debug - printf("parse token: '%s' \"%s\"\n", token_type_name(ttype), token); + printf("parse token: '%s' \"%s\"\n", token_type_name(ttype), s_token); #endif while (ps.p_stack[ps.tos] == if_expr_stmt && ttype != keyword_else) {