diff options
author | Russ Cox <rsc@swtch.com> | 2015-08-25 15:59:43 -0400 |
---|---|---|
committer | Russ Cox <rsc@swtch.com> | 2015-08-27 00:36:40 +0000 |
commit | 44eb2088299f10d45a1b3950285c3314217e0f44 (patch) | |
tree | 6a934a03efa3a62d299f64c6cbe4bbaf9869f12c /src/cmd/mk | |
parent | 775cb933ecea6361717ef1def27b5d9e90c385fd (diff) | |
download | plan9port-44eb2088299f10d45a1b3950285c3314217e0f44.tar.gz plan9port-44eb2088299f10d45a1b3950285c3314217e0f44.tar.bz2 plan9port-44eb2088299f10d45a1b3950285c3314217e0f44.zip |
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>
Diffstat (limited to 'src/cmd/mk')
-rw-r--r-- | src/cmd/mk/mk.h | 1 | ||||
-rw-r--r-- | src/cmd/mk/recipe.c | 5 |
2 files changed, 6 insertions, 0 deletions
diff --git a/src/cmd/mk/mk.h b/src/cmd/mk/mk.h index a40e9ded..ca14e9d6 100644 --- a/src/cmd/mk/mk.h +++ b/src/cmd/mk/mk.h @@ -109,6 +109,7 @@ typedef struct Node #define NORECIPE 0x0400 #define DELETE 0x0800 #define NOMINUSE 0x1000 +#define ONLIST 0x2000 typedef struct Job { diff --git a/src/cmd/mk/recipe.c b/src/cmd/mk/recipe.c index 7993e091..60325198 100644 --- a/src/cmd/mk/recipe.c +++ b/src/cmd/mk/recipe.c @@ -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); |