ref: a062a0574fa9bbff7f3cb62251b41d42a441440f
parent: b69af6813720ca5ca47f267d7e8d832ae0b77172
author: Peter Mikkelsen <peter@pmikkelsen.com>
date: Sat Jul 27 06:05:18 EDT 2024
Print a little less whitespace when displaying functions
--- a/array.c
+++ b/array.c
@@ -152,6 +152,15 @@
}
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 @@
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 @@
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;