home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 2
/
FFMCD02.bin
/
new
/
dev
/
misc
/
cweb
/
ctangle.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-12-21
|
33KB
|
1,659 lines
/*1:*/
#line 61 "ctangle.w"
/*2:*/
#line 159 "ctangle-p.ch"
#line 160 "ctangle-p.ch"
#include <string.h>
#line 80 "ctangle.w"
/*:2*//*6:*/
#line 195 "ctangle-p.ch"
#include <stdio.h>
#ifdef __TURBOC__
#include <io.h>
#endif
/*:6*//*62:*/
#line 873 "ctangle.w"
#include <ctype.h>
#include <stdlib.h>
/*:62*/
#line 62 "ctangle.w"
#define banner "This is CTANGLE (Version 3.0 [p8d])\n" \
#define max_bytes 90000 \
#define max_toks 270000
#define max_names 4000 \
#define max_texts 2500
#define hash_size 353
#define longest_name 1000
#define stack_size 50
#define buf_size 100 \
#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 length(c) (c+1) ->byte_start-(c) ->byte_start
#define print_id(c) term_write((c) ->byte_start,length((c) ) )
#define llink link
#define rlink dummy.Rlink
#define root name_dir->rlink \
#define chunk_marker 0 \
#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) fatal("! This can't happen: ",s) \
#define max_file_name_length 256
#define cur_file file[include_depth]
#define cur_file_name file_name[include_depth]
#define web_file_name file_name[0]
#define cur_line line[include_depth] \
#define show_banner flags['b']
#define show_happiness flags['h']
#define show_progress flags['p']
#define use_amiga_keywords flags['a']
#define use_german_macros flags['g']
#define indent_param_decl flags['i'] \
#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) \
#define equiv equiv_or_xref \
#define section_flag max_texts \
#define string 02
#define join 0177
#define output_defs_flag (2*024000-1) \
#define cur_end cur_state.end_field
#define cur_byte cur_state.byte_field
#define cur_name cur_state.name_field
#define cur_repl cur_state.repl_field
#define cur_section cur_state.section_field \
#define section_number 0201
#define identifier 0202 \
#define normal 0
#define num_or_id 1
#define unbreakable 3
#define verbatim 4 \
#define max_files 256
#define translit_length 10 \
#define ignore 0
#define ord 0302
#define control_text 0303
#define translit_code 0304
#define output_defs_code 0305
#define format_code 0306
#define definition 0307
#define begin_C 0310
#define section_name 0311
#define new_section 0312 \
#define constant 03 \
#define isxalpha(c) ((c) =='_')
#define ishigh(c) ((unsigned char) (c) >0177) \
\
#define compress(c) if(loc++<=limit) return(c) \
#define macro 0
#define app_repl(c) {if(tok_ptr==tok_mem_end) overflow("token") ;*tok_ptr++= c;} \
#line 63 "ctangle.w"
/*5:*/
#line 195 "ctangle-p.ch"
typedef short boolean;
#ifdef _AMIGA
typedef unsigned char eight_bits;
#else
typedef char unsigned eight_bits;
#endif
extern boolean program;
extern int phase;
#ifdef __TURBOC__
#define HUGE huge
#else
#define HUGE
#endif
/*:5*//*7:*/
#line 195 "ctangle-p.ch"
char section_text[longest_name+1];
char*section_text_end= section_text+longest_name;
char*id_first;
char*id_loc;
/*:7*//*8:*/
#line 195 "ctangle-p.ch"
extern char buffer[];
extern char*buffer_end;
extern char*loc;
extern char*limit;
/*:8*//*9:*/
#line 195 "ctangle-p.ch"
typedef struct name_info{
char HUGE*byte_start;
struct name_info HUGE*link;
union{
struct name_info HUGE*Rlink;
char Ilk;
}dummy;
char HUGE*equiv_or_xref;
}name_info;
typedef name_info HUGE*name_pointer;
typedef name_pointer*hash_pointer;
#ifdef __TURBOC__
extern char HUGE*byte_mem;
extern name_info HUGE*name_dir;
#else
extern char byte_mem[];
extern name_info name_dir[];
#endif
extern char HUGE*byte_mem_end;
extern name_pointer name_dir_end;
extern name_pointer name_ptr;
extern char HUGE*byte_ptr;
#ifdef __TURBOC__
void far*allocsafe(unsigned long nunits,unsigned long unitsz);
#endif
extern name_pointer hash[];
extern hash_pointer hash_end;
extern hash_pointer h;
extern name_pointer id_lookup(char*,char*,char);
extern void print_section_name(name_pointer);
extern void sprint_section_name(char*,name_pointer);
extern void print_prefix_name(name_pointer);
extern name_pointer section_lookup(char*,char*,int);
extern name_pointer prefix_lookup(char*,char*);
extern int names_match(name_pointer,char*,int,eight_bits);
extern void init_p(name_pointer,eight_bits);
extern void init_node(name_pointer);
/*:9*//*10:*/
#line 195 "ctangle-p.ch"
extern history;
extern void err_print(char*);
extern void wrap_up(void);
extern void fatal(char*,char*);
extern void overflow(char*);
/*:10*//*11:*/
#line 195 "ctangle-p.ch"
extern include_depth;
extern FILE*file[];
extern FILE*change_file;
extern char C_file_name[];
extern char tex_file_name[];
extern char idx_file_name[];
extern char scn_file_name[];
extern char file_name[][max_file_name_length];
extern char change_file_name[];
extern line[];
extern change_line;
extern boolean input_has_ended;
extern boolean changing;
extern boolean web_file_open;
extern void reset_input(void);
extern boolean get_line(void);
extern void check_complete(void);
/*:11*//*12:*/
#line 195 "ctangle-p.ch"
typedef unsigned short sixteen_bits;
extern sixteen_bits section_count;
extern boolean changed_section[];
extern boolean change_pending;
extern boolean print_where;
/*:12*//*13:*/
#line 195 "ctangle-p.ch"
extern int argc;
extern char**argv;
extern boolean flags[];
/*:13*//*14:*/
#line 195 "ctangle-p.ch"
extern FILE*C_file;
extern FILE*tex_file;
extern FILE*idx_file;
extern FILE*scn_file;
extern FILE*active_file;
/*:14*//*15:*/
#line 195 "ctangle-p.ch"
extern void common_init(void);
extern void print_stats(void);
#line 125 "ctangle.w"
/*:15*/
#line 64 "ctangle.w"
/*16:*/
#line 149 "ctangle.w"
typedef struct{
#line 201 "ctangle-p.ch"
eight_bits HUGE*tok_start;
#line 152 "ctangle.w"
sixteen_bits text_link;
}text;
typedef text*text_pointer;
/*:16*//*27:*/
#line 293 "ctangle.w"
typedef struct{
#line 290 "ctangle-p.ch"
eight_bits HUGE*end_field;
eight_bits HUGE*byte_field;
#line 297 "ctangle.w"
name_pointer name_field;
text_pointer repl_field;
sixteen_bits section_field;
}output_state;
typedef output_state*stack_pointer;
/*:27*/
#line 65 "ctangle.w"
/*17:*/
#line 156 "ctangle.w"
text text_info[max_texts];
text_pointer text_info_end= text_info+max_texts-1;
text_pointer text_ptr;
#line 209 "ctangle-p.ch"
#ifdef __TURBOC__
eight_bits HUGE*tok_mem;
eight_bits HUGE*tok_mem_end;
#else
eight_bits tok_mem[max_toks];
eight_bits*tok_mem_end= tok_mem+max_toks-1;
#endif
eight_bits HUGE*tok_ptr;
#line 163 "ctangle.w"
/*:17*//*23:*/
#line 224 "ctangle.w"
text_pointer last_unnamed;
/*:23*//*28:*/
#line 309 "ctangle.w"
output_state cur_state;
output_state stack[stack_size+1];
stack_pointer stack_ptr;
stack_pointer stack_end= stack+stack_size;
/*:28*//*32:*/
#line 381 "ctangle.w"
int cur_val;
/*:32*//*36:*/
#line 467 "ctangle.w"
eight_bits out_state;
boolean protect;
/*:36*//*38:*/
#line 496 "ctangle.w"
name_pointer output_files[max_files];
name_pointer*cur_out_file,*end_output_files,*an_output_file;
char cur_section_name_char;
char output_file_name[longest_name];
/*:38*//*45:*/
#line 592 "ctangle.w"
boolean output_defs_seen= 0;
#line 353 "ctangle-p.ch"
/*:45*//*51:*/
#line 699 "ctangle.w"
char translit[128][translit_length];
/*:51*//*56:*/
#line 775 "ctangle.w"
eight_bits ccode[128];
/*:56*//*59:*/
#line 831 "ctangle.w"
boolean comment_continues= 0;
/*:59*//*61:*/
#line 870 "ctangle.w"
name_pointer cur_section_name;
/*:61*//*75:*/
#line 1180 "ctangle.w"
text_pointer cur_text;
eight_bits next_control;
/*:75*//*82:*/
#line 1327 "ctangle.w"
extern sixteen_bits section_count;
/*:82*/
#line 66 "ctangle.w"
/*41:*/
#line 338 "ctangle-p.ch"
#line 339 "ctangle-p.ch"
static void phas