diff --git a/Makefile b/Makefile index dded5a3..81a964b 100644 --- a/Makefile +++ b/Makefile @@ -127,7 +127,7 @@ WEAVE=${WEAVE} \ XLIB=${XLIB} \ ZIPS=${ZIPS} -all: noweb ${MNT}/${SYS}/bin/document +all: tangle noweb ${MNT}/${SYS}/bin/document @ echo p1 making a parallel system build @ echo 1 making a ${SYS} system, PART=${PART} SUBPART=${SUBPART} @ echo 2 Environment ${ENV} @@ -220,6 +220,10 @@ book: rm book.aux ) @ echo 80 The book is at ${MNT}/${SYS}/doc/book.dvi +tangle: books/tangle.c + @echo t01 making tangle from tangle.c + @( cd books ; gcc -o tangle tangle.c ) + noweb: @echo 13 making noweb @mkdir -p ${OBJ}/noweb @@ -306,4 +310,5 @@ clean: @ for i in `find src -name "Makefile"` ; do rm -f $$i ; done @ for i in `find src -name "Makefile.dvi"` ; do rm -f $$i ; done @ rm -f lastBuildDate + @ rm -f books/tangle diff --git a/Makefile.pamphlet b/Makefile.pamphlet index 84b6601..7a0f542 100644 --- a/Makefile.pamphlet +++ b/Makefile.pamphlet @@ -163,6 +163,7 @@ clean: @ for i in `find src -name "Makefile"` ; do rm -f $$i ; done @ for i in `find src -name "Makefile.dvi"` ; do rm -f $$i ; done @ rm -f lastBuildDate + @ rm -f books/tangle @ @@ -549,6 +550,15 @@ book: @ echo 80 The book is at ${MNT}/${SYS}/doc/book.dvi @ +\subsection{tangle.c} +<>= + +tangle: books/tangle.c + @echo t01 making tangle from tangle.c + @( cd books ; gcc -o tangle tangle.c ) + +@ + \subsection{noweb} Note that this stanza echos a line into a file called noweb. @@ -965,6 +975,7 @@ all: rootdirs noweb srcsetup lspdir srcdir @- grep "result FAILED" int/input/*.regress <> +<> <> <> <> diff --git a/books/tangle.c b/books/tangle.c new file mode 100644 index 0000000..b4008ea --- /dev/null +++ b/books/tangle.c @@ -0,0 +1,158 @@ +#include +#include +#include +#include +#include +#include + +#define DEBUG 0 + +/* forward reference for the C compiler */ +int getchunk(char *chunkname); + +/* a memory mapped buffer copy of the file */ +char *buffer; +int bufsize; + +/* return the length of the next line */ +int nextline(int i) { + int j; + if (i >= bufsize) return(-1); + for (j=0; ((i+j < bufsize) && (buffer[i+j] != '\n')); j++); + return(j); +} + +/* output the line we need */ +int printline(int i, int length) { + int j; + for (j=0; j>>>"); printline(k,linelen); printf("<<<<\n"); + } + if ((getlen=foundGetchunk(k,linelen)) > 0) { + getname = getChunkname(k,getlen); + getchunk(getname); + free(getname); + k=k+getlen+12l; + } else { + if ((linelen >= 11) && (foundEnd(k) == 1)) { + if (DEBUG) { printf("=================\\end{%s}\n",chunkname); } + return(k+12); + } else { + if (DEBUG==2) { + printf("======== printchunk else %d %d\n",k,linelen); + } + printline(k,linelen); + k=k+linelen+1; + } + }} + if (DEBUG==2) { + printf("=================\\out{%s} %d\n",chunkname,k); + } + return(k); +} + +/* find the named chunk and call printchunk on it */ +int getchunk(char *chunkname) { + int i; + int j; + int linelen; + int chunklen = strlen(chunkname); + for (i=0; ((linelen=nextline(i)) != -1); ) { + if (DEBUG==2) { + printf("----"); printline(i,linelen); printf("----\n"); + } + if ((linelen >= chunklen+15) && (foundchunk(i,chunkname) == 1)) { + if (DEBUG) { + fprintf(stderr,"=================\\getchunk(%s)\n",chunkname); + } + i=printchunk(i,linelen,chunkname); + } else { + i=i+linelen+1; + } + } + if (DEBUG) { + fprintf(stderr,"=================getchunk returned=%d\n",i); + } + return(i); +} + +/* memory map the input file into the global buffer and get the chunk */ +int main(int argc, char *argv[]) { + int fd; + struct stat filestat; + if ((argc < 2) || (argc > 3)) { + perror("Usage: tangle filename chunkname"); + exit(-1); + } + fd = open(argv[1],O_RDONLY); + if (fd == -1) { + perror("Error opening file for reading"); + exit(-2); + } + if (fstat(fd,&filestat) < 0) { + perror("Error getting input file size"); + exit(-3); + } + bufsize = (int)filestat.st_size; + buffer = mmap(0,filestat.st_size,PROT_READ,MAP_SHARED,fd,0); + if (buffer == MAP_FAILED) { + close(fd); + perror("Error reading the file"); + exit(-4); + } + getchunk(argv[2]); + close(fd); + return(0); +} + diff --git a/changelog b/changelog index 2655c9f..5bfe02f 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,6 @@ +20140623 tpd src/axiom-website/patches.html 20140623.05.tpd.patch +20140623 tpd Makefile set up a native tangle function +20140623 tpd books/tangle.c set up a native tangle function 20140623 tpd src/axiom-website/patches.html 20140623.04.tpd.patch 20140623 tpd src/scripts/showdvi removed 20140623 tpd src/scripts/boxup removed diff --git a/src/axiom-website/patches.html b/src/axiom-website/patches.html index 37f8d7f..fe7b36e 100644 --- a/src/axiom-website/patches.html +++ b/src/axiom-website/patches.html @@ -4492,6 +4492,9 @@ books/bookvolbib.pamphlet add Baez09 src/axiom-website/download.html add texlive-fonts-extra 20140623.04.tpd.patch src/scripts/boxhead, boxtail, boxup, showdvi removed +20140623.05.tpd.patch +Makefile, books/tangle.c set up a native tangle function +