@@ 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;