| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: indent.c,v 1.213 2021/11/07 13:30:15 rillig Exp $ */ | | 1 | /* $NetBSD: indent.c,v 1.214 2021/11/07 14:00:35 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.213 2021/11/07 13:30:15 rillig Exp $"); | | 46 | __RCSID("$NetBSD: indent.c,v 1.214 2021/11/07 14:00:35 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 <assert.h> | | 56 | #include <assert.h> |
57 | #include <ctype.h> | | 57 | #include <ctype.h> |
58 | #include <err.h> | | 58 | #include <err.h> |
59 | #include <errno.h> | | 59 | #include <errno.h> |
| @@ -474,27 +474,27 @@ search_stmt(lexer_symbol *lsym, bool *fo | | | @@ -474,27 +474,27 @@ search_stmt(lexer_symbol *lsym, bool *fo |
474 | case lsym_newline: | | 474 | case lsym_newline: |
475 | search_stmt_newline(force_nl); | | 475 | search_stmt_newline(force_nl); |
476 | break; | | 476 | break; |
477 | case lsym_form_feed: | | 477 | case lsym_form_feed: |
478 | break; | | 478 | break; |
479 | case lsym_comment: | | 479 | case lsym_comment: |
480 | search_stmt_comment(); | | 480 | search_stmt_comment(); |
481 | comment_buffered = true; | | 481 | comment_buffered = true; |
482 | break; | | 482 | break; |
483 | case lsym_lbrace: | | 483 | case lsym_lbrace: |
484 | if (search_stmt_lbrace()) | | 484 | if (search_stmt_lbrace()) |
485 | goto switch_buffer; | | 485 | goto switch_buffer; |
486 | /* FALLTHROUGH */ | | 486 | /* FALLTHROUGH */ |
487 | default: /* it is the start of a normal statement */ | | 487 | default: |
488 | if (!search_stmt_other(*lsym, force_nl, comment_buffered, | | 488 | if (!search_stmt_other(*lsym, force_nl, comment_buffered, |
489 | *last_else)) | | 489 | *last_else)) |
490 | return; | | 490 | return; |
491 | switch_buffer: | | 491 | switch_buffer: |
492 | switch_buffer(); | | 492 | switch_buffer(); |
493 | } | | 493 | } |
494 | search_stmt_lookahead(lsym); | | 494 | search_stmt_lookahead(lsym); |
495 | } | | 495 | } |
496 | | | 496 | |
497 | *last_else = false; | | 497 | *last_else = false; |
498 | } | | 498 | } |
499 | | | 499 | |
500 | static void | | 500 | static void |
| @@ -1095,27 +1095,27 @@ process_do(bool *force_nl, bool *last_el | | | @@ -1095,27 +1095,27 @@ process_do(bool *force_nl, bool *last_el |
1095 | ps.want_blank = false; | | 1095 | ps.want_blank = false; |
1096 | } | | 1096 | } |
1097 | | | 1097 | |
1098 | *force_nl = true; /* following stuff must go onto new line */ | | 1098 | *force_nl = true; /* following stuff must go onto new line */ |
1099 | *last_else = false; | | 1099 | *last_else = false; |
1100 | parse(psym_do); | | 1100 | parse(psym_do); |
1101 | } | | 1101 | } |
1102 | | | 1102 | |
1103 | static void | | 1103 | static void |
1104 | process_else(bool *force_nl, bool *last_else) | | 1104 | process_else(bool *force_nl, bool *last_else) |
1105 | { | | 1105 | { |
1106 | ps.in_stmt = false; | | 1106 | ps.in_stmt = false; |
1107 | | | 1107 | |
1108 | if (code.e > code.s && (!opt.cuddle_else || code.e[-1] != '}')) { | | 1108 | if (code.e > code.s && !(opt.cuddle_else && code.e[-1] == '}')) { |
1109 | if (opt.verbose) | | 1109 | if (opt.verbose) |
1110 | diag(0, "Line broken"); | | 1110 | diag(0, "Line broken"); |
1111 | dump_line(); /* make sure this starts a line */ | | 1111 | dump_line(); /* make sure this starts a line */ |
1112 | ps.want_blank = false; | | 1112 | ps.want_blank = false; |
1113 | } | | 1113 | } |
1114 | | | 1114 | |
1115 | *force_nl = true; /* following stuff must go onto new line */ | | 1115 | *force_nl = true; /* following stuff must go onto new line */ |
1116 | *last_else = true; | | 1116 | *last_else = true; |
1117 | parse(psym_else); | | 1117 | parse(psym_else); |
1118 | } | | 1118 | } |
1119 | | | 1119 | |
1120 | static void | | 1120 | static void |
1121 | process_type(int *decl_ind, bool *tabs_to_var) | | 1121 | process_type(int *decl_ind, bool *tabs_to_var) |