From 79a47698484a9289c56dbfbc4a5e0e4aef4fc582 Mon Sep 17 00:00:00 2001 From: Andreas Scherer Date: Sun, 6 Jun 2021 10:49:47 +0000 Subject: [CWEB] New release 4.4. This is yet another service release for CWEB 4.0. * Upstream CWEB 4.4 has been reset to the original buffer sizes of CWEB 3.64c. These are now also used in stand-alone CWEBbin. CWEB for TeX Live uses extended/maxed-out buffer settings. * A few minor typographical bugs were fixed. * Tons of minutiae were addressed in the 'fullmanual' documents. git-svn-id: svn://tug.org/texlive/trunk@59486 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/web2c/cwebdir/ctangle.c | 322 +++++++++++++++--------------- 1 file changed, 158 insertions(+), 164 deletions(-) (limited to 'Build/source/texk/web2c/cwebdir/ctangle.c') diff --git a/Build/source/texk/web2c/cwebdir/ctangle.c b/Build/source/texk/web2c/cwebdir/ctangle.c index 26407b42ae4..14a0732742d 100644 --- a/Build/source/texk/web2c/cwebdir/ctangle.c +++ b/Build/source/texk/web2c/cwebdir/ctangle.c @@ -15,7 +15,7 @@ /*:4*/ #line 67 "ctangle.w" -#define banner "This is CTANGLE (Version 4.3)" \ +#define banner "This is CTANGLE (Version 4.4)" \ #define ctangle false #define cweave true \ @@ -51,7 +51,7 @@ #define max_include_depth 10 \ -#define max_file_name_length 1024 +#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] @@ -59,7 +59,7 @@ #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 print_id(c) term_write((c) ->byte_start,length(c) ) #define llink link #define rlink dummy.Rlink #define root name_dir->rlink \ @@ -84,18 +84,18 @@ #define new_line putchar('\n') #define term_write(a,b) fflush(stdout) ,fwrite(a,sizeof(char) ,b,stdout) \ -#define max_bytes 1000000 \ +#define buf_size 100 +#define longest_name 10000 \ -#define max_toks 1000000 -#define max_names 10239 \ +#define long_buf_size (buf_size+longest_name) +#define max_bytes 90000 \ -#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 max_names 4000 \ +#define max_sections 2000 \ + +#define max_texts 2500 +#define max_toks 270000 #define equiv equiv_or_xref \ #define macro 0 @@ -106,6 +106,7 @@ #define join 0177 #define output_defs_flag (2*024000-1) \ +#define stack_size 50 #define cur_end cur_state.end_field #define cur_byte cur_state.byte_field #define cur_name cur_state.name_field @@ -138,7 +139,11 @@ #define section_name 0311 #define new_section 0312 \ -#define app_repl(c) {if(tok_ptr==tok_mem_end) overflow("token") ;*tok_ptr++= c;} \ +#define app_repl(c) {if(tok_ptr==tok_mem_end) overflow("token") ;*(tok_ptr++) = c;} \ + +#define store_id(a) a= id_lookup(id_first,id_loc,0) -name_dir; \ +app_repl((a/0400) +0200) ; \ +app_repl(a%0400) ; \ #define keep_digit_separators flags['k'] \ @@ -257,7 +262,7 @@ sixteen_bits text_link; typedef text*text_pointer; /*:19*//*31:*/ -#line 273 "ctangle.w" +#line 274 "ctangle.w" typedef struct{ eight_bits*end_field; @@ -272,7 +277,7 @@ typedef output_state*stack_pointer; #line 70 "ctangle.w" /*20:*/ -#line 129 "ctangle.w" +#line 131 "ctangle.w" static text text_info[max_texts]; static text_pointer text_info_end= text_info+max_texts-1; @@ -282,12 +287,12 @@ static eight_bits*tok_mem_end= tok_mem+max_toks-1; static eight_bits*tok_ptr; /*:20*//*26:*/ -#line 199 "ctangle.w" +#line 200 "ctangle.w" static text_pointer last_unnamed; /*:26*//*32:*/ -#line 289 "ctangle.w" +#line 291 "ctangle.w" static output_state cur_state; @@ -296,18 +301,18 @@ static stack_pointer stack_end= stack+stack_size; static stack_pointer stack_ptr; /*:32*//*37:*/ -#line 365 "ctangle.w" +#line 367 "ctangle.w" static int cur_val; /*:37*//*42:*/ -#line 456 "ctangle.w" +#line 458 "ctangle.w" static eight_bits out_state; static boolean protect; /*:42*//*45:*/ -#line 487 "ctangle.w" +#line 489 "ctangle.w" static name_pointer output_files[max_files]; static name_pointer*cur_out_file,*end_output_files,*an_output_file; @@ -315,33 +320,33 @@ static char cur_section_name_char; static char output_file_name[longest_name+1]; /*:45*//*52:*/ -#line 584 "ctangle.w" +#line 589 "ctangle.w" static boolean output_defs_seen= false; /*:52*//*57:*/ -#line 696 "ctangle.w" +#line 701 "ctangle.w" static char translit[128][translit_length]; /*:57*//*62:*/ -#line 775 "ctangle.w" +#line 777 "ctangle.w" static eight_bits ccode[256]; /*:62*//*66:*/ -#line 835 "ctangle.w" +#line 837 "ctangle.w" static boolean comment_continues= false; /*:66*//*68:*/ -#line 872 "ctangle.w" +#line 874 "ctangle.w" static name_pointer cur_section_name; static boolean no_where; /*:68*//*82:*/ -#line 1189 "ctangle.w" +#line 1188 "ctangle.w" static text_pointer cur_text; static eight_bits next_control; @@ -384,57 +389,57 @@ extern void common_init(void); extern void print_stats(void); /*:16*//*30:*/ -#line 245 "ctangle.w" +#line 246 "ctangle.w" static void store_two_bytes(sixteen_bits); /*:30*//*35:*/ -#line 328 "ctangle.w" +#line 330 "ctangle.w" static void push_level(name_pointer); static void pop_level(boolean); /*:35*//*39:*/ -#line 401 "ctangle.w" +#line 403 "ctangle.w" static void get_output(void); /*:39*//*44:*/ -#line 477 "ctangle.w" +#line 479 "ctangle.w" static void flush_buffer(void); /*:44*//*49:*/ -#line 551 "ctangle.w" +#line 556 "ctangle.w" static void phase_two(void); /*:49*//*53:*/ -#line 587 "ctangle.w" +#line 592 "ctangle.w" static void output_defs(void); static void out_char(eight_bits); /*:53*//*65:*/ -#line 815 "ctangle.w" +#line 817 "ctangle.w" static eight_bits skip_ahead(void); static boolean skip_comment(boolean); /*:65*//*70:*/ -#line 922 "ctangle.w" +#line 924 "ctangle.w" static eight_bits get_next(void); /*:70*//*84:*/ -#line 1215 "ctangle.w" +#line 1214 "ctangle.w" static void scan_repl(eight_bits); /*:84*//*91:*/ -#line 1396 "ctangle.w" +#line 1397 "ctangle.w" static void scan_section(void); /*:91*//*99:*/ -#line 1477 "ctangle.w" +#line 1474 "ctangle.w" static void phase_one(void); /*:99*//*101:*/ -#line 1511 "ctangle.w" +#line 1507 "ctangle.w" static void skip_limbo(void); /*:101*/ @@ -451,28 +456,28 @@ char**av) argc= ac;argv= av; program= ctangle; /*21:*/ -#line 137 "ctangle.w" +#line 139 "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" +#line 149 "ctangle.w" init_node(name_dir); /*:23*//*27:*/ -#line 202 "ctangle.w" +#line 203 "ctangle.w" last_unnamed= text_info;text_info->text_link= macro; /*:27*//*46:*/ -#line 497 "ctangle.w" +#line 499 "ctangle.w" cur_out_file= end_output_files= output_files+max_files; /*:46*//*58:*/ -#line 699 "ctangle.w" +#line 704 "ctangle.w" { int i; @@ -480,7 +485,7 @@ for(i= 0;i<128;i++)sprintf(translit[i],"X%02X",(unsigned int)(128+i)); } /*:58*//*63:*/ -#line 778 "ctangle.w" +#line 780 "ctangle.w" { int c; for(c= 0;c<256;c++)ccode[c]= ignore; @@ -500,7 +505,7 @@ ccode['<']= ccode['(']= section_name; ccode['\'']= ord; /*:63*//*78:*/ -#line 1111 "ctangle.w" +#line 1112 "ctangle.w" section_text[0]= ' '; /*:78*/ @@ -514,7 +519,7 @@ return wrap_up(); } /*:2*//*24:*/ -#line 153 "ctangle.w" +#line 155 "ctangle.w" boolean names_match( name_pointer p, @@ -522,12 +527,11 @@ const char*first, size_t l, eight_bits t) {(void)t; -if(length(p)!=l)return false; -return!strncmp(first,p->byte_start,l); +return length(p)==l&&strncmp(first,p->byte_start,l)==0; } /*:24*//*25:*/ -#line 169 "ctangle.w" +#line 170 "ctangle.w" void init_node( @@ -539,7 +543,7 @@ void init_p(name_pointer p,eight_bits t){(void)p;(void)t;} /*:25*//*29:*/ -#line 235 "ctangle.w" +#line 236 "ctangle.w" static void store_two_bytes( @@ -551,7 +555,7 @@ if(tok_ptr+2> tok_mem_end)overflow("token"); } /*:29*//*34:*/ -#line 313 "ctangle.w" +#line 315 "ctangle.w" static void push_level( @@ -568,7 +572,7 @@ cur_section= 0; } /*:34*//*36:*/ -#line 336 "ctangle.w" +#line 338 "ctangle.w" static void pop_level( @@ -584,7 +588,7 @@ if(stack_ptr> stack)cur_state= *stack_ptr; } /*:36*//*38:*/ -#line 372 "ctangle.w" +#line 374 "ctangle.w" static void get_output(void) @@ -607,7 +611,7 @@ switch(a/024000){ case 0:cur_val= a;out_char(identifier);break; case 1:if(a==output_defs_flag)output_defs(); else/*40:*/ -#line 406 "ctangle.w" +#line 408 "ctangle.w" { a-= 024000; @@ -621,7 +625,7 @@ goto restart; } /*:40*/ -#line 393 "ctangle.w" +#line 395 "ctangle.w" break; default:cur_val= a-050000;if(cur_val> 0)cur_section= cur_val; @@ -631,7 +635,7 @@ out_char(section_number); } /*:38*//*43:*/ -#line 464 "ctangle.w" +#line 466 "ctangle.w" static void flush_buffer(void) @@ -646,29 +650,30 @@ cur_line++; } /*:43*//*48:*/ -#line 516 "ctangle.w" +#line 518 "ctangle.w" static void phase_two(void){ +phase= 2; web_file_open= false; cur_line= 1; /*33:*/ -#line 302 "ctangle.w" +#line 304 "ctangle.w" stack_ptr= stack+1;cur_name= name_dir;cur_repl= text_info->text_link+text_info; cur_byte= cur_repl->tok_start;cur_end= (cur_repl+1)->tok_start;cur_section= 0; /*:33*/ -#line 521 "ctangle.w" +#line 524 "ctangle.w" /*51:*/ -#line 580 "ctangle.w" +#line 585 "ctangle.w" if(!output_defs_seen) output_defs(); /*:51*/ -#line 522 "ctangle.w" +#line 525 "ctangle.w" if(text_info->text_link==macro&&cur_out_file==end_output_files){ fputs("\n! No program text was specified.",stdout);mark_harmless; @@ -676,8 +681,10 @@ fputs("\n! No program text was specified.",stdout);mark_harmless; } else{ if(cur_out_file==end_output_files){ -if(show_progress) +if(show_progress){ printf("\nWriting the output file (%s):",C_file_name); +update_terminal; +} } else{ if(show_progress){ @@ -691,7 +698,7 @@ if(text_info->text_link==macro)goto writeloop; while(stack_ptr> stack)get_output(); flush_buffer(); writeloop:/*50:*/ -#line 557 "ctangle.w" +#line 562 "ctangle.w" for(an_output_file= end_output_files;an_output_file> cur_out_file;){ an_output_file--; @@ -703,7 +710,7 @@ fatal("! Cannot open output file ",output_file_name); if(show_progress){printf("\n(%s)",output_file_name);update_terminal;} cur_line= 1; stack_ptr= stack+1; -cur_name= (*an_output_file); +cur_name= *an_output_file; cur_repl= (text_pointer)cur_name->equiv; cur_byte= cur_repl->tok_start; cur_end= (cur_repl+1)->tok_start; @@ -712,7 +719,7 @@ flush_buffer(); } /*:50*/ -#line 543 "ctangle.w" +#line 548 "ctangle.w" if(show_happiness){ if(show_progress)new_line; @@ -722,7 +729,7 @@ fputs("Done.",stdout); } /*:48*//*54:*/ -#line 594 "ctangle.w" +#line 599 "ctangle.w" static void output_defs(void) @@ -762,7 +769,7 @@ pop_level(false); } /*:54*//*55:*/ -#line 637 "ctangle.w" +#line 642 "ctangle.w" static void out_char( @@ -775,25 +782,22 @@ case'\n':if(protect&&out_state!=verbatim)C_putc(' '); if(protect||out_state==verbatim)C_putc('\\'); flush_buffer();if(out_state!=verbatim)out_state= normal;break; /*59:*/ -#line 705 "ctangle.w" +#line 710 "ctangle.w" case identifier: if(out_state==num_or_id)C_putc(' '); -j= (cur_val+name_dir)->byte_start; -k= (cur_val+name_dir+1)->byte_start; -while(jbyte_start,k= (cur_val+name_dir+1)->byte_start; +j 0)C_printf("/*%d:*/",cur_val); @@ -804,12 +808,12 @@ cur_char= '\n'; goto restart; }else{ sixteen_bits a; -a= 0400**cur_byte++; +a= *cur_byte++*0400; a+= *cur_byte++; C_printf("\n#line %d \"",a); -cur_val= *cur_byte++; -cur_val= 0400*(cur_val-0200)+*cur_byte++; +cur_val= (*cur_byte++-0200)*0400; +cur_val+= *cur_byte++; for(j= (cur_val+name_dir)->byte_start,k= (cur_val+name_dir+1)->byte_start; j');C_putc('*');out_state= normal; break; /*:56*/ -#line 650 "ctangle.w" +#line 655 "ctangle.w" case'=':case'>':C_putc(cur_char);C_putc(' '); out_state= normal;break; @@ -863,7 +867,7 @@ default:C_putc(cur_char);out_state= normal;break; } /*:55*//*64:*/ -#line 799 "ctangle.w" +#line 801 "ctangle.w" static eight_bits skip_ahead(void) @@ -881,7 +885,7 @@ if(c!=ignore||*(loc-1)=='>')return c; } /*:64*//*67:*/ -#line 838 "ctangle.w" +#line 840 "ctangle.w" static boolean skip_comment( boolean is_long_comment) @@ -915,7 +919,7 @@ else loc++; } /*:67*//*69:*/ -#line 879 "ctangle.w" +#line 881 "ctangle.w" static eight_bits get_next(void) @@ -929,9 +933,10 @@ if(get_line()==false)return new_section; else if(print_where&&!no_where){ print_where= false; /*85:*/ -#line 1221 "ctangle.w" +#line 1224 "ctangle.w" { +eight_bits a; store_two_bytes(0150000); if(changing&&include_depth==change_depth){ id_first= change_file_name; @@ -941,12 +946,11 @@ id_first= cur_file_name; store_two_bytes((sixteen_bits)cur_line); } id_loc= id_first+strlen(id_first); -{int a_l= id_lookup(id_first,id_loc,0)-name_dir;app_repl((a_l/0400)+0200); -app_repl(a_l%0400);} +store_id(a); } /*:85*/ -#line 891 "ctangle.w" +#line 893 "ctangle.w" } else return'\n'; @@ -960,7 +964,7 @@ else continue; } loc++; if(xisdigit(c)||c=='.')/*73:*/ -#line 963 "ctangle.w" +#line 965 "ctangle.w" { boolean hex_flag= false; id_first= loc-1; @@ -994,13 +998,13 @@ return constant; } /*:73*/ -#line 903 "ctangle.w" +#line 905 "ctangle.w" else if(c=='\''||c=='"' ||((c=='L'||c=='u'||c=='U')&&(*loc=='\''||*loc=='"')) ||((c=='u'&&*loc=='8')&&(*(loc+1)=='\''||*(loc+1)=='"'))) /*74:*/ -#line 1000 "ctangle.w" +#line 1002 "ctangle.w" { char delim= c; id_first= section_text+1; @@ -1044,11 +1048,11 @@ return string; } /*:74*/ -#line 907 "ctangle.w" +#line 909 "ctangle.w" else if(isalpha(c)||isxalpha(c)||ishigh(c)) /*72:*/ -#line 954 "ctangle.w" +#line 956 "ctangle.w" { id_first= --loc; do @@ -1059,11 +1063,11 @@ id_loc= loc;return identifier; } /*:72*/ -#line 909 "ctangle.w" +#line 911 "ctangle.w" else if(c=='@')/*75:*/ -#line 1045 "ctangle.w" -{ +#line 1047 "ctangle.w" + switch(c= ccode[(eight_bits)*loc++]){ case ignore:continue; case translit_code:err_print("! Use @l in limbo only");continue; @@ -1077,13 +1081,12 @@ continue; case section_name: cur_section_name_char= *(loc-1); /*77:*/ -#line 1091 "ctangle.w" +#line 1092 "ctangle.w" { -char*k; +char*k= section_text; /*79:*/ -#line 1113 "ctangle.w" +#line 1114 "ctangle.w" -k= section_text; while(true){ if(loc> limit&&get_line()==false){ err_print("! Input ended in section name"); @@ -1128,7 +1131,7 @@ printf("...");mark_harmless; if(*k==' '&&k> section_text)k--; /*:79*/ -#line 1093 "ctangle.w" +#line 1094 "ctangle.w" if(k-section_text> 3&&strncmp(k-2,"...",3)==0) cur_section_name= section_lookup(section_text+1,k-3,true); @@ -1137,7 +1140,7 @@ else cur_section_name= section_lookup(section_text+1,k,false); if(cur_section_name_char=='(') /*47:*/ -#line 501 "ctangle.w" +#line 503 "ctangle.w" { for(an_output_file= cur_out_file; @@ -1151,30 +1154,29 @@ else overflow("output files"); } /*:47*/ -#line 1101 "ctangle.w" +#line 1102 "ctangle.w" return section_name; } /*:77*/ -#line 1058 "ctangle.w" +#line 1060 "ctangle.w" case string:/*81:*/ #line 1159 "ctangle.w" -{ + id_first= loc++;*(limit+1)= '@';*(limit+2)= '>'; while(*loc!='@'||*(loc+1)!='>')loc++; if(loc>=limit)err_print("! Verbatim string didn't end"); id_loc= loc;loc+= 2; return string; -} /*:81*/ -#line 1059 "ctangle.w" +#line 1061 "ctangle.w" case ord:/*76:*/ -#line 1071 "ctangle.w" +#line 1072 "ctangle.w" id_first= loc; if(*loc=='\\') @@ -1196,14 +1198,13 @@ loc++; return ord; /*:76*/ -#line 1060 "ctangle.w" +#line 1062 "ctangle.w" default:return c; } -} /*:75*/ -#line 910 "ctangle.w" +#line 912 "ctangle.w" else if(xisspace(c)){ if(!preprocessing||loc> limit)continue; @@ -1212,7 +1213,7 @@ else return' '; } else if(c=='#'&&loc==buffer+1)preprocessing= true; mistake:/*71:*/ -#line 931 "ctangle.w" +#line 933 "ctangle.w" switch(c){ case'+':if(*loc=='+')compress(plus_plus);break; @@ -1237,14 +1238,14 @@ case'!':if(*loc=='=')compress(non_eq);break; } /*:71*/ -#line 917 "ctangle.w" +#line 919 "ctangle.w" return c; } } /*:69*//*83:*/ -#line 1193 "ctangle.w" +#line 1192 "ctangle.w" static void scan_repl( @@ -1252,9 +1253,10 @@ eight_bits t) { sixteen_bits a; if(t==section_name)/*85:*/ -#line 1221 "ctangle.w" +#line 1224 "ctangle.w" { +eight_bits a; store_two_bytes(0150000); if(changing&&include_depth==change_depth){ id_first= change_file_name; @@ -1264,24 +1266,21 @@ id_first= cur_file_name; store_two_bytes((sixteen_bits)cur_line); } id_loc= id_first+strlen(id_first); -{int a_l= id_lookup(id_first,id_loc,0)-name_dir;app_repl((a_l/0400)+0200); -app_repl(a_l%0400);} +store_id(a); } /*:85*/ -#line 1199 "ctangle.w" +#line 1198 "ctangle.w" while(true)switch(a= get_next()){ /*86:*/ -#line 1236 "ctangle.w" +#line 1239 "ctangle.w" -case identifier:a= id_lookup(id_first,id_loc,0)-name_dir; -app_repl((a/0400)+0200); -app_repl(a%0400);break; +case identifier:store_id(a);break; case section_name:if(t!=section_name)goto done; else{ /*87:*/ -#line 1269 "ctangle.w" +#line 1270 "ctangle.w" { char*try_loc= loc; while(*try_loc==' '&&try_loctok_start= tok_ptr; } /*:83*//*90:*/ -#line 1363 "ctangle.w" +#line 1364 "ctangle.w" static void scan_section(void) @@ -1460,7 +1459,7 @@ printf("*%d",section_count);update_terminal; next_control= ignore; while(true){ /*92:*/ -#line 1404 "ctangle.w" +#line 1405 "ctangle.w" while(next_controltext_link= macro; -} /*:93*/ -#line 1379 "ctangle.w" +#line 1380 "ctangle.w" continue; } @@ -1502,14 +1498,14 @@ p= name_dir;break; if(next_control==section_name){ p= cur_section_name; /*94:*/ -#line 1436 "ctangle.w" +#line 1434 "ctangle.w" while((next_control= get_next())=='+'); if(next_control!='='&&next_control!=eq_eq) continue; /*:94*/ -#line 1387 "ctangle.w" +#line 1388 "ctangle.w" break; } @@ -1517,23 +1513,23 @@ return; } no_where= print_where= false; /*95:*/ -#line 1441 "ctangle.w" +#line 1439 "ctangle.w" /*96:*/ -#line 1446 "ctangle.w" +#line 1444 "ctangle.w" store_two_bytes((sixteen_bits)(0150000+section_count)); /*:96*/ -#line 1442 "ctangle.w" +#line 1440 "ctangle.w" scan_repl(section_name); /*97:*/ -#line 1450 "ctangle.w" +#line 1448 "ctangle.w" if(p==name_dir||p==NULL){ -(last_unnamed)->text_link= cur_text-text_info;last_unnamed= cur_text; +last_unnamed->text_link= cur_text-text_info;last_unnamed= cur_text; } else if(p->equiv==(void*)text_info)p->equiv= (void*)cur_text; @@ -1547,16 +1543,16 @@ cur_text->text_link= section_flag; /*:97*/ -#line 1444 "ctangle.w" +#line 1442 "ctangle.w" /*:95*/ -#line 1393 "ctangle.w" +#line 1394 "ctangle.w" } /*:90*//*98:*/ -#line 1465 "ctangle.w" +#line 1463 "ctangle.w" static void phase_one(void){ @@ -1566,26 +1562,24 @@ reset_input(); skip_limbo(); while(!input_has_ended)scan_section(); check_complete(); -phase= 2; } /*:98*//*100:*/ -#line 1482 "ctangle.w" +#line 1479 "ctangle.w" static void skip_limbo(void) { -char c; while(true){ if(loc> limit&&get_line()==false)return; *(limit+1)= '@'; while(*loc!='@')loc++; if(loc++<=limit){ -c= *loc++; +char c= *loc++; if(ccode[(eight_bits)c]==new_section)break; switch(ccode[(eight_bits)c]){ case translit_code:/*102:*/ -#line 1513 "ctangle.w" +#line 1509 "ctangle.w" while(xisspace(*loc)&&loc