| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: indent.c,v 1.146 2021/10/24 11:19:25 rillig Exp $ */ | | 1 | /* $NetBSD: indent.c,v 1.147 2021/10/24 16:51:44 rillig Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * SPDX-License-Identifier: BSD-4-Clause | | 4 | * SPDX-License-Identifier: BSD-4-Clause |
5 | * | | 5 | * |
6 | * Copyright (c) 1985 Sun Microsystems, Inc. | | 6 | * Copyright (c) 1985 Sun Microsystems, Inc. |
7 | * Copyright (c) 1976 Board of Trustees of the University of Illinois. | | 7 | * Copyright (c) 1976 Board of Trustees of the University of Illinois. |
8 | * Copyright (c) 1980, 1993 | | 8 | * Copyright (c) 1980, 1993 |
9 | * The Regents of the University of California. All rights reserved. | | 9 | * The Regents of the University of California. All rights reserved. |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -33,27 +33,27 @@ | | | @@ -33,27 +33,27 @@ |
33 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 33 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
34 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 34 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
35 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 35 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
36 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 36 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
37 | * SUCH DAMAGE. | | 37 | * SUCH DAMAGE. |
38 | */ | | 38 | */ |
39 | | | 39 | |
40 | #if 0 | | 40 | #if 0 |
41 | static char sccsid[] = "@(#)indent.c 5.17 (Berkeley) 6/7/93"; | | 41 | static char sccsid[] = "@(#)indent.c 5.17 (Berkeley) 6/7/93"; |
42 | #endif | | 42 | #endif |
43 | | | 43 | |
44 | #include <sys/cdefs.h> | | 44 | #include <sys/cdefs.h> |
45 | #if defined(__NetBSD__) | | 45 | #if defined(__NetBSD__) |
46 | __RCSID("$NetBSD: indent.c,v 1.146 2021/10/24 11:19:25 rillig Exp $"); | | 46 | __RCSID("$NetBSD: indent.c,v 1.147 2021/10/24 16:51:44 rillig Exp $"); |
47 | #elif defined(__FreeBSD__) | | 47 | #elif defined(__FreeBSD__) |
48 | __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $"); | | 48 | __FBSDID("$FreeBSD: head/usr.bin/indent/indent.c 340138 2018-11-04 19:24:49Z oshogbo $"); |
49 | #endif | | 49 | #endif |
50 | | | 50 | |
51 | #include <sys/param.h> | | 51 | #include <sys/param.h> |
52 | #if HAVE_CAPSICUM | | 52 | #if HAVE_CAPSICUM |
53 | #include <sys/capsicum.h> | | 53 | #include <sys/capsicum.h> |
54 | #include <capsicum_helpers.h> | | 54 | #include <capsicum_helpers.h> |
55 | #endif | | 55 | #endif |
56 | #include <ctype.h> | | 56 | #include <ctype.h> |
57 | #include <err.h> | | 57 | #include <err.h> |
58 | #include <errno.h> | | 58 | #include <errno.h> |
59 | #include <fcntl.h> | | 59 | #include <fcntl.h> |
| @@ -140,26 +140,28 @@ init_capsicum(void) | | | @@ -140,26 +140,28 @@ init_capsicum(void) |
140 | } | | 140 | } |
141 | #endif | | 141 | #endif |
142 | | | 142 | |
143 | static void | | 143 | static void |
144 | search_brace_newline(bool *force_nl) | | 144 | search_brace_newline(bool *force_nl) |
145 | { | | 145 | { |
146 | if (sc_end == NULL) { | | 146 | if (sc_end == NULL) { |
147 | save_com = sc_buf; | | 147 | save_com = sc_buf; |
148 | save_com[0] = save_com[1] = ' '; | | 148 | save_com[0] = save_com[1] = ' '; |
149 | sc_end = &save_com[2]; | | 149 | sc_end = &save_com[2]; |
150 | } | | 150 | } |
151 | *sc_end++ = '\n'; | | 151 | *sc_end++ = '\n'; |
152 | | | 152 | |
| | | 153 | line_no++; |
| | | 154 | |
153 | /* | | 155 | /* |
154 | * We may have inherited a force_nl == true from the previous token (like | | 156 | * We may have inherited a force_nl == true from the previous token (like |
155 | * a semicolon). But once we know that a newline has been scanned in this | | 157 | * a semicolon). But once we know that a newline has been scanned in this |
156 | * loop, force_nl should be false. | | 158 | * loop, force_nl should be false. |
157 | * | | 159 | * |
158 | * However, the force_nl == true must be preserved if newline is never | | 160 | * However, the force_nl == true must be preserved if newline is never |
159 | * scanned in this loop, so this assignment cannot be done earlier. | | 161 | * scanned in this loop, so this assignment cannot be done earlier. |
160 | */ | | 162 | */ |
161 | *force_nl = false; | | 163 | *force_nl = false; |
162 | } | | 164 | } |
163 | | | 165 | |
164 | static void | | 166 | static void |
165 | search_brace_comment(bool *comment_buffered) | | 167 | search_brace_comment(bool *comment_buffered) |