summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>2004-02-09 15:57:35 +0000
committerbde <bde@FreeBSD.org>2004-02-09 15:57:35 +0000
commit801e658cdd4ee7e5d845318ee79c08f07be63ef5 (patch)
treea7d852fbde38e496bf0bc003ae93e91fb9a1d1fc /usr.bin
parent3239d7f6ae36b059e9a19a2e5d8854be31296917 (diff)
downloadFreeBSD-src-801e658cdd4ee7e5d845318ee79c08f07be63ef5.zip
FreeBSD-src-801e658cdd4ee7e5d845318ee79c08f07be63ef5.tar.gz
Fixed tab lossage in indented variable names. The -diN option was
worse than useless because it caused things like mangling of "^int\tfoo" to "int foo" (this for N = 8). This quick fix breaks the invariant that characters between s_code and e_code have width 1, but nothing seems to depend on this.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/indent/indent.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/usr.bin/indent/indent.c b/usr.bin/indent/indent.c
index 5f97f03..8878c7e 100644
--- a/usr.bin/indent/indent.c
+++ b/usr.bin/indent/indent.c
@@ -909,33 +909,49 @@ check_type:
* dec_ind = e_code - s_code + (ps.decl_indent>i ? ps.decl_indent
* : i);
*/
- dec_ind = ps.decl_indent > 0 ? ps.decl_indent : i;
+ dec_ind = ps.decl_indent > 0 &&
+ (ps.ind_level == 0 || ps.dec_nest > 0) ? ps.decl_indent : i;
goto copy_id;
case ident: /* got an identifier or constant */
if (ps.in_decl) { /* if we are in a declaration, we must indent
* identifier */
- if (ps.want_blank)
- *e_code++ = ' ';
- ps.want_blank = false;
if (is_procname == 0 || !procnames_start_line) {
if (!ps.block_init) {
if (troff && !ps.dumped_decl_indent) {
+ if (ps.want_blank)
+ *e_code++ = ' ';
+ ps.want_blank = false;
sprintf(e_code, "\n.De %dp+\200p\n", dec_ind * 7);
ps.dumped_decl_indent = 1;
e_code += strlen(e_code);
} else {
- while ((e_code - s_code) < dec_ind) {
+ int pos, startpos;
+
+ startpos = e_code - s_code;
+ pos = startpos;
+ while ((pos & ~7) + 8 <= dec_ind) {
+ CHECK_SIZE_CODE;
+ *e_code++ = '\t';
+ pos = (pos & ~7) + 8;
+ }
+ while (pos < dec_ind) {
CHECK_SIZE_CODE;
*e_code++ = ' ';
+ pos++;
}
+ if (ps.want_blank && e_code - s_code == startpos)
+ *e_code++ = ' ';
+ ps.want_blank = false;
}
}
} else {
+ if (ps.want_blank)
+ *e_code++ = ' ';
+ ps.want_blank = false;
if (dec_ind && s_code != e_code)
dump_line();
dec_ind = 0;
- ps.want_blank = false;
}
}
else if (sp_sw && ps.p_l_follow == 0) {
OpenPOWER on IntegriCloud