230 common.c

Large diffs are not rendered by default.

@@ -101,7 +101,7 @@ extern char byte_mem[]; /* characters of names */
extern char *byte_mem_end; /* end of |byte_mem| */
extern name_info name_dir[]; /* information about names */
extern name_pointer name_dir_end; /* end of |name_dir| */
extern name_pointer name_ptr; /* first unused position in |byte_start| */
extern name_pointer name_ptr; /* first unused position in |name_dir| */
extern char *byte_ptr; /* first unused position in |byte_mem| */
extern name_pointer hash[]; /* heads of hash lists */
extern hash_pointer hash_end; /* end of |hash| */
@@ -615,7 +615,7 @@ usually have |name_ptr->byte_start==byte_ptr|, and certainly
we want to keep |name_ptr<=name_dir_end| and |byte_ptr<=byte_mem_end|.

@<Defini...@>=
name_pointer name_ptr; /* first unused position in |byte_start| */
name_pointer name_ptr; /* first unused position in |name_dir| */
char *byte_ptr; /* first unused position in |byte_mem| */

@ @<Init...@>=
@@ -93,7 +93,7 @@ extern char byte_mem[]; /* characters of names */
extern char *byte_mem_end; /* end of |byte_mem| */
extern name_info name_dir[]; /* information about names */
extern name_pointer name_dir_end; /* end of |name_dir| */
extern name_pointer name_ptr; /* first unused position in |byte_start| */
extern name_pointer name_ptr; /* first unused position in |name_dir| */
extern char *byte_ptr; /* first unused position in |byte_mem| */
extern name_pointer hash[]; /* heads of hash lists */
extern hash_pointer hash_end; /* end of |hash| */
@@ -126,7 +126,7 @@ extern char huge byte_mem[]; /* characters of names */
extern char huge* byte_mem_end; /* end of |byte_mem| */
extern name_info name_dir[]; /* information about names */
extern name_pointer name_dir_end; /* end of |name_dir| */
extern name_pointer name_ptr; /* first unused position in |byte_start| */
extern name_pointer name_ptr; /* first unused position in |name_dir| */
extern char huge* byte_ptr; /* first unused position in |byte_mem| */
extern name_pointer hash[]; /* heads of hash lists */
extern hash_pointer hash_end; /* end of |hash| */
@@ -11,7 +11,7 @@

#include <ctype.h>
#include <stdlib.h>

#include <string.h>
/*:62*/
#line 65 "ctangle.w"

@@ -366,11 +366,11 @@ extern sixteen_bits section_count;
/*2:*/
#line 77 "ctangle.w"

extern int strlen();
extern int strcmp();
extern char*strcpy();
extern int strncmp();
extern char*strncpy();






