Fix long lines

This commit is contained in:
Graydon Hoare 2011-05-31 09:54:18 -07:00
parent 371c25683c
commit 1811513552
2 changed files with 16 additions and 8 deletions

View File

@ -443,13 +443,15 @@ fn indent(int amount) {
}
fn print(token x, int L) {
log #fmt("print %s %d (remaining line space=%d)", tok_str(x), L, space);
log #fmt("print %s %d (remaining line space=%d)",
tok_str(x), L, space);
log buf_str(token, size, left, right, 6u);
alt (x) {
case (BEGIN(?b)) {
if (L > space) {
auto col = (margin - space) + b.offset;
log #fmt("print BEGIN -> push broken block at col %d", col);
log #fmt("print BEGIN -> push broken block at col %d",
col);
vec::push(print_stack,
rec(offset = col,
pbreak = broken(b.breaks)));
@ -491,11 +493,11 @@ fn print(token x, int L) {
case (broken(inconsistent)) {
if (L > space) {
log "print BREAK w/ newline in inconsistent block";
log "print BREAK w/ newline in inconsistent";
self.print_newline(top.offset + b.offset);
space = margin - (top.offset + b.offset);
} else {
log "print BREAK w/o newline in inconsistent block";
log "print BREAK w/o newline in inconsistent";
self.indent(b.blank_space);
space -= b.blank_space;
}

View File

@ -72,8 +72,11 @@ fn block_to_str(&ast::block blk) -> str {
comments=option::none[vec[lexer::cmnt]],
mutable cur_cmnt=0u,
mode=mo_untyped);
cbox(s.s, indent_unit); // containing cbox, will be closed by print-block at }
ibox(s.s, 0u); // head-ibox, will be closed by print-block after {
// containing cbox, will be closed by print-block at }
cbox(s.s, indent_unit);
// head-ibox, will be closed by print-block after {
ibox(s.s, 0u);
print_block(s, blk);
eof(s.s);
ret writer.get_str();
@ -657,8 +660,11 @@ fn print_opt(ps s, &option::t[@ast::expr] expr) {
bclose(s, expr.span);
}
case (ast::expr_block(?block,_)) {
cbox(s.s, indent_unit); // containing cbox, will be closed by print-block at }
ibox(s.s, 0u); // head-box, will be closed by print-block after {
// containing cbox, will be closed by print-block at }
cbox(s.s, indent_unit);
// head-box, will be closed by print-block after {
ibox(s.s, 0u);
print_block(s, block);
}
case (ast::expr_assign(?lhs,?rhs,_)) {