summaryrefslogtreecommitdiffstats
path: root/usr.bin/indent/indent.c
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2004-02-09 20:42:08 +0000
committerbde <bde@FreeBSD.org>2004-02-09 20:42:08 +0000
commitfb0b5ce61d257b76d357e8c73de3a01f08a2d4b7 (patch)
treeb735332538fc49c228cec05cdd662781f6ec6408 /usr.bin/indent/indent.c
parentd02b8b76aeef136ecfee87d8320d15d21785afd4 (diff)
downloadFreeBSD-src-fb0b5ce61d257b76d357e8c73de3a01f08a2d4b7.zip
FreeBSD-src-fb0b5ce61d257b76d357e8c73de3a01f08a2d4b7.tar.gz
Only use tabs to indent variable names if the declaration indent is
nonzero (so that the 1-char indentation given by -di0 is never rendered by a tab). Removed garbage commented out code for setting the indentation of variable names.
Diffstat (limited to 'usr.bin/indent/indent.c')
-rw-r--r--usr.bin/indent/indent.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/usr.bin/indent/indent.c b/usr.bin/indent/indent.c
index bc132dc..ba7d463 100644
--- a/usr.bin/indent/indent.c
+++ b/usr.bin/indent/indent.c
@@ -91,6 +91,7 @@ main(int argc, char **argv)
int squest; /* when this is positive, we have seen a ?
* without the matching : in a <c>?<s>:<s>
* construct */
+ int use_tabs; /* true if using tabs to indent to var name */
const char *t_ptr; /* used for copying tokens */
int type_code; /* the type of token, returned by lexi */
@@ -905,11 +906,8 @@ check_type:
prefix_blankline_requested = 0;
for (i = 0; token[i++];); /* get length of token */
- /*
- * dec_ind = e_code - s_code + (ps.decl_indent>i ? ps.decl_indent
- * : i);
- */
dec_ind = ps.decl_indent > 0 ? ps.decl_indent : i;
+ use_tabs = ps.decl_indent > 0;
goto copy_id;
case ident: /* got an identifier or constant */
@@ -929,10 +927,12 @@ check_type:
startpos = e_code - s_code;
pos = startpos;
- while ((pos & ~7) + 8 <= dec_ind) {
- CHECK_SIZE_CODE;
- *e_code++ = '\t';
- pos = (pos & ~7) + 8;
+ if (use_tabs) {
+ while ((pos & ~7) + 8 <= dec_ind) {
+ CHECK_SIZE_CODE;
+ *e_code++ = '\t';
+ pos = (pos & ~7) + 8;
+ }
}
while (pos < dec_ind) {
CHECK_SIZE_CODE;
OpenPOWER on IntegriCloud