Commit b93a741f authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

vcc: Better format TOSTRANDS() C code

parent 7ead21cb
......@@ -148,6 +148,19 @@ vcc_delete_expr(struct expr *e)
* XXX: check line lengths in edit, should pass indent in for this
*/
static void
vcc_strands_edit(struct expr *e1, struct expr *e2)
{
if (e2->nstr == 1) {
VSB_printf(e1->vsb, "TOSTRAND(%s)", VSB_data(e2->vsb));
return;
}
VSB_printf(e1->vsb, "TOSTRANDS(%d,\v+\n%s\v-)",
e2->nstr, VSB_data(e2->vsb));
}
static struct expr *
vcc_expr_edit(struct vcc *tl, vcc_type_t fmt, const char *p, struct expr *e1,
struct expr *e2)
......@@ -179,9 +192,7 @@ vcc_expr_edit(struct vcc *tl, vcc_type_t fmt, const char *p, struct expr *e1,
if (e3->nstr > 1) {
VSB_cat(e->vsb,
"\nVRT_STRANDS_string(ctx,\v+\n");
VSB_printf(e->vsb,
"TOSTRANDS(%d,%s)",
e3->nstr, VSB_data(e3->vsb));
vcc_strands_edit(e, e3);
VSB_cat(e->vsb,
"\v-\n)\n");
} else {
......@@ -192,8 +203,7 @@ vcc_expr_edit(struct vcc *tl, vcc_type_t fmt, const char *p, struct expr *e1,
case 't':
e3 = (*p == 'T' ? e1 : e2);
AN(e3);
VSB_printf(e->vsb, "TOSTRANDS(%d,%s)",
e3->nstr, VSB_data(e3->vsb));
vcc_strands_edit(e, e3);
break;
case '1':
VSB_cat(e->vsb, VSB_data(e1->vsb));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment