use %q to make debugging output easier to read. also use %q when formatting arguments for rc. Notes: Tue Jul 13 16:47:33 EDT 2010 geoff I don't think that this solves a real problem. Reference: /n/sources/patch/sorry/mkfmtq Date: Wed Apr 7 21:13:03 CES 2010 Signed-off-by: quanstro@quanstro.net Reviewed-by: geoff --- /sys/src/cmd/mk/word.c Wed Apr 7 21:09:16 2010 +++ /sys/src/cmd/mk/word.c Wed Apr 7 21:09:10 2010 @@ -184,6 +184,6 @@ { Bprint(&bout, "%s", s); for(; w; w = w->next) - Bprint(&bout, " '%s'", w->s); + Bprint(&bout, " %q", w->s); Bputc(&bout, '\n'); } --- /sys/src/cmd/mk/var.c Wed Apr 7 21:09:28 2010 +++ /sys/src/cmd/mk/var.c Wed Apr 7 21:09:22 2010 @@ -14,7 +14,7 @@ Bprint(&bout, "\t%s=", s->name); for (w = s->u.ptr; w; w = w->next) - Bprint(&bout, "'%s'", w->s); + Bprint(&bout, "%q ", w->s); Bprint(&bout, "\n"); } --- /sys/src/cmd/mk/run.c Wed Apr 7 21:09:49 2010 +++ /sys/src/cmd/mk/run.c Wed Apr 7 21:09:32 2010 @@ -69,14 +69,14 @@ if(!(n->flags&VIRTUAL)) touch(n->name); else if(explain) - Bprint(&bout, "no touch of virtual '%s'\n", n->name); + Bprint(&bout, "no touch of virtual %q\n", n->name); } n->time = time((long *)0); MADESET(n, MADE); } } else { if(DEBUG(D_EXEC)) - fprint(1, "recipe='%s'\n", j->r->recipe); /**/ + fprint(1, "recipe=%q\n", j->r->recipe); /**/ Bflush(&bout); if(j->r->attr&NOMINUSE) flags = 0; @@ -154,7 +154,7 @@ if(n->flags&DELETE){ if(done++ == 0) fprint(2, ", deleting"); - fprint(2, " '%s'", n->name); + fprint(2, " %q", n->name); delete(n->name); } fprint(2, "\n"); --- /sys/src/cmd/mk/rule.c Wed Apr 7 21:10:10 2010 +++ /sys/src/cmd/mk/rule.c Wed Apr 7 21:10:01 2010 @@ -75,12 +75,12 @@ { Bprint(&bout, "%s: start=%p\n", s, r); for(; r; r = r->next){ - Bprint(&bout, "\tRule %p: %s:%d attr=%x next=%p chain=%p alltarget='%s'", + Bprint(&bout, "\tRule %p: %s:%d attr=%x next=%p chain=%p alltarget=%q", r, r->file, r->line, r->attr, r->next, r->chain, wtos(r->alltargets, ' ')); if(r->prog) - Bprint(&bout, " prog='%s'", r->prog); + Bprint(&bout, " prog=%q", r->prog); Bprint(&bout, "\n\ttarget=%s: %s\n", r->target, wtos(r->tail,' ')); - Bprint(&bout, "\trecipe@%p='%s'\n", r->recipe, r->recipe); + Bprint(&bout, "\trecipe@%p=%q\n", r->recipe, r->recipe); } } --- /sys/src/cmd/mk/main.c Wed Apr 7 21:10:22 2010 +++ /sys/src/cmd/mk/main.c Wed Apr 7 21:10:15 2010 @@ -35,6 +35,8 @@ Bufblock *buf; Bufblock *whatif; + quotefmtinstall(); + /* * start with a copy of the current environment variables * instead of sharing them --- /sys/src/cmd/mk/job.c Wed Apr 7 21:10:45 2010 +++ /sys/src/cmd/mk/job.c Wed Apr 7 21:10:29 2010 @@ -24,9 +24,9 @@ { Bprint(&bout, "%s\n", s); while(j){ - Bprint(&bout, "job@%p: r=%p n=%p stem='%s' nproc=%d\n", + Bprint(&bout, "job@%p: r=%p n=%p stem=%q nproc=%d\n", j, j->r, j->n, j->stem, j->nproc); - Bprint(&bout, "\ttarget='%s' alltarget='%s' prereq='%s' nprereq='%s'\n", + Bprint(&bout, "\ttarget=%q alltarget=%q prereq=%q nprereq=%q\n", wtos(j->t, ' '), wtos(j->at, ' '), wtos(j->p, ' '), wtos(j->np, ' ')); j = all? j->next : 0; } --- /sys/src/cmd/mk/arc.c Wed Apr 7 21:11:02 2010 +++ /sys/src/cmd/mk/arc.c Wed Apr 7 21:10:49 2010 @@ -21,10 +21,10 @@ { char buf[1024]; - Bprint(&bout, "%sArc@%p: n=%p r=%p flag=0x%x stem='%s'", + Bprint(&bout, "%sArc@%p: n=%p r=%p flag=0x%x stem=%q", s, a, a->n, a->r, a->flag, a->stem); if(a->prog) - Bprint(&bout, " prog='%s'", a->prog); + Bprint(&bout, " prog=%q", a->prog); Bprint(&bout, "\n"); if(a->n){