Back to index

tetex-bin  3.0
Classes | Defines | Typedefs | Functions | Variables
common.c File Reference
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>

Go to the source code of this file.

Classes

struct  name_info
union  name_info.dummy

Defines

#define ctangle   0
#define cweave   1 \
#define and_and   04
#define lt_lt   020
#define gt_gt   021
#define plus_plus   013
#define minus_minus   01
#define minus_gt   031
#define not_eq   032
#define lt_eq   034
#define gt_eq   035
#define eq_eq   036
#define or_or   037
#define dot_dot_dot   016
#define colon_colon   06
#define period_ast   026
#define minus_gt_ast   027 \
#define buf_size   100
#define longest_name   1000
#define long_buf_size   (buf_size+longest_name)
#define xisspace(c)   (isspace(c) &&((unsigned char) c<0200) )
#define xisupper(c)   (isupper(c) &&((unsigned char) c<0200) ) \
#define max_include_depth   10 \
#define max_file_name_length   60
#define cur_file   file[include_depth]
#define cur_file_name   file_name[include_depth]
#define cur_line   line[include_depth]
#define web_file   file[0]
#define web_file_name   file_name[0] \
#define lines_dont_match
#define if_section_start_make_pending(b)
#define max_sections
#define too_long()
#define max_bytes   90000 \
#define max_names
#define length(c)   (c+1) ->byte_start-(c) ->byte_start
#define print_id(c)   term_write((c) ->byte_start,length((c) ) ) \
#define hash_size   353 \
#define llink   link
#define rlink   dummy.Rlink
#define root
#define first_chunk(p)   ((p) ->byte_start+2)
#define prefix_length(p)
#define set_prefix_length(p, m)
#define less   0
#define equal   1
#define greater   2
#define prefix   3
#define extension   4 \
#define bad_extension   5 \
#define spotless   0
#define harmless_message   1
#define error_message   2
#define fatal_message   3
#define mark_harmless   {if(history==spotless) history= harmless_message;}
#define mark_error   history= error_message \
#define confusion(s)
#define show_banner   flags['b']
#define show_progress   flags['p']
#define show_stats   flags['s']
#define show_happiness   flags['h'] \
#define update_terminal   fflush(stdout) \
#define new_line   putchar('\n')
#define putxchar   putchar
#define term_write(a, b)   fflush(stdout) ,fwrite(a,sizeof(char) ,b,stdout)
#define C_printf(c, a)   fprintf(C_file,c,a)
#define C_putc(c)   putc(c,C_file) \

Typedefs

typedef short boolean
typedef unsigned short sixteen_bits
typedef struct name_info name_info
typedef name_infoname_pointer
typedef name_pointerhash_pointer

Functions

int names_match ()
void init_p ()
void init_node ()
int section_name_cmp ()
void err_print ()
int wrap_up ()
void print_stats ()
void fatal ()
void overflow ()
void scan_args ()
int strlen ()
int strcmp ()
char * strcpy ()
int strncmp ()
char * strncpy ()
void common_init ()
int input_ln (FILE *fp)
void prime_the_change_buffer ()
void check_change ()
void reset_input ()
int get_line ()
void check_complete ()
name_pointer id_lookup (char *first, char *last, char t)
void print_section_name (name_pointer p)
void sprint_section_name (char *dest, name_pointer p)
void print_prefix_name (name_pointer p)
int web_strcmp (char *j, int j_len, char *k, int k_len)
name_pointer add_section_name (name_pointer par, int c, char *first, char *last, int ispref)
void extend_section_name (name_pointer p, char *first, char *last, int ispref)
name_pointer section_lookup (char *first, char *last, int ispref)
int section_name_cmp (char **pfirst, int len, name_pointer r)
void err_print (char *s)
void fatal (char *s, char *t)
void overflow (char *t)

Variables

