summaryrefslogtreecommitdiff
path: root/web/c_cpp/cweb/ctangle.c
diff options
context:
space:
mode:
Diffstat (limited to 'web/c_cpp/cweb/ctangle.c')
-rw-r--r--web/c_cpp/cweb/ctangle.c73
1 files changed, 40 insertions, 33 deletions
diff --git a/web/c_cpp/cweb/ctangle.c b/web/c_cpp/cweb/ctangle.c
index d7bc2ecbf8..262469d611 100644
--- a/web/c_cpp/cweb/ctangle.c
+++ b/web/c_cpp/cweb/ctangle.c
@@ -15,7 +15,7 @@
/*:4*/
#line 67 "ctangle.w"
-#define banner "This is CTANGLE (Version 4.7)" \
+#define banner "This is CTANGLE (Version 4.8)" \
#define ctangle false
#define cweave true \
@@ -434,15 +434,15 @@ static eight_bits get_next(void);
static void scan_repl(eight_bits);
/*:84*//*91:*/
-#line 1404 "ctangle.w"
+#line 1411 "ctangle.w"
static void scan_section(void);
/*:91*//*99:*/
-#line 1481 "ctangle.w"
+#line 1488 "ctangle.w"
static void phase_one(void);
/*:99*//*101:*/
-#line 1514 "ctangle.w"
+#line 1521 "ctangle.w"
static void skip_limbo(void);
/*:101*/
@@ -866,7 +866,7 @@ case string:if(out_state==verbatim)out_state= normal;
else out_state= verbatim;break;
case'/':C_putc('/');out_state= post_slash;break;
case'*':if(out_state==post_slash)C_putc(' ');
-
+/* fall through */
default:C_putc(cur_char);out_state= normal;break;
}
}
@@ -1281,11 +1281,18 @@ 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_loc-id_first==5&&strncmp("endif",id_first,5)==0)||
+(id_loc-id_first==4&&strncmp("else",id_first,4)==0)||
+(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 1278 "ctangle.w"
+#line 1285 "ctangle.w"
{
char*try_loc= loc;
while(*try_loc==' '&&try_loc<limit)try_loc++;
@@ -1298,7 +1305,7 @@ if(*try_loc=='=')err_print("! Missing `@ ' before a named section");
}
/*:87*/
-#line 1248 "ctangle.w"
+#line 1255 "ctangle.w"
a= cur_section_name-name_dir;
app_repl((a/0400)+0250);
@@ -1321,7 +1328,7 @@ store_id(a);
}
/*:85*/
-#line 1252 "ctangle.w"
+#line 1259 "ctangle.w"
}
break;
@@ -1350,13 +1357,13 @@ store_id(a);
}
/*:85*/
-#line 1262 "ctangle.w"
+#line 1269 "ctangle.w"
}
break;
case constant:case string:
/*88:*/
-#line 1295 "ctangle.w"
+#line 1302 "ctangle.w"
app_repl(a);
while(id_first<id_loc){
@@ -1372,12 +1379,12 @@ app_repl(*id_first++);
app_repl(a);
/*:88*/
-#line 1266 "ctangle.w"
+#line 1273 "ctangle.w"
break;
case ord:
/*89:*/
-#line 1313 "ctangle.w"
+#line 1320 "ctangle.w"
{
int c= (int)((eight_bits)*id_first);
if(c=='\\'){
@@ -1427,7 +1434,7 @@ app_repl(constant);
}
/*:89*/
-#line 1269 "ctangle.w"
+#line 1276 "ctangle.w"
break;
case definition:case format_code:case begin_C:if(t!=section_name)goto done;
@@ -1451,7 +1458,7 @@ cur_text= text_ptr;(++text_ptr)->tok_start= tok_ptr;
}
/*:83*//*90:*/
-#line 1371 "ctangle.w"
+#line 1378 "ctangle.w"
static void
scan_section(void)
@@ -1466,7 +1473,7 @@ printf("*%d",(int)section_count);update_terminal;
next_control= ignore;
while(true){
/*92:*/
-#line 1412 "ctangle.w"
+#line 1419 "ctangle.w"
while(next_control<definition)
@@ -1475,11 +1482,11 @@ loc-= 2;next_control= get_next();
}
/*:92*/
-#line 1385 "ctangle.w"
+#line 1392 "ctangle.w"
if(next_control==definition){
/*93:*/
-#line 1419 "ctangle.w"
+#line 1426 "ctangle.w"
while((next_control= get_next())=='\n');
if(next_control!=identifier){
@@ -1495,7 +1502,7 @@ scan_repl(macro);
cur_text->text_link= macro;
/*:93*/
-#line 1387 "ctangle.w"
+#line 1394 "ctangle.w"
continue;
}
@@ -1505,14 +1512,14 @@ p= name_dir;break;
if(next_control==section_name){
p= cur_section_name;
/*94:*/
-#line 1441 "ctangle.w"
+#line 1448 "ctangle.w"
while((next_control= get_next())=='+');
if(next_control!='='&&next_control!=eq_eq)
continue;
/*:94*/
-#line 1395 "ctangle.w"
+#line 1402 "ctangle.w"
break;
}
@@ -1520,20 +1527,20 @@ return;
}
no_where= print_where= false;
/*95:*/
-#line 1446 "ctangle.w"
+#line 1453 "ctangle.w"
/*96:*/
-#line 1451 "ctangle.w"
+#line 1458 "ctangle.w"
store_two_bytes((sixteen_bits)(0150000+section_count));
/*:96*/
-#line 1447 "ctangle.w"
+#line 1454 "ctangle.w"
scan_repl(section_name);
/*97:*/
-#line 1455 "ctangle.w"
+#line 1462 "ctangle.w"
if(p==name_dir||p==NULL){
last_unnamed->text_link= cur_text-text_info;last_unnamed= cur_text;
@@ -1550,16 +1557,16 @@ cur_text->text_link= section_flag;
/*:97*/
-#line 1449 "ctangle.w"
+#line 1456 "ctangle.w"
/*:95*/
-#line 1401 "ctangle.w"
+#line 1408 "ctangle.w"
}
/*:90*//*98:*/
-#line 1470 "ctangle.w"
+#line 1477 "ctangle.w"
static void
phase_one(void){
@@ -1572,7 +1579,7 @@ check_complete();
}
/*:98*//*100:*/
-#line 1486 "ctangle.w"
+#line 1493 "ctangle.w"
static void
skip_limbo(void)
@@ -1586,7 +1593,7 @@ char c= *loc++;
switch(ccode[(eight_bits)c]){
case new_section:return;
case translit_code:/*102:*/
-#line 1516 "ctangle.w"
+#line 1523 "ctangle.w"
while(xisspace(*loc)&&loc<limit)loc++;
loc+= 3;
@@ -1611,7 +1618,7 @@ translit[i-0200][loc-beg]= '\0';
}
/*:102*/
-#line 1498 "ctangle.w"
+#line 1505 "ctangle.w"
break;
case format_code:case'@':break;
case control_text:if(c=='q'||c=='Q'){
@@ -1620,7 +1627,7 @@ if(*(loc-1)!='>')
err_print("! Double @ should be used in control text");
break;
-}
+}/* otherwise fall through */
default:err_print("! Double @ should be used in limbo");
}
@@ -1629,7 +1636,7 @@ default:err_print("! Double @ should be used in limbo");
}
/*:100*//*103:*/
-#line 1542 "ctangle.w"
+#line 1549 "ctangle.w"
void
print_stats(void){