1323 lines · 24.7 KB · C
RawDownload
/*1:*/#line 62 "common.w" /*3:*/#line 44 "common.h" #include <ctype.h>  #include <stdbool.h>  #include <stddef.h>  #include <stdint.h>  #include <stdlib.h>  #include <stdio.h>  #include <string.h>   /*:3*/#line 63 "common.w" #define ctangle false#define cweave true \ #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 non_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 compress(c) if(loc++<=limit) return c \ #define xisalpha(c) (isalpha((eight_bits) (c) ) &&((eight_bits) (c) <0200) ) #define xisdigit(c) (isdigit((eight_bits) (c) ) &&((eight_bits) (c) <0200) ) #define xisspace(c) (isspace((eight_bits) (c) ) &&((eight_bits) (c) <0200) ) #define xislower(c) (islower((eight_bits) (c) ) &&((eight_bits) (c) <0200) ) #define xisupper(c) (isupper((eight_bits) (c) ) &&((eight_bits) (c) <0200) ) #define xisxdigit(c) (isxdigit((eight_bits) (c) ) &&((eight_bits) (c) <0200) ) #define isxalpha(c) ((c) =='_'||(c) =='$')  \ #define ishigh(c) ((eight_bits) (c) > 0177)  \ \ #define max_include_depth 10 \ #define max_file_name_length 1024#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 length(c) (size_t) ((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 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 show_banner flags['b']#define show_progress flags['p']#define show_happiness flags['h']#define show_stats flags['s']#define make_xrefs flags['x'] \ #define update_terminal fflush(stdout) #define new_line putchar('\n') #define term_write(a,b) fflush(stdout) ,fwrite(a,sizeof(char) ,b,stdout)  \ #define max_bytes 1000000 \ #define max_toks 1000000#define max_names 10239 \ #define max_sections 4000#define max_texts 10239#define longest_name 10000#define stack_size 500#define buf_size 1000#define long_buf_size (buf_size+longest_name)  \ #define lines_dont_match (change_limit-change_buffer!=limit-buffer|| \strncmp(buffer,change_buffer,(size_t) (limit-buffer) ) )  \ #define if_section_start_make_pending(b) { \*limit= '!'; \for(loc= buffer;xisspace(*loc) ;loc++) ; \*limit= ' '; \if(*loc=='@'&&(xisspace(*(loc+1) ) ||*(loc+1) =='*') ) change_pending= b; \} \ #define too_long() {include_depth--; \err_print("! Include file name too long") ;goto restart;} \ #define hash_size 8501 \ #define first_chunk(p) ((p) ->byte_start+2) #define prefix_length(p) (int) ((eight_bits) *((p) ->byte_start) *256+ \(eight_bits) *((p) ->byte_start+1) ) #define set_prefix_length(p,m) (*((p) ->byte_start) = (m) /256, \*((p) ->byte_start+1) = (m) %256)  \ #define less 0#define equal 1#define greater 2#define prefix 3#define extension 4 \ #define bad_extension 5 \ #define flag_change (**argv!='-')  #line 64 "common.w" /*2:*/#line 35 "common.h" typedef bool boolean;typedef uint8_t eight_bits;typedef uint16_t sixteen_bits;extern boolean program;extern int phase; /*:2*//*4:*/#line 74 "common.h" extern char section_text[];extern char*section_text_end;extern char*id_first;extern char*id_loc; /*:4*//*5:*/#line 92 "common.h" extern char buffer[];extern char*buffer_end;extern char*loc;extern char*limit; /*:5*//*6:*/#line 109 "common.h" extern int include_depth;extern FILE*file[];extern FILE*change_file;extern char file_name[][max_file_name_length]; extern char change_file_name[];extern int line[];extern int change_line;extern int change_depth;extern boolean input_has_ended;extern boolean changing;extern boolean web_file_open; /*:6*//*8:*/#line 129 "common.h" extern sixteen_bits section_count;extern boolean changed_section[];extern boolean change_pending;extern boolean print_where; /*:8*//*9:*/#line 143 "common.h" typedef struct name_info{char*byte_start;struct name_info*link;union{struct name_info*Rlink; char Ilk;}dummy;void*equiv_or_xref;}name_info;typedef name_info*name_pointer;typedef name_pointer*hash_pointer;extern char byte_mem[];extern char*byte_mem_end;extern char*byte_ptr;extern name_info name_dir[];extern name_pointer name_dir_end;extern name_pointer name_ptr;extern name_pointer hash[];extern hash_pointer hash_end;extern hash_pointer h; /*:9*//*11:*/#line 187 "common.h" extern int history; /*:11*//*13:*/#line 203 "common.h" extern int argc;extern char**argv;extern char C_file_name[];extern char tex_file_name[];extern char idx_file_name[];extern char scn_file_name[];extern boolean flags[]; /*:13*//*14:*/#line 217 "common.h" extern FILE*C_file;extern FILE*tex_file;extern FILE*idx_file;extern FILE*scn_file;extern FILE*active_file; /*:14*/#line 65 "common.w" /*18:*/#line 79 "common.w" boolean program; /*:18*//*19:*/#line 88 "common.w" int phase; /*:19*//*21:*/#line 126 "common.w" char section_text[longest_name+1];char*section_text_end= section_text+longest_name;char*id_first;char*id_loc; /*:21*//*22:*/#line 146 "common.w" char buffer[long_buf_size];char*buffer_end= buffer+buf_size-2;char*loc= buffer;char*limit= buffer; /*:22*//*25:*/#line 190 "common.w" int include_depth;FILE*file[max_include_depth];FILE*change_file;char file_name[max_include_depth][max_file_name_length]; char change_file_name[max_file_name_length];static 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= false; /*:25*//*26:*/#line 216 "common.w" static char change_buffer[buf_size];static char*change_limit; /*:26*//*37:*/#line 396 "common.w" sixteen_bits section_count;boolean changed_section[max_sections];boolean change_pending; boolean print_where= false; /*:37*//*43:*/#line 593 "common.w" 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; /*:43*//*44:*/#line 604 "common.w" char*byte_ptr;name_pointer name_ptr; /*:44*//*46:*/#line 624 "common.w" name_pointer hash[hash_size];hash_pointer hash_end= hash+hash_size-1;hash_pointer h; /*:46*//*65:*/#line 1006 "common.w" int history= spotless; /*:65*//*73:*/#line 1129 "common.w" 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]; /*:73*//*83:*/#line 1272 "common.w" FILE*C_file;FILE*tex_file;FILE*idx_file;FILE*scn_file;FILE*active_file; /*:83*/#line 66 "common.w" /*7:*/#line 123 "common.h" extern boolean get_line(void);extern void check_complete(void);extern void reset_input(void); /*:7*//*10:*/#line 166 "common.h" extern boolean names_match(name_pointer,const char*,size_t,eight_bits);extern name_pointer id_lookup(const char*,const char*,char); extern name_pointer section_lookup(char*,char*,boolean);extern void init_node(name_pointer);extern void init_p(name_pointer,eight_bits);extern void print_prefix_name(name_pointer);extern void print_section_name(name_pointer);extern void sprint_section_name(char*,name_pointer); /*:10*//*12:*/#line 190 "common.h" extern int wrap_up(void);extern void err_print(const char*);extern void fatal(const char*,const char*);extern void overflow(const char*); /*:12*//*15:*/#line 225 "common.h" extern void common_init(void);extern void print_stats(void); /*:15*//*24:*/#line 176 "common.w"static boolean input_ln(FILE*); /*:24*//*28:*/#line 237 "common.w"static void prime_the_change_buffer(void); /*:28*//*33:*/#line 337 "common.w"static void check_change(void); /*:33*//*55:*/#line 767 "common.w" static int web_strcmp(char*,int,char*,int);static name_pointer add_section_name(name_pointer,int,char*,char*,boolean);static void extend_section_name(name_pointer,char*,char*,boolean); /*:55*//*64:*/#line 994 "common.w"static int section_name_cmp(char**,int,name_pointer); /*:64*//*76:*/#line 1189 "common.w"static void scan_args(void); /*:76*/#line 67 "common.w"  /*:1*//*20:*/#line 95 "common.w" voidcommon_init(void){/*45:*/#line 608 "common.w" name_dir->byte_start= byte_ptr= byte_mem;name_ptr= name_dir+1;name_ptr->byte_start= byte_mem;root= NULL; /*:45*//*47:*/#line 631 "common.w" for(h= hash;h<=hash_end;*h++= NULL); /*:47*/#line 99 "common.w" /*74:*/#line 1142 "common.w" show_banner= show_happiness= show_progress= make_xrefs= true; /*:74*/#line 100 "common.w" /*84:*/#line 1279 "common.w" scan_args();if(program==ctangle){if((C_file= fopen(C_file_name,"wb"))==NULL)fatal("! Cannot open output file ",C_file_name); }else{if((tex_file= fopen(tex_file_name,"wb"))==NULL)fatal("! Cannot open output file ",tex_file_name);} /*:84*/#line 101 "common.w" } /*:20*//*23:*/#line 156 "common.w" static boolean input_ln(FILE*fp){register int c= EOF;register char*k;if(feof(fp))return false;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 false; return true;} /*:23*//*27:*/#line 227 "common.w" static voidprime_the_change_buffer(void){change_limit= change_buffer;/*29:*/#line 243 "common.w" while(true){change_line++;if(!input_ln(change_file))return;if(limit<buffer+2)continue;if(buffer[0]!='@')continue;if(xisupper(buffer[1]))buffer[1]= tolower((eight_bits)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"); }} /*:29*/#line 232 "common.w"

Lines 1–500 of 1323.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t