Wed Jun 14 08:25:15 2023 UTC ()
indent: remove a redundant flag from the parser state

No functional change.


(rillig)
diff -r1.11 -r1.12 src/tests/usr.bin/indent/lsym_binary_op.c
diff -r1.54 -r1.55 src/usr.bin/indent/debug.c
diff -r1.189 -r1.190 src/usr.bin/indent/indent.h
diff -r1.225 -r1.226 src/usr.bin/indent/lexi.c
diff -r1.161 -r1.162 src/usr.bin/indent/pr_comment.c

cvs diff -r1.11 -r1.12 src/tests/usr.bin/indent/lsym_binary_op.c (expand / switch to unified diff)

--- src/tests/usr.bin/indent/lsym_binary_op.c 2023/06/04 22:57:18 1.11
+++ src/tests/usr.bin/indent/lsym_binary_op.c 2023/06/14 08:25:15 1.12
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: lsym_binary_op.c,v 1.11 2023/06/04 22:57:18 rillig Exp $ */ 1/* $NetBSD: lsym_binary_op.c,v 1.12 2023/06/14 08:25:15 rillig Exp $ */
2 2
3/* 3/*
4 * Tests for the token lsym_binary_op, which represents a binary operator in 4 * Tests for the token lsym_binary_op, which represents a binary operator in
5 * an expression. Examples for binary operators are '>>', '=', '+', '&&'. 5 * an expression. Examples for binary operators are '>>', '=', '+', '&&'.
6 * 6 *
7 * Binary operators are surrounded by blanks. 7 * Binary operators are surrounded by blanks.
8 * 8 *
9 * Some tokens like '+', '*' or '&' can be either binary or unary operators, 9 * Some tokens like '+', '*' or '&' can be either binary or unary operators,
10 * with an entirely different meaning. 10 * with an entirely different meaning.
11 * 11 *
12 * The token '*' is not only a binary or a unary operator, it is used in types 12 * The token '*' is not only a binary or a unary operator, it is used in types
13 * as well, to derive a pointer type. 13 * as well, to derive a pointer type.
14 * 14 *
@@ -137,27 +137,27 @@ joined_unary_and_binary_operators(void) @@ -137,27 +137,27 @@ joined_unary_and_binary_operators(void)
137void 137void
138joined_unary_and_binary_operators(void) 138joined_unary_and_binary_operators(void)
139{ 139{
140 if (a++ ++ ++ +b) 140 if (a++ ++ ++ +b)
141 return; 141 return;
142} 142}
143//indent end 143//indent end
144 144
145 145
146/* 146/*
147 * Ensure that the result of the indentation does not depend on whether a 147 * Ensure that the result of the indentation does not depend on whether a
148 * token from the input starts in column 1 or 9. 148 * token from the input starts in column 1 or 9.
149 * 149 *
150 * See process_binary_op, ps.curr_col_1. 150 * See process_binary_op.
151 */ 151 */
152//indent input 152//indent input
153int col_1 // 153int col_1 //
154= // 154= //
1551; 1551;
156 156
157int col_9 // 157int col_9 //
158 = // 158 = //
159 9; 159 9;
160//indent end 160//indent end
161 161
162//indent run 162//indent run
163int col_1 // 163int col_1 //

cvs diff -r1.54 -r1.55 src/usr.bin/indent/debug.c (expand / switch to unified diff)

