summaryrefslogtreecommitdiff
path: root/Build
diff options
context:
space:
mode:
authorAndreas Scherer <andreas_tex@freenet.de>2022-02-14 16:00:50 +0000
committerAndreas Scherer <andreas_tex@freenet.de>2022-02-14 16:00:50 +0000
commitdc54dfddee8aa51b8c0747c467abe3f6bed18309 (patch)
treed1cbf607da38a090f8d80f0ca2f68d76b31114cd /Build
parent08a57555563d6b19cb9bb66b168671033672f7aa (diff)
[CWEB] Add '#line' after '#endif'.
Some people incorporate '@<Section code@>' in preprocessor #if-blocks. (AFAIKS, DEK did this exactly _once_ in his 'reflect.w' example code, but never in any larger system program.) This adds material (lines of code) in the ctangle'd C code wrapped in '#line' directives for the benefit of the compiler/debugger/w.h.y. Depending on the #if-condition, the #line directives in the #if-block get eliminated and the resulting status from previous #line directives kicks the compiler (__LINE__ and possibly __FILE__) and the debugger (e.g., gdb, MSVS) off the track. git-svn-id: svn://tug.org/texlive/trunk@62021 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build')
-rw-r--r--Build/source/texk/web2c/ChangeLog4
-rw-r--r--Build/source/texk/web2c/ctangleboot.cin105
-rw-r--r--Build/source/texk/web2c/cwebdir/ChangeLog6
-rw-r--r--Build/source/texk/web2c/cwebdir/common.c4
-rw-r--r--Build/source/texk/web2c/cwebdir/ctangle.c83
-rw-r--r--Build/source/texk/web2c/cwebdir/ctangle.w6
6 files changed, 135 insertions, 73 deletions
diff --git a/Build/source/texk/web2c/ChangeLog b/Build/source/texk/web2c/ChangeLog
index 5a2f3d40139..8e452dde31a 100644
--- a/Build/source/texk/web2c/ChangeLog
+++ b/Build/source/texk/web2c/ChangeLog
@@ -1,3 +1,7 @@
+2022-02-14 Andreas Scherer <https://ascherer.github.io>
+
+ * ctangleboot.bin: Add '#line' after '#endif'.
+
2022-02-11 Andreas Scherer <https://ascherer.github.io>
* weave.ch: Fix spacing in math expression.
diff --git a/Build/source/texk/web2c/ctangleboot.cin b/Build/source/texk/web2c/ctangleboot.cin
index 76bb67f48fa..edb33142047 100644
--- a/Build/source/texk/web2c/ctangleboot.cin
+++ b/Build/source/texk/web2c/ctangleboot.cin
@@ -459,15 +459,15 @@ static eight_bits get_next(void);
static void scan_repl(eight_bits);
/*:84*//*91:*/
-#line 1404 "cwebdir/ctangle.w"
+#line 1408 "cwebdir/ctangle.w"
static void scan_section(void);
/*:91*//*99:*/
-#line 1481 "cwebdir/ctangle.w"
+#line 1485 "cwebdir/ctangle.w"
static void phase_one(void);
/*:99*//*101:*/
-#line 1514 "cwebdir/ctangle.w"
+#line 1518 "cwebdir/ctangle.w"
static void skip_limbo(void);
/*:101*/
@@ -1595,11 +1595,34 @@ while(true)switch(a= get_next()){
/*86:*/
#line 1244 "cwebdir/ctangle.w"
-case identifier:store_id(a);break;
+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"
+
+break;
case section_name:if(t!=section_name)goto done;
else{
/*87:*/
-#line 1278 "cwebdir/ctangle.w"
+#line 1282 "cwebdir/ctangle.w"
{
char*try_loc= loc;
while(*try_loc==' '&&try_loc<limit)try_loc++;
@@ -1607,14 +1630,14 @@ if(*try_loc=='+'&&try_loc<limit)try_loc++;
while(*try_loc==' '&&try_loc<limit)try_loc++;
#line 294 "cwebdir/ctang-w2c.ch"
if(*try_loc=='=')err_print(_("! Missing `@ ' before a named section"));
-#line 1284 "cwebdir/ctangle.w"
+#line 1288 "cwebdir/ctangle.w"
}
/*:87*/
-#line 1248 "cwebdir/ctangle.w"
+#line 1252 "cwebdir/ctangle.w"
a= cur_section_name-name_dir;
app_repl((a/0400)+0250);
@@ -1637,13 +1660,13 @@ store_id(a);
}
/*:85*/
-#line 1252 "cwebdir/ctangle.w"
+#line 1256 "cwebdir/ctangle.w"
}
break;
#line 282 "cwebdir/ctang-w2c.ch"
case output_defs_code:if(t!=section_name)err_print(_("! Misplaced @h"));
-#line 1256 "cwebdir/ctangle.w"
+#line 1260 "cwebdir/ctangle.w"
else{
output_defs_seen= true;
@@ -1668,13 +1691,13 @@ store_id(a);
}
/*:85*/
-#line 1262 "cwebdir/ctangle.w"
+#line 1266 "cwebdir/ctangle.w"
}
break;
case constant:case string:
/*88:*/
-#line 1295 "cwebdir/ctangle.w"
+#line 1299 "cwebdir/ctangle.w"
app_repl(a);
while(id_first<id_loc){
@@ -1682,7 +1705,7 @@ if(*id_first=='@'){
if(*(id_first+1)=='@')id_first++;
#line 300 "cwebdir/ctang-w2c.ch"
else err_print(_("! Double @ should be used in string"));
-#line 1301 "cwebdir/ctangle.w"
+#line 1305 "cwebdir/ctangle.w"
}
else if(a==constant&&*id_first=='\''&&!keep_digit_separators)
@@ -1692,12 +1715,12 @@ app_repl(*id_first++);
app_repl(a);
/*:88*/
-#line 1266 "cwebdir/ctangle.w"
+#line 1270 "cwebdir/ctangle.w"
break;
case ord:
/*89:*/
-#line 1313 "cwebdir/ctangle.w"
+#line 1317 "cwebdir/ctangle.w"
{
int c= (int)((eight_bits)*id_first);
if(c=='\\'){
@@ -1736,7 +1759,7 @@ case'\'':c= '\'';break;
case'\"':c= '\"';break;
#line 306 "cwebdir/ctang-w2c.ch"
default:err_print(_("! Unrecognized escape sequence"));
-#line 1350 "cwebdir/ctangle.w"
+#line 1354 "cwebdir/ctangle.w"
}
}
@@ -1749,14 +1772,14 @@ app_repl(constant);
}
/*:89*/
-#line 1269 "cwebdir/ctangle.w"
+#line 1273 "cwebdir/ctangle.w"
break;
case definition:case format_code:case begin_C:if(t!=section_name)goto done;
else{
#line 288 "cwebdir/ctang-w2c.ch"
err_print(_("! @d, @f and @c are ignored in C text"));continue;
-#line 1274 "cwebdir/ctangle.w"
+#line 1278 "cwebdir/ctangle.w"
}
case new_section:goto done;
@@ -1777,7 +1800,7 @@ cur_text= text_ptr;(++text_ptr)->tok_start= tok_ptr;
}
/*:83*//*90:*/
-#line 1371 "cwebdir/ctangle.w"
+#line 1375 "cwebdir/ctangle.w"
static void
scan_section(void)
@@ -1792,7 +1815,7 @@ printf("*%d",(int)section_count);update_terminal;
next_control= ignore;
while(true){
/*92:*/
-#line 1412 "cwebdir/ctangle.w"
+#line 1416 "cwebdir/ctangle.w"
while(next_control<definition)
@@ -1801,17 +1824,17 @@ loc-= 2;next_control= get_next();
}
/*:92*/
-#line 1385 "cwebdir/ctangle.w"
+#line 1389 "cwebdir/ctangle.w"
if(next_control==definition){
/*93:*/
-#line 1419 "cwebdir/ctangle.w"
+#line 1423 "cwebdir/ctangle.w"
while((next_control= get_next())=='\n');
if(next_control!=identifier){
#line 312 "cwebdir/ctang-w2c.ch"
err_print(_("! Definition flushed, must start with identifier"));
-#line 1423 "cwebdir/ctangle.w"
+#line 1427 "cwebdir/ctangle.w"
continue;
}
@@ -1823,7 +1846,7 @@ scan_repl(macro);
cur_text->text_link= macro;
/*:93*/
-#line 1387 "cwebdir/ctangle.w"
+#line 1391 "cwebdir/ctangle.w"
continue;
}
@@ -1833,14 +1856,14 @@ p= name_dir;break;
if(next_control==section_name){
p= cur_section_name;
/*94:*/
-#line 1441 "cwebdir/ctangle.w"
+#line 1445 "cwebdir/ctangle.w"
while((next_control= get_next())=='+');
if(next_control!='='&&next_control!=eq_eq)
continue;
/*:94*/
-#line 1395 "cwebdir/ctangle.w"
+#line 1399 "cwebdir/ctangle.w"
break;
}
@@ -1848,20 +1871,20 @@ return;
}
no_where= print_where= false;
/*95:*/
-#line 1446 "cwebdir/ctangle.w"
+#line 1450 "cwebdir/ctangle.w"
/*96:*/
-#line 1451 "cwebdir/ctangle.w"
+#line 1455 "cwebdir/ctangle.w"
store_two_bytes((sixteen_bits)(0150000+section_count));
/*:96*/
-#line 1447 "cwebdir/ctangle.w"
+#line 1451 "cwebdir/ctangle.w"
scan_repl(section_name);
/*97:*/
-#line 1455 "cwebdir/ctangle.w"
+#line 1459 "cwebdir/ctangle.w"
if(p==name_dir||p==NULL){
last_unnamed->text_link= cur_text-text_info;last_unnamed= cur_text;
@@ -1878,16 +1901,16 @@ cur_text->text_link= section_flag;
/*:97*/
-#line 1449 "cwebdir/ctangle.w"
+#line 1453 "cwebdir/ctangle.w"
/*:95*/
-#line 1401 "cwebdir/ctangle.w"
+#line 1405 "cwebdir/ctangle.w"
}
/*:90*//*98:*/
-#line 1470 "cwebdir/ctangle.w"
+#line 1474 "cwebdir/ctangle.w"
static void
phase_one(void){
@@ -1900,7 +1923,7 @@ check_complete();
}
/*:98*//*100:*/
-#line 1486 "cwebdir/ctangle.w"
+#line 1490 "cwebdir/ctangle.w"
static void
skip_limbo(void)
@@ -1914,7 +1937,7 @@ char c= *loc++;
switch(ccode[(eight_bits)c]){
case new_section:return;
case translit_code:/*102:*/
-#line 1516 "cwebdir/ctangle.w"
+#line 1520 "cwebdir/ctangle.w"
while(xisspace(*loc)&&loc<limit)loc++;
loc+= 3;
@@ -1922,7 +1945,7 @@ if(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 1522 "cwebdir/ctangle.w"
+#line 1526 "cwebdir/ctangle.w"
else{
unsigned int i;
@@ -1934,7 +1957,7 @@ while(loc<limit&&(xisalpha(*loc)||xisdigit(*loc)||*loc=='_'))loc++;
if(loc-beg>=translit_length)
#line 336 "cwebdir/ctang-w2c.ch"
err_print(_("! Replacement string in @l too long"));
-#line 1532 "cwebdir/ctangle.w"
+#line 1536 "cwebdir/ctangle.w"
else{
strncpy(translit[i-0200],beg,(size_t)(loc-beg));
@@ -1943,7 +1966,7 @@ translit[i-0200][loc-beg]= '\0';
}
/*:102*/
-#line 1498 "cwebdir/ctangle.w"
+#line 1502 "cwebdir/ctangle.w"
break;
case format_code:case'@':break;
case control_text:if(c=='q'||c=='Q'){
@@ -1951,13 +1974,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 1504 "cwebdir/ctangle.w"
+#line 1508 "cwebdir/ctangle.w"
break;
}
#line 324 "cwebdir/ctang-w2c.ch"
default:err_print(_("! Double @ should be used in limbo"));
-#line 1508 "cwebdir/ctangle.w"
+#line 1512 "cwebdir/ctangle.w"
}
}
@@ -1965,7 +1988,7 @@ default:err_print(_("! Double @ should be used in limbo"));
}
/*:100*//*103:*/
-#line 1542 "cwebdir/ctangle.w"
+#line 1546 "cwebdir/ctangle.w"
void
print_stats(void){
@@ -1978,7 +2001,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 1553 "cwebdir/ctangle.w"
+#line 1557 "cwebdir/ctangle.w"
(ptrdiff_t)(tok_ptr-tok_mem),(long)max_toks);
}
diff --git a/Build/source/texk/web2c/cwebdir/ChangeLog b/Build/source/texk/web2c/cwebdir/ChangeLog
index 04c561584b3..20dac101e9f 100644
--- a/Build/source/texk/web2c/cwebdir/ChangeLog
+++ b/Build/source/texk/web2c/cwebdir/ChangeLog
@@ -1,3 +1,9 @@
+2022-02-14 Andreas Scherer <https://ascherer.github.io>
+
+ * common.c,
+ * ctangle.c,
+ * ctangle.w: Add '#line' after '#endif'.
+
2022-02-10 Andreas Scherer <https://ascherer.github.io>
* ctwimac.tex: Add silent \datecontentspage macro.
diff --git a/Build/source/texk/web2c/cwebdir/common.c b/Build/source/texk/web2c/cwebdir/common.c
index 00575a0ebf5..c36f50ffb16 100644
--- a/Build/source/texk/web2c/cwebdir/common.c
+++ b/Build/source/texk/web2c/cwebdir/common.c
@@ -733,7 +733,9 @@ if((l= strlen(CWEBINPUTS))> max_file_name_length-2)too_long();
strcpy(temp_file_name,CWEBINPUTS);
#else
l= 0;
-#endif
+#endif
+#line 475 "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 d7bc2ecbf88..b7a7176646a 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 1404 "ctangle.w"
+#line 1408 "ctangle.w"
static void scan_section(void);
/*:91*//*99:*/
-#line 1481 "ctangle.w"
+#line 1485 "ctangle.w"
static void phase_one(void);
/*:99*//*101:*/
-#line 1514 "ctangle.w"
+#line 1518 "ctangle.w"
static void skip_limbo(void);
/*:101*/
@@ -1281,11 +1281,34 @@ while(true)switch(a= get_next()){
/*86:*/
#line 1244 "ctangle.w"
-case identifier:store_id(a);break;
+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"
+
+break;
case section_name:if(t!=section_name)goto done;
else{
/*87:*/
-#line 1278 "ctangle.w"
+#line 1282 "ctangle.w"
{
char*try_loc= loc;
while(*try_loc==' '&&try_loc<limit)try_loc++;
@@ -1298,7 +1321,7 @@ if(*try_loc=='=')err_print("! Missing `@ ' before a named section");
}
/*:87*/
-#line 1248 "ctangle.w"
+#line 1252 "ctangle.w"
a= cur_section_name-name_dir;
app_repl((a/0400)+0250);
@@ -1321,7 +1344,7 @@ store_id(a);
}
/*:85*/
-#line 1252 "ctangle.w"
+#line 1256 "ctangle.w"
}
break;
@@ -1350,13 +1373,13 @@ store_id(a);
}
/*:85*/
-#line 1262 "ctangle.w"
+#line 1266 "ctangle.w"
}
break;
case constant:case string:
/*88:*/
-#line 1295 "ctangle.w"
+#line 1299 "ctangle.w"
app_repl(a);
while(id_first<id_loc){
@@ -1372,12 +1395,12 @@ app_repl(*id_first++);
app_repl(a);
/*:88*/
-#line 1266 "ctangle.w"
+#line 1270 "ctangle.w"
break;
case ord:
/*89:*/
-#line 1313 "ctangle.w"
+#line 1317 "ctangle.w"
{
int c= (int)((eight_bits)*id_first);
if(c=='\\'){
@@ -1427,7 +1450,7 @@ app_repl(constant);
}
/*:89*/
-#line 1269 "ctangle.w"
+#line 1273 "ctangle.w"
break;
case definition:case format_code:case begin_C:if(t!=section_name)goto done;
@@ -1451,7 +1474,7 @@ cur_text= text_ptr;(++text_ptr)->tok_start= tok_ptr;
}
/*:83*//*90:*/
-#line 1371 "ctangle.w"
+#line 1375 "ctangle.w"
static void
scan_section(void)
@@ -1466,7 +1489,7 @@ printf("*%d",(int)section_count);update_terminal;
next_control= ignore;
while(true){
/*92:*/
-#line 1412 "ctangle.w"
+#line 1416 "ctangle.w"
while(next_control<definition)
@@ -1475,11 +1498,11 @@ loc-= 2;next_control= get_next();
}
/*:92*/
-#line 1385 "ctangle.w"
+#line 1389 "ctangle.w"
if(next_control==definition){
/*93:*/
-#line 1419 "ctangle.w"
+#line 1423 "ctangle.w"
while((next_control= get_next())=='\n');
if(next_control!=identifier){
@@ -1495,7 +1518,7 @@ scan_repl(macro);
cur_text->text_link= macro;
/*:93*/
-#line 1387 "ctangle.w"
+#line 1391 "ctangle.w"
continue;
}
@@ -1505,14 +1528,14 @@ p= name_dir;break;
if(next_control==section_name){
p= cur_section_name;
/*94:*/
-#line 1441 "ctangle.w"
+#line 1445 "ctangle.w"
while((next_control= get_next())=='+');
if(next_control!='='&&next_control!=eq_eq)
continue;
/*:94*/
-#line 1395 "ctangle.w"
+#line 1399 "ctangle.w"
break;
}
@@ -1520,20 +1543,20 @@ return;
}
no_where= print_where= false;
/*95:*/
-#line 1446 "ctangle.w"
+#line 1450 "ctangle.w"
/*96:*/
-#line 1451 "ctangle.w"
+#line 1455 "ctangle.w"
store_two_bytes((sixteen_bits)(0150000+section_count));
/*:96*/
-#line 1447 "ctangle.w"
+#line 1451 "ctangle.w"
scan_repl(section_name);
/*97:*/
-#line 1455 "ctangle.w"
+#line 1459 "ctangle.w"
if(p==name_dir||p==NULL){
last_unnamed->text_link= cur_text-text_info;last_unnamed= cur_text;
@@ -1550,16 +1573,16 @@ cur_text->text_link= section_flag;
/*:97*/
-#line 1449 "ctangle.w"
+#line 1453 "ctangle.w"
/*:95*/
-#line 1401 "ctangle.w"
+#line 1405 "ctangle.w"
}
/*:90*//*98:*/
-#line 1470 "ctangle.w"
+#line 1474 "ctangle.w"
static void
phase_one(void){
@@ -1572,7 +1595,7 @@ check_complete();
}
/*:98*//*100:*/
-#line 1486 "ctangle.w"
+#line 1490 "ctangle.w"
static void
skip_limbo(void)
@@ -1586,7 +1609,7 @@ char c= *loc++;
switch(ccode[(eight_bits)c]){
case new_section:return;
case translit_code:/*102:*/
-#line 1516 "ctangle.w"
+#line 1520 "ctangle.w"
while(xisspace(*loc)&&loc<limit)loc++;
loc+= 3;
@@ -1611,7 +1634,7 @@ translit[i-0200][loc-beg]= '\0';
}
/*:102*/
-#line 1498 "ctangle.w"
+#line 1502 "ctangle.w"
break;
case format_code:case'@':break;
case control_text:if(c=='q'||c=='Q'){
@@ -1629,7 +1652,7 @@ default:err_print("! Double @ should be used in limbo");
}
/*:100*//*103:*/
-#line 1542 "ctangle.w"
+#line 1546 "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 1ee2aaf1958..a49869b4dc6 100644
--- a/Build/source/texk/web2c/cwebdir/ctangle.w
+++ b/Build/source/texk/web2c/cwebdir/ctangle.w
@@ -1242,7 +1242,11 @@ file name.
}
@ @<In cases that |a| is...@>=@t\1\quad@>
-case identifier: store_id(a); break;
+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|@>@;
+ break;
case section_name: if (t!=section_name) goto done;
else {
@<Was an `\.{@@}' missed here?@>@;