boolean program
char buffer [long_buf_size]
char * buffer_end = buffer+buf_size-2
char * limit = buffer
char * loc = buffer
int include_depth
FILEfile [max_include_depth]
FILEchange_file
char file_name [max_include_depth][max_file_name_length]
char change_file_name [max_file_name_length]
char alt_web_file_name [max_file_name_length]
int line [max_include_depth]
int change_line
int change_depth
boolean input_has_ended
boolean changing
boolean web_file_open = 0
sixteen_bits section_count
boolean changed_section [max_sections]
boolean change_pending
boolean print_where = 0
char byte_mem [max_bytes]
char * byte_mem_end = byte_mem+max_bytes-1
name_info name_dir [max_names]
name_pointer name_dir_end = name_dir+max_names-1
name_pointer name_ptr
char * byte_ptr
name_pointer hash [hash_size]
hash_pointer hash_end = hash+hash_size-1
hash_pointer h
int history = spotless
int argc
char ** argv
char C_file_name [max_file_name_length]
char tex_file_name [max_file_name_length]
char idx_file_name [max_file_name_length]
char scn_file_name [max_file_name_length]
boolean flags [128]
FILEC_file
FILEtex_file
FILEidx_file
FILEscn_file
FILEactive_file
int phase
char change_buffer [buf_size]
char * change_limit

Class Documentation

struct name_info

Definition at line 174 of file ctangleboot.c.

Collaboration diagram for name_info:
Class Members
char * byte_start
union name_info dummy
union name_info dummy
union name_info dummy
union name_info dummy
char * equiv_or_xref
struct name_info * link
union name_info.dummy

Definition at line 180 of file common.c.

Class Members
char Ilk
struct name_info * Rlink

Define Documentation

#define and_and   04

Definition at line 25 of file common.c.

#define bad_extension   5 \

Definition at line 98 of file common.c.

#define buf_size   100

Definition at line 41 of file common.c.

#define C_printf (   c,
  a 
)    fprintf(C_file,c,a)

Definition at line 120 of file common.c.

#define C_putc (   c)    putc(c,C_file) \

Definition at line 121 of file common.c.

#define colon_colon   06

Definition at line 37 of file common.c.

#define confusion (   s)
Value:
fatal("! This can't happen: ",s)  \
 \

Definition at line 107 of file common.c.

#define ctangle   0

Definition at line 22 of file common.c.

#define cur_file   file[include_depth]

Definition at line 50 of file common.c.

Definition at line 51 of file common.c.

#define cur_line   line[include_depth]

Definition at line 52 of file common.c.

#define cweave   1 \

Definition at line 23 of file common.c.

#define dot_dot_dot   016

Definition at line 36 of file common.c.

#define eq_eq   036

Definition at line 34 of file common.c.

#define equal   1

Definition at line 93 of file common.c.

#define error_message   2

Definition at line 102 of file common.c.

#define extension   4 \

Definition at line 96 of file common.c.

#define fatal_message   3

Definition at line 103 of file common.c.

#define first_chunk (   p)    ((p) ->byte_start+2)

Definition at line 86 of file common.c.

#define greater   2

Definition at line 94 of file common.c.

#define gt_eq   035

Definition at line 33 of file common.c.

#define gt_gt   021

Definition at line 27 of file common.c.

#define harmless_message   1

Definition at line 101 of file common.c.

#define hash_size   353 \

Definition at line 79 of file common.c.

Value:
{*limit= '!'; \
for(loc= buffer;xisspace(*loc) ;loc++) ; \
*limit= ' '; \
if(*loc=='@'&&(xisspace(*(loc+1) ) ||*(loc+1) =='*') ) change_pending= b; \
} \

Definition at line 59 of file common.c.

#define length (   c)    (c+1) ->byte_start-(c) ->byte_start

Definition at line 76 of file common.c.

#define less   0

Definition at line 92 of file common.c.

Value:

Definition at line 56 of file common.c.

#define llink   link

Definition at line 81 of file common.c.

Definition at line 43 of file common.c.

#define longest_name   1000

Definition at line 42 of file common.c.

#define lt_eq   034

Definition at line 32 of file common.c.

#define lt_lt   020

Definition at line 26 of file common.c.

#define mark_error   history= error_message \

Definition at line 105 of file common.c.

Definition at line 104 of file common.c.

#define max_bytes   90000 \

Definition at line 71 of file common.c.

#define max_file_name_length   60

Definition at line 49 of file common.c.

#define max_include_depth   10 \

Definition at line 47 of file common.c.

#define max_names
Value:
4000 \
 \

Definition at line 73 of file common.c.

#define max_sections
Value:
2000 \
 \

Definition at line 65 of file common.c.

#define minus_gt   031

Definition at line 30 of file common.c.

#define minus_gt_ast   027 \

Definition at line 39 of file common.c.

#define minus_minus   01

Definition at line 29 of file common.c.

#define new_line   putchar('\n')

Definition at line 117 of file common.c.

#define not_eq   032

