summaryrefslogtreecommitdiff
path: root/web/c_cpp/cweb/ctangle.c
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-08-20 03:01:12 +0000
committerNorbert Preining <norbert@preining.info>2023-08-20 03:01:12 +0000
commit53b22757814343c6071be2e64dc0639f7afc5468 (patch)
tree17c8c7a1bd1da7c2f985ce7bfeffb21cc8e1cf3f /web/c_cpp/cweb/ctangle.c
parenta953fdb33424be714f17f4d46f05712637bd0c3a (diff)
CTAN sync 202308200301
Diffstat (limited to 'web/c_cpp/cweb/ctangle.c')
-rw-r--r--web/c_cpp/cweb/ctangle.c392
1 files changed, 192 insertions, 200 deletions
diff --git a/web/c_cpp/cweb/ctangle.c b/web/c_cpp/cweb/ctangle.c
index 262469d611..2c31732e22 100644
--- a/web/c_cpp/cweb/ctangle.c
+++ b/web/c_cpp/cweb/ctangle.c
@@ -1,8 +1,8 @@
/*1:*/
#line 66 "ctangle.w"
-/*4:*/
-#line 44 "common.h"
+/*5:*/
+#line 48 "common.h"
#include <ctype.h>
#include <stdbool.h>
@@ -12,10 +12,10 @@
#include <stdlib.h>
#include <string.h>
-/*:4*/
+/*:5*/
#line 67 "ctangle.w"
-#define banner "This is CTANGLE (Version 4.8)" \
+#define banner "This is CTANGLE (Version 4.10)" \
#define ctangle false
#define cweave true \
@@ -63,14 +63,15 @@
#define llink link
#define rlink dummy.Rlink
#define root name_dir->rlink \
- \
+
+#define ilk dummy.Ilk \
#define spotless 0
#define harmless_message 1
#define error_message 2
#define fatal_message 3
-#define mark_harmless if(history==spotless) history= harmless_message
-#define mark_error history= error_message
+#define mark_harmless() if(history==spotless) history= harmless_message
+#define mark_error() history= error_message
#define confusion(s) fatal("! This can't happen: ",s) \
\
@@ -80,8 +81,8 @@
#define show_stats flags['s']
#define make_xrefs flags['x'] \
-#define update_terminal fflush(stdout)
-#define new_line putchar('\n')
+#define update_terminal() fflush(stdout)
+#define new_line() putchar('\n')
#define term_write(a,b) fflush(stdout) ,fwrite(a,sizeof(char) ,b,stdout) \
#define buf_size 200
@@ -107,11 +108,13 @@
#define output_defs_flag (2*024000-1) \
#define stack_size 50
-#define cur_end cur_state.end_field
+#define cur_state stack[stack_size+1] \
+
#define cur_byte cur_state.byte_field
#define cur_name cur_state.name_field
#define cur_repl cur_state.repl_field
-#define cur_section cur_state.section_field \
+#define cur_section cur_state.section_field
+#define cur_end (cur_repl+1) ->tok_start \
#define section_number 0201
#define identifier 0202 \
@@ -123,8 +126,10 @@
#define verbatim 4 \
#define max_files 256
+#define macro_end (cur_text+1) ->tok_start \
+
#define C_printf(c,a) fprintf(C_file,c,a)
-#define C_putc(c) putc((int) (c) ,C_file) \
+#define C_putc(c) fputc((int) (c) ,C_file) \
#define translit_length 10 \
@@ -162,24 +167,24 @@ typedef uint16_t sixteen_bits;
extern boolean program;
extern int phase;
-/*:3*//*5:*/
-#line 74 "common.h"
+/*:3*//*6:*/
+#line 78 "common.h"
extern char section_text[];
extern char*section_text_end;
extern char*id_first;
extern char*id_loc;
-/*:5*//*6:*/
-#line 92 "common.h"
+/*:6*//*7:*/
+#line 96 "common.h"
extern char buffer[];
extern char*buffer_end;
extern char*loc;
extern char*limit;
-/*:6*//*7:*/
-#line 109 "common.h"
+/*:7*//*8:*/
+#line 113 "common.h"
extern int include_depth;
extern FILE*file[];
@@ -194,16 +199,16 @@ extern boolean input_has_ended;
extern boolean changing;
extern boolean web_file_open;
-/*:7*//*9:*/
-#line 129 "common.h"
+/*:8*//*10:*/
+#line 133 "common.h"
extern sixteen_bits section_count;
extern boolean changed_section[];
extern boolean change_pending;
extern boolean print_where;
-/*:9*//*10:*/
-#line 143 "common.h"
+/*:10*//*11:*/
+#line 148 "common.h"
typedef struct name_info{
char*byte_start;
@@ -211,7 +216,7 @@ struct name_info*link;
union{
struct name_info*Rlink;
-char Ilk;
+eight_bits Ilk;
}dummy;
void*equiv_or_xref;
}name_info;
@@ -227,13 +232,13 @@ extern name_pointer hash[];
extern hash_pointer hash_end;
extern hash_pointer h;
-/*:10*//*12:*/
-#line 187 "common.h"
+/*:11*//*13:*/
+#line 193 "common.h"
extern int history;
-/*:12*//*14:*/
-#line 203 "common.h"
+/*:13*//*15:*/
+#line 211 "common.h"
extern int argc;
extern char**argv;
@@ -243,8 +248,8 @@ extern char idx_file_name[];
extern char scn_file_name[];
extern boolean flags[];
-/*:14*//*15:*/
-#line 217 "common.h"
+/*:15*//*16:*/
+#line 225 "common.h"
extern FILE*C_file;
extern FILE*tex_file;
@@ -252,7 +257,7 @@ extern FILE*idx_file;
extern FILE*scn_file;
extern FILE*active_file;
-/*:15*/
+/*:16*/
#line 69 "ctangle.w"
/*19:*/
@@ -265,10 +270,9 @@ sixteen_bits text_link;
typedef text*text_pointer;
/*:19*//*31:*/
-#line 274 "ctangle.w"
+#line 267 "ctangle.w"
typedef struct{
-eight_bits*end_field;
eight_bits*byte_field;
name_pointer name_field;
text_pointer repl_field;
@@ -290,32 +294,30 @@ static eight_bits*tok_mem_end= tok_mem+max_toks-1;
static eight_bits*tok_ptr;
/*:20*//*26:*/
-#line 200 "ctangle.w"
+#line 196 "ctangle.w"
static text_pointer last_unnamed;
/*:26*//*32:*/
-#line 291 "ctangle.w"
+#line 285 "ctangle.w"
-static output_state cur_state;
-
-static output_state stack[stack_size+1];
+static output_state stack[stack_size+2];
static stack_pointer stack_end= stack+stack_size;
static stack_pointer stack_ptr;
/*:32*//*37:*/
-#line 367 "ctangle.w"
+#line 357 "ctangle.w"
static int cur_val;
/*:37*//*42:*/
-#line 459 "ctangle.w"
+#line 449 "ctangle.w"
static eight_bits out_state;
static boolean protect;
/*:42*//*45:*/
-#line 490 "ctangle.w"
+#line 480 "ctangle.w"
static name_pointer output_files[max_files];
static name_pointer*cur_out_file,*end_output_files,*an_output_file;
@@ -323,33 +325,33 @@ static char cur_section_name_char;
static char output_file_name[longest_name+1];
/*:45*//*52:*/
-#line 590 "ctangle.w"
+#line 573 "ctangle.w"
static boolean output_defs_seen= false;
/*:52*//*57:*/
-#line 703 "ctangle.w"
+#line 687 "ctangle.w"
-static char translit[128][translit_length];
+static char translit[0200][translit_length];
/*:57*//*62:*/
-#line 779 "ctangle.w"
+#line 763 "ctangle.w"
static eight_bits ccode[256];
/*:62*//*66:*/
-#line 839 "ctangle.w"
+#line 823 "ctangle.w"
static boolean comment_continues= false;
/*:66*//*68:*/
-#line 876 "ctangle.w"
+#line 860 "ctangle.w"
static name_pointer cur_section_name;
static boolean no_where;
/*:68*//*82:*/
-#line 1193 "ctangle.w"
+#line 1177 "ctangle.w"
static text_pointer cur_text;
static eight_bits next_control;
@@ -357,92 +359,94 @@ static eight_bits next_control;
/*:82*/
#line 71 "ctangle.w"
-/*8:*/
-#line 123 "common.h"
+/*4:*/
+#line 43 "common.h"
+
+extern void common_init(void);
+
+/*:4*//*9:*/
+#line 127 "common.h"
extern boolean get_line(void);
extern void check_complete(void);
extern void reset_input(void);
-/*:8*//*11:*/
-#line 166 "common.h"
+/*:9*//*12:*/
+#line 171 "common.h"
-extern boolean names_match(name_pointer,const char*,size_t,eight_bits);
extern name_pointer id_lookup(const char*,const char*,eight_bits);
extern name_pointer section_lookup(char*,char*,boolean);
-extern void init_node(name_pointer);
-extern void init_p(name_pointer,eight_bits);
extern void print_prefix_name(name_pointer);
extern void print_section_name(name_pointer);
extern void sprint_section_name(char*,name_pointer);
-/*:11*//*13:*/
-#line 190 "common.h"
+extern boolean names_match(name_pointer,const char*,size_t,eight_bits);
+
+extern void init_node(name_pointer);
+
+/*:12*//*14:*/
+#line 196 "common.h"
extern int wrap_up(void);
extern void err_print(const char*);
extern void fatal(const char*,const char*);
extern void overflow(const char*);
-/*:13*//*16:*/
-#line 225 "common.h"
-
-extern void common_init(void);
extern void print_stats(void);
-/*:16*//*30:*/
-#line 246 "ctangle.w"
+/*:14*//*30:*/
+#line 242 "ctangle.w"
static void store_two_bytes(sixteen_bits);
/*:30*//*35:*/
-#line 330 "ctangle.w"
+#line 321 "ctangle.w"
static void push_level(name_pointer);
static void pop_level(boolean);
/*:35*//*39:*/
-#line 404 "ctangle.w"
+#line 394 "ctangle.w"
static void get_output(void);
/*:39*//*44:*/
-#line 480 "ctangle.w"
+#line 470 "ctangle.w"
static void flush_buffer(void);
/*:44*//*49:*/
-#line 557 "ctangle.w"
+#line 541 "ctangle.w"
static void phase_two(void);
/*:49*//*53:*/
-#line 593 "ctangle.w"
+#line 576 "ctangle.w"
static void output_defs(void);
static void out_char(eight_bits);
/*:53*//*65:*/
-#line 819 "ctangle.w"
+#line 803 "ctangle.w"
static eight_bits skip_ahead(void);
static boolean skip_comment(boolean);
/*:65*//*70:*/
-#line 926 "ctangle.w"
+#line 910 "ctangle.w"
static eight_bits get_next(void);
/*:70*//*84:*/
-#line 1219 "ctangle.w"
+#line 1203 "ctangle.w"
static void scan_repl(eight_bits);
/*:84*//*91:*/
-#line 1411 "ctangle.w"
+#line 1395 "ctangle.w"
static void scan_section(void);
/*:91*//*99:*/
-#line 1488 "ctangle.w"
+#line 1472 "ctangle.w"
static void phase_one(void);
/*:99*//*101:*/
-#line 1521 "ctangle.w"
+#line 1505 "ctangle.w"
static void skip_limbo(void);
/*:101*/
@@ -471,24 +475,24 @@ text_ptr= text_info+1;text_ptr->tok_start= tok_mem;
init_node(name_dir);
/*:23*//*27:*/
-#line 203 "ctangle.w"
+#line 199 "ctangle.w"
last_unnamed= text_info;text_info->text_link= macro;
/*:27*//*46:*/
-#line 500 "ctangle.w"
+#line 490 "ctangle.w"
cur_out_file= end_output_files= output_files+max_files;
/*:46*//*58:*/
-#line 706 "ctangle.w"
+#line 690 "ctangle.w"
-{
-int i;
-for(i= 0;i<128;i++)sprintf(translit[i],"X%02X",(unsigned int)(128+i));
+{int i;
+for(i= 0;i<0200;i++)
+snprintf(translit[i],translit_length,"X%02X",(unsigned int)(0200+i));
}
/*:58*//*63:*/
-#line 782 "ctangle.w"
+#line 766 "ctangle.w"
{
int c;
for(c= 0;c<256;c++)ccode[c]= ignore;
@@ -508,7 +512,7 @@ ccode['<']= ccode['(']= section_name;
ccode['\'']= ord;
/*:63*//*78:*/
-#line 1114 "ctangle.w"
+#line 1098 "ctangle.w"
section_text[0]= ' ';
/*:78*/
@@ -534,7 +538,7 @@ return length(p)==l&&strncmp(first,p->byte_start,l)==0;
}
/*:24*//*25:*/
-#line 170 "ctangle.w"
+#line 168 "ctangle.w"
void
init_node(
@@ -542,11 +546,9 @@ name_pointer node)
{
node->equiv= (void*)text_info;
}
-void
-init_p(name_pointer p,eight_bits t){(void)p;(void)t;}
/*:25*//*29:*/
-#line 236 "ctangle.w"
+#line 232 "ctangle.w"
static void
store_two_bytes(
@@ -558,7 +560,7 @@ if(tok_ptr+2> tok_mem_end)overflow("token");
}
/*:29*//*34:*/
-#line 315 "ctangle.w"
+#line 307 "ctangle.w"
static void
push_level(
@@ -569,13 +571,12 @@ if(stack_ptr==stack_end)overflow("stack");
stack_ptr++;
if(p!=NULL){
cur_name= p;cur_repl= (text_pointer)p->equiv;
-cur_byte= cur_repl->tok_start;cur_end= (cur_repl+1)->tok_start;
-cur_section= 0;
+cur_byte= cur_repl->tok_start;cur_section= 0;
}
}
/*:34*//*36:*/
-#line 338 "ctangle.w"
+#line 329 "ctangle.w"
static void
pop_level(
@@ -583,15 +584,14 @@ boolean flag)
{
if(flag&&cur_repl->text_link<section_flag){
cur_repl= cur_repl->text_link+text_info;
-cur_byte= cur_repl->tok_start;cur_end= (cur_repl+1)->tok_start;
-return;
+cur_byte= cur_repl->tok_start;return;
}
stack_ptr--;
if(stack_ptr> stack)cur_state= *stack_ptr;
}
/*:36*//*38:*/
-#line 374 "ctangle.w"
+#line 364 "ctangle.w"
static void
get_output(void)
@@ -614,7 +614,7 @@ switch(a/024000){
case 0:cur_val= (int)a;out_char(identifier);break;
case 1:if(a==output_defs_flag)output_defs();
else/*40:*/
-#line 409 "ctangle.w"
+#line 399 "ctangle.w"
{
a-= 024000;
@@ -628,7 +628,7 @@ goto restart;
}
/*:40*/
-#line 395 "ctangle.w"
+#line 385 "ctangle.w"
break;
default:cur_val= (int)a-050000;
@@ -639,7 +639,7 @@ out_char(section_number);
}
/*:38*//*43:*/
-#line 467 "ctangle.w"
+#line 457 "ctangle.w"
static void
flush_buffer(void)
@@ -648,13 +648,13 @@ C_putc('\n');
if(cur_line%100==0&&show_progress){
putchar('.');
if(cur_line%500==0)printf("%d",cur_line);
-update_terminal;
+update_terminal();
}
cur_line++;
}
/*:43*//*48:*/
-#line 519 "ctangle.w"
+#line 509 "ctangle.w"
static void
phase_two(void){
@@ -662,47 +662,41 @@ phase= 2;
web_file_open= false;
cur_line= 1;
/*33:*/
-#line 304 "ctangle.w"
+#line 296 "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;
+cur_byte= cur_repl->tok_start;cur_section= 0;
/*:33*/
-#line 525 "ctangle.w"
+#line 515 "ctangle.w"
/*51:*/
-#line 586 "ctangle.w"
+#line 569 "ctangle.w"
if(!output_defs_seen)
output_defs();
/*:51*/
-#line 526 "ctangle.w"
+#line 516 "ctangle.w"
if(text_info->text_link==macro&&cur_out_file==end_output_files){
-fputs("\n! No program text was specified.",stdout);mark_harmless;
+fputs("\n! No program text was specified.",stdout);mark_harmless();
}
else{
-if(cur_out_file==end_output_files){
if(show_progress){
-printf("\nWriting the output file (%s):",C_file_name);
-update_terminal;
-}
-}
-else{
-if(show_progress){
-fputs("\nWriting the output files:",stdout);
+printf(cur_out_file==end_output_files?
+"\nWriting the output file (%s):":
+"\nWriting the output files: (%s)",C_file_name);
-printf(" (%s)",C_file_name);
-update_terminal;
-}
-if(text_info->text_link==macro)goto writeloop;
+update_terminal();
}
+if(text_info->text_link!=macro){
while(stack_ptr> stack)get_output();
flush_buffer();
-writeloop:/*50:*/
-#line 563 "ctangle.w"
+}
+/*50:*/
+#line 547 "ctangle.w"
for(an_output_file= end_output_files;an_output_file> cur_out_file;){
an_output_file--;
@@ -711,29 +705,28 @@ fclose(C_file);
if((C_file= fopen(output_file_name,"wb"))==NULL)
fatal("! Cannot open output file ",output_file_name);
-if(show_progress){printf("\n(%s)",output_file_name);update_terminal;}
+if(show_progress){printf("\n(%s)",output_file_name);update_terminal();}
cur_line= 1;
stack_ptr= stack+1;
cur_name= *an_output_file;
cur_repl= (text_pointer)cur_name->equiv;
cur_byte= cur_repl->tok_start;
-cur_end= (cur_repl+1)->tok_start;
while(stack_ptr> stack)get_output();
flush_buffer();
}
/*:50*/
-#line 549 "ctangle.w"
+#line 533 "ctangle.w"
if(show_happiness){
-if(show_progress)new_line;
+if(show_progress)new_line();
fputs("Done.",stdout);
}
}
}
/*:48*//*54:*/
-#line 600 "ctangle.w"
+#line 585 "ctangle.w"
static void
output_defs(void)
@@ -743,13 +736,12 @@ push_level(NULL);
for(cur_text= text_info+1;cur_text<text_ptr;cur_text++)
if(cur_text->text_link==macro){
cur_byte= cur_text->tok_start;
-cur_end= (cur_text+1)->tok_start;
C_printf("%s","#define ");
out_state= normal;
protect= true;
-while(cur_byte<cur_end){
+while(cur_byte<macro_end){
a= *cur_byte++;
-if(cur_byte==cur_end&&a=='\n')break;
+if(cur_byte==macro_end&&a=='\n')break;
if(out_state==verbatim&&a!=string&&a!=constant&&a!='\n')
C_putc(a);
@@ -774,35 +766,35 @@ pop_level(false);
}
/*:54*//*55:*/
-#line 644 "ctangle.w"
+#line 628 "ctangle.w"
static void
out_char(
eight_bits cur_char)
{
-char*j,*k;
+char*j;
restart:
switch(cur_char){
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 712 "ctangle.w"
+#line 696 "ctangle.w"
case identifier:
if(out_state==num_or_id)C_putc(' ');
-for(j= (cur_val+name_dir)->byte_start,k= (cur_val+name_dir+1)->byte_start;
-j<k;j++)
+for(j= (cur_val+name_dir)->byte_start;
+j<(cur_val+name_dir+1)->byte_start;j++)
if((eight_bits)(*j)<0200)C_putc(*j);
else C_printf("%s",translit[(eight_bits)(*j)-0200]);
out_state= num_or_id;break;
/*:59*/
-#line 655 "ctangle.w"
+#line 639 "ctangle.w"
/*60:*/
-#line 722 "ctangle.w"
+#line 706 "ctangle.w"
case section_number:
if(cur_val> 0)C_printf("/*%d:*/",cur_val);
@@ -819,8 +811,8 @@ C_printf("\n#line %d \"",(int)a);
cur_val= (int)(*cur_byte++-0200)*0400;
cur_val+= *cur_byte++;
-for(j= (cur_val+name_dir)->byte_start,k= (cur_val+name_dir+1)->byte_start;
-j<k;j++){
+for(j= (cur_val+name_dir)->byte_start;
+j<(cur_val+name_dir+1)->byte_start;j++){
if(*j=='\\'||*j=='"')C_putc('\\');
C_putc(*j);
}
@@ -829,10 +821,10 @@ C_putc('"');C_putc('\n');
break;
/*:60*/
-#line 656 "ctangle.w"
+#line 640 "ctangle.w"
/*56:*/
-#line 674 "ctangle.w"
+#line 658 "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 +845,7 @@ case minus_gt_ast:C_putc('-');C_putc('>');C_putc('*');out_state= normal;
break;
/*:56*/
-#line 657 "ctangle.w"
+#line 641 "ctangle.w"
case'=':case'>':C_putc(cur_char);C_putc(' ');
out_state= normal;break;
@@ -872,7 +864,7 @@ default:C_putc(cur_char);out_state= normal;break;
}
/*:55*//*64:*/
-#line 803 "ctangle.w"
+#line 787 "ctangle.w"
static eight_bits
skip_ahead(void)
@@ -890,7 +882,7 @@ if(c!=ignore||*(loc-1)=='>')return c;
}
/*:64*//*67:*/
-#line 842 "ctangle.w"
+#line 826 "ctangle.w"
static boolean skip_comment(
boolean is_long_comment)
@@ -924,7 +916,7 @@ else loc++;
}
/*:67*//*69:*/
-#line 883 "ctangle.w"
+#line 867 "ctangle.w"
static eight_bits
get_next(void)
@@ -938,7 +930,7 @@ if(get_line()==false)return new_section;
else if(print_where&&!no_where){
print_where= false;
/*85:*/
-#line 1229 "ctangle.w"
+#line 1213 "ctangle.w"
{
eight_bits a;
@@ -955,7 +947,7 @@ store_id(a);
}
/*:85*/
-#line 895 "ctangle.w"
+#line 879 "ctangle.w"
}
else return(eight_bits)'\n';
@@ -968,7 +960,7 @@ else continue;
}
loc++;
if(xisdigit(c)||c=='.')/*73:*/
-#line 967 "ctangle.w"
+#line 951 "ctangle.w"
{
boolean hex_flag= false;
id_first= loc-1;
@@ -1002,13 +994,13 @@ return constant;
}
/*:73*/
-#line 906 "ctangle.w"
+#line 890 "ctangle.w"
else if(c=='\''||c=='"'
||((c=='L'||c=='u'||c=='U')&&(*loc=='\''||*loc=='"'))
||((c=='u'&&*loc=='8')&&(*(loc+1)=='\''||*(loc+1)=='"')))
/*74:*/
-#line 1004 "ctangle.w"
+#line 988 "ctangle.w"
{
char delim= (char)c;
id_first= section_text+1;
@@ -1052,11 +1044,11 @@ return string;
}
/*:74*/
-#line 910 "ctangle.w"
+#line 894 "ctangle.w"
else if(isalpha((int)c)||isxalpha(c)||ishigh(c))
/*72:*/
-#line 958 "ctangle.w"
+#line 942 "ctangle.w"
{
id_first= --loc;
do
@@ -1067,10 +1059,10 @@ id_loc= loc;return identifier;
}
/*:72*/
-#line 912 "ctangle.w"
+#line 896 "ctangle.w"
else if(c=='@')/*75:*/
-#line 1049 "ctangle.w"
+#line 1033 "ctangle.w"
switch(c= ccode[(eight_bits)*loc++]){
case ignore:continue;
@@ -1085,11 +1077,11 @@ continue;
case section_name:
cur_section_name_char= *(loc-1);
/*77:*/
-#line 1094 "ctangle.w"
+#line 1078 "ctangle.w"
{
char*k= section_text;
/*79:*/
-#line 1116 "ctangle.w"
+#line 1100 "ctangle.w"
while(true){
if(loc> limit&&get_line()==false){
@@ -1099,7 +1091,7 @@ loc= buffer+1;break;
}
c= (eight_bits)*loc;
/*80:*/
-#line 1139 "ctangle.w"
+#line 1123 "ctangle.w"
if(c=='@'){
c= (eight_bits)*(loc+1);
@@ -1118,7 +1110,7 @@ err_print("! Nesting of section names not allowed");break;
}
/*:80*/
-#line 1124 "ctangle.w"
+#line 1108 "ctangle.w"
loc++;if(k<section_text_end)k++;
if(xisspace(c)){
@@ -1130,12 +1122,12 @@ if(k>=section_text_end){
fputs("\n! Section name too long: ",stdout);
term_write(section_text+1,25);
-printf("...");mark_harmless;
+printf("...");mark_harmless();
}
if(*k==' '&&k> section_text)k--;
/*:79*/
-#line 1096 "ctangle.w"
+#line 1080 "ctangle.w"
if(k-section_text> 3&&strncmp(k-2,"...",3)==0)
cur_section_name= section_lookup(section_text+1,k-3,true);
@@ -1144,7 +1136,7 @@ else cur_section_name= section_lookup(section_text+1,k,false);
if(cur_section_name_char=='(')
/*47:*/
-#line 504 "ctangle.w"
+#line 494 "ctangle.w"
{
for(an_output_file= cur_out_file;
@@ -1158,16 +1150,16 @@ else overflow("output files");
}
/*:47*/
-#line 1104 "ctangle.w"
+#line 1088 "ctangle.w"
return section_name;
}
/*:77*/
-#line 1062 "ctangle.w"
+#line 1046 "ctangle.w"
case string:/*81:*/
-#line 1161 "ctangle.w"
+#line 1145 "ctangle.w"
id_first= loc++;*(limit+1)= '@';*(limit+2)= '>';
while(*loc!='@'||*(loc+1)!='>')loc++;
@@ -1177,10 +1169,10 @@ id_loc= loc;loc+= 2;
return string;
/*:81*/
-#line 1063 "ctangle.w"
+#line 1047 "ctangle.w"
case ord:/*76:*/
-#line 1074 "ctangle.w"
+#line 1058 "ctangle.w"
id_first= loc;
if(*loc=='\\')
@@ -1202,13 +1194,13 @@ loc++;
return ord;
/*:76*/
-#line 1064 "ctangle.w"
+#line 1048 "ctangle.w"
default:return c;
}
/*:75*/
-#line 913 "ctangle.w"
+#line 897 "ctangle.w"
else if(xisspace(c)){
if(!preprocessing||loc> limit)continue;
@@ -1218,7 +1210,7 @@ else return(eight_bits)' ';
}
else if(c=='#'&&loc==buffer+1)preprocessing= true;
mistake:/*71:*/
-#line 935 "ctangle.w"
+#line 919 "ctangle.w"
switch(c){
case'+':if(*loc=='+')compress(plus_plus);break;
@@ -1243,14 +1235,14 @@ case'!':if(*loc=='=')compress(non_eq);break;
}
/*:71*/
-#line 921 "ctangle.w"
+#line 905 "ctangle.w"
return c;
}
}
/*:69*//*83:*/
-#line 1197 "ctangle.w"
+#line 1181 "ctangle.w"
static void
scan_repl(
@@ -1258,7 +1250,7 @@ eight_bits t)
{
sixteen_bits a;
if(t==section_name)/*85:*/
-#line 1229 "ctangle.w"
+#line 1213 "ctangle.w"
{
eight_bits a;
@@ -1275,11 +1267,11 @@ store_id(a);
}
/*:85*/
-#line 1203 "ctangle.w"
+#line 1187 "ctangle.w"
while(true)switch(a= get_next()){
/*86:*/
-#line 1244 "ctangle.w"
+#line 1228 "ctangle.w"
case identifier:store_id(a);
if(*buffer=='#'&&(
@@ -1292,7 +1284,7 @@ break;
case section_name:if(t!=section_name)goto done;
else{
/*87:*/
-#line 1285 "ctangle.w"
+#line 1269 "ctangle.w"
{
char*try_loc= loc;
while(*try_loc==' '&&try_loc<limit)try_loc++;
@@ -1305,13 +1297,13 @@ if(*try_loc=='=')err_print("! Missing `@ ' before a named section");
}
/*:87*/
-#line 1255 "ctangle.w"
+#line 1239 "ctangle.w"
a= cur_section_name-name_dir;
app_repl((a/0400)+0250);
app_repl(a%0400);
/*85:*/
-#line 1229 "ctangle.w"
+#line 1213 "ctangle.w"
{
eight_bits a;
@@ -1328,7 +1320,7 @@ store_id(a);
}
/*:85*/
-#line 1259 "ctangle.w"
+#line 1243 "ctangle.w"
}
break;
@@ -1340,7 +1332,7 @@ a= output_defs_flag;
app_repl((a/0400)+0200);
app_repl(a%0400);
/*85:*/
-#line 1229 "ctangle.w"
+#line 1213 "ctangle.w"
{
eight_bits a;
@@ -1357,13 +1349,13 @@ store_id(a);
}
/*:85*/
-#line 1269 "ctangle.w"
+#line 1253 "ctangle.w"
}
break;
case constant:case string:
/*88:*/
-#line 1302 "ctangle.w"
+#line 1286 "ctangle.w"
app_repl(a);
while(id_first<id_loc){
@@ -1379,12 +1371,12 @@ app_repl(*id_first++);
app_repl(a);
/*:88*/
-#line 1273 "ctangle.w"
+#line 1257 "ctangle.w"
break;
case ord:
/*89:*/
-#line 1320 "ctangle.w"
+#line 1304 "ctangle.w"
{
int c= (int)((eight_bits)*id_first);
if(c=='\\'){
@@ -1434,7 +1426,7 @@ app_repl(constant);
}
/*:89*/
-#line 1276 "ctangle.w"
+#line 1260 "ctangle.w"
break;
case definition:case format_code:case begin_C:if(t!=section_name)goto done;
@@ -1445,7 +1437,7 @@ err_print("! @d, @f and @c are ignored in C text");continue;
case new_section:goto done;
/*:86*/
-#line 1208 "ctangle.w"
+#line 1192 "ctangle.w"
case')':app_repl(a);
if(t==macro)app_repl(' ');
@@ -1458,7 +1450,7 @@ cur_text= text_ptr;(++text_ptr)->tok_start= tok_ptr;
}
/*:83*//*90:*/
-#line 1378 "ctangle.w"
+#line 1362 "ctangle.w"
static void
scan_section(void)
@@ -1468,12 +1460,12 @@ text_pointer q;
sixteen_bits a;
section_count++;no_where= true;
if(*(loc-1)=='*'&&show_progress){
-printf("*%d",(int)section_count);update_terminal;
+printf("*%d",(int)section_count);update_terminal();
}
next_control= ignore;
while(true){
/*92:*/
-#line 1419 "ctangle.w"
+#line 1403 "ctangle.w"
while(next_control<definition)
@@ -1482,11 +1474,11 @@ loc-= 2;next_control= get_next();
}
/*:92*/
-#line 1392 "ctangle.w"
+#line 1376 "ctangle.w"
if(next_control==definition){
/*93:*/
-#line 1426 "ctangle.w"
+#line 1410 "ctangle.w"
while((next_control= get_next())=='\n');
if(next_control!=identifier){
@@ -1502,7 +1494,7 @@ scan_repl(macro);
cur_text->text_link= macro;
/*:93*/
-#line 1394 "ctangle.w"
+#line 1378 "ctangle.w"
continue;
}
@@ -1512,14 +1504,14 @@ p= name_dir;break;
if(next_control==section_name){
p= cur_section_name;
/*94:*/
-#line 1448 "ctangle.w"
+#line 1432 "ctangle.w"
while((next_control= get_next())=='+');
if(next_control!='='&&next_control!=eq_eq)
continue;
/*:94*/
-#line 1402 "ctangle.w"
+#line 1386 "ctangle.w"
break;
}
@@ -1527,20 +1519,20 @@ return;
}
no_where= print_where= false;
/*95:*/
-#line 1453 "ctangle.w"
+#line 1437 "ctangle.w"
/*96:*/
-#line 1458 "ctangle.w"
+#line 1442 "ctangle.w"
store_two_bytes((sixteen_bits)(0150000+section_count));
/*:96*/
-#line 1454 "ctangle.w"
+#line 1438 "ctangle.w"
scan_repl(section_name);
/*97:*/
-#line 1462 "ctangle.w"
+#line 1446 "ctangle.w"
if(p==name_dir||p==NULL){
last_unnamed->text_link= cur_text-text_info;last_unnamed= cur_text;
@@ -1557,16 +1549,16 @@ cur_text->text_link= section_flag;
/*:97*/
-#line 1456 "ctangle.w"
+#line 1440 "ctangle.w"
/*:95*/
-#line 1408 "ctangle.w"
+#line 1392 "ctangle.w"
}
/*:90*//*98:*/
-#line 1477 "ctangle.w"
+#line 1461 "ctangle.w"
static void
phase_one(void){
@@ -1579,7 +1571,7 @@ check_complete();
}
/*:98*//*100:*/
-#line 1493 "ctangle.w"
+#line 1477 "ctangle.w"
static void
skip_limbo(void)
@@ -1593,7 +1585,7 @@ char c= *loc++;
switch(ccode[(eight_bits)c]){
case new_section:return;
case translit_code:/*102:*/
-#line 1523 "ctangle.w"
+#line 1507 "ctangle.w"
while(xisspace(*loc)&&loc<limit)loc++;
loc+= 3;
@@ -1607,7 +1599,7 @@ char*beg;
sscanf(loc-3,"%x",&i);
while(xisspace(*loc)&&loc<limit)loc++;
beg= loc;
-while(loc<limit&&(xisalpha(*loc)||xisdigit(*loc)||*loc=='_'))loc++;
+while(loc<limit&&(xisalpha(*loc)||xisdigit(*loc)||isxalpha(*loc)))loc++;
if(loc-beg>=translit_length)
err_print("! Replacement string in @l too long");
@@ -1618,7 +1610,7 @@ translit[i-0200][loc-beg]= '\0';
}
/*:102*/
-#line 1505 "ctangle.w"
+#line 1489 "ctangle.w"
break;
case format_code:case'@':break;
case control_text:if(c=='q'||c=='Q'){
@@ -1636,7 +1628,7 @@ default:err_print("! Double @ should be used in limbo");
}
/*:100*//*103:*/
-#line 1549 "ctangle.w"
+#line 1533 "ctangle.w"
void
print_stats(void){