1646 lines · 32.1 KB · C
RawDownload
/*1:*/#line 66 "ctangle.w" /*4:*/#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>   /*:4*/#line 67 "ctangle.w" #define banner "This is CTANGLE (Version 4.3)" \ #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 equiv equiv_or_xref \ #define macro 0#define section_flag max_texts \ #define string 02#define constant 03#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 post_slash 2#define unbreakable 3#define verbatim 4 \ #define max_files 256#define C_printf(c,a) fprintf(C_file,c,a) #define C_putc(c) putc(c,C_file)  \ #define translit_length 10 \ #define ignore 00#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 app_repl(c) {if(tok_ptr==tok_mem_end) overflow("token") ;*tok_ptr++= c;} \ #define keep_digit_separators flags['k'] \  #line 68 "ctangle.w" /*3:*/#line 35 "common.h" typedef bool boolean;typedef uint8_t eight_bits;typedef uint16_t sixteen_bits;extern boolean program;extern int phase; /*:3*//*5:*/#line 74 "common.h" extern char section_text[];extern char*section_text_end;extern char*id_first;extern char*id_loc; /*:5*//*6:*/#line 92 "common.h" extern char buffer[];extern char*buffer_end;extern char*loc;extern char*limit; /*:6*//*7:*/#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; /*:7*//*9:*/#line 129 "common.h" extern sixteen_bits section_count;extern boolean changed_section[];extern boolean change_pending;extern boolean print_where; /*:9*//*10:*/#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; /*:10*//*12:*/#line 187 "common.h" extern int history; /*:12*//*14:*/#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[]; /*:14*//*15:*/#line 217 "common.h" extern FILE*C_file;extern FILE*tex_file;extern FILE*idx_file;extern FILE*scn_file;extern FILE*active_file; /*:15*/#line 69 "ctangle.w" /*19:*/#line 122 "ctangle.w" typedef struct{eight_bits*tok_start;sixteen_bits text_link;}text;typedef text*text_pointer; /*:19*//*31:*/#line 273 "ctangle.w" typedef struct{eight_bits*end_field;eight_bits*byte_field;name_pointer name_field;text_pointer repl_field;sixteen_bits section_field;}output_state;typedef output_state*stack_pointer; /*:31*/#line 70 "ctangle.w" /*20:*/#line 129 "ctangle.w" static text text_info[max_texts];static text_pointer text_info_end= text_info+max_texts-1;static text_pointer text_ptr;static eight_bits tok_mem[max_toks];static eight_bits*tok_mem_end= tok_mem+max_toks-1;static eight_bits*tok_ptr; /*:20*//*26:*/#line 199 "ctangle.w" static text_pointer last_unnamed; /*:26*//*32:*/#line 289 "ctangle.w" static output_state cur_state; static output_state stack[stack_size+1];static stack_pointer stack_end= stack+stack_size;static stack_pointer stack_ptr; /*:32*//*37:*/#line 365 "ctangle.w" static int cur_val; /*:37*//*42:*/#line 456 "ctangle.w" static eight_bits out_state;static boolean protect; /*:42*//*45:*/#line 487 "ctangle.w" static name_pointer output_files[max_files];static name_pointer*cur_out_file,*end_output_files,*an_output_file;static char cur_section_name_char;static char output_file_name[longest_name+1]; /*:45*//*52:*/#line 584 "ctangle.w" static boolean output_defs_seen= false; /*:52*//*57:*/#line 696 "ctangle.w" static char translit[128][translit_length]; /*:57*//*62:*/#line 775 "ctangle.w" static eight_bits ccode[256]; /*:62*//*66:*/#line 835 "ctangle.w" static boolean comment_continues= false; /*:66*//*68:*/#line 872 "ctangle.w" static name_pointer cur_section_name;static boolean no_where; /*:68*//*82:*/#line 1189 "ctangle.w" static text_pointer cur_text;static eight_bits next_control; /*:82*/#line 71 "ctangle.w" /*8:*/#line 123 "common.h" extern boolean get_line(void);extern void check_complete(void);extern void reset_input(void); /*:8*//*11:*/#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); /*:11*//*13:*/#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*); /*:13*//*16:*/#line 225 "common.h" extern void common_init(void);extern void print_stats(void); /*:16*//*30:*/#line 245 "ctangle.w"static void store_two_bytes(sixteen_bits); /*:30*//*35:*/#line 328 "ctangle.w" static void push_level(name_pointer);static void pop_level(boolean); /*:35*//*39:*/#line 401 "ctangle.w"static void get_output(void); /*:39*//*44:*/#line 477 "ctangle.w"static void flush_buffer(void); /*:44*//*49:*/#line 551 "ctangle.w"static void phase_two(void); /*:49*//*53:*/#line 587 "ctangle.w" static void output_defs(void);static void out_char(eight_bits); /*:53*//*65:*/#line 815 "ctangle.w" static eight_bits skip_ahead(void);static boolean skip_comment(boolean); /*:65*//*70:*/#line 922 "ctangle.w"static eight_bits get_next(void); /*:70*//*84:*/#line 1215 "ctangle.w"static void scan_repl(eight_bits); /*:84*//*91:*/#line 1396 "ctangle.w"static void scan_section(void); /*:91*//*99:*/#line 1477 "ctangle.w"static void phase_one(void); /*:99*//*101:*/#line 1511 "ctangle.w"static void skip_limbo(void); /*:101*/#line 72 "ctangle.w"  /*:1*//*2:*/#line 81 "ctangle.w" int main(int ac,char**av){argc= ac;argv= av;program= ctangle;/*21:*/#line 137 "ctangle.w" text_info->tok_start= tok_ptr= tok_mem;text_ptr= text_info+1;text_ptr->tok_start= tok_mem;  /*:21*//*23:*/#line 147 "ctangle.w" init_node(name_dir); /*:23*//*27:*/#line 202 "ctangle.w"last_unnamed= text_info;text_info->text_link= macro; /*:27*//*46:*/#line 497 "ctangle.w" cur_out_file= end_output_files= output_files+max_files; /*:46*//*58:*/#line 699 "ctangle.w" {int i;for(i= 0;i<128;i++)sprintf(translit[i],"X%02X",(unsigned int)(128+i));} /*:58*//*63:*/#line 778 "ctangle.w"{int c;for(c= 0;c<256;c++)ccode[c]= ignore;}ccode[' ']= ccode['\t']= ccode['\n']= ccode['\v']= ccode['\r']= ccode['\f']= ccode['*']= new_section;ccode['@']= '@';ccode['=']= string;ccode['d']= ccode['D']= definition;ccode['f']= ccode['F']= ccode['s']= ccode['S']= format_code;ccode['c']= ccode['C']= ccode['p']= ccode['P']= begin_C;ccode['^']= ccode[':']= ccode['.']= ccode['t']= ccode['T']= ccode['q']= ccode['Q']= control_text;ccode['h']= ccode['H']= output_defs_code;ccode['l']= ccode['L']= translit_code;ccode['&']= join;ccode['<']= ccode['(']= section_name;ccode['\'']= ord;

Lines 1–500 of 1646.

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