--- src/usr.bin/indent/debug.c 2023/06/14 07:20:55 1.54
+++ src/usr.bin/indent/debug.c 2023/06/14 08:25:15 1.55
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: debug.c,v 1.54 2023/06/14 07:20:55 rillig Exp $ */ 1/* $NetBSD: debug.c,v 1.55 2023/06/14 08:25:15 rillig Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2023 The NetBSD Foundation, Inc. 4 * Copyright (c) 2023 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Roland Illig <rillig@NetBSD.org>. 8 * by Roland Illig <rillig@NetBSD.org>.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__RCSID("$NetBSD: debug.c,v 1.54 2023/06/14 07:20:55 rillig Exp $"); 33__RCSID("$NetBSD: debug.c,v 1.55 2023/06/14 08:25:15 rillig Exp $");
34 34
35#include <stdarg.h> 35#include <stdarg.h>
36#include <string.h> 36#include <string.h>
37 37
38#include "indent.h" 38#include "indent.h"
39 39
40#ifdef debug 40#ifdef debug
41 41
42static struct { 42static struct {
43 /*- 43 /*-
44 * false show only the changes to the parser state 44 * false show only the changes to the parser state
45 * true show unchanged parts of the parser state as well 45 * true show unchanged parts of the parser state as well
46 */ 46 */
@@ -365,27 +365,26 @@ debug_parser_state(void) @@ -365,27 +365,26 @@ debug_parser_state(void)
365 365
366 state.heading = "horizontal spacing for comments"; 366 state.heading = "horizontal spacing for comments";
367 debug_ps_int(comment_delta); 367 debug_ps_int(comment_delta);
368 debug_ps_int(n_comment_delta); 368 debug_ps_int(n_comment_delta);
369 debug_ps_int(com_ind); 369 debug_ps_int(com_ind);
370 370
371 state.heading = "vertical spacing"; 371 state.heading = "vertical spacing";
372 debug_ps_bool(break_after_comma); 372 debug_ps_bool(break_after_comma);
373 debug_ps_bool(force_nl); 373 debug_ps_bool(force_nl);
374 debug_ps_enum(declaration, declaration_name); 374 debug_ps_enum(declaration, declaration_name);
375 debug_ps_bool(blank_line_after_decl); 375 debug_ps_bool(blank_line_after_decl);
376 376
377 state.heading = "comments"; 377 state.heading = "comments";
378 debug_ps_bool(curr_col_1); 
379 debug_ps_bool(next_col_1); 378 debug_ps_bool(next_col_1);
380 379
381 state.heading = NULL; 380 state.heading = NULL;
382 debug_blank_line(); 381 debug_blank_line();
383 382
384 state.prev_ps = ps; 383 state.prev_ps = ps;
385 state.ps_first = false; 384 state.ps_first = false;
386} 385}
387 386
388void 387void
389debug_psyms_stack(const char *situation) 388debug_psyms_stack(const char *situation)
390{ 389{
391 debug_printf("parse stack %s:", situation); 390 debug_printf("parse stack %s:", situation);

cvs diff -r1.189 -r1.190 src/usr.bin/indent/indent.h (expand / switch to unified diff)

--- src/usr.bin/indent/indent.h 2023/06/14 07:20:55 1.189
+++ src/usr.bin/indent/indent.h 2023/06/14 08:25:15 1.190
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: indent.h,v 1.189 2023/06/14 07:20:55 rillig Exp $ */ 1/* $NetBSD: indent.h,v 1.190 2023/06/14 08:25:15 rillig Exp $ */
2 2
3/*- 3/*-
4 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 4 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
5 * 5 *
6 * Copyright (c) 2001 Jens Schweikhardt 6 * Copyright (c) 2001 Jens Schweikhardt
7 * All rights reserved. 7 * All rights reserved.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -395,29 +395,28 @@ extern struct parser_state { @@ -395,29 +395,28 @@ extern struct parser_state {
395 * new line; used after 'if (expr)' and in 395 * new line; used after 'if (expr)' and in
396 * similar situations; tokens like '{' may 396 * similar situations; tokens like '{' may
397 * ignore this */ 397 * ignore this */
398 398
399 enum declaration { 399 enum declaration {
400 decl_no, /* no declaration anywhere nearby */ 400 decl_no, /* no declaration anywhere nearby */
401 decl_begin, /* collecting tokens of a declaration */ 401 decl_begin, /* collecting tokens of a declaration */
402 decl_end, /* finished a declaration */ 402 decl_end, /* finished a declaration */
403 } declaration; 403 } declaration;
404 bool blank_line_after_decl; 404 bool blank_line_after_decl;
405 405
406 /* Comments */ 406 /* Comments */
407 407
408 bool curr_col_1; /* whether the current token started in column 408 bool next_col_1; /* whether the next token starts in column 1 of
409 * 1 of the original input */ 409 * the original input */
410 bool next_col_1; 
411} ps; 410} ps;
412 411
413extern struct output_state { 412extern struct output_state {
414 enum line_kind { 413 enum line_kind {
415 lk_other, 414 lk_other,
416 lk_blank, 415 lk_blank,
417 lk_if, /* #if, #ifdef, #ifndef */ 416 lk_if, /* #if, #ifdef, #ifndef */
418 lk_endif, /* #endif */ 417 lk_endif, /* #endif */
419 lk_stmt_head, /* the ')' of an incomplete statement such as 418 lk_stmt_head, /* the ')' of an incomplete statement such as
420 * 'if (expr)' or 'for (expr; expr; expr)' */ 419 * 'if (expr)' or 'for (expr; expr; expr)' */
421 lk_func_end, /* the last '}' of a function body */ 420 lk_func_end, /* the last '}' of a function body */
422 lk_block_comment, 421 lk_block_comment,
423 lk_case_or_default, 422 lk_case_or_default,

cvs diff -r1.225 -r1.226 src/usr.bin/indent/lexi.c (expand / switch to unified diff)

--- src/usr.bin/indent/lexi.c 2023/06/10 16:43:56 1.225
+++ src/usr.bin/indent/lexi.c 2023/06/14 08:25:15 1.226
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: lexi.c,v 1.225 2023/06/10 16:43:56 rillig Exp $ */ 1/* $NetBSD: lexi.c,v 1.226 2023/06/14 08:25:15 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) 1980, 1993 7 * Copyright (c) 1980, 1993
8 * The Regents of the University of California. All rights reserved. 8 * The Regents of the University of California. All rights reserved.
9 * All rights reserved. 9 * 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
@@ -28,27 +28,27 @@ @@ -28,27 +28,27 @@
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
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#include <sys/cdefs.h> 40#include <sys/cdefs.h>
41__RCSID("$NetBSD: lexi.c,v 1.225 2023/06/10 16:43:56 rillig Exp $"); 41__RCSID("$NetBSD: lexi.c,v 1.226 2023/06/14 08:25:15 rillig Exp $");
42 42
43#include <stdlib.h> 43#include <stdlib.h>
44#include <string.h> 44#include <string.h>
45 45
46#include "indent.h" 46#include "indent.h"
47 47
48/* In lexi_alnum, this constant marks a type, independent of parentheses. */ 48/* In lexi_alnum, this constant marks a type, independent of parentheses. */
49#define lsym_type lsym_type_outside_parentheses 49#define lsym_type lsym_type_outside_parentheses
50 50
51/* must be sorted alphabetically, is used in binary search */ 51/* must be sorted alphabetically, is used in binary search */
52static const struct keyword { 52static const struct keyword {
53 const char name[12]; 53 const char name[12];
54 lexer_symbol lsym; 54 lexer_symbol lsym;
@@ -522,34 +522,32 @@ lex_indent_comment(void) @@ -522,34 +522,32 @@ lex_indent_comment(void)
522 if (skip(&p, "*/\n")) { 522 if (skip(&p, "*/\n")) {
523 if (lab.len > 0 || code.len > 0 || com.len > 0) 523 if (lab.len > 0 || code.len > 0 || com.len > 0)
524 output_line(); 524 output_line();
525 indent_enabled = enabled; 525 indent_enabled = enabled;
526 } 526 }
527 } 527 }
528} 528}
529 529
530/* Reads the next token, placing it in the global variable "token". */ 530/* Reads the next token, placing it in the global variable "token". */
531lexer_symbol 531lexer_symbol
532lexi(void) 532lexi(void)
533{ 533{
534 buf_clear(&token); 534 buf_clear(&token);
535 ps.curr_col_1 = ps.next_col_1; 
536 ps.next_col_1 = false; 535 ps.next_col_1 = false;
537 536
538 for (;;) { 537 for (;;) {
539 if (ch_isblank(inp_p[0])) { 538 if (ch_isblank(inp_p[0]))
540 ps.curr_col_1 = false; 
541 inp_p++; 539 inp_p++;
542 } else if (inp_p[0] == '\\' && inp_p[1] == '\n') { 540 else if (inp_p[0] == '\\' && inp_p[1] == '\n') {
543 inp_p++; 541 inp_p++;
544 inp_skip(); 542 inp_skip();
545 line_no++; 543 line_no++;
546 } else 544 } else
547 break; 545 break;
548 } 546 }
549 547
550 lexer_symbol alnum_lsym = lexi_alnum(); 548 lexer_symbol alnum_lsym = lexi_alnum();
551 if (alnum_lsym != lsym_eof) 549 if (alnum_lsym != lsym_eof)
552 return alnum_lsym; 550 return alnum_lsym;
553 551
554 /* Scan a non-alphanumeric token */ 552 /* Scan a non-alphanumeric token */
555 553

cvs diff -r1.161 -r1.162 src/usr.bin/indent/pr_comment.c (expand / switch to unified diff)

--- src/usr.bin/indent/pr_comment.c 2023/06/10 16:43:56 1.161
+++ src/usr.bin/indent/pr_comment.c 2023/06/14 08:25:15 1.162
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: pr_comment.c,v 1.161 2023/06/10 16:43:56 rillig Exp $ */ 1/* $NetBSD: pr_comment.c,v 1.162 2023/06/14 08:25:15 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) 1980, 1993 7 * Copyright (c) 1980, 1993
8 * The Regents of the University of California. All rights reserved. 8 * The Regents of the University of California. All rights reserved.
9 * All rights reserved. 9 * 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
@@ -28,27 +28,27 @@ @@ -28,27 +28,27 @@
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
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#include <sys/cdefs.h> 40#include <sys/cdefs.h>
41__RCSID("$NetBSD: pr_comment.c,v 1.161 2023/06/10 16:43:56 rillig Exp $"); 41__RCSID("$NetBSD: pr_comment.c,v 1.162 2023/06/14 08:25:15 rillig Exp $");
42 42
43#include <string.h> 43#include <string.h>
44 44
45#include "indent.h" 45#include "indent.h"
46 46
47static void 47static void
48com_add_char(char ch) 48com_add_char(char ch)
49{ 49{
50 buf_add_char(&com, ch); 50 buf_add_char(&com, ch);
51} 51}
52 52
53static void 53static void
54com_add_delim(void) 54com_add_delim(void)
@@ -74,27 +74,27 @@ fits_in_one_line(int com_ind, int max_li @@ -74,27 +74,27 @@ fits_in_one_line(int com_ind, int max_li
74 } 74 }
75 return false; 75 return false;
76} 76}
77 77
78static void 78static void
79analyze_comment(bool *p_may_wrap, bool *p_delim, 79analyze_comment(bool *p_may_wrap, bool *p_delim,
80 int *p_ind, int *p_line_length) 80 int *p_ind, int *p_line_length)
81{ 81{
82 bool may_wrap = true; 82 bool may_wrap = true;
83 bool delim = false; 83 bool delim = false;
84 int ind; 84 int ind;
85 int line_length = opt.max_line_length; 85 int line_length = opt.max_line_length;
86 86
87 if (ps.curr_col_1 && !opt.format_col1_comments) { 87 if (inp_p - inp.s == 2 && !opt.format_col1_comments) {
88 may_wrap = false; 88 may_wrap = false;
89 ind = 0; 89 ind = 0;
90 } else { 90 } else {
91 if (inp_p[0] == '-' || inp_p[0] == '*' || 91 if (inp_p[0] == '-' || inp_p[0] == '*' ||
92 token.s[token.len - 1] == '/' || 92 token.s[token.len - 1] == '/' ||
93 (inp_p[0] == '\n' && !opt.format_block_comments)) 93 (inp_p[0] == '\n' && !opt.format_block_comments))
94 may_wrap = false; 94 may_wrap = false;
95 if (code.len == 0 && inp_p[strspn(inp_p, "*")] == '\n') 95 if (code.len == 0 && inp_p[strspn(inp_p, "*")] == '\n')
96 out.line_kind = lk_block_comment; 96 out.line_kind = lk_block_comment;
97 97
98 if (com.len > 0) 98 if (com.len > 0)
99 output_line(); 99 output_line();
100 if (lab.len == 0 && code.len == 0) { 100 if (lab.len == 0 && code.len == 0) {