Refactor print_width and enforce minimum value 20
This commit is contained in:
parent
96962da3d3
commit
6defff3696
25
c/print.h
25
c/print.h
|
@ -7,7 +7,7 @@ static int print_readably;
|
||||||
static int print_pretty;
|
static int print_pretty;
|
||||||
|
|
||||||
// *print-width* -- maximum line length when indenting, ignored when not
|
// *print-width* -- maximum line length when indenting, ignored when not
|
||||||
static int print_width = 80;
|
static int print_width;
|
||||||
|
|
||||||
// *print-length* -- truncate lists after N items and write "..."
|
// *print-length* -- truncate lists after N items and write "..."
|
||||||
static fixnum_t print_length;
|
static fixnum_t print_length;
|
||||||
|
@ -859,23 +859,11 @@ static void cvalue_print(struct ios *f, value_t v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_print_width(void)
|
|
||||||
{
|
|
||||||
value_t pw;
|
|
||||||
|
|
||||||
pw = symbol_value(printwidthsym);
|
|
||||||
if (!isfixnum(pw))
|
|
||||||
return;
|
|
||||||
print_width = numval(pw);
|
|
||||||
}
|
|
||||||
|
|
||||||
void fl_print(struct ios *f, value_t v)
|
void fl_print(struct ios *f, value_t v)
|
||||||
{
|
{
|
||||||
value_t pl;
|
value_t pl;
|
||||||
|
|
||||||
print_pretty = (symbol_value(printprettysym) != FL_F);
|
print_pretty = (symbol_value(printprettysym) != FL_F);
|
||||||
if (print_pretty)
|
|
||||||
set_print_width();
|
|
||||||
print_readably = (symbol_value(printreadablysym) != FL_F);
|
print_readably = (symbol_value(printreadablysym) != FL_F);
|
||||||
|
|
||||||
pl = symbol_value(printlengthsym);
|
pl = symbol_value(printlengthsym);
|
||||||
|
@ -883,13 +871,22 @@ void fl_print(struct ios *f, value_t v)
|
||||||
print_length = numval(pl);
|
print_length = numval(pl);
|
||||||
else
|
else
|
||||||
print_length = -1;
|
print_length = -1;
|
||||||
|
|
||||||
pl = symbol_value(printlevelsym);
|
pl = symbol_value(printlevelsym);
|
||||||
if (isfixnum(pl))
|
if (isfixnum(pl))
|
||||||
print_level = numval(pl);
|
print_level = numval(pl);
|
||||||
else
|
else
|
||||||
print_level = -1;
|
print_level = -1;
|
||||||
cur_level = 0;
|
|
||||||
|
|
||||||
|
pl = symbol_value(printwidthsym);
|
||||||
|
if (isfixnum(pl))
|
||||||
|
print_width = numval(pl);
|
||||||
|
else
|
||||||
|
print_width = 80;
|
||||||
|
if (print_width < 20)
|
||||||
|
print_width = 20;
|
||||||
|
|
||||||
|
cur_level = 0;
|
||||||
cycle_used_labels = 0;
|
cycle_used_labels = 0;
|
||||||
if (print_readably)
|
if (print_readably)
|
||||||
print_traverse(v);
|
print_traverse(v);
|
||||||
|
|
Loading…
Reference in New Issue