/*:2*//*41:*/
#line 533 "ctangle.w"
@@ -49,7 +49,7 @@ extern char byte_mem[]; /* characters of names */
extern char *byte_mem_end; /* end of |byte_mem| */
extern name_info name_dir[]; /* information about names */
extern name_pointer name_dir_end; /* end of |name_dir| */
extern name_pointer name_ptr; /* first unused position in |byte_start| */
extern name_pointer name_ptr; /* first unused position in |name_dir| */
extern char *byte_ptr; /* first unused position in |byte_mem| */
extern name_pointer hash[]; /* heads of hash lists */
extern hash_pointer hash_end; /* end of |hash| */
@@ -82,7 +82,7 @@ extern char huge byte_mem[]; /* characters of names */
extern char huge* byte_mem_end; /* end of |byte_mem| */
extern name_info name_dir[]; /* information about names */
extern name_pointer name_dir_end; /* end of |name_dir| */
extern name_pointer name_ptr; /* first unused position in |byte_start| */
extern name_pointer name_ptr; /* first unused position in |name_dir| */
extern char huge* byte_ptr; /* first unused position in |byte_mem| */
extern name_pointer hash[]; /* heads of hash lists */
extern hash_pointer hash_end; /* end of |hash| */
@@ -110,6 +110,8 @@ otherwise do an ordinary Meta-y."
(insert ch)
(setq arg (1- arg)))))
(global-set-key "\M-\"" 'ditto)
; If "ditto" suddenly fails to work, you have probably set goal-column
; inadvertently. To unset it, say C-u C-x C-n.

;; OK, here's part (2): Changes to TeX mode.
; The WEB modes below are very much like TeX mode, but some improvements were
@@ -210,6 +212,7 @@ for relative module movement. The automatic \" feature is disabled."
(modify-syntax-entry ?% "@")
(setq mode-name "CWEB")
(setq major-mode 'cweb-mode)
(setq tex-fontify-script nil) ;; needed in GNU Emacs version 22?
(run-hooks 'cweb-mode-hook))
(setq auto-mode-alist (cons '("\\.w$" . cweb-mode) auto-mode-alist))
(setq auto-mode-alist (cons '("\\.ch$" . cweb-mode) auto-mode-alist))
@@ -1,8 +1,8 @@
% standard macros for CWEB listings (in addition to plain.tex)
% Version 3.67 --- July 2006
% Version 3.68 --- January 2016
\ifx\renewenvironment\undefined\else\endinput\fi % LaTeX will use other macros
\xdef\fmtversion{\fmtversion+CWEB3.67}
\chardef\cwebversion=3 \chardef\cwebrevision=67
\xdef\fmtversion{\fmtversion+CWEB3.68}
\chardef\cwebversion=3 \chardef\cwebrevision=68
\newif\ifpdf
\ifx\pdf+\pdftrue\fi
% Uncomment the following line if you want PDF goodies to be the default
@@ -278,7 +278,8 @@
\sfcode`;=1500 \pretolerance 200 \hyphenpenalty 50 \exhyphenpenalty 50
\noindent{\let\*=\lapstar\bf\secstar.\quad}%
\ifpdftex\smash{\raise\baselineskip\hbox to0pt{%
\let\*=\empty\pdfdest num \secstar fith}}
% \let\*=\empty\pdfdest num \secstar fith}} % bad space in versions < 3.68
\let\*=\empty\pdfdest num \secstar fith}}% changed in version 3.68
\else\ifpdf\smash{\raise\baselineskip\hbox to0pt{%
\let\*=\empty\special{%
pdf: dest (\romannumeral\secstar) [ @thispage /FitH @ypos ]}}}\fi\fi}
@@ -340,7 +341,7 @@
\def\T#1{\leavevmode % octal, hex or decimal constant
\hbox{$\def\?{\kern.2em}%
% \def\$##1{\egroup_{\,\rm##1}\bgroup}% suffix to constant % versions < 3.67
\def\$##1{\egroup_{\rm##1}\bgroup}% suffix to constant
\def\$##1{\egroup_{\rm##1}\bgroup}% suffix to constant % in version 3.67
\def\_{\cdot 10^{\aftergroup}}% power of ten (via dirty trick)
\let\~=\oct \let\^=\hex {#1}$}}
\def\U{\note{This code is used in section}} % xref for use of a section
@@ -457,6 +458,7 @@
\def\fin{\par\vfill\eject % this is done when we are ending the index
\ifpagesaved\null\vfill\eject\fi % output a null index column
\if L\lr\else\null\vfill\eject\fi % finish the current page
\ifpdftex \makebookmarks \fi % added in Version 3.68
\parfillskip 0pt plus 1fil
\def\grouptitle{NAMES OF THE SECTIONS}
\let\topsecno=\nullsec
@@ -470,7 +472,8 @@
\def\Us{\note{Used in sections}} % crossref for uses of a section
\def\I{\par\hangindent 2em}\let\*=*
\ifacro \def\outsecname{Names of the sections} \let\Xpdf\X
\ifpdftex \makebookmarks \pdfdest name {NOS} fitb
% \ifpdftex \makebookmarks \pdfdest name {NOS} fitb % in versions < 3.68
\ifpdftex \pdfdest name {NOS} fitb % changed in version 3.68
\pdfoutline goto name {NOS} count -\secno {\outsecname}
\def\X##1:##2\X{\Xpdf##1:##2\X \firstsecno##1.%
{\toksF={}\makeoutlinetoks##2\outlinedone\outlinedone}%
@@ -1514,7 +1514,7 @@

\point 1. Four fonts have been declared in addition to the standard fonts of
\.{PLAIN} format: You can say `\.{\{\\mc UNIX\}}' to get {\mc UNIX} in
xmedium-size caps; you can say `\.{\{\\sc STUFF\}}' to get {\sc STUFF}
medium-size caps; you can say `\.{\{\\sc STUFF\}}' to get {\sc STUFF}
in small caps; and you can select the largish fonts \.{\\titlefont}
and \.{\\ttitlefont} in the title of your document, where \.{\\ttitlefont}
is a typewriter style of type. There are macros \.{\\UNIX/} and \.{\\CEE/}
@@ -14,19 +14,20 @@ if(cc=='\\'&&c==cc) c= '\0';} \
#define ignore_line 7 \

/*2:*/
#line 47 "extex.w"
#line 47 "./extex.w"

#include <stdio.h>
#include <ctype.h>
#include <string.h>
extern void exit();

/*3:*/
#line 75 "extex.w"
#line 76 "./extex.w"

int c;

/*:3*//*14:*/
#line 233 "extex.w"
#line 234 "./extex.w"

char ptab[]= {0,1,1,1,1,0,
1,1,1,1,1,0,0,1,
@@ -39,7 +40,7 @@ char ptab[]= {0,1,1,1,1,0,
0,0,0,1,1,1,0};

/*:14*//*17:*/
#line 290 "extex.w"
#line 291 "./extex.w"

char wtab[]= {start_section,nop,nop,nop,nop,nop,nop,nop,
start_name,nop,start_section,nop,nop,nop,start_index,nop,
@@ -55,10 +56,10 @@ nop,ignore_line,nop,nop,ignore_line,nop,nop,nop,
start_C,start_insert,nop,start_C,start_insert};

/*:17*/
#line 52 "extex.w"
#line 53 "./extex.w"

/*6:*/
#line 109 "extex.w"
#line 110 "./extex.w"

int get()
{register int x;
@@ -68,7 +69,7 @@ return x;
}

/*:6*//*12:*/
#line 188 "extex.w"
#line 189 "./extex.w"

int controlseq()
{
@@ -83,7 +84,7 @@ if(l==1)b= c;
}
if(l==0)c= getchar();
/*13:*/
#line 208 "extex.w"
#line 209 "./extex.w"

if((a>='"'&&a<='~'&&ptab[a-'"']==l)||
(l==2&&(pair('a','e')||pair('A','E')
@@ -107,21 +108,21 @@ return 1;
}

/*:13*/
#line 202 "extex.w"
#line 203 "./extex.w"
;
return 0;
}

/*:12*/
#line 53 "extex.w"
#line 54 "./extex.w"


int main(argc,argv)
int argc;
char*argv[];
{
/*4:*/
#line 78 "extex.w"
#line 79 "./extex.w"

int web;
int comment;
@@ -130,25 +131,25 @@ int save_skipping;
register int cc;

/*:4*/
#line 59 "extex.w"
#line 60 "./extex.w"
;
if(strlen(*argv)>=6&&strcmp(*argv+strlen(*argv)-6,"excweb")==0){
web= 1;
/*15:*/
#line 248 "extex.w"
#line 249 "./extex.w"

ptab[12]= 1;

/*:15*/
#line 62 "extex.w"
#line 63 "./extex.w"
;
}else web= 0;
comment= skipping= c= 0;
main_cycle:if(c)goto big_switch;
restart:c= get();
big_switch:switch(c){
/*5:*/
#line 94 "extex.w"
#line 95 "./extex.w"

case'%':discard_to('\n');goto restart;
case'$':c= getchar();
@@ -160,7 +161,7 @@ while(getchar()!='$');
goto restart;

/*:5*//*7:*/
#line 121 "extex.w"
#line 122 "./extex.w"

case'a':case'A':
case'b':case'B':
@@ -191,13 +192,13 @@ case'z':case'Z':
goto out_word;

/*:7*//*11:*/
#line 184 "extex.w"
#line 185 "./extex.w"

case'\\':if(controlseq())goto control_seq_in_word;
goto main_cycle;

/*:11*//*16:*/
#line 262 "extex.w"
#line 263 "./extex.w"

case'@':if(web)goto do_web;
goto restart;
@@ -215,13 +216,13 @@ goto skip_C;
goto big_switch;

/*:16*/
#line 68 "extex.w"
#line 69 "./extex.w"

case EOF:exit(0);
default:goto restart;
}
/*8:*/
#line 154 "extex.w"
#line 155 "./extex.w"

out_word:putchar(c);
continue_word:c= getchar();
@@ -239,13 +240,13 @@ end_word:putchar('\n');
goto main_cycle;

/*:8*//*10:*/
#line 180 "extex.w"
#line 181 "./extex.w"

control_seq_in_word:if(!c)goto continue_word;
goto checkout_word;

/*:10*//*18:*/
#line 306 "extex.w"
#line 307 "./extex.w"

do_web:c= getchar();
if(c<' '||c> 't')goto restart;
@@ -264,7 +265,7 @@ goto restart;
}

/*:18*//*19:*/
#line 328 "extex.w"
#line 329 "./extex.w"

skip_C:save_skipping= 2;
skip_C_prime:skipping= 1;
@@ -303,7 +304,7 @@ default:continue;
}

/*:19*/
#line 72 "extex.w"
#line 73 "./extex.w"
;
}

@@ -47,6 +47,7 @@ any other programs that simulate finite-state automata.)
@c
#include <stdio.h>
#include <ctype.h>
#include <string.h>
extern void exit(); /* system routine that terminates execution */
@#
@<Global variables@>@;

Large diffs are not rendered by default.

@@ -45,7 +45,7 @@ are not as standard as the names of the functions. (There's confusion
between \.{<string.h>} and \.{<strings.h>}.)

@<Predecl...@>=
extern int strlen(); /* length of string */
extern size_t strlen(); /* length of string */
extern char* strcpy(); /* copy one string to another */
extern int strncmp(); /* compare up to $n$ string characters */
extern char* strncpy(); /* copy up to $n$ string characters */
@@ -9,17 +9,18 @@
return x;} \

/*3:*/
#line 92 "wordtest.w"
#line 92 "./wordtest.w"

#include <stdio.h>
#include <stdlib.h>

/*4:*/
#line 107 "wordtest.w"
#line 108 "./wordtest.w"

typedef unsigned char byte;

/*:4*//*9:*/
#line 195 "wordtest.w"
#line 196 "./wordtest.w"

typedef struct node_struct{
struct node_struct*left,*right;
@@ -28,7 +29,7 @@ unsigned long rank;
}node;

/*:9*//*20:*/
#line 391 "wordtest.w"
#line 392 "./wordtest.w"

typedef struct filenode_struct{
struct filenode_struct*link;
@@ -40,14 +41,14 @@ byte*endword;
}filenode;

/*:20*/
#line 95 "wordtest.w"
#line 96 "./wordtest.w"

int main(argc,argv)
int argc;
char*argv[];
{
/*5:*/
#line 110 "wordtest.w"
#line 111 "./wordtest.w"

int targc;
byte**targv;
@@ -59,12 +60,12 @@ register int c;
register byte*u,*v;

/*:5*//*12:*/
#line 251 "wordtest.w"
#line 252 "./wordtest.w"

unsigned long current_rank= 0;

/*:12*//*16:*/
#line 309 "wordtest.w"
#line 310 "./wordtest.w"

node*next_node= NULL,*bad_node= NULL;
byte*next_string= NULL,*bad_string= NULL;
@@ -73,23 +74,23 @@ byte*buffer;
int l;

/*:16*//*22:*/
#line 409 "wordtest.w"
#line 410 "./wordtest.w"

filenode*curfile;
filenode*f;

/*:22*/
#line 100 "wordtest.w"
#line 101 "./wordtest.w"
;
/*6:*/
#line 122 "wordtest.w"
#line 123 "./wordtest.w"

for(c= 0;c<256;c++)ord[c]= c;
delta= 0;
targc= argc-1;targv= (byte**)argv+1;
while(targc&&**targv=='-'){
/*7:*/
#line 139 "wordtest.w"
#line 140 "./wordtest.w"

switch((*targv)[1]){
case'a':for(c= delta,u= *targv+2;*u;u++)ord[*u]= ++c;break;
@@ -110,7 +111,7 @@ return-1;
}

/*:7*/
#line 127 "wordtest.w"
#line 128 "./wordtest.w"
;
targc--;targv++;
}
@@ -119,7 +120,7 @@ else{
breakchar= '\0';
for(c= 255;c;c--)if(ord[c]<0)breakchar= c;
if(!breakchar)/*8:*/
#line 158 "wordtest.w"
#line 159 "./wordtest.w"

{
ord['\n']= -1;
@@ -128,11 +129,11 @@ for(c= 1;c<=26;c++)ord['a'-1+c]= 'A'-1+c;
}

/*:8*/
#line 134 "wordtest.w"
#line 135 "./wordtest.w"
;
}
/*21:*/
#line 401 "wordtest.w"
#line 402 "./wordtest.w"

if(targc){
curfile= (filenode*)calloc(targc,sizeof(filenode));
@@ -142,10 +143,10 @@ f->link= curfile;
}else curfile= NULL;

/*:21*/
#line 136 "wordtest.w"
#line 137 "./wordtest.w"
;
for(;targc;targc--,targv++)/*23:*/
#line 413 "wordtest.w"
#line 414 "./wordtest.w"

{
curfile->dfile= fopen((char*)*targv,"r");
@@ -161,20 +162,20 @@ curfile= curfile->link;
}

/*:23*/
#line 137 "wordtest.w"
#line 138 "./wordtest.w"
;

/*:6*/
#line 101 "wordtest.w"
#line 102 "./wordtest.w"
;
/*17:*/
#line 319 "wordtest.w"
#line 320 "./wordtest.w"

buffer= (byte*)malloc(max_length+1);
if(buffer==NULL)out_of_mem(-5);
while(1){
/*18:*/
#line 332 "wordtest.w"
#line 333 "./wordtest.w"

u= buffer;l= 0;
while(l<max_length){
@@ -196,11 +197,11 @@ l++;
*u= breakchar;

/*:18*/
#line 323 "wordtest.w"
#line 324 "./wordtest.w"
;
if(l){
/*10:*/
#line 213 "wordtest.w"
#line 214 "./wordtest.w"

{register node*p= root;
while(p){
@@ -212,10 +213,10 @@ else p= p->right;
}

/*:10*/
#line 325 "wordtest.w"
#line 326 "./wordtest.w"
;
/*11:*/
#line 235 "wordtest.w"
#line 236 "./wordtest.w"

{register node*p,**q,**qq,*r;
current_rank+= PHICLONE;
@@ -227,7 +228,7 @@ if(ord[*u]<ord[*v])q= &(p->left),p= *q;
else q= &(p->right),p= *q;
}
/*14:*/
#line 285 "wordtest.w"
#line 286 "./wordtest.w"

if(next_node==bad_node){
next_node= (node*)calloc(NODES_PER_BLOCK,sizeof(node));
@@ -236,7 +237,7 @@ bad_node= next_node+NODES_PER_BLOCK;
}
r= next_node++;
/*15:*/
#line 295 "wordtest.w"
#line 296 "./wordtest.w"

if(next_string+l+1>=bad_string){int block_size= CHARS_PER_BLOCK+l+1;
next_string= (byte*)malloc(block_size);
@@ -249,16 +250,16 @@ for(u= buffer,v= next_string;ord[*u]> 0;u++,v++)*v= *u;
next_string= v+1;

/*:15*/
#line 293 "wordtest.w"
#line 294 "./wordtest.w"
;

/*:14*/
#line 245 "wordtest.w"
#line 246 "./wordtest.w"
;
r->rank= current_rank;
*q= r;
/*13:*/
#line 259 "wordtest.w"
#line 260 "./wordtest.w"

q= &(r->left);qq= &(r->right);
while(p){
@@ -276,23 +277,23 @@ p= *q;
*q= *qq= NULL;

/*:13*/
#line 248 "wordtest.w"
#line 249 "./wordtest.w"
;
}

/*:11*/
#line 326 "wordtest.w"
#line 327 "./wordtest.w"
;
found:;
}
}
done:;

/*:17*/
#line 102 "wordtest.w"
#line 103 "./wordtest.w"
;
/*19:*/
#line 358 "wordtest.w"
#line 359 "./wordtest.w"

if(root!=NULL){register node*p,*q;
p= root;
@@ -305,18 +306,18 @@ root= p;
p= q;
}
visit:/*25:*/
#line 437 "wordtest.w"
#line 438 "./wordtest.w"

while(curfile!=NULL){
for(u= p->keyword,v= curfile->curword;ord[*u]==ord[*v];u++,v++);
if(*u=='\0'&&*v==breakchar)goto word_done;

if(ord[*u]<ord[*v])break;
/*27:*/
#line 452 "wordtest.w"
#line 453 "./wordtest.w"

/*28:*/
#line 472 "wordtest.w"
#line 473 "./wordtest.w"

v= curfile->curword;
l= max_length;
@@ -342,7 +343,7 @@ break;
}
if(u==w){
/*29:*/
#line 504 "wordtest.w"
#line 505 "./wordtest.w"

if(ferror(curfile->dfile)){
fprintf(stderr,"%s: File read error on dictionary file!\n",*argv);
@@ -363,7 +364,7 @@ curfile->limit= curfile->buf+fread(curfile->buf,1,BUFSIZ,curfile->dfile);
curfile->pos= curfile->buf;

/*:29*/
#line 497 "wordtest.w"
#line 498 "./wordtest.w"
;
}else curfile->pos= u+1;
}
@@ -372,15 +373,15 @@ curfile->endword= v;
update_done:;

/*:28*/
#line 453 "wordtest.w"
#line 454 "./wordtest.w"
;
/*30:*/
#line 523 "wordtest.w"
#line 524 "./wordtest.w"

if(curfile!=NULL){filenode*sentinel= curfile;
for(f= curfile->link;f!=sentinel;f= f->link)
/*31:*/
#line 529 "wordtest.w"
#line 530 "./wordtest.w"

{
*f->endword= '\0';
@@ -390,31 +391,31 @@ if(ord[*u]<ord[*v])curfile= f;
}

/*:31*/
#line 526 "wordtest.w"
#line 527 "./wordtest.w"
;
}

/*:30*/
#line 455 "wordtest.w"
#line 456 "./wordtest.w"
;

/*:27*/
#line 443 "wordtest.w"
#line 444 "./wordtest.w"
;
}
/*26:*/
#line 448 "wordtest.w"
#line 449 "./wordtest.w"

for(u= p->keyword;*u;u++)putchar(*u);
putchar(breakchar);

/*:26*/
#line 445 "wordtest.w"
#line 446 "./wordtest.w"

word_done:;

/*:25*/
#line 369 "wordtest.w"
#line 370 "./wordtest.w"
;
if(p->right==NULL){
if(root==NULL)break;
@@ -426,7 +427,7 @@ goto visit;
}

/*:19*/
#line 103 "wordtest.w"
#line 104 "./wordtest.w"
;
return 0;
}
@@ -91,6 +91,7 @@ a nonzero value is returned.

@p
#include <stdio.h>
#include <stdlib.h>
@#
@<Typedefs@>@;
int main(argc,argv)