From 5f6231423ff11a042181be707faa0db6012b8e35 Mon Sep 17 00:00:00 2001 From: Andreas Scherer Date: Wed, 24 Feb 2021 18:19:47 +0000 Subject: [CWEB] Code review. Compactify single function declarations. git-svn-id: svn://tug.org/texlive/trunk@57874 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/web2c/cwebdir/ctangle.c | 285 +++++++++++++++--------------- 1 file changed, 138 insertions(+), 147 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 769dc071f7c..aead827388e 100644 --- a/Build/source/texk/web2c/cwebdir/ctangle.c +++ b/Build/source/texk/web2c/cwebdir/ctangle.c @@ -257,7 +257,7 @@ sixteen_bits text_link; typedef text*text_pointer; /*:19*//*31:*/ -#line 270 "ctangle.w" +#line 269 "ctangle.w" typedef struct{ eight_bits*end_field; @@ -287,7 +287,7 @@ static eight_bits*tok_ptr; static text_pointer last_unnamed; /*:26*//*32:*/ -#line 286 "ctangle.w" +#line 285 "ctangle.w" static output_state cur_state; @@ -296,18 +296,18 @@ static stack_pointer stack_end= stack+stack_size; static stack_pointer stack_ptr; /*:32*//*37:*/ -#line 362 "ctangle.w" +#line 361 "ctangle.w" static int cur_val; /*:37*//*42:*/ -#line 454 "ctangle.w" +#line 452 "ctangle.w" static eight_bits out_state; static boolean protect; /*:42*//*45:*/ -#line 486 "ctangle.w" +#line 483 "ctangle.w" static name_pointer output_files[max_files]; static name_pointer*cur_out_file,*end_output_files,*an_output_file; @@ -315,33 +315,33 @@ static char cur_section_name_char; static char output_file_name[longest_name+1]; /*:45*//*52:*/ -#line 586 "ctangle.w" +#line 582 "ctangle.w" static boolean output_defs_seen= false; /*:52*//*57:*/ -#line 695 "ctangle.w" +#line 691 "ctangle.w" static char translit[128][translit_length]; /*:57*//*62:*/ -#line 774 "ctangle.w" +#line 770 "ctangle.w" static eight_bits ccode[256]; /*:62*//*66:*/ -#line 834 "ctangle.w" +#line 830 "ctangle.w" static boolean comment_continues= false; /*:66*//*68:*/ -#line 873 "ctangle.w" +#line 869 "ctangle.w" static name_pointer cur_section_name; static boolean no_where; /*:68*//*82:*/ -#line 1187 "ctangle.w" +#line 1182 "ctangle.w" static text_pointer cur_text; static eight_bits next_control; @@ -383,70 +383,61 @@ extern void overflow(const char*); extern void common_init(void); extern void print_stats(void); -/*:16*//*29:*/ -#line 231 "ctangle.w" - +/*:16*//*30:*/ +#line 241 "ctangle.w" static void store_two_bytes(sixteen_bits); -/*:29*//*34:*/ -#line 310 "ctangle.w" +/*:30*//*35:*/ +#line 324 "ctangle.w" static void push_level(name_pointer); static void pop_level(boolean); -/*:34*//*38:*/ -#line 369 "ctangle.w" - +/*:35*//*39:*/ +#line 397 "ctangle.w" static void get_output(void); -/*:38*//*43:*/ -#line 462 "ctangle.w" - +/*:39*//*44:*/ +#line 473 "ctangle.w" static void flush_buffer(void); -/*:43*//*48:*/ -#line 517 "ctangle.w" - +/*:44*//*49:*/ +#line 549 "ctangle.w" static void phase_two(void); -/*:48*//*53:*/ -#line 589 "ctangle.w" +/*:49*//*53:*/ +#line 585 "ctangle.w" static void output_defs(void); static void out_char(eight_bits); -/*:53*//*64:*/ -#line 798 "ctangle.w" +/*:53*//*65:*/ +#line 810 "ctangle.w" static eight_bits skip_ahead(void); static boolean skip_comment(boolean); -/*:64*//*69:*/ -#line 885 "ctangle.w" - +/*:65*//*70:*/ +#line 924 "ctangle.w" static eight_bits get_next(void); -/*:69*//*83:*/ -#line 1191 "ctangle.w" - +/*:70*//*84:*/ +#line 1208 "ctangle.w" static void scan_repl(eight_bits); -/*:83*//*90:*/ -#line 1348 "ctangle.w" - +/*:84*//*91:*/ +#line 1379 "ctangle.w" static void scan_section(void); -/*:90*//*98:*/ -#line 1455 "ctangle.w" - +/*:91*//*99:*/ +#line 1460 "ctangle.w" static void phase_one(void); -/*:98*//*100:*/ -#line 1473 "ctangle.w" - +/*:99*//*101:*/ +#line 1494 "ctangle.w" static void skip_limbo(void); -/*:100*/ +/*:101*/ #line 72 "ctangle.w" @@ -476,12 +467,12 @@ init_node(name_dir); last_unnamed= text_info;text_info->text_link= 0; /*:27*//*46:*/ -#line 496 "ctangle.w" +#line 493 "ctangle.w" cur_out_file= end_output_files= output_files+max_files; /*:46*//*58:*/ -#line 698 "ctangle.w" +#line 694 "ctangle.w" { int i; @@ -489,7 +480,7 @@ for(i= 0;i<128;i++)sprintf(translit[i],"X%02X",(unsigned int)(128+i)); } /*:58*//*63:*/ -#line 777 "ctangle.w" +#line 773 "ctangle.w" { int c; for(c= 0;c<256;c++)ccode[c]= ignore; @@ -509,7 +500,7 @@ ccode['\'']= ord; } /*:63*//*78:*/ -#line 1108 "ctangle.w" +#line 1103 "ctangle.w" section_text[0]= ' '; /*:78*/ @@ -547,10 +538,10 @@ node->equiv= (void*)text_info; void init_p(name_pointer p,eight_bits t){(void)p;(void)t;} -/*:25*//*30:*/ -#line 234 "ctangle.w" +/*:25*//*29:*/ +#line 231 "ctangle.w" -void +static void store_two_bytes( sixteen_bits x) { @@ -559,8 +550,8 @@ if(tok_ptr+2> tok_mem_end)overflow("token"); *tok_ptr++= x&0377; } -/*:30*//*35:*/ -#line 314 "ctangle.w" +/*:29*//*34:*/ +#line 309 "ctangle.w" static void push_level( @@ -576,8 +567,8 @@ cur_section= 0; } } -/*:35*//*36:*/ -#line 333 "ctangle.w" +/*:34*//*36:*/ +#line 332 "ctangle.w" static void pop_level( @@ -592,8 +583,8 @@ stack_ptr--; if(stack_ptr> stack)cur_state= *stack_ptr; } -/*:36*//*39:*/ -#line 372 "ctangle.w" +/*:36*//*38:*/ +#line 368 "ctangle.w" static void get_output(void) @@ -616,7 +607,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 404 "ctangle.w" +#line 402 "ctangle.w" { a-= 024000; @@ -630,7 +621,7 @@ goto restart; } /*:40*/ -#line 393 "ctangle.w" +#line 389 "ctangle.w" break; default:cur_val= a-050000;if(cur_val> 0)cur_section= cur_val; @@ -639,8 +630,8 @@ out_char(section_number); } } -/*:39*//*44:*/ -#line 465 "ctangle.w" +/*:38*//*43:*/ +#line 460 "ctangle.w" static void flush_buffer(void) @@ -654,30 +645,30 @@ update_terminal; cur_line++; } -/*:44*//*49:*/ -#line 520 "ctangle.w" +/*:43*//*48:*/ +#line 514 "ctangle.w" static void phase_two(void){ web_file_open= false; cur_line= 1; /*33:*/ -#line 299 "ctangle.w" +#line 298 "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 525 "ctangle.w" +#line 519 "ctangle.w" /*51:*/ -#line 582 "ctangle.w" +#line 578 "ctangle.w" if(!output_defs_seen) output_defs(); /*:51*/ -#line 526 "ctangle.w" +#line 520 "ctangle.w" if(text_info->text_link==0&&cur_out_file==end_output_files){ fputs("\n! No program text was specified.",stdout);mark_harmless; @@ -700,7 +691,7 @@ if(text_info->text_link==0)goto writeloop; while(stack_ptr> stack)get_output(); flush_buffer(); writeloop:/*50:*/ -#line 559 "ctangle.w" +#line 555 "ctangle.w" for(an_output_file= end_output_files;an_output_file> cur_out_file;){ an_output_file--; @@ -721,7 +712,7 @@ flush_buffer(); } /*:50*/ -#line 547 "ctangle.w" +#line 541 "ctangle.w" if(show_happiness){ if(show_progress)new_line; @@ -730,8 +721,8 @@ fputs("Done.",stdout); } } -/*:49*//*54:*/ -#line 593 "ctangle.w" +/*:48*//*54:*/ +#line 589 "ctangle.w" static void output_defs(void) @@ -771,7 +762,7 @@ pop_level(false); } /*:54*//*55:*/ -#line 636 "ctangle.w" +#line 632 "ctangle.w" static void out_char( @@ -784,7 +775,7 @@ 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 704 "ctangle.w" +#line 700 "ctangle.w" case identifier: if(out_state==num_or_id)C_putc(' '); @@ -799,10 +790,10 @@ j++; out_state= num_or_id;break; /*:59*/ -#line 647 "ctangle.w" +#line 643 "ctangle.w" /*60:*/ -#line 717 "ctangle.w" +#line 713 "ctangle.w" case section_number: if(cur_val> 0)C_printf("/*%d:*/",cur_val); @@ -829,10 +820,10 @@ C_printf("%s","\"\n"); break; /*:60*/ -#line 648 "ctangle.w" +#line 644 "ctangle.w" /*56:*/ -#line 666 "ctangle.w" +#line 662 "ctangle.w" case plus_plus:C_putc('+');C_putc('+');out_state= normal;break; case minus_minus:C_putc('-');C_putc('-');out_state= normal;break; @@ -853,7 +844,7 @@ case minus_gt_ast:C_putc('-');C_putc('>');C_putc('*');out_state= normal; break; /*:56*/ -#line 649 "ctangle.w" +#line 645 "ctangle.w" case'=':case'>':C_putc(cur_char);C_putc(' '); out_state= normal;break; @@ -871,8 +862,8 @@ default:C_putc(cur_char);out_state= normal;break; } } -/*:55*//*65:*/ -#line 802 "ctangle.w" +/*:55*//*64:*/ +#line 794 "ctangle.w" static eight_bits skip_ahead(void) @@ -889,8 +880,8 @@ if(c!=ignore||*(loc-1)=='>')return c; } } -/*:65*//*67:*/ -#line 837 "ctangle.w" +/*:64*//*67:*/ +#line 833 "ctangle.w" static boolean skip_comment( boolean is_long_comment) @@ -923,8 +914,8 @@ else loc++; } } -/*:67*//*70:*/ -#line 888 "ctangle.w" +/*:67*//*69:*/ +#line 881 "ctangle.w" static eight_bits get_next(void) @@ -938,7 +929,7 @@ if(get_line()==false)return new_section; else if(print_where&&!no_where){ print_where= false; /*85:*/ -#line 1220 "ctangle.w" +#line 1214 "ctangle.w" store_two_bytes(0150000); if(changing&&include_depth==change_depth){ @@ -953,7 +944,7 @@ id_loc= id_first+strlen(id_first); app_repl(a_l%0400);} /*:85*/ -#line 900 "ctangle.w" +#line 893 "ctangle.w" } else return'\n'; @@ -967,7 +958,7 @@ else continue; } loc++; if(xisdigit(c)||c=='.')/*73:*/ -#line 969 "ctangle.w" +#line 964 "ctangle.w" { id_first= loc-1; if(*id_first=='.'&&!xisdigit(*loc))goto mistake; @@ -992,13 +983,13 @@ return constant; } /*:73*/ -#line 912 "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 997 "ctangle.w" +#line 992 "ctangle.w" { char delim= c; id_first= section_text+1; @@ -1042,11 +1033,11 @@ return string; } /*:74*/ -#line 916 "ctangle.w" +#line 909 "ctangle.w" else if(isalpha(c)||isxalpha(c)||ishigh(c)) /*72:*/ -#line 962 "ctangle.w" +#line 957 "ctangle.w" { id_first= --loc; while(isalpha((eight_bits)*++loc)||isdigit((eight_bits)*loc) @@ -1055,10 +1046,10 @@ id_loc= loc;return identifier; } /*:72*/ -#line 918 "ctangle.w" +#line 911 "ctangle.w" else if(c=='@')/*75:*/ -#line 1042 "ctangle.w" +#line 1037 "ctangle.w" { c= ccode[(eight_bits)*loc++]; switch(c){ @@ -1074,11 +1065,11 @@ continue; case section_name: cur_section_name_char= *(loc-1); /*77:*/ -#line 1090 "ctangle.w" +#line 1085 "ctangle.w" { char*k; /*79:*/ -#line 1110 "ctangle.w" +#line 1105 "ctangle.w" k= section_text; while(true){ @@ -1089,7 +1080,7 @@ loc= buffer+1;break; } c= *loc; /*80:*/ -#line 1134 "ctangle.w" +#line 1129 "ctangle.w" if(c=='@'){ c= *(loc+1); @@ -1108,7 +1099,7 @@ err_print("! Nesting of section names not allowed");break; } /*:80*/ -#line 1119 "ctangle.w" +#line 1114 "ctangle.w" loc++;if(k section_text)k--; /*:79*/ -#line 1092 "ctangle.w" +#line 1087 "ctangle.w" if(k-section_text> 3&&strncmp(k-2,"...",3)==0) cur_section_name= section_lookup(section_text+1,k-3,1); else cur_section_name= section_lookup(section_text+1,k,0); if(cur_section_name_char=='(') /*47:*/ -#line 500 "ctangle.w" +#line 497 "ctangle.w" { for(an_output_file= cur_out_file; @@ -1148,16 +1139,16 @@ overflow("output files"); } /*:47*/ -#line 1098 "ctangle.w" +#line 1093 "ctangle.w" return section_name; } /*:77*/ -#line 1056 "ctangle.w" +#line 1051 "ctangle.w" case string:/*81:*/ -#line 1156 "ctangle.w" +#line 1151 "ctangle.w" { id_first= loc++;*(limit+1)= '@';*(limit+2)= '>'; while(*loc!='@'||*(loc+1)!='>')loc++; @@ -1168,10 +1159,10 @@ return string; } /*:81*/ -#line 1057 "ctangle.w" +#line 1052 "ctangle.w" case ord:/*76:*/ -#line 1069 "ctangle.w" +#line 1064 "ctangle.w" id_first= loc; if(*loc=='\\'){ @@ -1194,14 +1185,14 @@ loc++; return ord; /*:76*/ -#line 1058 "ctangle.w" +#line 1053 "ctangle.w" default:return c; } } /*:75*/ -#line 919 "ctangle.w" +#line 912 "ctangle.w" else if(xisspace(c)){ if(!preprocessing||loc> limit)continue; @@ -1210,7 +1201,7 @@ else return' '; } else if(c=='#'&&loc==buffer+1)preprocessing= 1; mistake:/*71:*/ -#line 940 "ctangle.w" +#line 935 "ctangle.w" switch(c){ case'+':if(*loc=='+')compress(plus_plus);break; @@ -1234,14 +1225,14 @@ case'!':if(*loc=='=')compress(non_eq);break; } /*:71*/ -#line 926 "ctangle.w" +#line 919 "ctangle.w" return c; } } -/*:70*//*84:*/ -#line 1194 "ctangle.w" +/*:69*//*83:*/ +#line 1186 "ctangle.w" static void scan_repl( @@ -1249,7 +1240,7 @@ eight_bits t) { sixteen_bits a; if(t==section_name){/*85:*/ -#line 1220 "ctangle.w" +#line 1214 "ctangle.w" store_two_bytes(0150000); if(changing&&include_depth==change_depth){ @@ -1264,11 +1255,11 @@ id_loc= id_first+strlen(id_first); app_repl(a_l%0400);} /*:85*/ -#line 1200 "ctangle.w" +#line 1192 "ctangle.w" } while(true)switch(a= get_next()){ /*86:*/ -#line 1233 "ctangle.w" +#line 1227 "ctangle.w" case identifier:a= id_lookup(id_first,id_loc,0)-name_dir; app_repl((a/0400)+0200); @@ -1276,7 +1267,7 @@ app_repl(a%0400);break; case section_name:if(t!=section_name)goto done; else{ /*87:*/ -#line 1266 "ctangle.w" +#line 1260 "ctangle.w" { char*try_loc= loc; while(*try_loc==' '&&try_loc text_info_end)overflow("text"); cur_text= text_ptr;(++text_ptr)->tok_start= tok_ptr; } -/*:84*//*91:*/ -#line 1355 "ctangle.w" +/*:83*//*90:*/ +#line 1346 "ctangle.w" static void scan_section(void) @@ -1449,7 +1440,7 @@ printf("*%d",section_count);update_terminal; next_control= 0; while(true){ /*92:*/ -#line 1394 "ctangle.w" +#line 1387 "ctangle.w" while(next_controltext_link= macro; } /*:93*/ -#line 1371 "ctangle.w" +#line 1362 "ctangle.w" continue; } @@ -1491,14 +1482,14 @@ p= name_dir;break; if(next_control==section_name){ p= cur_section_name; /*94:*/ -#line 1426 "ctangle.w" +#line 1419 "ctangle.w" while((next_control= get_next())=='+'); if(next_control!='='&&next_control!=eq_eq) continue; /*:94*/ -#line 1379 "ctangle.w" +#line 1370 "ctangle.w" break; } @@ -1506,20 +1497,20 @@ return; } no_where= print_where= false; /*95:*/ -#line 1431 "ctangle.w" +#line 1424 "ctangle.w" /*96:*/ -#line 1436 "ctangle.w" +#line 1429 "ctangle.w" store_two_bytes((sixteen_bits)(0150000+section_count)); /*:96*/ -#line 1432 "ctangle.w" +#line 1425 "ctangle.w" scan_repl(section_name); /*97:*/ -#line 1440 "ctangle.w" +#line 1433 "ctangle.w" if(p==name_dir||p==0){ (last_unnamed)->text_link= cur_text-text_info;last_unnamed= cur_text; @@ -1536,16 +1527,16 @@ cur_text->text_link= section_flag; /*:97*/ -#line 1434 "ctangle.w" +#line 1427 "ctangle.w" /*:95*/ -#line 1385 "ctangle.w" +#line 1376 "ctangle.w" } -/*:91*//*99:*/ -#line 1458 "ctangle.w" +/*:90*//*98:*/ +#line 1448 "ctangle.w" static void phase_one(void){ @@ -1558,8 +1549,8 @@ check_complete(); phase= 2; } -/*:99*//*101:*/ -#line 1476 "ctangle.w" +/*:98*//*100:*/ +#line 1465 "ctangle.w" static void skip_limbo(void) @@ -1574,7 +1565,7 @@ c= *loc++; if(ccode[(eight_bits)c]==new_section)break; switch(ccode[(eight_bits)c]){ case translit_code:/*102:*/ -#line 1505 "ctangle.w" +#line 1496 "ctangle.w" while(xisspace(*loc)&&loc