mk: avoid infinite loop when targets are repeated

Fixes "mk -f /tmp/x.mk y x" or "mk -f /tmp/x.mk" where /tmp/x.mk is:

x y x: f
	echo hi

Change-Id: I7fa87dc4750c04fdba010b990c190722b432b333
Reviewed-on: https://plan9port-review.googlesource.com/1361
Reviewed-by: Russ Cox <rsc@swtch.com>
This commit is contained in:
Russ Cox 2015-08-25 15:59:43 -04:00
parent 775cb933ec
commit 44eb208829
2 changed files with 6 additions and 0 deletions

View file

@ -109,6 +109,7 @@ typedef struct Node
#define NORECIPE 0x0400
#define DELETE 0x0800
#define NOMINUSE 0x1000
#define ONLIST 0x2000
typedef struct Job
{

View file

@ -70,10 +70,15 @@ dorecipe(Node *node)
ww->next = newword(buf);
ww = ww->next;
if(n == node) continue;
if((n->flags&ONLIST) != 0)
continue;
n->flags |= ONLIST;
n->next = node->next;
node->next = n;
}
}
for(n = node->next; n; n = n->next)
n->flags &= ~ONLIST;
for(n = node; n; n = n->next)
if((n->flags&READY) == 0)
return(did);