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: sprinkle a few const
details: https://anonhg.NetBSD.org/src/rev/73a6af07c570
branches: trunk
changeset: 960098:73a6af07c570
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Mar 07 20:52:11 2021 +0000
description:
indent: sprinkle a few const
No functional change.
diffstat:
usr.bin/indent/args.c | 16 +++++++---------
usr.bin/indent/indent.c | 9 ++++-----
2 files changed, 11 insertions(+), 14 deletions(-)
diffs (93 lines):
diff -r 4c71d9b3274e -r 73a6af07c570 usr.bin/indent/args.c
--- a/usr.bin/indent/args.c Sun Mar 07 20:47:13 2021 +0000
+++ b/usr.bin/indent/args.c Sun Mar 07 20:52:11 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: args.c,v 1.16 2021/03/07 20:47:13 rillig Exp $ */
+/* $NetBSD: args.c,v 1.17 2021/03/07 20:52:11 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@
#include <sys/cdefs.h>
#ifndef lint
#if defined(__NetBSD__)
-__RCSID("$NetBSD: args.c,v 1.16 2021/03/07 20:47:13 rillig Exp $");
+__RCSID("$NetBSD: args.c,v 1.17 2021/03/07 20:52:11 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/args.c 336318 2018-07-15 21:04:21Z pstef $");
#endif
@@ -98,14 +98,13 @@
* must be first. Also, while (most) booleans occur more than once, the last
* default value is the one actually assigned.
*/
-struct pro {
+const struct pro {
const char *p_name; /* name, e.g. -bl, -cli */
int p_type; /* type (int, bool, special) */
int p_default; /* the default value (if int) */
int p_special; /* depends on type */
int *p_obj; /* the associated variable */
} pro[] = {
-
{"T", PRO_SPECIAL, 0, KEY, 0},
{"U", PRO_SPECIAL, 0, KEY_FILE, 0},
{"-version", PRO_SPECIAL, 0, VERSION, 0},
@@ -257,14 +256,13 @@
void
set_defaults(void)
{
- struct pro *p;
-
/*
* Because ps.case_indent is a float, we can't initialize it from the
* table:
*/
- opt.case_indent = 0.0; /* -cli0.0 */
- for (p = pro; p->p_name; p++)
+ opt.case_indent = 0.0F; /* -cli0.0 */
+
+ for (const struct pro *p = pro; p->p_name; p++)
if (p->p_type != PRO_SPECIAL)
*p->p_obj = p->p_default;
}
@@ -272,7 +270,7 @@
void
set_option(char *arg)
{
- struct pro *p;
+ const struct pro *p;
const char *param_start;
arg++; /* ignore leading "-" */
diff -r 4c71d9b3274e -r 73a6af07c570 usr.bin/indent/indent.c
--- a/usr.bin/indent/indent.c Sun Mar 07 20:47:13 2021 +0000
+++ b/usr.bin/indent/indent.c Sun Mar 07 20:52:11 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: indent.c,v 1.31 2021/03/07 20:30:48 rillig Exp $ */
+/* $NetBSD: indent.c,v 1.32 2021/03/07 20:52:11 rillig Exp $ */
/*-
* SPDX-License-Identifier: BSD-4-Clause
@@ -46,7 +46,7 @@
#include <sys/cdefs.h>
#ifndef lint
#if defined(__NetBSD__)
-__RCSID("$NetBSD: indent.c,v 1.31 2021/03/07 20:30:48 rillig Exp $");
+__RCSID("$NetBSD: indent.c,v 1.32 2021/03/07 20:52:11 rillig Exp $");
#elif defined(__FreeBSD__)
__FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $");
#endif
@@ -1237,11 +1237,10 @@
else
ifdef_level--;
} else {
- struct directives {
+ static const struct directives {
int size;
const char *string;
- }
- recognized[] = {
+ } recognized[] = {
{7, "include"},
{6, "define"},
{5, "undef"},
Home |
Main Index |
Thread Index |
Old Index