Skip to content

Commit

Permalink
[feature] Add -sac (space after cast) and -nsac options.
Browse files Browse the repository at this point in the history
These control whether space character is put after a cast operator or not. Default is -nsac.
  • Loading branch information
pstef committed Jul 31, 2016
1 parent 01f36f4 commit 84b00e3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions args.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,15 @@ struct pro {
{"npro", PRO_SPECIAL, 0, IGN, 0},
{"npsl", PRO_BOOL, true, OFF, &procnames_start_line},
{"nps", PRO_BOOL, false, OFF, &pointer_as_binop},
{"nsac", PRO_BOOL, false, OFF, &space_after_cast},
{"nsc", PRO_BOOL, true, OFF, &star_comment_cont},
{"nsob", PRO_BOOL, false, OFF, &swallow_optional_blanklines},
{"nut", PRO_BOOL, true, OFF, &use_tabs},
{"nv", PRO_BOOL, false, OFF, &verbose},
{"pcs", PRO_BOOL, false, ON, &proc_calls_space},
{"psl", PRO_BOOL, true, ON, &procnames_start_line},
{"ps", PRO_BOOL, false, ON, &pointer_as_binop},
{"sac", PRO_BOOL, false, ON, &space_after_cast},
{"sc", PRO_BOOL, true, ON, &star_comment_cont},
{"sob", PRO_BOOL, false, ON, &swallow_optional_blanklines},
{"st", PRO_SPECIAL, 0, STDIN, 0},
Expand Down
6 changes: 6 additions & 0 deletions indent.1
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
.Op Fl npro
.Op Fl pcs | Fl npcs
.Op Fl psl | Fl npsl
.Op Fl sac | Fl nsac
.Op Fl \&sc | Fl nsc
.Bk -words
.Op Fl sob | Fl nsob
Expand Down Expand Up @@ -378,6 +379,11 @@ column 1 \- their types, if any, will be left on the previous lines.
The
default is
.Fl psl .
.It Fl sac , nsac
Control whether parenthesized type names in casts are followed by a space or
not.
The default is
.Fl nsac .
.It Fl \&sc , nsc
Enables (disables) the placement of asterisks (`*'s) at the left edge of all
comments.
Expand Down
5 changes: 3 additions & 2 deletions indent.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,8 +554,9 @@ main(int argc, char **argv)
if (ps.cast_mask & (1 << ps.p_l_follow) & ~ps.not_cast_mask) {
ps.last_u_d = true;
ps.cast_mask &= (1 << ps.p_l_follow) - 1;
ps.want_blank = false;
} else
ps.want_blank = space_after_cast;
}
else
ps.want_blank = true;
ps.not_cast_mask &= (1 << ps.p_l_follow) - 1;
if (--ps.p_l_follow < 0) {
Expand Down
1 change: 1 addition & 0 deletions indent_globs.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ int use_tabs; /* set true to use tabs for spacing,
* false uses all spaces */
int auto_typedefs; /* set true to recognize identifiers
* ending in "_t" like typedefs */
int space_after_cast; /* "b = (int) a" vs "b = (int)a" */

/* -troff font state information */

Expand Down

0 comments on commit 84b00e3

Please sign in to comment.