Definition at line 31 of file common.c.

#define or_or   037

Definition at line 35 of file common.c.

#define period_ast   026

Definition at line 38 of file common.c.

#define plus_plus   013

Definition at line 28 of file common.c.

#define prefix   3

Definition at line 95 of file common.c.

#define prefix_length (   p)
Value:
(int) ((unsigned char) *((p) ->byte_start) *256+ \
(unsigned char) *((p) ->byte_start+1) )

Definition at line 87 of file common.c.

#define print_id (   c)    term_write((c) ->byte_start,length((c) ) ) \

Definition at line 77 of file common.c.

#define putxchar   putchar

Definition at line 118 of file common.c.

#define rlink   dummy.Rlink

Definition at line 82 of file common.c.

#define root
Value:
name_dir->rlink \
 \

Definition at line 83 of file common.c.

#define set_prefix_length (   p,
 
)
Value:
(*((p) ->byte_start) = (m) /256, \
*((p) ->byte_start+1) = (m) %256)  \

Definition at line 89 of file common.c.

#define show_banner   flags['b']

Definition at line 110 of file common.c.

#define show_happiness   flags['h'] \

Definition at line 113 of file common.c.

#define show_progress   flags['p']

Definition at line 111 of file common.c.

#define show_stats   flags['s']

Definition at line 112 of file common.c.

#define spotless   0

Definition at line 100 of file common.c.

#define term_write (   a,
  b 
)    fflush(stdout) ,fwrite(a,sizeof(char) ,b,stdout)

Definition at line 119 of file common.c.

#define too_long ( )
Value:
{include_depth--; \
err_print("! Include file name too long") ;goto restart;} \

Definition at line 68 of file common.c.

#define update_terminal   fflush(stdout) \

Definition at line 115 of file common.c.

#define web_file   file[0]

Definition at line 53 of file common.c.

#define web_file_name   file_name[0] \

Definition at line 54 of file common.c.

#define xisspace (   c)    (isspace(c) &&((unsigned char) c<0200) )

Definition at line 44 of file common.c.

#define xisupper (   c)    (isupper(c) &&((unsigned char) c<0200) ) \

Definition at line 45 of file common.c.


Typedef Documentation

typedef short boolean

Definition at line 129 of file common.c.

Definition at line 210 of file common.c.

typedef struct name_info name_info

Definition at line 195 of file common.c.

typedef unsigned short sixteen_bits

Definition at line 160 of file common.c.


Function Documentation

name_pointer add_section_name ( name_pointer  par,
int  c,
char*  first,
char*  last,
int  ispref 
)

Definition at line 821 of file common.c.

