From a08701547a59868dd82bab32735f7c56d2636370 Mon Sep 17 00:00:00 2001 From: Andreas Scherer Date: Fri, 18 Feb 2022 15:05:01 +0000 Subject: [CWEB] Avoid preprocessor calamities. Trying to fix all loopholes in weird stuff like https://github.com/ascherer/cweb/blob/cweb-4.8-dev/if.w by repeating '#line' directives after all '#elif', '#else', and '#endif' preprocessor statements. In almost all cases this information is redundant, but in the past years people have come up with the idea to jump to '@' in '#if' blocks. git-svn-id: svn://tug.org/texlive/trunk@62066 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/web2c/ctangleboot.cin | 117 ++++++++++++++------------------ 1 file changed, 51 insertions(+), 66 deletions(-) (limited to 'Build/source/texk/web2c/ctangleboot.cin') diff --git a/Build/source/texk/web2c/ctangleboot.cin b/Build/source/texk/web2c/ctangleboot.cin index 45e0de89ab6..83b438ce35f 100644 --- a/Build/source/texk/web2c/ctangleboot.cin +++ b/Build/source/texk/web2c/ctangleboot.cin @@ -15,16 +15,15 @@ #ifndef HAVE_GETTEXT #define HAVE_GETTEXT 0 #endif -#line 65 "cwebdir/comm-w2c.h" - +#line 66 "cwebdir/comm-w2c.h" #if HAVE_GETTEXT #include #else +#line 70 "cwebdir/comm-w2c.h" #define gettext(a) a #endif -#line 71 "cwebdir/comm-w2c.h" - +#line 72 "cwebdir/comm-w2c.h" /*:4*/ #line 67 "cwebdir/ctangle.w" @@ -463,15 +462,15 @@ static eight_bits get_next(void); static void scan_repl(eight_bits); /*:84*//*91:*/ -#line 1408 "cwebdir/ctangle.w" +#line 1413 "cwebdir/ctangle.w" static void scan_section(void); /*:91*//*99:*/ -#line 1485 "cwebdir/ctangle.w" +#line 1490 "cwebdir/ctangle.w" static void phase_one(void); /*:99*//*101:*/ -#line 1518 "cwebdir/ctangle.w" +#line 1523 "cwebdir/ctangle.w" static void skip_limbo(void); /*:101*/ @@ -1600,33 +1599,19 @@ while(true)switch(a= get_next()){ #line 1244 "cwebdir/ctangle.w" case identifier:store_id(a); -if(*buffer=='#'&&id_first==buffer+1&&id_loc-id_first==5 -&&strncmp("endif",id_first,5)==0) -/*85:*/ -#line 1229 "cwebdir/ctangle.w" - -{ -eight_bits a; -store_two_bytes(0150000); -if(changing&&include_depth==change_depth){ -id_first= change_file_name; -store_two_bytes((sixteen_bits)change_line); -}else{ -id_first= cur_file_name; -store_two_bytes((sixteen_bits)cur_line); -} -id_loc= id_first+strlen(id_first); -store_id(a); -} - -/*:85*/ -#line 1248 "cwebdir/ctangle.w" - +if(*buffer=='#'&&( +(id_first==buffer+1&&id_loc-id_first==5 +&&strncmp("endif",id_first,5)==0)|| +(id_first==buffer+1&&id_loc-id_first==4 +&&strncmp("else",id_first,4)==0)|| +(id_first==buffer+1&&id_loc-id_first==4 +&&strncmp("elif",id_first,4)==0))) +print_where= true; break; case section_name:if(t!=section_name)goto done; else{ /*87:*/ -#line 1282 "cwebdir/ctangle.w" +#line 1287 "cwebdir/ctangle.w" { char*try_loc= loc; while(*try_loc==' '&&try_loctok_start= tok_ptr; } /*:83*//*90:*/ -#line 1375 "cwebdir/ctangle.w" +#line 1380 "cwebdir/ctangle.w" static void scan_section(void) @@ -1819,7 +1804,7 @@ printf("*%d",(int)section_count);update_terminal; next_control= ignore; while(true){ /*92:*/ -#line 1416 "cwebdir/ctangle.w" +#line 1421 "cwebdir/ctangle.w" while(next_controltext_link= macro; /*:93*/ -#line 1391 "cwebdir/ctangle.w" +#line 1396 "cwebdir/ctangle.w" continue; } @@ -1860,14 +1845,14 @@ p= name_dir;break; if(next_control==section_name){ p= cur_section_name; /*94:*/ -#line 1445 "cwebdir/ctangle.w" +#line 1450 "cwebdir/ctangle.w" while((next_control= get_next())=='+'); if(next_control!='='&&next_control!=eq_eq) continue; /*:94*/ -#line 1399 "cwebdir/ctangle.w" +#line 1404 "cwebdir/ctangle.w" break; } @@ -1875,20 +1860,20 @@ return; } no_where= print_where= false; /*95:*/ -#line 1450 "cwebdir/ctangle.w" +#line 1455 "cwebdir/ctangle.w" /*96:*/ -#line 1455 "cwebdir/ctangle.w" +#line 1460 "cwebdir/ctangle.w" store_two_bytes((sixteen_bits)(0150000+section_count)); /*:96*/ -#line 1451 "cwebdir/ctangle.w" +#line 1456 "cwebdir/ctangle.w" scan_repl(section_name); /*97:*/ -#line 1459 "cwebdir/ctangle.w" +#line 1464 "cwebdir/ctangle.w" if(p==name_dir||p==NULL){ last_unnamed->text_link= cur_text-text_info;last_unnamed= cur_text; @@ -1905,16 +1890,16 @@ cur_text->text_link= section_flag; /*:97*/ -#line 1453 "cwebdir/ctangle.w" +#line 1458 "cwebdir/ctangle.w" /*:95*/ -#line 1405 "cwebdir/ctangle.w" +#line 1410 "cwebdir/ctangle.w" } /*:90*//*98:*/ -#line 1474 "cwebdir/ctangle.w" +#line 1479 "cwebdir/ctangle.w" static void phase_one(void){ @@ -1927,7 +1912,7 @@ check_complete(); } /*:98*//*100:*/ -#line 1490 "cwebdir/ctangle.w" +#line 1495 "cwebdir/ctangle.w" static void skip_limbo(void) @@ -1941,7 +1926,7 @@ char c= *loc++; switch(ccode[(eight_bits)c]){ case new_section:return; case translit_code:/*102:*/ -#line 1520 "cwebdir/ctangle.w" +#line 1525 "cwebdir/ctangle.w" while(xisspace(*loc)&&loc limit||!xisxdigit(*(loc-3))||!xisxdigit(*(loc-2)) ||(*(loc-3)>='0'&&*(loc-3)<='7')||!xisspace(*(loc-1))) #line 330 "cwebdir/ctang-w2c.ch" err_print(_("! Improper hex number following @l")); -#line 1526 "cwebdir/ctangle.w" +#line 1531 "cwebdir/ctangle.w" else{ unsigned int i; @@ -1961,7 +1946,7 @@ while(loc=translit_length) #line 336 "cwebdir/ctang-w2c.ch" err_print(_("! Replacement string in @l too long")); -#line 1536 "cwebdir/ctangle.w" +#line 1541 "cwebdir/ctangle.w" else{ strncpy(translit[i-0200],beg,(size_t)(loc-beg)); @@ -1970,7 +1955,7 @@ translit[i-0200][loc-beg]= '\0'; } /*:102*/ -#line 1502 "cwebdir/ctangle.w" +#line 1507 "cwebdir/ctangle.w" break; case format_code:case'@':break; case control_text:if(c=='q'||c=='Q'){ @@ -1978,13 +1963,13 @@ while((c= (char)skip_ahead())=='@'); if(*(loc-1)!='>') #line 318 "cwebdir/ctang-w2c.ch" err_print(_("! Double @ should be used in control text")); -#line 1508 "cwebdir/ctangle.w" +#line 1513 "cwebdir/ctangle.w" break; } #line 324 "cwebdir/ctang-w2c.ch" default:err_print(_("! Double @ should be used in limbo")); -#line 1512 "cwebdir/ctangle.w" +#line 1517 "cwebdir/ctangle.w" } } @@ -1992,7 +1977,7 @@ default:err_print(_("! Double @ should be used in limbo")); } /*:100*//*103:*/ -#line 1546 "cwebdir/ctangle.w" +#line 1551 "cwebdir/ctangle.w" void print_stats(void){ @@ -2005,7 +1990,7 @@ printf(_("%td replacement texts (out of %ld)\n"), printf(_("%td bytes (out of %ld)\n"), (ptrdiff_t)(byte_ptr-byte_mem),(long)max_bytes); printf(_("%td tokens (out of %ld)\n"), -#line 1557 "cwebdir/ctangle.w" +#line 1562 "cwebdir/ctangle.w" (ptrdiff_t)(tok_ptr-tok_mem),(long)max_toks); } -- cgit v1.2.3