diff options
author | rsc <devnull@localhost> | 2003-09-30 17:47:42 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2003-09-30 17:47:42 +0000 |
commit | ed7c8e8d02c02bdbff1e88a6d8d1419f39af48ad (patch) | |
tree | ebcd32d20b0df2584bce713fefa87620ecd1cce7 /src/cmd/mk | |
parent | b2cfc4e2e71d0f0a5113ddfbd93c8285cc4d74e4 (diff) | |
download | plan9port-ed7c8e8d02c02bdbff1e88a6d8d1419f39af48ad.tar.gz plan9port-ed7c8e8d02c02bdbff1e88a6d8d1419f39af48ad.tar.bz2 plan9port-ed7c8e8d02c02bdbff1e88a6d8d1419f39af48ad.zip |
Initial import.
Diffstat (limited to 'src/cmd/mk')
-rw-r--r-- | src/cmd/mk/NOTICE | 27 | ||||
-rw-r--r-- | src/cmd/mk/README | 7 | ||||
-rw-r--r-- | src/cmd/mk/bufblock.c | 88 | ||||
-rw-r--r-- | src/cmd/mk/job.c | 33 | ||||
-rw-r--r-- | src/cmd/mk/mk.pdf | bin | 0 -> 69685 bytes |
5 files changed, 155 insertions, 0 deletions
diff --git a/src/cmd/mk/NOTICE b/src/cmd/mk/NOTICE new file mode 100644 index 00000000..9911f992 --- /dev/null +++ b/src/cmd/mk/NOTICE @@ -0,0 +1,27 @@ +Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved. +Portions Copyright © 1995-1997 C H Forsyth (forsyth@caldo.demon.co.uk). All rights reserved. +Portions Copyright © 1997-1999 Vita Nuova Limited. All rights reserved. +Portions Copyright © 2000-2002 Vita Nuova Holdings Limited (www.vitanuova.com). All rights reserved. + +Under a licence agreement with Lucent Technologies Inc. effective 1st March 2000, +Vita Nuova Holdings Limited has the right to determine (within a specified scope) +the form and content of sublicences for this software. + +Vita Nuova Holdings Limited now makes this software available as Free +Software under the terms of the `GNU General Public LIcense, Version 2' +(see the file LICENCE or http://www.fsf.org/copyleft/gpl.html for +the full terms and conditions). One of the conditions of that licence +is that you must keep intact all notices that refer to that licence and to the absence of +of any warranty: for this software, note that includes this NOTICE file in particular. + +This suite of programs is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +`GNU General Public License' for more details. + +This copyright NOTICE applies to all files in this directory and +subdirectories, unless another copyright notice appears in a given +file or subdirectory. If you take code from this software to use in +other programs, you must somehow include with it an appropriate +copyright notice that includes the copyright notice and the other +notices above. diff --git a/src/cmd/mk/README b/src/cmd/mk/README new file mode 100644 index 00000000..3bd11ff2 --- /dev/null +++ b/src/cmd/mk/README @@ -0,0 +1,7 @@ +This is a Unix port of mk, +originally done for the Inferno operating system. + +Russ Cox repackaged this to build as a standalone +Unix program. Send comments about packaging to +Russ Cox <rsc@post.harvard.edu> + diff --git a/src/cmd/mk/bufblock.c b/src/cmd/mk/bufblock.c new file mode 100644 index 00000000..979403bc --- /dev/null +++ b/src/cmd/mk/bufblock.c @@ -0,0 +1,88 @@ +#include "mk.h" + +static Bufblock *freelist; +#define QUANTA 4096 + +Bufblock * +newbuf(void) +{ + Bufblock *p; + + if (freelist) { + p = freelist; + freelist = freelist->next; + } else { + p = (Bufblock *) Malloc(sizeof(Bufblock)); + p->start = Malloc(QUANTA*sizeof(*p->start)); + p->end = p->start+QUANTA; + } + p->current = p->start; + *p->start = 0; + p->next = 0; + return p; +} + +void +freebuf(Bufblock *p) +{ + p->next = freelist; + freelist = p; +} + +void +growbuf(Bufblock *p) +{ + int n; + Bufblock *f; + char *cp; + + n = p->end-p->start+QUANTA; + /* search the free list for a big buffer */ + for (f = freelist; f; f = f->next) { + if (f->end-f->start >= n) { + memcpy(f->start, p->start, p->end-p->start); + cp = f->start; + f->start = p->start; + p->start = cp; + cp = f->end; + f->end = p->end; + p->end = cp; + f->current = f->start; + break; + } + } + if (!f) { /* not found - grow it */ + p->start = Realloc(p->start, n); + p->end = p->start+n; + } + p->current = p->start+n-QUANTA; +} + +void +bufcpy(Bufblock *buf, char *cp, int n) +{ + + while (n--) + insert(buf, *cp++); +} + +void +insert(Bufblock *buf, int c) +{ + + if (buf->current >= buf->end) + growbuf(buf); + *buf->current++ = c; +} + +void +rinsert(Bufblock *buf, Rune r) +{ + int n; + + n = runelen(r); + if (buf->current+n > buf->end) + growbuf(buf); + runetochar(buf->current, &r); + buf->current += n; +} diff --git a/src/cmd/mk/job.c b/src/cmd/mk/job.c new file mode 100644 index 00000000..cee93760 --- /dev/null +++ b/src/cmd/mk/job.c @@ -0,0 +1,33 @@ +#include "mk.h" + +Job * +newjob(Rule *r, Node *nlist, char *stem, char **match, Word *pre, Word *npre, Word *tar, Word *atar) +{ + register Job *j; + + j = (Job *)Malloc(sizeof(Job)); + j->r = r; + j->n = nlist; + j->stem = stem; + j->match = match; + j->p = pre; + j->np = npre; + j->t = tar; + j->at = atar; + j->nproc = -1; + j->next = 0; + return(j); +} + +void +dumpj(char *s, Job *j, int all) +{ + Bprint(&bout, "%s\n", s); + while(j){ + Bprint(&bout, "job@%ld: r=%ld n=%ld stem='%s' nproc=%d\n", + j, j->r, j->n, j->stem, j->nproc); + Bprint(&bout, "\ttarget='%s' alltarget='%s' prereq='%s' nprereq='%s'\n", + wtos(j->t, ' '), wtos(j->at, ' '), wtos(j->p, ' '), wtos(j->np, ' ')); + j = all? j->next : 0; + } +} diff --git a/src/cmd/mk/mk.pdf b/src/cmd/mk/mk.pdf Binary files differnew file mode 100644 index 00000000..d7b68c76 --- /dev/null +++ b/src/cmd/mk/mk.pdf |