{
name_pointer p= name_ptr;
char*s= first_chunk(p);
int name_len= last-first+ispref;
if(s+name_len> byte_mem_end)overflow("byte memory");
if(name_ptr+1>=name_dir_end)overflow("name");
(++name_ptr)->byte_start= byte_ptr= s+name_len;
if(ispref){
*(byte_ptr-1)= ' ';
name_len--;
name_ptr->link= name_dir;
(++name_ptr)->byte_start= byte_ptr;
}
set_prefix_length(p,name_len);
strncpy(s,first,name_len);
p->llink= NULL;
p->rlink= NULL;
init_node(p);
return par==NULL?(root= p):c==less?(par->llink= p):(par->rlink= p);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 444 of file common.c.

{
int n= 0;
if(lines_dont_match)return;
change_pending= 0;
if(!changed_section[section_count]){
if_section_start_make_pending(1);
if(!change_pending)changed_section[section_count]= 1;
}
while(1){
changing= 1;print_where= 1;change_line++;
if(!input_ln(change_file)){
err_print("! Change file ended before @y");

change_limit= change_buffer;changing= 0;
return;
}
if(limit> buffer+1&&buffer[0]=='@'){
char xyz_code= xisupper(buffer[1])?tolower(buffer[1]):buffer[1];
/*17:*/
#line 358 "common.w"

if(xyz_code=='x'||xyz_code=='z'){
loc= buffer+2;err_print("! Where is the matching @y?");

}
else if(xyz_code=='y'){
if(n> 0){
loc= buffer+2;
printf("\n! Hmm... %d ",n);
err_print("of the preceding lines failed to match");

}
change_depth= include_depth;
return;
}

/*:17*/
#line 342 "common.w"
;
}
/*15:*/
#line 292 "common.w"

{
change_limit= change_buffer+(limit-buffer);
strncpy(change_buffer,buffer,limit-buffer+1);
}

/*:15*/
#line 344 "common.w"
;
changing= 0;cur_line++;
while(!input_ln(cur_file)){
if(include_depth==0){
err_print("! CWEB file ended during a change");

input_has_ended= 1;return;
}
include_depth--;cur_line++;
}
if(lines_dont_match)n++;
}
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 680 of file common.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 314 of file common.c.

{
/*30:*/
#line 621 "common.w"

name_dir->byte_start= byte_ptr= byte_mem;
name_ptr= name_dir+1;
name_ptr->byte_start= byte_mem;

/*:30*//*34:*/
#line 655 "common.w"

for(h= hash;h<=hash_end;*h++= NULL);

/*:34*//*41:*/
#line 737 "common.w"

root= NULL;

/*:41*/
#line 93 "common.w"
;
/*68:*/
#line 1233 "common.w"

show_banner= show_happiness= show_progress= 1;

/*:68*/
#line 94 "common.w"
;
/*78:*/
#line 1377 "common.w"

scan_args();
if(program==ctangle){
if((C_file= fopen(C_file_name,"w"))==NULL)
fatal("! Cannot open output file ",C_file_name);

}
else{
if((tex_file= fopen(tex_file_name,"w"))==NULL)
fatal("! Cannot open output file ",tex_file_name);
}

/*:78*/
#line 95 "common.w"
;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void err_print ( char*  s)

Definition at line 1003 of file common.c.

{
char*k,*l;
printf(*s=='!'?"\n%s":"%s",s);
if(web_file_open)/*59:*/
#line 1115 "common.w"

{if(changing&&include_depth==change_depth)
printf(". (l. %d of change file)\n",change_line);
else if(include_depth==0)printf(". (l. %d)\n",cur_line);
else printf(". (l. %d of include file %s)\n",cur_line,cur_file_name);
l= (loc>=limit?limit:loc);
if(l> buffer){
for(k= buffer;k<l;k++)
if(*k=='\t')putchar(' ');
else putchar(*k);
putchar('\n');
for(k= buffer;k<l;k++)putchar(' ');
}
for(k= l;k<limit;k++)putchar(*k);
if(*limit=='|')putchar('|');
putchar(' ');
}

/*:59*/
#line 1102 "common.w"
;
update_terminal;mark_error;
}

Here is the call graph for this function:

void extend_section_name ( name_pointer  p,
char*  first,
char*  last,
int  ispref 
)

Definition at line 852 of file common.c.

{
char*s;
name_pointer q= p+1;
int name_len= last-first+ispref;
if(name_ptr>=name_dir_end)overflow("name");
while(q->link!=name_dir)q= q->link;
q->link= name_ptr;
s= name_ptr->byte_start;
name_ptr->link= name_dir;
if(s+name_len> byte_mem_end)overflow("byte memory");
(++name_ptr)->byte_start= byte_ptr= s+name_len;
strncpy(s,first,name_len);
if(ispref)*(byte_ptr-1)= ' ';
}

Here is the call graph for this function:

Here is the caller graph for this function:

void fatal ( )
void fatal ( char*  s,
char*  t 
)

Definition at line 1063 of file common.c.

Here is the call graph for this function:

static char * get_line ( void  )

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;
}

Here is the call graph for this function:

name_pointer id_lookup ( char*  first,
char*  last,
char  t 
)

Definition at line 694 of file common.c.

{
char*i= first;
int h;
int l;
name_pointer p;
if(last==NULL)for(last= first;*last!='\0';last++);
l= last-first;
/*36:*/
#line 683 "common.w"

h= (unsigned char)*i;
while(++i<last)h= (h+h+(int)((unsigned char)*i))%hash_size;


/*:36*/
#line 673 "common.w"
;
/*37:*/
#line 691 "common.w"

p= hash[h];
while(p&&!names_match(p,first,l,t))p= p->link;
if(p==NULL){
p= name_ptr;
p->link= hash[h];hash[h]= p;
}

/*:37*/
#line 674 "common.w"
;
if(p==name_ptr)/*39:*/
#line 706 "common.w"
{
if(byte_ptr+l> byte_mem_end)overflow("byte memory");
if(name_ptr>=name_dir_end)overflow("name");
strncpy(byte_ptr,first,l);
(++name_ptr)->byte_start= byte_ptr+= l;
if(program==cweave)init_p(p,t);
}

/*:39*/
#line 675 "common.w"
;
return(p);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Here is the caller graph for this function:

void init_p ( )

Definition at line 498 of file ctangle.c.

{}

Here is the caller graph for this function:

int input_ln ( FILE fp)

Definition at line 366 of file common.c.

{
register int c= EOF;
register char*k;
if(feof(fp))return(0);
limit= k= buffer;
while(k<=buffer_end&&(c= getc(fp))!=EOF&&c!='\n')
if((*(k++)= c)!=' ')limit= k;
if(k> buffer_end)
if((c= getc(fp))!=EOF&&c!='\n'){
ungetc(c,fp);loc= buffer;err_print("! Input line too long");

}
if(c==EOF&&limit==buffer)return(0);

return(1);
}

Here is the caller graph for this function:

Here is the caller graph for this function:

void overflow ( char*  t)

Definition at line 1074 of file common.c.

{
printf("\n! Sorry, %s capacity exceeded",t);fatal("","");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 389 of file common.c.

{
change_limit= change_buffer;
/*13:*/
#line 265 "common.w"

while(1){
change_line++;
if(!input_ln(change_file))return;
if(limit<buffer+2)continue;
if(buffer[0]!='@')continue;
if(xisupper(buffer[1]))buffer[1]= tolower(buffer[1]);
if(buffer[1]=='x')break;
if(buffer[1]=='y'||buffer[1]=='z'||buffer[1]=='i'){
loc= buffer+2;
err_print("! Missing @x in change file");

}
}

/*:13*/
#line 256 "common.w"
;
/*14:*/
#line 282 "common.w"

do{
change_line++;
if(!input_ln(change_file)){
err_print("! Change file ended after @x");

return;
}
}while(limit==buffer);

/*:14*/
#line 257 "common.w"
;
/*15:*/
#line 292 "common.w"

{
change_limit= change_buffer+(limit-buffer);
strncpy(change_buffer,buffer,limit-buffer+1);
}

/*:15*/
#line 258 "common.w"
;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 792 of file common.c.

{
char*s= first_chunk(p);
int l= prefix_length(p);
term_write(s,l);
if(s+l<(p+1)->byte_start)term_write("...",3);
}

Here is the caller graph for this function:

Definition at line 748 of file common.c.

{
char*ss,*s= first_chunk(p);
name_pointer q= p+1;
while(p!=name_dir){
ss= (p+1)->byte_start-1;
if(*ss==' '&&ss>=s){
term_write(s,ss-s);p= q->link;q= p;
}else{
term_write(s,ss+1-s);p= name_dir;q= NULL;
}
s= p->byte_start;
}
if(q)term_write("...",3);
}

Here is the caller graph for this function:

Definition at line 1554 of file ctangle.c.

             {
printf("\nMemory usage statistics:\n");
printf("%ld names (out of %ld)\n",
(long)(name_ptr-name_dir),(long)max_names);
printf("%ld replacement texts (out of %ld)\n",
(long)(text_ptr-text_info),(long)max_texts);
printf("%ld bytes (out of %ld)\n",
(long)(byte_ptr-byte_mem),(long)max_bytes);
printf("%ld tokens (out of %ld)\n",
(long)(tok_ptr-tok_mem),(long)max_toks);
}

Here is the call graph for this function:

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;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1085 of file common.c.

{
char*dot_pos;
char*name_pos;
register char*s;
boolean found_web= 0,found_change= 0,found_out= 0;

boolean flag_change;

while(--argc> 0){
if((**(++argv)=='-'||**argv=='+')&&*(*argv+1))/*74:*/
#line 1344 "common.w"

{
if(**argv=='-')flag_change= 0;
else flag_change= 1;
for(dot_pos= *argv+1;*dot_pos> '\0';dot_pos++)
flags[*dot_pos]= flag_change;
}

/*:74*/
#line 1266 "common.w"

else{
s= name_pos= *argv;dot_pos= NULL;
while(*s){
if(*s=='.')dot_pos= s++;
else if(*s=='/')dot_pos= NULL,name_pos= ++s;
else s++;
}
if(!found_web)/*71:*/
#line 1292 "common.w"

{
if(s-*argv> max_file_name_length-5)
/*76:*/
#line 1364 "common.w"
fatal("! Filename too long\n",*argv);


/*:76*/
#line 1295 "common.w"
;
if(dot_pos==NULL)
sprintf(web_file_name,"%s.w",*argv);
else{
strcpy(web_file_name,*argv);
*dot_pos= 0;
}
sprintf(alt_web_file_name,"%s.web",*argv);
sprintf(tex_file_name,"%s.tex",name_pos);
sprintf(idx_file_name,"%s.idx",name_pos);
sprintf(scn_file_name,"%s.scn",name_pos);
sprintf(C_file_name,"%s.c",name_pos);
found_web= 1;
}

/*:71*/
#line 1275 "common.w"

else if(!found_change)/*72:*/
#line 1310 "common.w"

{
if(strcmp(*argv,"-")==0)found_change= -1;
else{
if(s-*argv> max_file_name_length-4)
/*76:*/
#line 1364 "common.w"
fatal("! Filename too long\n",*argv);


/*:76*/
#line 1315 "common.w"
;
if(dot_pos==NULL)
sprintf(change_file_name,"%s.ch",*argv);
else strcpy(change_file_name,*argv);
found_change= 1;
}
}

/*:72*/
#line 1276 "common.w"

else if(!found_out)/*73:*/
#line 1323 "common.w"

{
if(s-*argv> max_file_name_length-5)
/*76:*/
#line 1364 "common.w"
fatal("! Filename too long\n",*argv);


/*:76*/
#line 1326 "common.w"
;
if(dot_pos==NULL){
sprintf(tex_file_name,"%s.tex",*argv);
sprintf(idx_file_name,"%s.idx",*argv);
sprintf(scn_file_name,"%s.scn",*argv);
sprintf(C_file_name,"%s.c",*argv);
}else{
strcpy(tex_file_name,*argv);
strcpy(C_file_name,*argv);
if(flags['x']){
*dot_pos= 0;
sprintf(idx_file_name,"%s.idx",*argv);
sprintf(scn_file_name,"%s.scn",*argv);
}
}
found_out= 1;
}

/*:73*/
#line 1277 "common.w"

else/*75:*/
#line 1352 "common.w"

{
if(program==ctangle)
fatal(
"! Usage: ctangle [options] webfile[.w] [{changefile[.ch]|-} [outfile[.c]]]\n"
,"");

else fatal(
"! Usage: cweave [options] webfile[.w] [{changefile[.ch]|-} [outfile[.tex]]]\n"
,"");
}

/*:75*/
#line 1278 "common.w"
;
}
}
if(!found_web)/*75:*/
#line 1352 "common.w"

{
if(program==ctangle)
fatal(
"! Usage: ctangle [options] webfile[.w] [{changefile[.ch]|-} [outfile[.c]]]\n"
,"");

else fatal(
"! Usage: cweave [options] webfile[.w] [{changefile[.ch]|-} [outfile[.tex]]]\n"
,"");
}

/*:75*/
#line 1281 "common.w"
;
if(found_change<=0)strcpy(change_file_name,"/dev/null");
}

Here is the call graph for this function:

Here is the caller graph for this function:

name_pointer section_lookup ( char*  first,
char*  last,
int  ispref 
)

Definition at line 876 of file common.c.

{
int c= 0;
name_pointer p= root;
name_pointer q= NULL;
name_pointer r= NULL;
name_pointer par= NULL;

int name_len= last-first+1;
/*50:*/
#line 936 "common.w"

while(p){
c= web_strcmp(first,name_len,first_chunk(p),prefix_length(p));
if(c==less||c==greater){
if(r==NULL)
par= p;
p= (c==less?p->llink:p->rlink);
}else{
if(r!=NULL){
printf("\n! Ambiguous prefix: matches <");

print_prefix_name(p);
printf(">\n and <");
print_prefix_name(r);
err_print(">");
return name_dir;
}
r= p;
p= p->llink;
q= r->rlink;
}
if(p==NULL)
p= q,q= NULL;
}

/*:50*/
#line 926 "common.w"
;
/*51:*/
#line 961 "common.w"

if(r==NULL)
return add_section_name(par,c,first,last+1,ispref);

/*:51*/
#line 927 "common.w"
;
/*52:*/
#line 969 "common.w"

switch(section_name_cmp(&first,name_len,r)){

case prefix:
if(!ispref){
printf("\n! New name is a prefix of <");

print_section_name(r);
err_print(">");
}
else if(name_len<prefix_length(r))set_prefix_length(r,name_len);

case equal:return r;
case extension:if(!ispref||first<=last)
extend_section_name(r,first,last+1,ispref);
return r;
case bad_extension:
printf("\n! New name extends <");

print_section_name(r);
err_print(">");
return r;
default:
printf("\n! Section name incompatible with <");

print_prefix_name(r);
printf(">,\n which abbreviates <");
print_section_name(r);
err_print(">");
return r;
}

/*:52*/
#line 928 "common.w"
;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Here is the caller graph for this function:

int section_name_cmp ( char**  pfirst,
int  len,
name_pointer  r 
)

Definition at line 968 of file common.c.

{
char*first= *pfirst;
name_pointer q= r+1;
char*ss,*s= first_chunk(r);
int c;
int ispref;
while(1){
ss= (r+1)->byte_start-1;
if(*ss==' '&&ss>=r->byte_start)ispref= 1,q= q->link;
else ispref= 0,ss++,q= name_dir;
switch(c= web_strcmp(first,len,s,ss-s)){
case equal:if(q==name_dir)
if(ispref){
*pfirst= first+(ss-s);
return extension;
}else return equal;
else return(q->byte_start==(q+1)->byte_start)?equal:prefix;
case extension:
if(!ispref)return bad_extension;
first+= ss-s;
if(q!=name_dir){len-= ss-s;s= q->byte_start;r= q;continue;}
*pfirst= first;return extension;
default:return c;
}
}
}

Here is the call graph for this function:

void sprint_section_name ( char*  dest,
name_pointer  p 
)

Definition at line 769 of file common.c.

{
char*ss,*s= first_chunk(p);
name_pointer q= p+1;
while(p!=name_dir){
ss= (p+1)->byte_start-1;
if(*ss==' '&&ss>=s){
p= q->link;q= p;
}else{
ss++;p= name_dir;
}
strncpy(dest,s,ss-s),dest+= ss-s;
s= p->byte_start;
}
*dest= '\0';
}

Here is the call graph for this function:

Here is the caller graph for this function:

int strcmp ( )
char* strcpy ( )
int strlen ( )
int strncmp ( )
char* strncpy ( )
int web_strcmp ( char*  j,
int  j_len,
char*  k,
int  k_len 
)

Definition at line 804 of file common.c.

{
char*j1= j+j_len,*k1= k+k_len;
while(k<k1&&j<j1&&*j==*k)k++,j++;
if(k==k1)if(j==j1)return equal;
else return extension;
else if(j==j1)return prefix;
else if(*j<*k)return less;
else return greater;
}

Here is the caller graph for this function:

int 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;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 238 of file common.c.

Definition at line 149 of file common.c.

Definition at line 223 of file common.c.

char** argv

Definition at line 224 of file common.c.

Definition at line 135 of file common.c.

Definition at line 136 of file common.c.

Definition at line 196 of file common.c.

Definition at line 197 of file common.c.

char* byte_ptr

Definition at line 205 of file common.c.

Definition at line 234 of file common.c.

Definition at line 225 of file common.c.

Definition at line 250 of file common.c.

Definition at line 152 of file common.c.

Definition at line 145 of file common.c.

Definition at line 148 of file common.c.

char* change_limit

Definition at line 251 of file common.c.

Definition at line 151 of file common.c.

Definition at line 163 of file common.c.

Definition at line 162 of file common.c.

Definition at line 154 of file common.c.

Definition at line 144 of file common.c.

Definition at line 146 of file common.c.

boolean flags[128]

Definition at line 229 of file common.c.

Definition at line 213 of file common.c.

Definition at line 211 of file common.c.

Definition at line 212 of file common.c.

Definition at line 218 of file common.c.

Definition at line 236 of file common.c.

Definition at line 227 of file common.c.

Definition at line 143 of file common.c.

Definition at line 153 of file common.c.

char* limit = buffer

Definition at line 137 of file common.c.

Definition at line 150 of file common.c.

char* loc = buffer

Definition at line 138 of file common.c.

Definition at line 198 of file common.c.

Definition at line 199 of file common.c.

Definition at line 204 of file common.c.

Definition at line 245 of file common.c.

Definition at line 165 of file common.c.

Definition at line 130 of file common.c.

Definition at line 237 of file common.c.

Definition at line 228 of file common.c.

Definition at line 161 of file common.c.

Definition at line 235 of file common.c.

Definition at line 226 of file common.c.

Definition at line 155 of file common.c.