~pmikkelsen/lpa

a062a0574fa9bbff7f3cb62251b41d42a441440f — Peter Mikkelsen 2 months ago b69af68
Print a little less whitespace when displaying functions
1 files changed, 13 insertions(+), 4 deletions(-)

M array.c
M array.c => array.c +13 -4
@@ 152,6 152,15 @@ printarray(Array *a)
}

static int
addspace(char *p)
{
	if(*(p-1) == ' ')
		return 0;
	else
		return sprint(p, " ");
}

static int
printexpr(char *start, Ast *e, int left)
{
	if(e == nil)


@@ 173,11 182,11 @@ printexpr(char *start, Ast *e, int left)

	switch(e->tag){
	case AstName:
		if(left)
			p += sprint(p, " ");
		if(!left)
			p += addspace(p);
		p += sprint(p, "%s", e->name);
		if(left)
			p += sprint(p, " ");
			p += addspace(p);
		break;
	case AstAssign:
		p += printexpr(p, e->left, 0);


@@ 202,7 211,7 @@ printexpr(char *start, Ast *e, int left)
	case AstStrand:
		for(uvlong i = 0; i < e->childcount; i++){
			if(i != 0)
				p += sprint(p, " ");
				p += addspace(p);
			p += printexpr(p, e->children[i], 1);
		}
		break;