Back to index

tetex-bin  3.0
ctangleboot.c
Go to the documentation of this file.
00001 /*1:*/
00002 #line 64 "./cwebdir/ctangle.w"
00003 
00004 /*5:*/
00005 #line 35 "./cwebdir/common.h"
00006 
00007 #line 93 "./cwebdir/ctang-w2c.ch"
00008 #include <stdio.h> 
00009 
00010 extern char*versionstring;
00011 #include <kpathsea/kpathsea.h> 
00012 #line 37 "./cwebdir/common.h"
00013 
00014 /*:5*//*61:*/
00015 #line 888 "./cwebdir/ctangle.w"
00016 
00017 #line 890 "./cwebdir/ctangle.w"
00018 #include <stdlib.h>  
00019 
00020 /*:61*/
00021 #line 65 "./cwebdir/ctangle.w"
00022 
00023 #define banner "This is CTANGLE, Version 3.64" \
00024 
00025 #define max_bytes 90000 \
00026 
00027 #define max_toks 270000
00028 #define max_names 4000 \
00029 
00030 #define max_texts 2500
00031 #define hash_size 353
00032 #define longest_name 10000
00033 #define stack_size 50
00034 #define buf_size 100 \
00035 
00036 #define ctangle 0
00037 #define cweave 1 \
00038 
00039 #define and_and 04
00040 #define lt_lt 020
00041 #define gt_gt 021
00042 #define plus_plus 013
00043 #define minus_minus 01
00044 #define minus_gt 031
00045 #define not_eq 032
00046 #define lt_eq 034
00047 #define gt_eq 035
00048 #define eq_eq 036
00049 #define or_or 037
00050 #define dot_dot_dot 016
00051 #define colon_colon 06
00052 #define period_ast 026
00053 #define minus_gt_ast 027 \
00054 
00055 #define xisalpha(c) (isalpha(c) &&((eight_bits) c<0200) ) 
00056 #define xisdigit(c) (isdigit(c) &&((eight_bits) c<0200) ) 
00057 #define xisspace(c) (isspace(c) &&((eight_bits) c<0200) ) 
00058 #define xislower(c) (islower(c) &&((eight_bits) c<0200) ) 
00059 #define xisupper(c) (isupper(c) &&((eight_bits) c<0200) ) 
00060 #define xisxdigit(c) (isxdigit(c) &&((eight_bits) c<0200) )  \
00061 
00062 #define length(c) (c+1) ->byte_start-(c) ->byte_start
00063 #define print_id(c) term_write((c) ->byte_start,length((c) ) ) 
00064 #define llink link
00065 #define rlink dummy.Rlink
00066 #define root name_dir->rlink \
00067 
00068 #define chunk_marker 0 \
00069 
00070 #define spotless 0
00071 #define harmless_message 1
00072 #define error_message 2
00073 #define fatal_message 3
00074 #define mark_harmless {if(history==spotless) history= harmless_message;}
00075 #define mark_error history= error_message
00076 #define confusion(s) fatal("! This can't happen: ",s)  \
00077 
00078 #define max_file_name_length 1024
00079 #define cur_file file[include_depth]
00080 #define cur_file_name file_name[include_depth]
00081 #define web_file_name file_name[0]
00082 #define cur_line line[include_depth] \
00083 
00084 #define show_banner flags['b']
00085 #define show_progress flags['p']
00086 #define show_happiness flags['h'] \
00087 
00088 #define update_terminal fflush(stdout) 
00089 #define new_line putchar('\n') 
00090 #define putxchar putchar
00091 #define term_write(a,b) fflush(stdout) ,fwrite(a,sizeof(char) ,b,stdout) 
00092 #define C_printf(c,a) fprintf(C_file,c,a) 
00093 #define C_putc(c) putc(c,C_file)  \
00094 
00095 #define equiv equiv_or_xref \
00096 
00097 #define section_flag max_texts \
00098 
00099 #define string 02
00100 #define join 0177
00101 #define output_defs_flag (2*024000-1)  \
00102 
00103 #define cur_end cur_state.end_field
00104 #define cur_byte cur_state.byte_field
00105 #define cur_name cur_state.name_field
00106 #define cur_repl cur_state.repl_field
00107 #define cur_section cur_state.section_field \
00108 
00109 #define section_number 0201
00110 #define identifier 0202 \
00111 
00112 #define normal 0
00113 #define num_or_id 1
00114 #define post_slash 2
00115 #define unbreakable 3
00116 #define verbatim 4 \
00117 
00118 #define max_files 256
00119 #define translit_length 10 \
00120 
00121 #define ignore 0
00122 #define ord 0302
00123 #define control_text 0303
00124 #define translit_code 0304
00125 #define output_defs_code 0305
00126 #define format_code 0306
00127 #define definition 0307
00128 #define begin_C 0310
00129 #define section_name 0311
00130 #define new_section 0312 \
00131 
00132 #define constant 03 \
00133 
00134 #define isxalpha(c) ((c) =='_'||(c) =='$')  \
00135 
00136 #define ishigh(c) ((unsigned char) (c) > 0177)  \
00137  \
00138 
00139 #define compress(c) if(loc++<=limit) return(c)  \
00140 
00141 #define macro 0
00142 #define app_repl(c) {if(tok_ptr==tok_mem_end) overflow("token") ;*tok_ptr++= c;} \
00143 
00144 
00145 #line 66 "./cwebdir/ctangle.w"
00146 
00147 /*4:*/
00148 #line 29 "./cwebdir/common.h"
00149 
00150 #line 31 "./cwebdir/common.h"
00151 typedef char unsigned eight_bits;
00152 extern boolean program;
00153 extern int phase;
00154 
00155 /*:4*//*6:*/
00156 #line 57 "./cwebdir/common.h"
00157 
00158 char section_text[longest_name+1];
00159 char*section_text_end= section_text+longest_name;
00160 char*id_first;
00161 char*id_loc;
00162 
00163 /*:6*//*7:*/
00164 #line 72 "./cwebdir/common.h"
00165 
00166 extern char buffer[];
00167 extern char*buffer_end;
00168 extern char*loc;
00169 extern char*limit;
00170 
00171 /*:7*//*8:*/
00172 #line 87 "./cwebdir/common.h"
00173 
00174 typedef struct name_info{
00175 char*byte_start;
00176 struct name_info*link;
00177 union{
00178 struct name_info*Rlink;
00179 
00180 char Ilk;
00181 }dummy;
00182 char*equiv_or_xref;
00183 }name_info;
00184 typedef name_info*name_pointer;
00185 typedef name_pointer*hash_pointer;
00186 extern char byte_mem[];
00187 extern char*byte_mem_end;
00188 extern name_info name_dir[];
00189 extern name_pointer name_dir_end;
00190 extern name_pointer name_ptr;
00191 extern char*byte_ptr;
00192 extern name_pointer hash[];
00193 extern hash_pointer hash_end;
00194 extern hash_pointer h;
00195 #line 106 "./cwebdir/ctang-w2c.ch"
00196 
00197 extern name_pointer id_lookup P3H(char*,char*,char);
00198 
00199 extern name_pointer section_lookup P3H(char*,char*,char);
00200 extern void print_section_name P1H(name_pointer);
00201 extern void sprint_section_name P2H(char*,name_pointer);
00202 #line 112 "./cwebdir/common.h"
00203 
00204 /*:8*//*9:*/
00205 #line 122 "./cwebdir/common.h"
00206 
00207 #line 123 "./cwebdir/ctang-w2c.ch"
00208 extern int history;
00209 extern void err_print P1H(char*);
00210 extern int wrap_up P1H(void);
00211 extern void fatal P2H(char*,char*);
00212 extern void overflow P1H(char*);
00213 #line 128 "./cwebdir/common.h"
00214 
00215 /*:9*//*10:*/
00216 #line 137 "./cwebdir/common.h"
00217 
00218 #line 141 "./cwebdir/ctang-w2c.ch"
00219 extern int include_depth;
00220 #line 139 "./cwebdir/common.h"
00221 extern FILE*file[];
00222 extern FILE*change_file;
00223 extern char C_file_name[];
00224 extern char tex_file_name[];
00225 extern char idx_file_name[];
00226 extern char scn_file_name[];
00227 extern char file_name[][max_file_name_length];
00228 
00229 extern char change_file_name[];
00230 #line 148 "./cwebdir/ctang-w2c.ch"
00231 extern int line[];
00232 extern int change_line;
00233 #line 150 "./cwebdir/common.h"
00234 extern boolean input_has_ended;
00235 extern boolean changing;
00236 extern boolean web_file_open;
00237 #line 157 "./cwebdir/ctang-w2c.ch"
00238 extern void reset_input P1H(void);
00239 extern int get_line P1H(void);
00240 extern void check_complete P1H(void);
00241 #line 156 "./cwebdir/common.h"
00242 
00243 /*:10*//*11:*/
00244 #line 158 "./cwebdir/common.h"
00245 
00246 typedef unsigned short sixteen_bits;
00247 extern sixteen_bits section_count;
00248 extern boolean changed_section[];
00249 extern boolean change_pending;
00250 extern boolean print_where;
00251 
00252 /*:11*//*12:*/
00253 #line 170 "./cwebdir/common.h"
00254 
00255 extern int argc;
00256 extern char**argv;
00257 extern boolean flags[];
00258 
00259 /*:12*//*13:*/
00260 #line 182 "./cwebdir/common.h"
00261 
00262 extern FILE*C_file;
00263 extern FILE*tex_file;
00264 extern FILE*idx_file;
00265 extern FILE*scn_file;
00266 extern FILE*active_file;
00267 
00268 /*:13*//*14:*/
00269 #line 191 "./cwebdir/common.h"
00270 
00271 #line 167 "./cwebdir/ctang-w2c.ch"
00272 extern void common_init P1H(void);
00273 #line 128 "./cwebdir/ctangle.w"
00274 
00275 /*:14*/
00276 #line 67 "./cwebdir/ctangle.w"
00277 
00278 /*15:*/
00279 #line 152 "./cwebdir/ctangle.w"
00280 
00281 typedef struct{
00282 eight_bits*tok_start;
00283 sixteen_bits text_link;
00284 }text;
00285 typedef text*text_pointer;
00286 
00287 /*:15*//*26:*/
00288 #line 296 "./cwebdir/ctangle.w"
00289 
00290 typedef struct{
00291 eight_bits*end_field;
00292 eight_bits*byte_field;
00293 name_pointer name_field;
00294 text_pointer repl_field;
00295 sixteen_bits section_field;
00296 }output_state;
00297 typedef output_state*stack_pointer;
00298 
00299 /*:26*/
00300 #line 68 "./cwebdir/ctangle.w"
00301 
00302 /*16:*/
00303 #line 159 "./cwebdir/ctangle.w"
00304 
00305 text text_info[max_texts];
00306 text_pointer text_info_end= text_info+max_texts-1;
00307 text_pointer text_ptr;
00308 eight_bits tok_mem[max_toks];
00309 eight_bits*tok_mem_end= tok_mem+max_toks-1;
00310 eight_bits*tok_ptr;
00311 
00312 /*:16*//*22:*/
00313 #line 227 "./cwebdir/ctangle.w"
00314 
00315 text_pointer last_unnamed;
00316 
00317 /*:22*//*27:*/
00318 #line 312 "./cwebdir/ctangle.w"
00319 
00320 output_state cur_state;
00321 
00322 output_state stack[stack_size+1];
00323 stack_pointer stack_ptr;
00324 stack_pointer stack_end= stack+stack_size;
00325 
00326 /*:27*//*31:*/
00327 #line 384 "./cwebdir/ctangle.w"
00328 
00329 int cur_val;
00330 
00331 /*:31*//*35:*/
00332 #line 473 "./cwebdir/ctangle.w"
00333 
00334 eight_bits out_state;
00335 boolean protect;
00336 
00337 /*:35*//*37:*/
00338 #line 502 "./cwebdir/ctangle.w"
00339 
00340 name_pointer output_files[max_files];
00341 name_pointer*cur_out_file,*end_output_files,*an_output_file;
00342 char cur_section_name_char;
00343 char output_file_name[longest_name];
00344 
00345 /*:37*//*44:*/
00346 #line 599 "./cwebdir/ctangle.w"
00347 
00348 boolean output_defs_seen= 0;
00349 
00350 /*:44*//*50:*/
00351 #line 710 "./cwebdir/ctangle.w"
00352 
00353 char translit[128][translit_length];
00354 
00355 /*:50*//*55:*/
00356 #line 789 "./cwebdir/ctangle.w"
00357 
00358 eight_bits ccode[256];
00359 
00360 /*:55*//*58:*/
00361 #line 845 "./cwebdir/ctangle.w"
00362 
00363 boolean comment_continues= 0;
00364 
00365 /*:58*//*60:*/
00366 #line 884 "./cwebdir/ctangle.w"
00367 
00368 name_pointer cur_section_name;
00369 int no_where;
00370 
00371 /*:60*//*74:*/
00372 #line 1195 "./cwebdir/ctangle.w"
00373 
00374 text_pointer cur_text;
00375 eight_bits next_control;
00376 
00377 /*:74*//*81:*/
00378 #line 1350 "./cwebdir/ctangle.w"
00379 
00380 extern sixteen_bits section_count;
00381 
00382 /*:81*/
00383 #line 69 "./cwebdir/ctangle.w"
00384 
00385 /*40:*/
00386 #line 533 "./cwebdir/ctangle.w"
00387 
00388 #line 244 "./cwebdir/ctang-w2c.ch"
00389 void phase_two P1H(void);
00390 #line 535 "./cwebdir/ctangle.w"
00391 
00392 /*:40*//*45:*/
00393 #line 602 "./cwebdir/ctangle.w"
00394 
00395 #line 260 "./cwebdir/ctang-w2c.ch"
00396 void output_defs P1H(void);
00397 #line 604 "./cwebdir/ctangle.w"
00398 
00399 /*:45*//*47:*/
00400 #line 648 "./cwebdir/ctangle.w"
00401 
00402 #line 276 "./cwebdir/ctang-w2c.ch"
00403 static void out_char P1H(eight_bits);
00404 #line 650 "./cwebdir/ctangle.w"
00405 
00406 /*:47*//*89:*/
00407 #line 1457 "./cwebdir/ctangle.w"
00408 
00409 #line 342 "./cwebdir/ctang-w2c.ch"
00410 void phase_one P1H(void);
00411 #line 1459 "./cwebdir/ctangle.w"
00412 
00413 /*:89*//*91:*/
00414 #line 1475 "./cwebdir/ctangle.w"
00415 
00416 #line 358 "./cwebdir/ctang-w2c.ch"
00417 void skip_limbo P1H(void);
00418 #line 1477 "./cwebdir/ctangle.w"
00419 
00420 /*:91*/
00421 #line 70 "./cwebdir/ctangle.w"
00422 
00423 
00424 #line 83 "./cwebdir/ctangle.w"
00425 
00426 /*:1*//*2:*/
00427 #line 91 "./cwebdir/ctangle.w"
00428 
00429 #line 70 "./cwebdir/ctang-w2c.ch"
00430 int main P2C(int,ac,char**,av)
00431 #line 95 "./cwebdir/ctangle.w"
00432 {
00433 argc= ac;argv= av;
00434 program= ctangle;
00435 /*17:*/
00436 #line 167 "./cwebdir/ctangle.w"
00437 
00438 text_info->tok_start= tok_ptr= tok_mem;
00439 text_ptr= text_info+1;text_ptr->tok_start= tok_mem;
00440 
00441 
00442 /*:17*//*19:*/
00443 #line 177 "./cwebdir/ctangle.w"
00444 
00445 name_dir->equiv= (char*)text_info;
00446 
00447 /*:19*//*23:*/
00448 #line 230 "./cwebdir/ctangle.w"
00449 last_unnamed= text_info;text_info->text_link= 0;
00450 
00451 /*:23*//*38:*/
00452 #line 512 "./cwebdir/ctangle.w"
00453 
00454 cur_out_file= end_output_files= output_files+max_files;
00455 
00456 /*:38*//*51:*/
00457 #line 713 "./cwebdir/ctangle.w"
00458 
00459 {
00460 int i;
00461 for(i= 0;i<128;i++)sprintf(translit[i],"X%02X",(unsigned)(128+i));
00462 }
00463 
00464 /*:51*//*56:*/
00465 #line 792 "./cwebdir/ctangle.w"
00466 {
00467 int c;
00468 for(c= 0;c<256;c++)ccode[c]= ignore;
00469 ccode[' ']= ccode['\t']= ccode['\n']= ccode['\v']= ccode['\r']= ccode['\f']
00470 = ccode['*']= new_section;
00471 ccode['@']= '@';ccode['=']= string;
00472 ccode['d']= ccode['D']= definition;
00473 ccode['f']= ccode['F']= ccode['s']= ccode['S']= format_code;
00474 ccode['c']= ccode['C']= ccode['p']= ccode['P']= begin_C;
00475 ccode['^']= ccode[':']= ccode['.']= ccode['t']= ccode['T']= 
00476 ccode['q']= ccode['Q']= control_text;
00477 ccode['h']= ccode['H']= output_defs_code;
00478 ccode['l']= ccode['L']= translit_code;
00479 ccode['&']= join;
00480 ccode['<']= ccode['(']= section_name;
00481 ccode['\'']= ord;
00482 }
00483 
00484 /*:56*//*70:*/
00485 #line 1116 "./cwebdir/ctangle.w"
00486 section_text[0]= ' ';
00487 
00488 /*:70*/
00489 #line 98 "./cwebdir/ctangle.w"
00490 ;
00491 common_init();
00492 #line 76 "./cwebdir/ctang-w2c.ch"
00493 if(show_banner){
00494 printf("%s%s\n",banner,versionstring);
00495 }
00496 #line 101 "./cwebdir/ctangle.w"
00497 phase_one();
00498 phase_two();
00499 return wrap_up();
00500 }
00501 
00502 /*:2*//*20:*/
00503 #line 183 "./cwebdir/ctangle.w"
00504 
00505 #line 178 "./cwebdir/ctang-w2c.ch"
00506 int names_match P4C(name_pointer,p,char*,first,int,l,char,t)
00507 #line 188 "./cwebdir/ctangle.w"
00508 {
00509 if(length(p)!=l)return 0;
00510 return!strncmp(first,p->byte_start,l);
00511 }
00512 
00513 /*:20*//*21:*/
00514 #line 198 "./cwebdir/ctangle.w"
00515 
00516 void
00517 #line 187 "./cwebdir/ctang-w2c.ch"
00518  init_node P1C(name_pointer,node)
00519 #line 202 "./cwebdir/ctangle.w"
00520 {
00521 node->equiv= (char*)text_info;
00522 }
00523 void
00524 #line 193 "./cwebdir/ctang-w2c.ch"
00525  init_p P2C(name_pointer,p,char,t){}
00526 #line 207 "./cwebdir/ctangle.w"
00527 
00528 /*:21*//*25:*/
00529 #line 260 "./cwebdir/ctangle.w"
00530 
00531 void
00532 #line 202 "./cwebdir/ctang-w2c.ch"
00533  store_two_bytes P1C(sixteen_bits,x)
00534 #line 264 "./cwebdir/ctangle.w"
00535 {
00536 if(tok_ptr+2> tok_mem_end)overflow("token");
00537 *tok_ptr++= x>>8;
00538 *tok_ptr++= x&0377;
00539 }
00540 
00541 /*:25*//*29:*/
00542 #line 336 "./cwebdir/ctangle.w"
00543 
00544 void
00545 #line 211 "./cwebdir/ctang-w2c.ch"
00546  push_level P1C(name_pointer,p)
00547 #line 340 "./cwebdir/ctangle.w"
00548 {
00549 if(stack_ptr==stack_end)overflow("stack");
00550 *stack_ptr= cur_state;
00551 stack_ptr++;
00552 if(p!=NULL){
00553 cur_name= p;cur_repl= (text_pointer)p->equiv;
00554 cur_byte= cur_repl->tok_start;cur_end= (cur_repl+1)->tok_start;
00555 cur_section= 0;
00556 }
00557 }
00558 
00559 /*:29*//*30:*/
00560 #line 355 "./cwebdir/ctangle.w"
00561 
00562 void
00563 #line 220 "./cwebdir/ctang-w2c.ch"
00564  pop_level P1C(int,flag)
00565 #line 359 "./cwebdir/ctangle.w"
00566 {
00567 if(flag&&cur_repl->text_link<section_flag){
00568 cur_repl= cur_repl->text_link+text_info;
00569 cur_byte= cur_repl->tok_start;cur_end= (cur_repl+1)->tok_start;
00570 return;
00571 }
00572 stack_ptr--;
00573 if(stack_ptr> stack)cur_state= *stack_ptr;
00574 }
00575 
00576 /*:30*//*32:*/
00577 #line 391 "./cwebdir/ctangle.w"
00578 
00579 void
00580 #line 228 "./cwebdir/ctang-w2c.ch"
00581  get_output P1H(void)
00582 #line 394 "./cwebdir/ctangle.w"
00583 {
00584 sixteen_bits a;
00585 restart:if(stack_ptr==stack)return;
00586 if(cur_byte==cur_end){
00587 cur_val= -((int)cur_section);
00588 pop_level(1);
00589 if(cur_val==0)goto restart;
00590 out_char(section_number);return;
00591 }
00592 a= *cur_byte++;
00593 if(out_state==verbatim&&a!=string&&a!=constant&&a!='\n')
00594 C_putc(a);
00595 else if(a<0200)out_char(a);
00596 else{
00597 a= (a-0200)*0400+*cur_byte++;
00598 switch(a/024000){
00599 case 0:cur_val= a;out_char(identifier);break;
00600 case 1:if(a==output_defs_flag)output_defs();
00601 else/*33:*/
00602 #line 423 "./cwebdir/ctangle.w"
00603 
00604 {
00605 a-= 024000;
00606 if((a+name_dir)->equiv!=(char*)text_info)push_level(a+name_dir);
00607 else if(a!=0){
00608 printf("\n! Not present: <");
00609 print_section_name(a+name_dir);err_print(">");
00610 
00611 }
00612 goto restart;
00613 }
00614 
00615 /*:33*/
00616 #line 412 "./cwebdir/ctangle.w"
00617 ;
00618 break;
00619 default:cur_val= a-050000;if(cur_val> 0)cur_section= cur_val;
00620 out_char(section_number);
00621 }
00622 }
00623 }
00624 
00625 /*:32*//*36:*/
00626 #line 481 "./cwebdir/ctangle.w"
00627 
00628 void
00629 #line 236 "./cwebdir/ctang-w2c.ch"
00630  flush_buffer P1H(void)
00631 #line 484 "./cwebdir/ctangle.w"
00632 {
00633 C_putc('\n');
00634 if(cur_line%100==0&&show_progress){
00635 printf(".");
00636 if(cur_line%500==0)printf("%d",cur_line);
00637 update_terminal;
00638 }
00639 cur_line++;
00640 }
00641 
00642 /*:36*//*41:*/
00643 #line 536 "./cwebdir/ctangle.w"
00644 
00645 void
00646 #line 252 "./cwebdir/ctang-w2c.ch"
00647  phase_two P1H(void){
00648 #line 539 "./cwebdir/ctangle.w"
00649 web_file_open= 0;
00650 cur_line= 1;
00651 /*28:*/
00652 #line 325 "./cwebdir/ctangle.w"
00653 
00654 stack_ptr= stack+1;cur_name= name_dir;cur_repl= text_info->text_link+text_info;
00655 cur_byte= cur_repl->tok_start;cur_end= (cur_repl+1)->tok_start;cur_section= 0;
00656 
00657 /*:28*/
00658 #line 541 "./cwebdir/ctangle.w"
00659 ;
00660 /*43:*/
00661 #line 595 "./cwebdir/ctangle.w"
00662 
00663 if(!output_defs_seen)
00664 output_defs();
00665 
00666 /*:43*/
00667 #line 542 "./cwebdir/ctangle.w"
00668 ;
00669 if(text_info->text_link==0&&cur_out_file==end_output_files){
00670 printf("\n! No program text was specified.");mark_harmless;
00671 
00672 }
00673 else{
00674 if(cur_out_file==end_output_files){
00675 if(show_progress)
00676 printf("\nWriting the output file (%s):",C_file_name);
00677 }
00678 else{
00679 if(show_progress){
00680 printf("\nWriting the output files:");
00681 
00682 printf(" (%s)",C_file_name);
00683 update_terminal;
00684 }
00685 if(text_info->text_link==0)goto writeloop;
00686 }
00687 while(stack_ptr> stack)get_output();
00688 flush_buffer();
00689 writeloop:/*42:*/
00690 #line 572 "./cwebdir/ctangle.w"
00691 
00692 for(an_output_file= end_output_files;an_output_file> cur_out_file;){
00693 an_output_file--;
00694 sprint_section_name(output_file_name,*an_output_file);
00695 fclose(C_file);
00696 C_file= fopen(output_file_name,"w");
00697 if(C_file==0)fatal("! Cannot open output file:",output_file_name);
00698 
00699 printf("\n(%s)",output_file_name);update_terminal;
00700 cur_line= 1;
00701 stack_ptr= stack+1;
00702 cur_name= (*an_output_file);
00703 cur_repl= (text_pointer)cur_name->equiv;
00704 cur_byte= cur_repl->tok_start;
00705 cur_end= (cur_repl+1)->tok_start;
00706 while(stack_ptr> stack)get_output();
00707 flush_buffer();
00708 }
00709 
00710 /*:42*/
00711 #line 563 "./cwebdir/ctangle.w"
00712 ;
00713 if(show_happiness)printf("\nDone.");
00714 }
00715 }
00716 
00717 /*:41*//*46:*/
00718 #line 605 "./cwebdir/ctangle.w"
00719 
00720 void
00721 #line 268 "./cwebdir/ctang-w2c.ch"
00722  output_defs P1H(void)
00723 #line 608 "./cwebdir/ctangle.w"
00724 {
00725 sixteen_bits a;
00726 push_level(NULL);
00727 for(cur_text= text_info+1;cur_text<text_ptr;cur_text++)
00728 if(cur_text->text_link==0){
00729 cur_byte= cur_text->tok_start;
00730 cur_end= (cur_text+1)->tok_start;
00731 C_printf("%s","#define ");
00732 out_state= normal;
00733 protect= 1;
00734 while(cur_byte<cur_end){
00735 a= *cur_byte++;
00736 if(cur_byte==cur_end&&a=='\n')break;
00737 if(out_state==verbatim&&a!=string&&a!=constant&&a!='\n')
00738 C_putc(a);
00739 
00740 else if(a<0200)out_char(a);
00741 else{
00742 a= (a-0200)*0400+*cur_byte++;
00743 if(a<024000){
00744 cur_val= a;out_char(identifier);
00745 }
00746 else if(a<050000){confusion("macro defs have strange char");}
00747 else{
00748 cur_val= a-050000;cur_section= cur_val;out_char(section_number);
00749 }
00750 
00751 }
00752 }
00753 protect= 0;
00754 flush_buffer();
00755 }
00756 pop_level(0);
00757 }
00758 
00759 /*:46*//*48:*/
00760 #line 651 "./cwebdir/ctangle.w"
00761 
00762 static void
00763 #line 285 "./cwebdir/ctang-w2c.ch"
00764  out_char P1C(eight_bits,cur_char)
00765 #line 655 "./cwebdir/ctangle.w"
00766 {
00767 char*j,*k;
00768 restart:
00769 switch(cur_char){
00770 case'\n':if(protect&&out_state!=verbatim)C_putc(' ');
00771 if(protect||out_state==verbatim)C_putc('\\');
00772 flush_buffer();if(out_state!=verbatim)out_state= normal;break;
00773 /*52:*/
00774 #line 719 "./cwebdir/ctangle.w"
00775 
00776 case identifier:
00777 if(out_state==num_or_id)C_putc(' ');
00778 j= (cur_val+name_dir)->byte_start;
00779 k= (cur_val+name_dir+1)->byte_start;
00780 while(j<k){
00781 if((unsigned char)(*j)<0200)C_putc(*j);
00782 
00783 else C_printf("%s",translit[(unsigned char)(*j)-0200]);
00784 j++;
00785 }
00786 out_state= num_or_id;break;
00787 
00788 /*:52*/
00789 #line 662 "./cwebdir/ctangle.w"
00790 ;
00791 /*53:*/
00792 #line 732 "./cwebdir/ctangle.w"
00793 
00794 case section_number:
00795 if(cur_val> 0)C_printf("/*%d:*/",cur_val);
00796 else if(cur_val<0)C_printf("/*:%d*/",-cur_val);
00797 else if(protect){
00798 cur_byte+= 4;
00799 cur_char= '\n';
00800 goto restart;
00801 }else{
00802 sixteen_bits a;
00803 a= 0400**cur_byte++;
00804 a+= *cur_byte++;
00805 C_printf("\n#line %d \"",a);
00806 
00807 cur_val= *cur_byte++;
00808 cur_val= 0400*(cur_val-0200)+*cur_byte++;
00809 for(j= (cur_val+name_dir)->byte_start,k= (cur_val+name_dir+1)->byte_start;
00810 j<k;j++){
00811 if(*j=='\\'||*j=='"')C_putc('\\');
00812 C_putc(*j);
00813 }
00814 C_printf("%s","\"\n");
00815 }
00816 break;
00817 
00818 /*:53*/
00819 #line 663 "./cwebdir/ctangle.w"
00820 ;
00821 /*49:*/
00822 #line 681 "./cwebdir/ctangle.w"
00823 
00824 case plus_plus:C_putc('+');C_putc('+');out_state= normal;break;
00825 case minus_minus:C_putc('-');C_putc('-');out_state= normal;break;
00826 case minus_gt:C_putc('-');C_putc('>');out_state= normal;break;
00827 case gt_gt:C_putc('>');C_putc('>');out_state= normal;break;
00828 case eq_eq:C_putc('=');C_putc('=');out_state= normal;break;
00829 case lt_lt:C_putc('<');C_putc('<');out_state= normal;break;
00830 case gt_eq:C_putc('>');C_putc('=');out_state= normal;break;
00831 case lt_eq:C_putc('<');C_putc('=');out_state= normal;break;
00832 case not_eq:C_putc('!');C_putc('=');out_state= normal;break;
00833 case and_and:C_putc('&');C_putc('&');out_state= normal;break;
00834 case or_or:C_putc('|');C_putc('|');out_state= normal;break;
00835 case dot_dot_dot:C_putc('.');C_putc('.');C_putc('.');out_state= normal;
00836 break;
00837 case colon_colon:C_putc(':');C_putc(':');out_state= normal;break;
00838 case period_ast:C_putc('.');C_putc('*');out_state= normal;break;
00839 case minus_gt_ast:C_putc('-');C_putc('>');C_putc('*');out_state= normal;
00840 break;
00841 
00842 /*:49*/
00843 #line 664 "./cwebdir/ctangle.w"
00844 ;
00845 case'=':case'>':C_putc(cur_char);C_putc(' ');
00846 out_state= normal;break;
00847 case join:out_state= unbreakable;break;
00848 case constant:if(out_state==verbatim){
00849 out_state= num_or_id;break;
00850 }
00851 if(out_state==num_or_id)C_putc(' ');out_state= verbatim;break;
00852 case string:if(out_state==verbatim)out_state= normal;
00853 else out_state= verbatim;break;
00854 case'/':C_putc('/');out_state= post_slash;break;
00855 case'*':if(out_state==post_slash)C_putc(' ');
00856 
00857 default:C_putc(cur_char);out_state= normal;break;
00858 }
00859 }
00860 
00861 /*:48*//*57:*/
00862 #line 813 "./cwebdir/ctangle.w"
00863 
00864 eight_bits
00865 #line 293 "./cwebdir/ctang-w2c.ch"
00866  skip_ahead P1H(void)
00867 #line 816 "./cwebdir/ctangle.w"
00868 {
00869 eight_bits c;
00870 while(1){
00871 if(loc> limit&&(get_line()==0))return(new_section);
00872 *(limit+1)= '@';
00873 while(*loc!='@')loc++;
00874 if(loc<=limit){
00875 loc++;c= ccode[(eight_bits)*loc];loc++;
00876 if(c!=ignore||*(loc-1)=='>')return(c);
00877 }
00878 }
00879 }
00880 
00881 /*:57*//*59:*/
00882 #line 848 "./cwebdir/ctangle.w"
00883 
00884 #line 302 "./cwebdir/ctang-w2c.ch"
00885 int skip_comment P1C(boolean,is_long_comment)
00886 #line 851 "./cwebdir/ctangle.w"
00887 {
00888 char c;
00889 while(1){
00890 if(loc> limit){
00891 if(is_long_comment){
00892 if(get_line())return(comment_continues= 1);
00893 else{
00894 err_print("! Input ended in mid-comment");
00895 
00896 return(comment_continues= 0);
00897 }
00898 }
00899 else return(comment_continues= 0);
00900 }
00901 c= *(loc++);
00902 if(is_long_comment&&c=='*'&&*loc=='/'){
00903 loc++;return(comment_continues= 0);
00904 }
00905 if(c=='@'){
00906 if(ccode[(eight_bits)*loc]==new_section){
00907 err_print("! Section name ended in mid-comment");loc--;
00908 
00909 return(comment_continues= 0);
00910 }
00911 else loc++;
00912 }
00913 }
00914 }
00915 
00916 /*:59*//*62:*/
00917 #line 900 "./cwebdir/ctangle.w"
00918 
00919 eight_bits
00920 #line 317 "./cwebdir/ctang-w2c.ch"
00921  get_next P1H(void)
00922 #line 903 "./cwebdir/ctangle.w"
00923 {
00924 static int preprocessing= 0;
00925 eight_bits c;
00926 while(1){
00927 if(loc> limit){
00928 if(preprocessing&&*(limit-1)!='\\')preprocessing= 0;
00929 if(get_line()==0)return(new_section);
00930 else if(print_where&&!no_where){
00931 print_where= 0;
00932 /*76:*/
00933 #line 1225 "./cwebdir/ctangle.w"
00934 
00935 store_two_bytes(0150000);
00936 if(changing)id_first= change_file_name;
00937 else id_first= cur_file_name;
00938 id_loc= id_first+strlen(id_first);
00939 if(changing)store_two_bytes((sixteen_bits)change_line);
00940 else store_two_bytes((sixteen_bits)cur_line);
00941 {int a= id_lookup(id_first,id_loc,0)-name_dir;app_repl((a/0400)+0200);
00942 app_repl(a%0400);}
00943 
00944 /*:76*/
00945 #line 912 "./cwebdir/ctangle.w"
00946 ;
00947 }
00948 else return('\n');
00949 }
00950 c= *loc;
00951 if(comment_continues||(c=='/'&&(*(loc+1)=='*'||*(loc+1)=='/'))){
00952 skip_comment(comment_continues||*(loc+1)=='*');
00953 
00954 if(comment_continues)return('\n');
00955 else continue;
00956 }
00957 loc++;
00958 if(xisdigit(c)||c=='.')/*65:*/
00959 #line 978 "./cwebdir/ctangle.w"
00960 {
00961 id_first= loc-1;
00962 if(*id_first=='.'&&!xisdigit(*loc))goto mistake;
00963 if(*id_first=='0'){
00964 if(*loc=='x'||*loc=='X'){
00965 loc++;while(xisxdigit(*loc))loc++;goto found;
00966 }
00967 }
00968 while(xisdigit(*loc))loc++;
00969 if(*loc=='.'){
00970 loc++;
00971 while(xisdigit(*loc))loc++;
00972 }
00973 if(*loc=='e'||*loc=='E'){
00974 if(*++loc=='+'||*loc=='-')loc++;
00975 while(xisdigit(*loc))loc++;
00976 }
00977 found:while(*loc=='u'||*loc=='U'||*loc=='l'||*loc=='L'
00978 ||*loc=='f'||*loc=='F')loc++;
00979 id_loc= loc;
00980 return(constant);
00981 }
00982 
00983 /*:65*/
00984 #line 924 "./cwebdir/ctangle.w"
00985 
00986 else if(c=='\''||c=='"'||(c=='L'&&(*loc=='\''||*loc=='"')))
00987 /*66:*/
00988 #line 1006 "./cwebdir/ctangle.w"
00989 {
00990 char delim= c;
00991 id_first= section_text+1;
00992 id_loc= section_text;*++id_loc= delim;
00993 if(delim=='L'){
00994 delim= *loc++;*++id_loc= delim;
00995 }
00996 while(1){
00997 if(loc>=limit){
00998 if(*(limit-1)!='\\'){
00999 err_print("! String didn't end");loc= limit;break;
01000 
01001 }
01002 if(get_line()==0){
01003 err_print("! Input ended in middle of string");loc= buffer;break;
01004 
01005 }
01006 else if(++id_loc<=section_text_end)*id_loc= '\n';
01007 
01008 }
01009 if((c= *loc++)==delim){
01010 if(++id_loc<=section_text_end)*id_loc= c;
01011 break;
01012 }
01013 if(c=='\\'){
01014 if(loc>=limit)continue;
01015 if(++id_loc<=section_text_end)*id_loc= '\\';
01016 c= *loc++;
01017 }
01018 if(++id_loc<=section_text_end)*id_loc= c;
01019 }
01020 if(id_loc>=section_text_end){
01021 printf("\n! String too long: ");
01022 
01023 term_write(section_text+1,25);
01024 err_print("...");
01025 }
01026 id_loc++;
01027 return(string);
01028 }
01029 
01030 /*:66*/
01031 #line 926 "./cwebdir/ctangle.w"
01032 
01033 else if(isalpha(c)||isxalpha(c)||ishigh(c))
01034 /*64:*/
01035 #line 972 "./cwebdir/ctangle.w"
01036 {
01037 id_first= --loc;
01038 while(isalpha(*++loc)||isdigit(*loc)||isxalpha(*loc)||ishigh(*loc));
01039 id_loc= loc;return(identifier);
01040 }
01041 
01042 /*:64*/
01043 #line 928 "./cwebdir/ctangle.w"
01044 
01045 else if(c=='@')/*67:*/
01046 #line 1050 "./cwebdir/ctangle.w"
01047 {
01048 c= ccode[(eight_bits)*loc++];
01049 switch(c){
01050 case ignore:continue;
01051 case translit_code:err_print("! Use @l in limbo only");continue;
01052 
01053 case control_text:while((c= skip_ahead())=='@');
01054 
01055 if(*(loc-1)!='>')
01056 err_print("! Double @ should be used in control text");
01057 
01058 continue;
01059 case section_name:
01060 cur_section_name_char= *(loc-1);
01061 /*69:*/
01062 #line 1098 "./cwebdir/ctangle.w"
01063 {
01064 char*k;
01065 /*71:*/
01066 #line 1118 "./cwebdir/ctangle.w"
01067 
01068 k= section_text;
01069 while(1){
01070 if(loc> limit&&get_line()==0){
01071 err_print("! Input ended in section name");
01072 
01073 loc= buffer+1;break;
01074 }
01075 c= *loc;
01076 /*72:*/
01077 #line 1142 "./cwebdir/ctangle.w"
01078 
01079 if(c=='@'){
01080 c= *(loc+1);
01081 if(c=='>'){
01082 loc+= 2;break;
01083 }
01084 if(ccode[(eight_bits)c]==new_section){
01085 err_print("! Section name didn't end");break;
01086 
01087 }
01088 if(ccode[(eight_bits)c]==section_name){
01089 err_print("! Nesting of section names not allowed");break;
01090 
01091 }
01092 *(++k)= '@';loc++;
01093 }
01094 
01095 /*:72*/
01096 #line 1127 "./cwebdir/ctangle.w"
01097 ;
01098 loc++;if(k<section_text_end)k++;
01099 if(xisspace(c)){
01100 c= ' ';if(*(k-1)==' ')k--;
01101 }
01102 *k= c;
01103 }
01104 if(k>=section_text_end){
01105 printf("\n! Section name too long: ");
01106 
01107 term_write(section_text+1,25);
01108 printf("...");mark_harmless;
01109 }
01110 if(*k==' '&&k> section_text)k--;
01111 
01112 /*:71*/
01113 #line 1100 "./cwebdir/ctangle.w"
01114 ;
01115 if(k-section_text> 3&&strncmp(k-2,"...",3)==0)
01116 cur_section_name= section_lookup(section_text+1,k-3,1);
01117 else cur_section_name= section_lookup(section_text+1,k,0);
01118 if(cur_section_name_char=='(')
01119 /*39:*/
01120 #line 516 "./cwebdir/ctangle.w"
01121 
01122 {
01123 for(an_output_file= cur_out_file;
01124 an_output_file<end_output_files;an_output_file++)
01125 if(*an_output_file==cur_section_name)break;
01126 if(an_output_file==end_output_files){
01127 if(cur_out_file> output_files)
01128 *--cur_out_file= cur_section_name;
01129 else{
01130 overflow("output files");
01131 }
01132 }
01133 }
01134 
01135 /*:39*/
01136 #line 1106 "./cwebdir/ctangle.w"
01137 ;
01138 return(section_name);
01139 }
01140 
01141 /*:69*/
01142 #line 1064 "./cwebdir/ctangle.w"
01143 ;
01144 case string:/*73:*/
01145 #line 1164 "./cwebdir/ctangle.w"
01146 {
01147 id_first= loc++;*(limit+1)= '@';*(limit+2)= '>';
01148 while(*loc!='@'||*(loc+1)!='>')loc++;
01149 if(loc>=limit)err_print("! Verbatim string didn't end");
01150 
01151 id_loc= loc;loc+= 2;
01152 return(string);
01153 }
01154 
01155 /*:73*/
01156 #line 1065 "./cwebdir/ctangle.w"
01157 ;
01158 case ord:/*68:*/
01159 #line 1077 "./cwebdir/ctangle.w"
01160 
01161 id_first= loc;
01162 if(*loc=='\\'){
01163 if(*++loc=='\'')loc++;
01164 }
01165 while(*loc!='\''){
01166 if(*loc=='@'){
01167 if(*(loc+1)!='@')
01168 err_print("! Double @ should be used in ASCII constant");
01169 
01170 else loc++;
01171 }
01172 loc++;
01173 if(loc> limit){
01174 err_print("! String didn't end");loc= limit-1;break;
01175 
01176 }
01177 }
01178 loc++;
01179 return(ord);
01180 
01181 /*:68*/
01182 #line 1066 "./cwebdir/ctangle.w"
01183 ;
01184 default:return(c);
01185 }
01186 }
01187 
01188 /*:67*/
01189 #line 929 "./cwebdir/ctangle.w"
01190 
01191 else if(xisspace(c)){
01192 if(!preprocessing||loc> limit)continue;
01193 
01194 else return(' ');
01195 }
01196 else if(c=='#'&&loc==buffer+1)preprocessing= 1;
01197 mistake:/*63:*/
01198 #line 950 "./cwebdir/ctangle.w"
01199 
01200 switch(c){
01201 case'+':if(*loc=='+')compress(plus_plus);break;
01202 case'-':if(*loc=='-'){compress(minus_minus);}
01203 else if(*loc=='>')if(*(loc+1)=='*'){loc++;compress(minus_gt_ast);}
01204 else compress(minus_gt);break;
01205 case'.':if(*loc=='*'){compress(period_ast);}
01206 else if(*loc=='.'&&*(loc+1)=='.'){
01207 loc++;compress(dot_dot_dot);
01208 }
01209 break;
01210 case':':if(*loc==':')compress(colon_colon);break;
01211 case'=':if(*loc=='=')compress(eq_eq);break;
01212 case'>':if(*loc=='='){compress(gt_eq);}
01213 else if(*loc=='>')compress(gt_gt);break;
01214 case'<':if(*loc=='='){compress(lt_eq);}
01215 else if(*loc=='<')compress(lt_lt);break;
01216 case'&':if(*loc=='&')compress(and_and);break;
01217 case'|':if(*loc=='|')compress(or_or);break;
01218 case'!':if(*loc=='=')compress(not_eq);break;
01219 }
01220 
01221 /*:63*/
01222 #line 936 "./cwebdir/ctangle.w"
01223 
01224 return(c);
01225 }
01226 }
01227 
01228 /*:62*//*75:*/
01229 #line 1199 "./cwebdir/ctangle.w"
01230 
01231 void
01232 #line 326 "./cwebdir/ctang-w2c.ch"
01233  scan_repl P1C(eight_bits,t)
01234 #line 1203 "./cwebdir/ctangle.w"
01235 {
01236 sixteen_bits a;
01237 if(t==section_name){/*76:*/
01238 #line 1225 "./cwebdir/ctangle.w"
01239 
01240 store_two_bytes(0150000);
01241 if(changing)id_first= change_file_name;
01242 else id_first= cur_file_name;
01243 id_loc= id_first+strlen(id_first);
01244 if(changing)store_two_bytes((sixteen_bits)change_line);
01245 else store_two_bytes((sixteen_bits)cur_line);
01246 {int a= id_lookup(id_first,id_loc,0)-name_dir;app_repl((a/0400)+0200);
01247 app_repl(a%0400);}
01248 
01249 /*:76*/
01250 #line 1205 "./cwebdir/ctangle.w"
01251 ;}
01252 while(1)switch(a= get_next()){
01253 /*77:*/
01254 #line 1235 "./cwebdir/ctangle.w"
01255 
01256 case identifier:a= id_lookup(id_first,id_loc,0)-name_dir;
01257 app_repl((a/0400)+0200);
01258 app_repl(a%0400);break;
01259 case section_name:if(t!=section_name)goto done;
01260 else{
01261 /*78:*/
01262 #line 1268 "./cwebdir/ctangle.w"
01263 {
01264 char*try_loc= loc;
01265 while(*try_loc==' '&&try_loc<limit)try_loc++;
01266 if(*try_loc=='+'&&try_loc<limit)try_loc++;
01267 while(*try_loc==' '&&try_loc<limit)try_loc++;
01268 if(*try_loc=='=')err_print("! Missing `@ ' before a named section");
01269 
01270 
01271 
01272 }
01273 
01274 /*:78*/
01275 #line 1241 "./cwebdir/ctangle.w"
01276 ;
01277 a= cur_section_name-name_dir;
01278 app_repl((a/0400)+0250);
01279 app_repl(a%0400);
01280 /*76:*/
01281 #line 1225 "./cwebdir/ctangle.w"
01282 
01283 store_two_bytes(0150000);
01284 if(changing)id_first= change_file_name;
01285 else id_first= cur_file_name;
01286 id_loc= id_first+strlen(id_first);
01287 if(changing)store_two_bytes((sixteen_bits)change_line);
01288 else store_two_bytes((sixteen_bits)cur_line);
01289 {int a= id_lookup(id_first,id_loc,0)-name_dir;app_repl((a/0400)+0200);
01290 app_repl(a%0400);}
01291 
01292 /*:76*/
01293 #line 1245 "./cwebdir/ctangle.w"
01294 ;break;
01295 }
01296 case output_defs_code:if(t!=section_name)err_print("! Misplaced @h");
01297 
01298 else{
01299 output_defs_seen= 1;
01300 a= output_defs_flag;
01301 app_repl((a/0400)+0200);
01302 app_repl(a%0400);
01303 /*76:*/
01304 #line 1225 "./cwebdir/ctangle.w"
01305 
01306 store_two_bytes(0150000);
01307 if(changing)id_first= change_file_name;
01308 else id_first= cur_file_name;
01309 id_loc= id_first+strlen(id_first);
01310 if(changing)store_two_bytes((sixteen_bits)change_line);
01311 else store_two_bytes((sixteen_bits)cur_line);
01312 {int a= id_lookup(id_first,id_loc,0)-name_dir;app_repl((a/0400)+0200);
01313 app_repl(a%0400);}
01314 
01315 /*:76*/
01316 #line 1254 "./cwebdir/ctangle.w"
01317 ;
01318 }
01319 break;
01320 case constant:case string:
01321 /*79:*/
01322 #line 1279 "./cwebdir/ctangle.w"
01323 
01324 app_repl(a);
01325 while(id_first<id_loc){
01326 if(*id_first=='@'){
01327 if(*(id_first+1)=='@')id_first++;
01328 else err_print("! Double @ should be used in string");
01329 
01330 }
01331 app_repl(*id_first++);
01332 }
01333 app_repl(a);break;
01334 
01335 /*:79*/
01336 #line 1258 "./cwebdir/ctangle.w"
01337 ;
01338 case ord:
01339 /*80:*/
01340 #line 1295 "./cwebdir/ctangle.w"
01341 {
01342 int c= (eight_bits)*id_first;
01343 if(c=='\\'){
01344 c= *++id_first;
01345 if(c>='0'&&c<='7'){
01346 c-= '0';
01347 if(*(id_first+1)>='0'&&*(id_first+1)<='7'){
01348 c= 8*c+*(++id_first)-'0';
01349 if(*(id_first+1)>='0'&&*(id_first+1)<='7'&&c<32)
01350 c= 8*c+*(++id_first)-'0';
01351 }
01352 }
01353 else switch(c){
01354 case't':c= '\t';break;
01355 case'n':c= '\n';break;
01356 case'b':c= '\b';break;
01357 case'f':c= '\f';break;
01358 case'v':c= '\v';break;
01359 case'r':c= '\r';break;
01360 case'a':c= '\7';break;
01361 case'?':c= '?';break;
01362 case'x':
01363 if(xisdigit(*(id_first+1)))c= *(++id_first)-'0';
01364 else if(xisxdigit(*(id_first+1))){
01365 ++id_first;
01366 c= toupper(*id_first)-'A'+10;
01367 }
01368 if(xisdigit(*(id_first+1)))c= 16*c+*(++id_first)-'0';
01369 else if(xisxdigit(*(id_first+1))){
01370 ++id_first;
01371 c= 16*c+toupper(*id_first)-'A'+10;
01372 }
01373 break;
01374 case'\\':c= '\\';break;
01375 case'\'':c= '\'';break;
01376 case'\"':c= '\"';break;
01377 default:err_print("! Unrecognized escape sequence");
01378 
01379 }
01380 }
01381 
01382 app_repl(constant);
01383 if(c>=100)app_repl('0'+c/100);
01384 if(c>=10)app_repl('0'+(c/10)%10);
01385 app_repl('0'+c%10);
01386 app_repl(constant);
01387 }
01388 break;
01389 
01390 /*:80*/
01391 #line 1260 "./cwebdir/ctangle.w"
01392 ;
01393 case definition:case format_code:case begin_C:if(t!=section_name)goto done;
01394 else{
01395 err_print("! @d, @f and @c are ignored in C text");continue;
01396 
01397 }
01398 case new_section:goto done;
01399 
01400 /*:77*/
01401 #line 1210 "./cwebdir/ctangle.w"
01402 
01403 case')':app_repl(a);
01404 if(t==macro)app_repl(' ');
01405 break;
01406 default:app_repl(a);
01407 }
01408 done:next_control= (eight_bits)a;
01409 if(text_ptr> text_info_end)overflow("text");
01410 cur_text= text_ptr;(++text_ptr)->tok_start= tok_ptr;
01411 }
01412 
01413 /*:75*//*82:*/
01414 #line 1357 "./cwebdir/ctangle.w"
01415 
01416 void
01417 #line 334 "./cwebdir/ctang-w2c.ch"
01418  scan_section P1H(void)
01419 #line 1360 "./cwebdir/ctangle.w"
01420 {
01421 name_pointer p;
01422 text_pointer q;
01423 sixteen_bits a;
01424 section_count++;no_where= 1;
01425 if(*(loc-1)=='*'&&show_progress){
01426 printf("*%d",section_count);update_terminal;
01427 }
01428 next_control= 0;
01429 while(1){
01430 /*83:*/
01431 #line 1396 "./cwebdir/ctangle.w"
01432 
01433 while(next_control<definition)
01434 
01435 if((next_control= skip_ahead())==section_name){
01436 loc-= 2;next_control= get_next();
01437 }
01438 
01439 /*:83*/
01440 #line 1371 "./cwebdir/ctangle.w"
01441 ;
01442 if(next_control==definition){
01443 /*84:*/
01444 #line 1403 "./cwebdir/ctangle.w"
01445 {
01446 while((next_control= get_next())=='\n');
01447 if(next_control!=identifier){
01448 err_print("! Definition flushed, must start with identifier");
01449 
01450 continue;
01451 }
01452 app_repl(((a= id_lookup(id_first,id_loc,0)-name_dir)/0400)+0200);
01453 
01454 app_repl(a%0400);
01455 if(*loc!='('){
01456 app_repl(string);app_repl(' ');app_repl(string);
01457 }
01458 scan_repl(macro);
01459 cur_text->text_link= 0;
01460 }
01461 
01462 /*:84*/
01463 #line 1373 "./cwebdir/ctangle.w"
01464 
01465 continue;
01466 }
01467 if(next_control==begin_C){
01468 p= name_dir;break;
01469 }
01470 if(next_control==section_name){
01471 p= cur_section_name;
01472 /*85:*/
01473 #line 1428 "./cwebdir/ctangle.w"
01474 
01475 while((next_control= get_next())=='+');
01476 if(next_control!='='&&next_control!=eq_eq)
01477 continue;
01478 
01479 /*:85*/
01480 #line 1381 "./cwebdir/ctangle.w"
01481 ;
01482 break;
01483 }
01484 return;
01485 }
01486 no_where= print_where= 0;
01487 /*86:*/
01488 #line 1433 "./cwebdir/ctangle.w"
01489 
01490 /*87:*/
01491 #line 1438 "./cwebdir/ctangle.w"
01492 
01493 store_two_bytes((sixteen_bits)(0150000+section_count));
01494 
01495 
01496 /*:87*/
01497 #line 1434 "./cwebdir/ctangle.w"
01498 ;
01499 scan_repl(section_name);
01500 /*88:*/
01501 #line 1442 "./cwebdir/ctangle.w"
01502 
01503 if(p==name_dir||p==0){
01504 (last_unnamed)->text_link= cur_text-text_info;last_unnamed= cur_text;
01505 }
01506 else if(p->equiv==(char*)text_info)p->equiv= (char*)cur_text;
01507 
01508 else{
01509 q= (text_pointer)p->equiv;
01510 while(q->text_link<section_flag)
01511 q= q->text_link+text_info;
01512 q->text_link= cur_text-text_info;
01513 }
01514 cur_text->text_link= section_flag;
01515 
01516 
01517 /*:88*/
01518 #line 1436 "./cwebdir/ctangle.w"
01519 ;
01520 
01521 /*:86*/
01522 #line 1387 "./cwebdir/ctangle.w"
01523 ;
01524 }
01525 
01526 /*:82*//*90:*/
01527 #line 1460 "./cwebdir/ctangle.w"
01528 
01529 void
01530 #line 350 "./cwebdir/ctang-w2c.ch"
01531  phase_one P1H(void){
01532 #line 1463 "./cwebdir/ctangle.w"
01533 phase= 1;
01534 section_count= 0;
01535 reset_input();
01536 skip_limbo();
01537 while(!input_has_ended)scan_section();
01538 check_complete();
01539 phase= 2;
01540 }
01541 
01542 /*:90*//*92:*/
01543 #line 1478 "./cwebdir/ctangle.w"
01544 
01545 void
01546 #line 366 "./cwebdir/ctang-w2c.ch"
01547  skip_limbo P1H(void)
01548 #line 1481 "./cwebdir/ctangle.w"
01549 {
01550 char c;
01551 while(1){
01552 if(loc> limit&&get_line()==0)return;
01553 *(limit+1)= '@';
01554 while(*loc!='@')loc++;
01555 if(loc++<=limit){
01556 c= *loc++;
01557 if(ccode[(eight_bits)c]==new_section)break;
01558 switch(ccode[(eight_bits)c]){
01559 case translit_code:/*93:*/
01560 #line 1507 "./cwebdir/ctangle.w"
01561 
01562 while(xisspace(*loc)&&loc<limit)loc++;
01563 loc+= 3;
01564 if(loc> limit||!xisxdigit(*(loc-3))||!xisxdigit(*(loc-2))
01565 ||(*(loc-3)>='0'&&*(loc-3)<='7')||!xisspace(*(loc-1)))
01566 err_print("! Improper hex number following @l");
01567 
01568 else{
01569 unsigned i;
01570 char*beg;
01571 sscanf(loc-3,"%x",&i);
01572 while(xisspace(*loc)&&loc<limit)loc++;
01573 beg= loc;
01574 while(loc<limit&&(xisalpha(*loc)||xisdigit(*loc)||*loc=='_'))loc++;
01575 if(loc-beg>=translit_length)
01576 err_print("! Replacement string in @l too long");
01577 
01578 else{
01579 strncpy(translit[i-0200],beg,loc-beg);
01580 translit[i-0200][loc-beg]= '\0';
01581 }
01582 }
01583 
01584 /*:93*/
01585 #line 1491 "./cwebdir/ctangle.w"
01586 ;break;
01587 case format_code:case'@':break;
01588 case control_text:if(c=='q'||c=='Q'){
01589 while((c= skip_ahead())=='@');
01590 if(*(loc-1)!='>')
01591 err_print("! Double @ should be used in control text");
01592 
01593 break;
01594 }
01595 default:err_print("! Double @ should be used in limbo");
01596 
01597 }
01598 }
01599 }
01600 }
01601 
01602 /*:92*//*94:*/
01603 #line 1533 "./cwebdir/ctangle.w"
01604 
01605 void
01606 #line 374 "./cwebdir/ctang-w2c.ch"
01607  print_stats P1H(void){
01608 #line 1536 "./cwebdir/ctangle.w"
01609 printf("\nMemory usage statistics:\n");
01610 printf("%ld names (out of %ld)\n",
01611 (long)(name_ptr-name_dir),(long)max_names);
01612 printf("%ld replacement texts (out of %ld)\n",
01613 (long)(text_ptr-text_info),(long)max_texts);
01614 printf("%ld bytes (out of %ld)\n",
01615 (long)(byte_ptr-byte_mem),(long)max_bytes);
01616 printf("%ld tokens (out of %ld)\n",
01617 (long)(tok_ptr-tok_mem),(long)max_toks);
01618 }
01619 
01620 /*:94*/