Back to index

tetex-bin  3.0
Typedefs | Functions | Variables
common.h File Reference
#include <stdio.h>

Go to the source code of this file.

Typedefs

typedef char unsigned eight_bits
typedef name_infoname_pointer
typedef name_pointerhash_pointer

Functions

%This file is part of CWEB%This
program by Silvio Levy and
Donald E Knuth%is based on a
program by Knuth%It is
distributed WITHOUT ANY
express or implied%Version 
June (works also with later versions)%Copyright(C) 1987
Code related to identifier and
section name 
length ((c)))@d llink link @d rlink dummy.Rlink @d root name_dir->rlink @d chunk_marker 0 @< Common code...@>
name_pointer id_lookup ()
name_pointer section_lookup ()
void print_section_name ()
void sprint_section_name ()
 err_print ()
 wrap_up ()
void fatal ()
void overflow ()
 reset_input ()
 get_line ()
 check_complete ()
Code relating to b fflush (stdout)
Code relating to b fwrite (a, sizeof(char), b, stdout)@d C_printf(c
Code relating to b a fprintf (C_file, c, a)@d C_putc(c) putc(c

Variables

%This file is part of CWEB%This
program by Silvio Levy and
Donald E Knuth%is based on a
program by Knuth%It is
distributed WITHOUT ANY 
WARRANTY
%This file is part of CWEB%This
program by Silvio Levy and
Donald E Knuth%is based on a
program by Knuth%It is
distributed WITHOUT ANY
express or implied%Version
Silvio Levy and Donald E Knuth%Permission
is granted to make and
distribute verbatim copies of
this%document provided that
the copyright notice and this
permission notice%are
preserved on all copies%Permission
is granted to copy and
distribute modified versions
of this%document under the
conditions for verbatim 
copying
%This file is part of CWEB%This
program by Silvio Levy and
Donald E Knuth%is based on a
program by Knuth%It is
distributed WITHOUT ANY
express or implied%Version
Silvio Levy and Donald E Knuth%Permission
is granted to make and
distribute verbatim copies of
this%document provided that
the copyright notice and this
permission notice%are
preserved on all copies%Permission
is granted to copy and
distribute modified versions
of this%document under the
conditions for verbatim
provided that the%entire
resulting derived work is
distributed under the terms of
a%permission notice identical
to this one%Please send 
comments
%This file is part of CWEB%This
program by Silvio Levy and
Donald E Knuth%is based on a
program by Knuth%It is
distributed WITHOUT ANY
express or implied%Version
Silvio Levy and Donald E Knuth%Permission
is granted to make and
distribute verbatim copies of
this%document provided that
the copyright notice and this
permission notice%are
preserved on all copies%Permission
is granted to copy and
distribute modified versions
of this%document under the
conditions for verbatim
provided that the%entire
resulting derived work is
distributed under the terms of
a%permission notice identical
to this one%Please send 
suggestions
%This file is part of CWEB%This
program by Silvio Levy and
Donald E Knuth%is based on a
program by Knuth%It is
distributed WITHOUT ANY
express or implied%Version
Silvio Levy and Donald E Knuth%Permission
is granted to make and
distribute verbatim copies of
this%document provided that
the copyright notice and this
permission notice%are
preserved on all copies%Permission
is granted to copy and
distribute modified versions
of this%document under the
conditions for verbatim
provided that the%entire
resulting derived work is
distributed under the terms of
a%permission notice identical
to this one%Please send etc to
levy math berkeley edu%The
next few sections contain
stuff from the file common w
that has%to be included in
both ctangle w and cweave w It
appears in this%file common 
h
%This file is part of CWEB%This
program by Silvio Levy and
Donald E Knuth%is based on a
program by Knuth%It is
distributed WITHOUT ANY
express or implied%Version
Silvio Levy and Donald E Knuth%Permission
is granted to make and
distribute verbatim copies of
this%document provided that
the copyright notice and this
permission notice%are
preserved on all copies%Permission
is granted to copy and
distribute modified versions
of this%document under the
conditions for verbatim
provided that the%entire
resulting derived work is
distributed under the terms of
a%permission notice identical
to this one%Please send etc to
levy math berkeley edu%The
next few sections contain
stuff from the file common w
that has%to be included in
both ctangle w and cweave w It
appears in this%file common
which needs to be updated when
common w changes First comes
general 
stuff
boolean program
int phase
< Includefiles @> char * section_text_end
char * id_first
char * id_loc
Code related to input routines
char * buffer_end
char * loc
char * limit
Code related to identifier and
section name 
storage
char byte_mem []
char * byte_mem_end
name_info name_dir []
name_pointer name_dir_end
name_pointer name_ptr
char * byte_ptr
name_pointer hash []
hash_pointer hash_end
Code related to error handling
d mark_error history
FILEfile []
FILEchange_file
char C_file_name []
char tex_file_name []
char idx_file_name []
char scn_file_name []
char file_name [][max_file_name_length]
char change_file_name []
 line []
 change_line
boolean input_has_ended
boolean changing
boolean web_file_open
Code related to section numbers
sixteen_bits section_count
boolean changed_section []
boolean change_pending
boolean print_where
Code related to command line arguments
char ** argv
boolean flags []
Code relating to output
Code relating to b a C_file
< Commoncode...@> FILE
tex_file
FILEidx_file
FILEscn_file
FILEactive_file
The procedure that gets everything rolling

Typedef Documentation

typedef char unsigned eight_bits

Definition at line 31 of file common.h.

Definition at line 99 of file common.h.

Definition at line 98 of file common.h.


Function Documentation

err_print ( )
void fatal ( )
Code relating to b fflush ( stdout  )
Code relating to b a fprintf ( C_file  ,
c  ,
a   
)
Code relating to b fwrite ( a  ,
sizeof(char)  ,
b  ,
stdout   
)

Here is the caller graph for this function:

get_line ( )

Definition at line 542 of file common.c.

{
restart:
if(changing&&include_depth==change_depth)
/*25:*/
#line 537 "common.w"
{
change_line++;
if(!input_ln(change_file)){
err_print("! Change file ended without @z");

buffer[0]= '@';buffer[1]= 'z';limit= buffer+2;
}
if(limit> buffer){
if(change_pending){
if_section_start_make_pending(0);
if(change_pending){
changed_section[section_count]= 1;change_pending= 0;
}
}
*limit= ' ';
if(buffer[0]=='@'){
if(xisupper(buffer[1]))buffer[1]= tolower(buffer[1]);
if(buffer[1]=='x'||buffer[1]=='y'){
loc= buffer+2;
err_print("! Where is the matching @z?");

}
else if(buffer[1]=='z'){
prime_the_change_buffer();changing= !changing;print_where= 1;
}
}
}
}

/*:25*/
#line 431 "common.w"
;
if(!changing||include_depth> change_depth){
/*24:*/
#line 520 "common.w"
{
cur_line++;
while(!input_ln(cur_file)){
print_where= 1;
if(include_depth==0){input_has_ended= 1;break;}
else{
fclose(cur_file);include_depth--;
if(changing&&include_depth==change_depth)break;
cur_line++;
}
}
if(!changing&&!input_has_ended)
if(limit-buffer==change_limit-change_buffer)
if(buffer[0]==change_buffer[0])
if(change_limit> change_buffer)check_change();
}

/*:24*/
#line 433 "common.w"
;
if(changing&&include_depth==change_depth)goto restart;
}
if(input_has_ended)return 0;
loc= buffer;*limit= ' ';
if(buffer[0]=='@'&&(buffer[1]=='i'||buffer[1]=='I')){
loc= buffer+2;*limit= '"';
while(*loc==' '||*loc=='\t')loc++;
if(loc>=limit){
err_print("! Include file name not given");

goto restart;
}
if(include_depth>=max_include_depth-1){
err_print("! Too many nested includes");

goto restart;
}
include_depth++;
/*23:*/
#line 474 "common.w"
{
char temp_file_name[max_file_name_length];
char*cur_file_name_end= cur_file_name+max_file_name_length-1;
char*k= cur_file_name,*kk;
int l;

if(*loc=='"'){
loc++;
while(*loc!='"'&&k<=cur_file_name_end)*k++= *loc++;
if(loc==limit)k= cur_file_name_end+1;
}else
while(*loc!=' '&&*loc!='\t'&&*loc!='"'&&k<=cur_file_name_end)*k++= *loc++;
if(k> cur_file_name_end)too_long();

*k= '\0';
if((cur_file= fopen(cur_file_name,"r"))!=NULL){
cur_line= 0;print_where= 1;
goto restart;
}
kk= getenv("CWEBINPUTS");
if(kk!=NULL){
if((l= strlen(kk))> max_file_name_length-2)too_long();
strcpy(temp_file_name,kk);
}
else{
#ifdef CWEBINPUTS
if((l= strlen(CWEBINPUTS))> max_file_name_length-2)too_long();
strcpy(temp_file_name,CWEBINPUTS);
#else
l= 0;
#endif 
}
if(l> 0){
if(k+l+2>=cur_file_name_end)too_long();

for(;k>=cur_file_name;k--)*(k+l+1)= *k;
strcpy(cur_file_name,temp_file_name);
cur_file_name[l]= '/';
if((cur_file= fopen(cur_file_name,"r"))!=NULL){
cur_line= 0;print_where= 1;
goto restart;
}
}
include_depth--;err_print("! Cannot open include file");goto restart;
}

/*:23*/
#line 452 "common.w"
;
}
return 1;
}
% This file is part of CWEB % This program by Silvio Levy and Donald E Knuth % is based on a program by Knuth % It is distributed WITHOUT ANY express or implied % Version June ( works also with later  versions)
Code related to identifier and section name length ( (c )

Definition at line 513 of file common.c.

{
limit= buffer;loc= buffer+1;buffer[0]= ' ';
/*19:*/
#line 393 "common.w"

if((web_file= fopen(web_file_name,"r"))==NULL){
strcpy(web_file_name,alt_web_file_name);
if((web_file= fopen(web_file_name,"r"))==NULL)
fatal("! Cannot open input file ",web_file_name);
}


web_file_open= 1;
if((change_file= fopen(change_file_name,"r"))==NULL)
fatal("! Cannot open change file ",change_file_name);

/*:19*/
#line 383 "common.w"
;
include_depth= 0;cur_line= 0;change_line= 0;
change_depth= include_depth;
changing= 1;prime_the_change_buffer();changing= !changing;
limit= buffer;loc= buffer+1;buffer[0]= ' ';input_has_ended= 0;
}
wrap_up ( )

Definition at line 554 of file ctie.c.

{
/*34:*/
#line 682 "./ctie.w"

switch(history){
case spotless:
printf("\n(No errors were found.)\n");break;
case troublesome:
printf("\n(Pardon me, but I think I spotted something wrong.)\n");break;
case fatal:printf("(That was a fatal error, my friend.)\n");
}


/*:34*/
#line 666 "./ctie.w"
;
if(history> spotless)return 1;
else return 0;
}

Variable Documentation

Definition at line 252 of file cwebboot.c.

Definition at line 171 of file common.h.

char** argv

Definition at line 237 of file cwebboot.c.

char* buffer_end

Definition at line 149 of file cwebboot.c.

char byte_mem[]

Definition at line 209 of file cwebboot.c.

char* byte_mem_end

Definition at line 210 of file cwebboot.c.

char* byte_ptr

Definition at line 218 of file cwebboot.c.

char C_file_name[]

Definition at line 238 of file cwebboot.c.

Definition at line 158 of file cwebboot.c.

Definition at line 161 of file cwebboot.c.

Definition at line 164 of file cwebboot.c.

Definition at line 176 of file cwebboot.c.

Definition at line 175 of file cwebboot.c.

Definition at line 167 of file cwebboot.c.

% This file is part of CWEB % This program by Silvio Levy and Donald E Knuth % is based on a program by Knuth % It is distributed WITHOUT ANY express or implied % Version Silvio Levy and Donald E Knuth % Permission is granted to make and distribute verbatim copies of this % document provided that the copyright notice and this permission notice % are preserved on all copies % Permission is granted to copy and distribute modified versions of this % document under the conditions for verbatim provided that the % entire resulting derived work is distributed under the terms of a % permission notice identical to this one % Please send comments

Definition at line 7 of file common.h.

% This file is part of CWEB % This program by Silvio Levy and Donald E Knuth % is based on a program by Knuth % It is distributed WITHOUT ANY express or implied % Version Silvio Levy and Donald E Knuth % Permission is granted to make and distribute verbatim copies of this % document provided that the copyright notice and this permission notice % are preserved on all copies % Permission is granted to copy and distribute modified versions of this % document under the conditions for verbatim copying

Definition at line 7 of file common.h.

FILE* file[]

Definition at line 157 of file cwebboot.c.

Definition at line 159 of file cwebboot.c.

Definition at line 1530 of file png.h.

Definition at line 7 of file common.h.

Code related to file handling

Definition at line 118 of file common.h.

Definition at line 224 of file cwebboot.c.

Definition at line 225 of file cwebboot.c.

Initial value:
error_message
@d confusion(s) fatal("! This can't happen: ",s)

@<Common...@>=
extern history

Definition at line 119 of file common.h.

char* id_first

Definition at line 60 of file common.h.

char* id_loc

Definition at line 61 of file common.h.

Definition at line 249 of file cwebboot.c.

char idx_file_name[]

Definition at line 240 of file cwebboot.c.

Definition at line 182 of file ctie-k.c.

char* limit

Definition at line 150 of file cwebboot.c.

line[]

Definition at line 176 of file t1part.c.

char* loc

Definition at line 151 of file cwebboot.c.

Definition at line 211 of file cwebboot.c.

Definition at line 212 of file cwebboot.c.

Definition at line 217 of file cwebboot.c.

Code related to section numbers

Definition at line 159 of file common.h.

static void output

Definition at line 178 of file common.h.

Definition at line 261 of file cwebboot.c.

Definition at line 178 of file cwebboot.c.

Definition at line 143 of file cwebboot.c.

The procedure that gets everything rolling

Definition at line 192 of file common.h.

Code related to input routines

Definition at line 73 of file common.h.

Definition at line 250 of file cwebboot.c.

char scn_file_name[]

Definition at line 241 of file cwebboot.c.

Definition at line 174 of file cwebboot.c.

<Includefiles@> char* section_text_end
Initial value:


@ Code related to the character set:
@^ASCII code dependencies@>

@d and_and 04 
@d lt_lt 020 
@d gt_gt 021 
@d plus_plus 013 
@d minus_minus 01 
@d minus_gt 031 
@d not_eq 032 
@d lt_eq 034 
@d gt_eq 035 
@d eq_eq 036 
@d or_or 037 
@d dot_dot_dot 016 
@d colon_colon 06 
@d period_ast 026 
@d minus_gt_ast 027 

@<Common code...@>=
char section_text[longest_name+1] section_text+longest_name

Definition at line 59 of file common.h.

Code related to identifier and section name storage

Definition at line 80 of file common.h.

% This file is part of CWEB % This program by Silvio Levy and Donald E Knuth % is based on a program by Knuth % It is distributed WITHOUT ANY express or implied % Version Silvio Levy and Donald E Knuth % Permission is granted to make and distribute verbatim copies of this % document provided that the copyright notice and this permission notice % are preserved on all copies % Permission is granted to copy and distribute modified versions of this % document under the conditions for verbatim provided that the % entire resulting derived work is distributed under the terms of a % permission notice identical to this one % Please send etc to levy math berkeley edu % The next few sections contain stuff from the file common w that has % to be included in both ctangle w and cweave w It appears in this % file common which needs to be updated when common w changes First comes general stuff

Definition at line 7 of file common.h.

% This file is part of CWEB % This program by Silvio Levy and Donald E Knuth % is based on a program by Knuth % It is distributed WITHOUT ANY express or implied % Version Silvio Levy and Donald E Knuth % Permission is granted to make and distribute verbatim copies of this % document provided that the copyright notice and this permission notice % are preserved on all copies % Permission is granted to copy and distribute modified versions of this % document under the conditions for verbatim provided that the % entire resulting derived work is distributed under the terms of a % permission notice identical to this one % Please send suggestions

Definition at line 7 of file common.h.

Code relating to b a C_file<Commoncode...@> FILE* tex_file
Initial value:
extern FILE *C_file

Definition at line 248 of file cwebboot.c.

char tex_file_name[]

Definition at line 239 of file cwebboot.c.

% This file is part of CWEB % This program by Silvio Levy and Donald E Knuth % is based on a program by Knuth % It is distributed WITHOUT ANY WARRANTY

Definition at line 4 of file common.h.

Definition at line 168 of file cwebboot.c.