summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/cwebdir
diff options
context:
space:
mode:
authorAndreas Scherer <andreas_tex@freenet.de>2022-02-18 15:05:01 +0000
committerAndreas Scherer <andreas_tex@freenet.de>2022-02-18 15:05:01 +0000
commita08701547a59868dd82bab32735f7c56d2636370 (patch)
tree62fb36019157e66b07ebe7c4bf9f953811911cf6 /Build/source/texk/web2c/cwebdir
parent316ad31f72ca37c485f1261b13d3fee400359163 (diff)
[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 '@<code sections@>' in '#if' blocks. git-svn-id: svn://tug.org/texlive/trunk@62066 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/web2c/cwebdir')
-rw-r--r--Build/source/texk/web2c/cwebdir/ChangeLog6
-rw-r--r--Build/source/texk/web2c/cwebdir/common.c8
-rw-r--r--Build/source/texk/web2c/cwebdir/ctangle.c88
-rw-r--r--Build/source/texk/web2c/cwebdir/ctangle.w11
4 files changed, 55 insertions, 58 deletions
diff --git a/Build/source/texk/web2c/cwebdir/ChangeLog b/Build/source/texk/web2c/cwebdir/ChangeLog
index 1c76d57ed44..c370c7d0621 100644
--- a/Build/source/texk/web2c/cwebdir/ChangeLog
+++ b/Build/source/texk/web2c/cwebdir/ChangeLog
@@ -1,3 +1,9 @@
+2022-02-18 Andreas Scherer <https://ascherer.github.io>
+
+ * common.c,
+ * ctangle.c,
+ * ctangle.w: Add '#line' after '#elif', '#else', and '#endif'.
+
2022-02-14 Andreas Scherer <https://ascherer.github.io>
* cwebmac.tex,
diff --git a/Build/source/texk/web2c/cwebdir/common.c b/Build/source/texk/web2c/cwebdir/common.c
index c36f50ffb16..bcf6c54f84f 100644
--- a/Build/source/texk/web2c/cwebdir/common.c
+++ b/Build/source/texk/web2c/cwebdir/common.c
@@ -732,10 +732,10 @@ else{
if((l= strlen(CWEBINPUTS))> max_file_name_length-2)too_long();
strcpy(temp_file_name,CWEBINPUTS);
#else
-l= 0;
-#endif
-#line 475 "common.w"
-
+#line 474 "common.w"
+ l= 0;
+#endif
+#line 476 "common.w"
}
if(l> 0){
if(k+l+2>=cur_file_name_end)too_long();
diff --git a/Build/source/texk/web2c/cwebdir/ctangle.c b/Build/source/texk/web2c/cwebdir/ctangle.c
index b7a7176646a..d8bdb7e30f4 100644
--- a/Build/source/texk/web2c/cwebdir/ctangle.c
+++ b/Build/source/texk/web2c/cwebdir/ctangle.c
@@ -434,15 +434,15 @@ static eight_bits get_next(void);
static void scan_repl(eight_bits);
/*:84*//*91:*/
-#line 1408 "ctangle.w"
+#line 1413 "ctangle.w"
static void scan_section(void);
/*:91*//*99:*/
-#line 1485 "ctangle.w"
+#line 1490 "ctangle.w"
static void phase_one(void);
/*:99*//*101:*/
-#line 1518 "ctangle.w"
+#line 1523 "ctangle.w"
static void skip_limbo(void);
/*:101*/
@@ -1282,33 +1282,19 @@ while(true)switch(a= get_next()){
#line 1244 "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 "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 "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 "ctangle.w"
+#line 1287 "ctangle.w"
{
char*try_loc= loc;
while(*try_loc==' '&&try_loc<limit)try_loc++;
@@ -1321,7 +1307,7 @@ if(*try_loc=='=')err_print("! Missing `@ ' before a named section");
}
/*:87*/
-#line 1252 "ctangle.w"
+#line 1257 "ctangle.w"
a= cur_section_name-name_dir;
app_repl((a/0400)+0250);
@@ -1344,7 +1330,7 @@ store_id(a);
}
/*:85*/
-#line 1256 "ctangle.w"
+#line 1261 "ctangle.w"
}
break;
@@ -1373,13 +1359,13 @@ store_id(a);
}
/*:85*/
-#line 1266 "ctangle.w"
+#line 1271 "ctangle.w"
}
break;
case constant:case string:
/*88:*/
-#line 1299 "ctangle.w"
+#line 1304 "ctangle.w"
app_repl(a);
while(id_first<id_loc){
@@ -1395,12 +1381,12 @@ app_repl(*id_first++);
app_repl(a);
/*:88*/
-#line 1270 "ctangle.w"
+#line 1275 "ctangle.w"
break;
case ord:
/*89:*/
-#line 1317 "ctangle.w"
+#line 1322 "ctangle.w"
{
int c= (int)((eight_bits)*id_first);
if(c=='\\'){
@@ -1450,7 +1436,7 @@ app_repl(constant);
}
/*:89*/
-#line 1273 "ctangle.w"
+#line 1278 "ctangle.w"
break;
case definition:case format_code:case begin_C:if(t!=section_name)goto done;
@@ -1474,7 +1460,7 @@ cur_text= text_ptr;(++text_ptr)->tok_start= tok_ptr;
}
/*:83*//*90:*/
-#line 1375 "ctangle.w"
+#line 1380 "ctangle.w"
static void
scan_section(void)
@@ -1489,7 +1475,7 @@ printf("*%d",(int)section_count);update_terminal;
next_control= ignore;
while(true){
/*92:*/
-#line 1416 "ctangle.w"
+#line 1421 "ctangle.w"
while(next_control<definition)
@@ -1498,11 +1484,11 @@ loc-= 2;next_control= get_next();
}
/*:92*/
-#line 1389 "ctangle.w"
+#line 1394 "ctangle.w"
if(next_control==definition){
/*93:*/
-#line 1423 "ctangle.w"
+#line 1428 "ctangle.w"
while((next_control= get_next())=='\n');
if(next_control!=identifier){
@@ -1518,7 +1504,7 @@ scan_repl(macro);
cur_text->text_link= macro;
/*:93*/
-#line 1391 "ctangle.w"
+#line 1396 "ctangle.w"
continue;
}
@@ -1528,14 +1514,14 @@ p= name_dir;break;
if(next_control==section_name){
p= cur_section_name;
/*94:*/
-#line 1445 "ctangle.w"
+#line 1450 "ctangle.w"
while((next_control= get_next())=='+');
if(next_control!='='&&next_control!=eq_eq)
continue;
/*:94*/
-#line 1399 "ctangle.w"
+#line 1404 "ctangle.w"
break;
}
@@ -1543,20 +1529,20 @@ return;
}
no_where= print_where= false;
/*95:*/
-#line 1450 "ctangle.w"
+#line 1455 "ctangle.w"
/*96:*/
-#line 1455 "ctangle.w"
+#line 1460 "ctangle.w"
store_two_bytes((sixteen_bits)(0150000+section_count));
/*:96*/
-#line 1451 "ctangle.w"
+#line 1456 "ctangle.w"
scan_repl(section_name);
/*97:*/
-#line 1459 "ctangle.w"
+#line 1464 "ctangle.w"
if(p==name_dir||p==NULL){
last_unnamed->text_link= cur_text-text_info;last_unnamed= cur_text;
@@ -1573,16 +1559,16 @@ cur_text->text_link= section_flag;
/*:97*/
-#line 1453 "ctangle.w"
+#line 1458 "ctangle.w"
/*:95*/
-#line 1405 "ctangle.w"
+#line 1410 "ctangle.w"
}
/*:90*//*98:*/
-#line 1474 "ctangle.w"
+#line 1479 "ctangle.w"
static void
phase_one(void){
@@ -1595,7 +1581,7 @@ check_complete();
}
/*:98*//*100:*/
-#line 1490 "ctangle.w"
+#line 1495 "ctangle.w"
static void
skip_limbo(void)
@@ -1609,7 +1595,7 @@ char c= *loc++;
switch(ccode[(eight_bits)c]){
case new_section:return;
case translit_code:/*102:*/
-#line 1520 "ctangle.w"
+#line 1525 "ctangle.w"
while(xisspace(*loc)&&loc<limit)loc++;
loc+= 3;
@@ -1634,7 +1620,7 @@ translit[i-0200][loc-beg]= '\0';
}
/*:102*/
-#line 1502 "ctangle.w"
+#line 1507 "ctangle.w"
break;
case format_code:case'@':break;
case control_text:if(c=='q'||c=='Q'){
@@ -1652,7 +1638,7 @@ default:err_print("! Double @ should be used in limbo");
}
/*:100*//*103:*/
-#line 1546 "ctangle.w"
+#line 1551 "ctangle.w"
void
print_stats(void){
diff --git a/Build/source/texk/web2c/cwebdir/ctangle.w b/Build/source/texk/web2c/cwebdir/ctangle.w
index a49869b4dc6..cd462961e24 100644
--- a/Build/source/texk/web2c/cwebdir/ctangle.w
+++ b/Build/source/texk/web2c/cwebdir/ctangle.w
@@ -1243,9 +1243,14 @@ file name.
@ @<In cases that |a| is...@>=@t\1\quad@>
case identifier: store_id(a);
- if (*buffer=='#' && id_first==buffer+1 && id_loc-id_first==5
- && strncmp("endif",id_first,5)==0)
- @<Insert the line number into |tok_mem|@>@;
+ 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; /* Avoid preprocessor calamities */
break;
case section_name: if (t!=section_name) goto done;
else {