use %q when printing names and commands to prevent confusing debugging output Reference: /n/atom/patch/applied2013/mkfmtq Date: Thu Jun 20 00:24:36 CES 2013 Signed-off-by: quanstro@quanstro.net --- /sys/src/cmd/mk/arc.c Thu Jun 20 00:23:57 2013 +++ /sys/src/cmd/mk/arc.c Thu Jun 20 00:23:57 2013 @@ -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){ --- /sys/src/cmd/mk/job.c Thu Jun 20 00:23:57 2013 +++ /sys/src/cmd/mk/job.c Thu Jun 20 00:23:57 2013 @@ -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/main.c Thu Jun 20 00:23:57 2013 +++ /sys/src/cmd/mk/main.c Thu Jun 20 00:23:57 2013 @@ -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/rule.c Thu Jun 20 00:23:57 2013 +++ /sys/src/cmd/mk/rule.c Thu Jun 20 00:23:57 2013 @@ -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/run.c Thu Jun 20 00:23:57 2013 +++ /sys/src/cmd/mk/run.c Thu Jun 20 00:23:57 2013 @@ -15,7 +15,7 @@ struct Process *b, *f; } Process; static Process *phead, *pfree; -static void sched(void); +static int sched(void); static void pnew(int, int), pdelete(Process *); int pidslot(int); @@ -33,11 +33,12 @@ jobs = j; j->next = 0; /* this code also in waitup after parse redirect */ - if(nrunning < nproclimit) - sched(); + while(nrunning < nproclimit) + if(sched() == -1) + break; } -static void +static int sched(void) { char *flags; @@ -49,7 +50,7 @@ if(jobs == 0){ usage(); - return; + return -1; } j = jobs; jobs = j->next; @@ -69,14 +70,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; @@ -88,6 +89,7 @@ if(DEBUG(D_EXEC)) fprint(1, "pid for target %s = %d\n", wtos(j->t, ' '), events[slot].pid); } + return 0; } int @@ -154,7 +156,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"); @@ -171,8 +173,9 @@ continue; /* not interested in this node */ update(uarg, s->u.ptr); } - if(nrunning < nproclimit) - sched(); + while(nrunning < nproclimit) + if(sched() == -1) + break; return(0); } --- /sys/src/cmd/mk/var.c Thu Jun 20 00:23:57 2013 +++ /sys/src/cmd/mk/var.c Thu Jun 20 00:23:57 2013 @@ -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/word.c Thu Jun 20 00:23:57 2013 +++ /sys/src/cmd/mk/word.c Thu Jun 20 00:23:57 2013 @@ -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'); }