diff --git a/books/tangle.c b/books/tangle.c index 04a2e20..5eb6c11 100644 --- a/books/tangle.c +++ b/books/tangle.c @@ -5,6 +5,7 @@ #include #include +// set this to 3 for further information #define DEBUG 0 /* forward reference for the C compiler */ @@ -34,15 +35,19 @@ int printline(int i, int length) { int foundchunk(int i, char *chunkname) { if ((strncmp(&buffer[i+14],chunkname,strlen(chunkname)) == 0) && (buffer[i+13] == '{') && - (buffer[i+14+strlen(chunkname)] == '}')) return(1); + (buffer[i+14+strlen(chunkname)] == '}')) { + if (DEBUG==3) { printf("foundchunk(%s)\n",chunkname); } + return(1); + } return(0); } /* handle end{chunk} */ /* is it really an end? */ -int foundEnd(int i) { +int foundEnd(int i, char* chunkname) { if ((buffer[i] == '\\') && (strncmp(&buffer[i+1],"end{chunk}",10) == 0)) { + if (DEBUG==3) { printf("foundEnd(%s)\n",chunkname); } return(1); } return(0); @@ -75,18 +80,16 @@ int printchunk(int i, int chunklinelen, char *chunkname) { int linelen; char *getname; int getlen = 0; + if (DEBUG==3) { printf("=== \\start{%s} ===\n",chunkname); } for (k=i+chunklinelen+1; ((linelen=nextline(k)) != -1); ) { - if (DEBUG==2) { - printf(">>>>"); 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); } + if ((linelen >= 11) && (foundEnd(k,chunkname) == 1)) { + if (DEBUG==3) { printf("=== \\end{%s} ===\n",chunkname); } return(k+12); } else { if (DEBUG==2) { @@ -108,12 +111,13 @@ int getchunk(char *chunkname) { int j; int linelen; int chunklen = strlen(chunkname); + if (DEBUG==3) { printf("getchunk(%s)\n",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) { + if (DEBUG==2) { fprintf(stderr,"=================\\getchunk(%s)\n",chunkname); } i=printchunk(i,linelen,chunkname); @@ -121,7 +125,7 @@ int getchunk(char *chunkname) { i=i+linelen+1; } } - if (DEBUG) { + if (DEBUG==2) { fprintf(stderr,"=================getchunk returned=%d\n",i); } return(i); diff --git a/changelog b/changelog index dd1b005..6ac2d76 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,5 @@ +20140629 tpd src/axiom-website/patches.html 20140629.06.tpd.patch +20140629 tpd books/tangle.c improve the debugging output (DEBUG==3) 20140629 tpd src/axiom-website/patches.html 20140629.05.tpd.patch 20140629 tpd books/bookvol10.3 add information to SingleInteger 20140629 tpd src/axiom-website/patches.html 20140629.04.tpd.patch diff --git a/patch b/patch index 63f0393..40f2fed 100644 --- a/patch +++ b/patch @@ -1,10 +1,6 @@ -books/bookvol10.3 add information to SingleInteger +books/tangle.c improve the debugging output (DEBUG==3) + +Improve the debugging output (DEBUG==3) so that it is obvious +what chunk is being expanded. It also shows the expanded output +delimited by begin/end markers. -This type represents finite (machine) precision integers which wrap -around at a machine dependent value. However, {\bf SingleInteger} has -type {\bf EntireRing} which should have no non-zero divisors. But -\[ (2**16:SINT)**2 = 0\] -on a 32 bit machine. Using {\bf SingleInteger} is a pragmatic -efficiency choice. In this condition, Axiom will complain that the -result is not of type FIXNUM, which is the Common Lisp type for -machine integers. diff --git a/src/axiom-website/patches.html b/src/axiom-website/patches.html index 22c699c..d1a1461 100644 --- a/src/axiom-website/patches.html +++ b/src/axiom-website/patches.html @@ -4512,6 +4512,8 @@ src/axiom-website/documentation.html add McNamara quote Makefile default to notests for users 20140629.05.tpd.patch books/bookvol10.3 add information to SingleInteger +20140629.06.tpd.patch +books/tangle.c improve the debugging output (DEBUG==3)