3
created with UNIX on "Thursday, September 24, 1998 at 16:12." \
4
COMMAND LINE: "Web/ftangle Web/ftangle -A -# --F -= 1.62/Web/ftangle.c"\
5
RUN TIME: "Friday, September 25, 1998 at 8:02."\
6
WEB FILE: "Web/ftangle.web"\
14
#define SILENT (boolean)NO
15
#define COMPLAIN (boolean)YES \
17
#define OUTER_MACRO 0xFF
18
#define OUTER_UNMACRO 0xFE
19
#define UNDEFINED_MACRO 0xFD \
21
#define MAX_XLEVELS 200 \
23
#define equiv equiv_or_xref
24
#define EQUIV ASCII HUGE* \
28
#define MAC_LOOKUP(cur_val)(cur_val<MODULE_NAME? \
29
(text_pointer)(name_dir+(cur_val))->equiv:NULL) \
37
#define DEFERRED_MACRO 1 \
39
#define IMMEDIATE_MACRO 2
43
#define MCHECK(n,reason)if(mp+(n)>macrobuf_end) \
44
mbuf_full((unsigned long)(n),(outer_char*)reason) \
46
#define RST_LAST_EXPR {plast_char= last_char;last_xpr_overflowed= NO;} \
48
#define INDENT_SIZE 2 \
54
#define OUT_FILE outp_file[lan_num(out_language)] \
57
#define C_printf(c,a) \
59
if(!out_file)open_out(OC(""),YES); \
60
if(fprintf(out_file,c,a)<0)out_error(OC("fprintf")); \
63
#define NOT_CONTINUATION 0
64
#define CONTINUATION 1 \
66
#define N_STRBUF 150 \
68
#define send_new_line RST_LAST_EXPR flush0();PUTC('\n') \
70
#define NEWLINE_TO_FORTRAN(continuation_flag) \
72
rst_out(continuation_flag) \
75
#define TO_BUFFER(type) \
78
px= t_style.meta[lan_num(language)].msg.type; \
79
STRCPY(outp_buf,px); \
80
out_pos= STRLEN(px); \
83
#define CUR_BUF (pai->text_buf[pai->ilevel]) \
85
#define module_flag (sixteen_bits)max_texts \
88
#define cur_end cur_state.end_field
89
#define cur_byte cur_state.byte_field
90
#define cur_name cur_state.name_field
91
#define cur_repl cur_state.repl_field
92
#define cur_mod cur_state.mod_field \
94
#define cur_language cur_state.language
95
#define cur_global_language cur_state.global_params.Language \
99
#define cur_params cur_state.params
100
#define cur_global_params cur_state.global_params \
103
#define macrobuf cur_state.macro_buf
104
#define cur_mp cur_state.mp
105
#define macrobuf_end cur_state.macro_buf_end \
107
#define UNNAMED_MODULE 0 \
109
#define UNNAMED_MOD "unnamed"
110
#define flush_buffer()C_putc('\n') \
112
#define NEWLINE puts("") \
114
#define BP_MARKER 1 \
116
#define PROPER_END(end) \
117
end= (np+1)->byte_start; \
118
if(*end==BP_MARKER&&np!=npmax)end= ((BP*)end)->byte_start \
120
#define MAX_ID_LENGTH 32 \
122
#define GLOBAL_SCOPE YES
123
#define LOCAL_SCOPE NO \
125
#define CHECK_OPEN if(!out_file)open_out(OC(""),GLOBAL_SCOPE) \
127
#define OUT_OP(s)out_op(OC(s))
128
#define OUT_STR(s)out_str(OC(s)) \
130
#define F_OP(op77,op88)(Fortran88?op88:op77) \
132
#define LINE_CHAR '@' \
134
#define stringg (eight_bits)02
135
#define constant (eight_bits)03
136
#define begin_Xmeta or_or
137
#define end_Xmeta star_star
138
#define cdir (eight_bits)06
139
#define colon_colon (eight_bits)011 \
141
#define join (eight_bits)0177 \
144
#define TOKEN1(a)((a)<ID0) \
146
#define MACRO_ARGUMENT 0377 \
150
#define MODULE_NAME 10240
151
#define MODULE_NUM 20480
152
#define LINE_NUM 53248L \
154
#define IDENTIFIER(left,right) \
155
((sixteen_bits)(((left)-ID0)*BASE2+(sixteen_bits)(right))) \
158
#define LEFT(a,id)((eight_bits)(((a)/BASE2+(id)))) \
160
#define RIGHT(a)((eight_bits)(((a)%BASE2))) \
164
#define begin_comment0 (eight_bits)0376
165
#define begin_comment1 (eight_bits)0375 \
167
#define module_number (eight_bits)0201
168
#define identifier (eight_bits)0202
169
#define id_keyword (eight_bits)0203 \
171
#define L_switch (eight_bits)0257
172
#define begin_FORTRAN (eight_bits)0260
173
#define begin_RATFOR (eight_bits)0261
174
#define begin_C (eight_bits)0262
175
#define begin_LITERAL (eight_bits)0263 \
177
#define verbatim (eight_bits)0264 \
180
#define invisible_cmnt (eight_bits)0265
181
#define compiler_directive (eight_bits)0266
182
#define Compiler_Directive (eight_bits)0267 \
184
#define keyword_name (eight_bits)0270 \
186
#define no_index (eight_bits)0300
187
#define yes_index (eight_bits)0301 \
189
#define ascii_constant (eight_bits)0302
190
#define begin_vcmnt (eight_bits)0303
191
#define big_line_break (eight_bits)0304 \
193
#define begin_bp (eight_bits)0305
194
#define insert_bp (eight_bits)0306 \
196
#define begin_meta (eight_bits)017
197
#define end_meta (eight_bits)027 \
199
#define TeX_string (eight_bits)0307
200
#define xref_roman (eight_bits)0310
201
#define xref_typewriter (eight_bits)0311
202
#define xref_wildcard (eight_bits)0312 \
204
#define control_text (eight_bits)0313 \
206
#define begin_nuweb (eight_bits)0314
207
#define no_mac_expand (eight_bits)0315
208
#define set_line_info (eight_bits)0316
209
#define short_fcn (eight_bits)0317 \
211
#define formatt (eight_bits)0320 \
213
#define limbo_text (eight_bits)0323
214
#define op_def (eight_bits)0324
215
#define macro_def (eight_bits)0325 \
217
#define ignore_defn (eight_bits)0327 \
219
#define new_output_file (eight_bits)0331 \
221
#define definition (eight_bits)0332
222
#define undefinition (eight_bits)0333
223
#define WEB_definition (eight_bits)0334 \
225
#define m_ifdef (eight_bits)0335
226
#define m_ifndef (eight_bits)0336
227
#define m_if (eight_bits)0337
228
#define m_else (eight_bits)0340
229
#define m_elif (eight_bits)0341
230
#define m_endif (eight_bits)0342
231
#define m_for (eight_bits)0343
232
#define m_endfor (eight_bits)0344
233
#define m_line (eight_bits)0345
234
#define m_undef (eight_bits)0346 \
236
#define end_of_buffer (eight_bits)0347 \
238
#define begin_code (eight_bits)0350
239
#define module_name (eight_bits)0351 \
241
#define new_module (eight_bits)0352 \
243
#define MAYBE_SET_OUTPUT(l)if(last_char!=0174)set_output_file(l) \
245
#define RETURN(pcode)return(eight_bits)pcode \
247
#define compress(c)if(loc++<=limit)return(eight_bits)(c)
248
#define Fcompress(c)if(is_FORTRAN_(language)&&loc<limit) \
249
return(eight_bits)(c)
250
#define STOP (boolean)YES
251
#define DONT_STOP (boolean)NO \
254
#define app_repl(c){if(tok_ptr==tok_m_end) \
255
OVERFLW("tokens","tt"); \
256
*tok_ptr++= (eight_bits)(c);} \
258
#define BP_BUF_SIZE (13+MAX_ID_LENGTH) \
265
err0_print(ERR_T,OC("Construction too big to convert on \
266
this machine; max is 0x%x"),1,ULONG_MAX); \
268
#define MAX_LEVEL 20 \
274
#define DEF_OR_NDEF(flag) \
279
goto next_macro_token; \
284
if((next_control= get_next())!=identifier) \
287
err0_print(ERR_T,OC("Expected identifier after @#ifdef \
288
or @#ifndef; assuming not defined"),0); \
292
BOOLEAN(flag((m= MAC_LOOKUP(ID_NUM(id_first,id_loc)))!=NULL \
293
&&!(m->built_in))); \
299
scan_text(text_type,p,if_switch); \
303
expand= NO;to_else(); \
305
if(next_control!=m_endif) \
308
goto next_macro_token; \
312
next_control= ignore; \
331
#define OUT_OF_ORDER(cmd)out_of_order((outer_char*)cmd) \
333
#define IS_PROTECTED(np)((npq= (text_pointer)(np->equiv))&&npq->protected) \
335
#define LKWD "$L_KEYWORD" \
337
#define SPCS_AFTER_CMNT 1 \
345
#if(part != 1 && part != 2 && part != 3)
353
#if(part == 0 || part == 1)
354
#define part1_or_extern
355
#define SET1(stuff) = stuff
356
#define TSET1(stuff) = stuff
358
#define part1_or_extern extern
367
#include "typedefs.h"
381
typedef enum{BAD_TOKEN,OR_OR,AND_AND,BIT_OR,BIT_XOR,BIT_AND,LOG_EQ,LOG_LT,
382
BIT_SHIFT,PLUS_MINUS,TIMES,EXP,UNARY,HIGHEST_UNARY}PRECEDENCE;
388
PRECEDENCE precedence;
402
typedef enum{Int,Double,Id,Op}TYPE;
410
struct val HUGE*last,HUGE*next;
418
sixteen_bits token[MAX_XLEVELS];
428
outer_char HUGE*start,HUGE*pos,HUGE*end;
435
TEXT_BUF HUGE*HUGE*text_buf;
436
TEXT_BUF HUGE*last_buf;
439
EXTERN PAREN_LEVEL HUGE*paren_level,HUGE*paren_level_end,HUGE*pai;
441
EXTERN int rparen TSET(NO);
448
eight_bits HUGE*tok_start;
450
sixteen_bits text_link;
463
typedef text HUGE*text_pointer;
468
eight_bits HUGE*end_field;
469
eight_bits HUGE*byte_field;
470
name_pointer name_field;
471
text_pointer repl_field;
472
sixteen_bits mod_field;
473
PARAMS global_params,params;
474
eight_bits HUGE*macro_buf,HUGE*mp,HUGE*macro_buf_end;
478
typedef output_state HUGE*stack_pointer;
483
IN_COMMON boolean truncate_ids;
484
IN_COMMON unsigned short tr_max[];
485
IN_COMMON name_pointer npmax;
493
CONST ASCII HUGE*byte_start,HUGE*byte_end;
497
struct Trunc HUGE*Root;
504
size_t num[NUM_LANGUAGES];
506
ASCII HUGE*id,HUGE*id_end;
507
BP HUGE*first,HUGE*last;
508
struct Trunc HUGE*next;
515
ASCII HUGE*start,HUGE*end;
530
#define N_MSGBUF 2000
532
#define N_MSGBUF 10000
539
IN_COMMON STMT_LBL max_stmt;
541
EXTERN sixteen_bits outp_line[NUM_LANGUAGES]
543
#if(part == 0 || part == 1)
552
EXTERN int indnt_size SET(INDENT_SIZE);
555
EXTERN outer_char HUGE*last_char,HUGE*last_end;
556
EXTERN outer_char HUGE*plast_char;
557
EXTERN BUF_SIZE max_expr_chars;
559
EXTERN boolean last_xpr_overflowed SET(NO);
561
EXTERN int indent_level SET(0);
566
EXTERN outer_char HUGE*C_buffer,HUGE*pC_end;
567
EXTERN outer_char HUGE*pC_buffer;
568
EXTERN BUF_SIZE C_buf_size;
571
EXTERN outer_char HUGE*split_pos;
574
EXTERN outer_char HUGE*X_buffer,HUGE*pX_end;
575
EXTERN outer_char HUGE*pX_buffer;
576
EXTERN BUF_SIZE X_buf_size;
580
EXTERN int rst_pos SET(0);
581
EXTERN int out_pos SET(0);
582
EXTERN boolean in_string SET(NO);
583
EXTERN boolean in_constant SET(NO);
584
EXTERN boolean started_vcmnt SET(NO);
585
EXTERN boolean meta_mode SET(NO);
589
IN_COMMON outer_char outp_buf[];
590
IN_COMMON int nbuf_length;
591
EXTERN boolean out_at_beginning SET(YES);
595
EXTERN long max_texts;
596
EXTERN text HUGE*text_info;
597
EXTERN text_pointer text_end;
599
EXTERN long dtexts_max;
600
EXTERN text HUGE*txt_dinfo;
601
EXTERN text_pointer textd_end;
603
EXTERN text_pointer text_ptr,txt_dptr;
606
EXTERN long max_toks;
607
EXTERN eight_bits HUGE*tok_mem;
608
EXTERN eight_bits HUGE*tok_m_end;
610
EXTERN long max_dtoks;
611
EXTERN eight_bits HUGE*tok_dmem;
612
EXTERN eight_bits HUGE*tokd_end;
614
EXTERN eight_bits HUGE*tok_ptr,HUGE*tok_dptr;
616
EXTERN eight_bits HUGE*mx_tok_ptr,HUGE*mx_dtok_ptr;
619
EXTERN text_pointer macro_text;
624
EXTERN text_pointer last_unnamed;
629
EXTERN output_state cur_state;
632
EXTERN long stck_size;
633
EXTERN output_state HUGE*stack;
634
EXTERN stack_pointer stck_end;
635
EXTERN stack_pointer stck_ptr;
642
#undef begin_format_stmt
643
#define begin_format_stmt (eight_bits)014
645
#undef end_format_stmt
646
#define end_format_stmt (eight_bits)015
655
EXTERN eight_bits sent;
659
IN_RATFOR sixteen_bits id_function,id_program,id_subroutine;
663
EXTERN sixteen_bits cur_mod_no SET(0);
667
EXTERN OUTPUT_STATE out_state;
668
EXTERN boolean protect;
669
EXTERN boolean copying_macros SET(NO);
670
EXTERN boolean in_cdir SET(NO);
678
EXTERN boolean mac_protected SET(NO);
680
EXTERN boolean send_rp SET(NO);
684
EXTERN boolean in_version SET(NO);
689
EXTERN OPEN_FILE HUGE*open_file,HUGE*open_file_end,HUGE*last_file;
690
EXTERN BUF_SIZE num_files;
694
EXTERN LINE_NUMBER nearest_line SET(0);
698
IN_STYLE eight_bits ccode[128];
702
EXTERN boolean comment_continues SET(NO);
706
EXTERN name_pointer cur_module SET(NULL);
708
EXTERN boolean strt_cmnt;
709
EXTERN boolean strt_point_cmnt;
710
EXTERN boolean suppress_newline;
711
EXTERN boolean eat_blank_lines;
712
EXTERN boolean no_expand SET(NO);
713
EXTERN boolean insrt_line SET(NO);
717
EXTERN boolean starts_with_0,hex_constant,bin_constant,floating_constant;
721
EXTERN text_pointer cur_text;
723
EXTERN eight_bits next_control;
724
EXTERN boolean scanning_meta SET(NO);
725
EXTERN boolean macro_scan SET(NO);
729
EXTERN boolean breakpoints;
733
EXTERN int n_unique SET(0);
734
EXTERN boolean deferred_macro SET(NO);
738
EXTERN boolean is_WEB_macro SET(NO);
739
EXTERN boolean scanning_defn;
740
EXTERN boolean scanning_TeX;
742
EXTERN boolean nuweb_mode1;
744
EXTERN int mlevel SET(0);
748
EXTERN boolean found_else SET(NO);
760
EXTERN sixteen_bits num_distinct_modules SET(1);
761
EXTERN sixteen_bits num_modules;
766
#define MSG_BUF_SIZE 5000
768
#define MSG_BUF_SIZE 50000L
775
#if(part == 0 || part == 1)
778
int main FCN((ac,av))
779
int ac C0("Number of arguments.")
780
outer_char**av C1("Argument list.")
796
ALLOC(OPEN_FILE,open_file,"nf",num_files,0);
797
last_file= open_file;
798
open_file_end= open_file+num_files;
805
ALLOC(outer_char,last_char,"lx",max_expr_chars,0);
806
last_end= last_char+max_expr_chars;
807
plast_char= last_char;
812
ALLOC(outer_char,C_buffer,"cb",C_buf_size,0);
813
pC_end= C_buffer+C_buf_size-1;
826
ALLOC(outer_char,X_buffer,"xb",X_buf_size,0);
827
pX_end= X_buffer+X_buf_size;
832
paren_level= GET_MEM("paren_level",t_style.paren.nest,PAREN_LEVEL);
833
paren_level_end= paren_level+t_style.paren.nest;
836
for(pai= paren_level;pai<paren_level_end;pai++)
837
pai->text_buf= GET_MEM("pai->text_buf",t_style.paren.num,
842
pai->text_buf[0]= pai->last_buf= calloc(1,sizeof(TEXT_BUF));
849
ALLOC(text,text_info,"x",max_texts,0);
850
text_end= text_info+max_texts-1;
852
ALLOC(text,txt_dinfo,"dx",dtexts_max,0);
853
textd_end= txt_dinfo+dtexts_max-1;
855
ALLOC(eight_bits,tok_mem,"tt",max_toks,0);
856
tok_m_end= tok_mem+max_toks-1;
858
ALLOC(eight_bits,tok_dmem,"dt",max_dtoks,0);
859
tokd_end= tok_dmem+max_dtoks-1;
863
ALLOC(output_state,stack,"kt",stck_size,1);
864
stck_end= stack+stck_size;
868
BUF_SIZE cur_num= last_file-open_file;
871
alloc((outer_char*)"nf",(BUF_SIZE HUGE*)&num_files,
872
sizeof(*open_file),-1);
875
open_file= (OPEN_FILE*)REALLOC(open_file,
876
num_files*sizeof(OPEN_FILE),cur_num*sizeof(OPEN_FILE));
877
last_file= open_file+cur_num;
878
open_file_end= open_file+num_files;
884
CAST(text_pointer,text_info)->tok_start= tok_ptr= tok_mem;
885
CAST(text_pointer,txt_dinfo)->tok_start= tok_dptr= tok_dmem;
888
text_ptr= text_info+1;text_ptr->tok_start= tok_mem;
889
txt_dptr= txt_dinfo+1;txt_dptr->tok_start= tok_dmem;
893
CAST(name_pointer,name_dir)->equiv= (EQUIV)text_info;
897
last_unnamed= text_info;
898
CAST(text_pointer,text_info)->text_link= 0;
903
ccode[057]= begin_vcmnt;
910
ini_ccode((outer_char*)"new_module",(outer_char*)" \t*",new_module);
913
ini_ccode((outer_char*)"begin_code",(outer_char*)"aA",begin_code);
915
ini_ccode((outer_char*)"module_name",(outer_char*)"<",module_name);
918
ini_ccode((outer_char*)"definition",(outer_char*)"dD",definition);
920
ini_ccode((outer_char*)"undefinition",(outer_char*)"uU",undefinition);
922
ini_ccode((outer_char*)"WEB_definition",(outer_char*)"mM",WEB_definition);
924
ini_ccode((outer_char*)"formatt",(outer_char*)"fF",formatt);
927
ini_ccode((outer_char*)"ascii_constant",(outer_char*)"'\"",ascii_constant);
929
ini_ccode((outer_char*)"verbatim",(outer_char*)"=",verbatim);
932
ini_ccode((outer_char*)"TeX_string",(outer_char*)"tT",TeX_string);
935
ini_ccode((outer_char*)"L_switch",(outer_char*)"L",L_switch);
937
ini_ccode((outer_char*)"begin_C",(outer_char*)"c",begin_C);
939
ini_ccode((outer_char*)"begin_RATFOR",(outer_char*)"r",begin_RATFOR);
941
ini_ccode((outer_char*)"begin_FORTRAN",(outer_char*)"n",begin_FORTRAN);
943
ini_ccode((outer_char*)"begin_nuweb",(outer_char*)"N",begin_nuweb);
946
ini_ccode((outer_char*)"join",(outer_char*)"&",join);
949
ini_ccode((outer_char*)"Compiler_Directive",(outer_char*)"?",Compiler_Directive);
951
ini_ccode((outer_char*)"invisible_cmnt",(outer_char*)"%",invisible_cmnt);
955
ini_ccode((outer_char*)"xref_roman",(outer_char*)"^",xref_roman);
957
ini_ccode((outer_char*)"xref_typewriter",(outer_char*)".",xref_typewriter);
959
ini_ccode((outer_char*)"xref_wildcard",(outer_char*)"9",xref_wildcard);
962
ini_ccode((outer_char*)"big_line_break",(outer_char*)"#",big_line_break);
965
ini_ccode((outer_char*)"begin_meta",(outer_char*)"(",begin_meta);
967
ini_ccode((outer_char*)"end_meta",(outer_char*)")",end_meta);
970
ini_ccode((outer_char*)"limbo_text",(outer_char*)"l",limbo_text);
972
ini_ccode((outer_char*)"op_def",(outer_char*)"vV",op_def);
974
ini_ccode((outer_char*)"macro_def",(outer_char*)"wW",macro_def);
976
ini_ccode((outer_char*)"short_fcn",(outer_char*)"{",short_fcn);
979
ini_ccode((outer_char*)"begin_bp",(outer_char*)"B",begin_bp);
981
ini_ccode((outer_char*)"insert_bp",(outer_char*)"}b",insert_bp);
984
ini_ccode((outer_char*)"no_mac_expand",(outer_char*)"!",no_mac_expand);
986
ini_ccode((outer_char*)"set_line_info",(outer_char*)"q",set_line_info);
989
ini_ccode((outer_char*)"new_output_file",(outer_char*)"oO",new_output_file);
992
ini_ccode((outer_char*)"USED_BY_OTHER",(outer_char*)"\001",USED_BY_OTHER);
995
ini_ccode((outer_char*)"USED_BY_OTHER",(outer_char*)"/",USED_BY_OTHER);
998
ini_ccode((outer_char*)"USED_BY_OTHER",(outer_char*)"\\",USED_BY_OTHER);
1000
ini_ccode((outer_char*)"USED_BY_OTHER",(outer_char*)"_",USED_BY_OTHER);
1002
ini_ccode((outer_char*)"USED_BY_OTHER",(outer_char*)"[",USED_BY_OTHER);
1004
ini_ccode((outer_char*)"USED_BY_OTHER",(outer_char*)"`]",USED_BY_OTHER);
1006
ini_ccode((outer_char*)"USED_BY_OTHER",(outer_char*)"$",USED_BY_OTHER);
1009
ini_ccode((outer_char*)"keyword_name",(outer_char*)"kK",keyword_name);
1014
sprintf(temp,";%c",XCHR(interior_semi));
1016
ini_ccode((outer_char*)"USED_BY_OTHER",(outer_char*)temp,USED_BY_OTHER);
1019
ini_ccode((outer_char*)"USED_BY_OTHER",(outer_char*)"e",USED_BY_OTHER);
1021
ini_ccode((outer_char*)"USED_BY_OTHER",(outer_char*)":",USED_BY_OTHER);
1023
ini_ccode((outer_char*)"USED_BY_OTHER",(outer_char*)",",USED_BY_OTHER);
1025
ini_ccode((outer_char*)"USED_BY_OTHER",(outer_char*)"|",USED_BY_OTHER);
1027
ini_ccode((outer_char*)"USED_BY_OTHER",(outer_char*)"~",USED_BY_OTHER);
1029
ini_ccode((outer_char*)"USED_BY_OTHER",(outer_char*)"-",USED_BY_OTHER);
1031
ini_ccode((outer_char*)"USED_BY_OTHER",(outer_char*)"+",USED_BY_OTHER);
1033
ini_ccode((outer_char*)"USED_BY_OTHER",(outer_char*)"p",USED_BY_OTHER);
1036
ini_ccode((outer_char*)"USED_BY_OTHER",(outer_char*)"012",USED_BY_OTHER);
1043
reassign(xref_roman,control_text);
1044
reassign(xref_typewriter,control_text);
1045
reassign(xref_wildcard,control_text);
1046
reassign(TeX_string,control_text);
1048
reassign(verbatim,stringg);
1059
ini_internal_fcns();
1087
if(in_string&&split_pos==C_buffer)
1094
C_out(C_buffer,pC_buffer,&pC_buffer,OC("\n"),OC(""),NO_INDENT);
1103
split0_C(split_pos);
1113
C_out(C_buffer,pC_buffer,&pC_buffer,OC("\n"),OC(""),NO_INDENT);
1127
outer_char*p C1("Position for the split")
1141
C_out(C_buffer,p,&pC_buffer,OC("\n"),OC(""),indent);
1150
C_out FCN((C_buffer,p,ppC_buffer,end_str,begin_str,indent))
1151
outer_char HUGE*C_buffer C0("Buffer we're working with")
1152
outer_char HUGE*p C0("End (next available pos)")
1153
outer_char HUGE*HUGE*ppC_buffer C0("")
1154
outer_char*end_str C0("")
1155
CONST outer_char*begin_str C0("")
1156
int indent C1("Should the next buffer be indented?")
1158
int n= PTR_DIFF(int,*ppC_buffer,p);
1161
WRITE1(C_buffer,p-C_buffer)
1165
WRITE1(end_str,STRLEN(end_str))
1168
*ppC_buffer= C_buffer;
1171
*(*ppC_buffer)++= *begin_str++;
1175
*(*ppC_buffer)++= ' ';
1180
STRNCPY(*ppC_buffer,p,n);
1187
split_pos= C_buffer;
1197
outer_char c C1("Character to be sent to output.")
1199
static CONST outer_char HUGE*prefx= OC("");
1204
printf("c = '%c' (0x%x)\n",c,c);
1206
if(at_beginning&&meta_mode&&!nuweb_mode&&(in_string||in_version))
1210
pmeta= &t_style.meta[lan_num(language)];
1211
prefx= OUT_STR(in_version?pmeta->hdr.prefx:pmeta->msg.prefx);
1228
&&((pai>paren_level)||rparen||!(in_string||in_version)))
1239
if(pai->ilevel==(int)t_style.paren.num)
1240
NEW_SPRM("paren.num",t_style.paren.num);
1245
CUR_BUF= GET_MEM("CUR_BUF",1,TEXT_BUF);
1258
(pai+1)->last_buf= CUR_BUF;
1261
if(pai==paren_level_end)
1262
NEW_SPRM("paren.nest",t_style.paren.nest);
1269
CUR_BUF= GET_MEM("CUR_BUF",1,TEXT_BUF);
1293
if(in_string&&pai==paren_level)
1315
C_out(X_buffer,pX_buffer,&pX_buffer,OC(""),
1316
(outer_char HUGE*)CHOICE(meta_mode&&language==TEX,prefx,OC("")),
1318
else if(pX_buffer==pX_end)
1334
C_out(C_buffer,pC_buffer,&pC_buffer,OC(""),OC(""),NO_INDENT);
1336
else if(pC_buffer==pC_end)
1351
at_beginning= BOOLEAN(c=='\n');
1357
split_X FCN((prefx))
1358
CONST outer_char HUGE*prefx C1("")
1360
outer_char HUGE*p= pX_buffer-1;
1368
err0_print(ERR_T,OC("Line had to be broken"),0);
1369
C_out(X_buffer,pX_buffer,&pX_buffer,
1370
language==TEX?OC("%\n"):OC("\n"),
1379
C_out(X_buffer,p+1,&pX_buffer,OC("\n"),
1380
(outer_char HUGE*)CHOICE(meta_mode&&language==TEX,
1386
if(*(p--)=='\\'&&*p!='\\')
1388
C_out(X_buffer,p+1,&pX_buffer,
1389
language==TEX?OC("%\n"):OC("\n"),
1390
(outer_char HUGE*)CHOICE(meta_mode&&language==TEX,
1400
static outer_char last_out= '\0';
1403
static boolean is_label= NO;
1404
static boolean should_continue= NO;
1405
static continuation_line= NOT_CONTINUATION;
1407
static STMT_LBL stmt_num[50];
1409
static short do_level= 0;
1413
C_sprintf FCN(VA_ALIST((fmt,n VA_ARGS)))
1415
CONST outer_char fmt[]C0("String to be printed.")
1416
int n C2("Number of arguments to follow."))
1419
outer_char temp[N_STRBUF];
1422
VA_START(arg_ptr,n);
1426
char*fmt0= va_arg(arg_ptr,char*);
1428
va_arg(arg_ptr,int);
1429
vsprintf((char*)(char*)temp,fmt0,arg_ptr);
1432
vsprintf((char*)temp,(CONST char*)fmt,arg_ptr);
1444
outer_char c C1("Output this character to \Ratfor.")
1453
if(meta_mode)return;
1458
if(meta_mode)PUTC('#');
1471
outer_char c C1("Output this character to the \Fortran\ buffer.")
1478
if(compound_assignments&&!send_rp)
1479
if(plast_char>=last_end)
1480
last_xpr_overflowed= YES;
1488
case '\0':if(!in_string)
1493
if(in_string&&started_vcmnt)
1495
NEWLINE_TO_FORTRAN(should_continue);
1504
if(!in_string&&xpn_Ratfor)
1510
if(out_at_beginning)
1521
else if(!in_string||(in_string&&started_vcmnt))
1523
NEWLINE_TO_FORTRAN(NOT_CONTINUATION);
1525
if(in_string&&started_vcmnt)
1532
outp_buf[0]= begin_comment_char[lan_num(out_language)];
1534
for(out_pos= 1,k= spcs_after_cmnt;k;k--)
1535
outp_buf[out_pos++]= ' ';
1538
nbuf_length= MAX(t_style.output_line_length[lan_num(out_language)],80);
1539
out_at_beginning= NO;
1544
else if(!started_vcmnt)
1547
should_continue= BOOLEAN(out_pos>rst_pos);
1551
{NEWLINE_TO_FORTRAN(NOT_CONTINUATION);}
1553
should_continue= BOOLEAN((!free_Fortran)&&should_continue);
1560
outp_buf[0]= begin_comment_char[lan_num(out_language)];
1562
for(out_pos= 1,k= spcs_after_cmnt;k;k--)
1563
outp_buf[out_pos++]= ' ';
1566
nbuf_length= MAX(t_style.output_line_length[lan_num(out_language)],80);
1567
out_at_beginning= NO;
1582
if(!(in_string||in_constant))
1585
outp_buf[out_pos++]= ';';
1589
NEWLINE_TO_FORTRAN(NOT_CONTINUATION);
1601
if(!meta_mode&&last_out!='\n')
1610
rst_out(NOT_CONTINUATION);
1624
rst_out(NOT_CONTINUATION);
1630
if(out_pos>=nbuf_length)
1633
outp_buf[out_pos++]= '&';
1636
rst_out(CONTINUATION);
1638
if(in_string&&started_vcmnt)
1645
outp_buf[0]= begin_comment_char[lan_num(out_language)];
1647
for(out_pos= 1,k= spcs_after_cmnt;k;k--)
1648
outp_buf[out_pos++]= ' ';
1651
nbuf_length= MAX(t_style.output_line_length[lan_num(out_language)],80);
1652
out_at_beginning= NO;
1658
if(out_at_beginning)
1660
out_at_beginning= NO;
1665
if(isdigit(c)&&!is_label)
1670
else if(c==LINE_CHAR)
1672
outp_buf[0]= t_style.line_char[lan_num(language)];
1684
if(is_label&&!isdigit(c))
1687
out_pos= 6+indent_level*INDENT_SIZE;
1694
if(number_dos&&!continuation_line&&(language==FORTRAN||
1695
language==FORTRAN_90||R66))
1697
outer_char HUGE*do_pos;
1703
if(STRNCMP(do_pos,"do ",3)==0&&!isdigit(c))
1705
sprintf((char*)(do_pos+= 3),"%lu ",
1706
stmt_num[do_level++]= max_stmt++);
1708
while(*do_pos++!='\0')
1712
else if((out_pos==10&&STRNCMP(do_pos,"endd",4)==0)||
1713
(out_pos==11&&STRNCMP(do_pos,"end d",5)==0))
1718
err0_print(ERR_T,OC("Too many END DOs"),0);
1723
sprintf((char*)outp_buf,"%-5lu CONTINUE",
1724
stmt_num[--do_level]);
1734
last_out= outp_buf[out_pos++]= c;
1742
flush_out FCN((prn_new_line))
1743
boolean prn_new_line C1("Do we print a newline?")
1745
outp_buf[out_pos]= '\0';
1748
WRITE1(outp_buf,out_pos)
1761
rst_out FCN((continuation))
1762
boolean continuation C1("Is line a continuation?")
1769
for(out_pos= 0;out_pos<5;++out_pos)
1770
outp_buf[out_pos]= ' ';
1773
outp_buf[out_pos++]= continuation?t_style.cchar:(outer_char)' ';
1774
continuation_line= continuation;
1775
out_at_beginning= BOOLEAN(!continuation_line);
1777
nbuf_length= t_style.output_line_length[lan_num(out_language)];
1781
if(!in_string||in_version)
1783
outp_buf[0]= begin_comment_char[lan_num(out_language)];
1786
out_pos= 1+spcs_after_cmnt;
1789
nbuf_length= MAX(nbuf_length,80);
1794
if(out_at_beginning&&xpn_Ratfor)
1795
blank_out(indent_level);
1797
return rst_pos= out_pos;
1804
int n C1("Number of levels to indent.")
1809
for(i= 0,p= outp_buf+out_pos;i<n*INDENT_SIZE;i++)*p++= ' ';
1819
TEXT_BUF HUGE*t C0("")
1822
if(pai==paren_level||t==paren_level[0].last_buf)
1831
t->pos= t->start= GET_MEM("t->start",t_style.paren.len,outer_char);
1832
t->end= t->start+t_style.paren.len;
1837
size_t len= PTR_DIFF(size_t,t->end,t->start);
1839
t->start= (outer_char*)REALLOC(t->start,len+t_style.paren.len,len);
1840
t->pos= t->start+len;
1841
t->end= t->start+len+t_style.paren.len;
1856
if(pai==paren_level)
1859
err0_print(ERR_T,OC("Missing '('"),0);
1864
for(i= pai->ilevel;i>=0;i--)
1866
t= pai->text_buf[i];
1868
for(s1= t->start;s1<t->pos;s1++)
1869
store(pai->last_buf,*s1);
1874
store(pai->last_buf,',');
1877
store(pai->last_buf,')');
1884
boolean names_match FCN((p,first,l,dummy))
1885
name_pointer p C0("Points to the proposed match.")
1886
CONST ASCII HUGE*first C0("Position of first character of string.")
1887
int l C0("length of identifier.")
1888
eight_bits dummy C1("Not used here")
1890
if(length(p)!=l)return NO;
1891
return(boolean)(!STRNCMP(first,p->byte_start,l));
1897
ini_node FCN((node))
1898
CONST name_pointer node C1("")
1900
node->equiv= (EQUIV)text_info;
1905
node->mod_info= GET_MEM("mod_info",1,MOD_INFO);
1907
node->mod_info->Ilk= expr;
1908
node->mod_info->params= params;
1909
node->mod_info->params.uses= 0;
1911
node->Language= (boolean)language;
1922
name_pointer p C0("")
1933
store_two_bytes FCN((x))
1934
sixteen_bits x C1("Two-byte token to be entered into |tok_mem|.")
1936
if(tok_ptr+2>tok_m_end)OVERFLW("tokens","tt");
1938
*tok_ptr++= (eight_bits)(x>>8);
1939
*tok_ptr++= (eight_bits)(x&0377);
1946
push_level FCN((p,b0,b1))
1947
name_pointer p C0("The new replacement text.")
1948
CONST eight_bits HUGE*b0 C0("If |p == NULL|, beginning of new \
1950
CONST eight_bits HUGE*b1 C1("If |p == NULL|, end of new stuff in \
1953
if(stck_ptr==stck_end)
1954
OVERFLW("stack levels","kt");
1958
*stck_ptr= cur_state;
1965
cur_repl= (text_pointer)p->equiv;
1969
confusion(OC("push_level"),OC("cur_repl is NULL"));
1971
cur_byte= cur_repl->tok_start;
1972
cur_end= cur_byte+cur_repl->nbytes;
1978
cur_byte= (eight_bits HUGE*)b0;
1979
cur_end= (eight_bits HUGE*)b1;
1987
(stck_ptr++)->params= cur_params= cur_global_params=
1988
(p!=NULL)?params:params;
1989
set_output_file(cur_language);
1990
cur_mod= UNNAMED_MODULE;
1998
if(cur_repl!=NULL&&cur_repl->text_link<module_flag)
2001
cur_repl= cur_repl->text_link+text_info;
2002
cur_byte= cur_repl->tok_start;
2003
cur_end= cur_byte+cur_repl->nbytes;
2006
if(cur_repl->module_text)
2008
params= cur_params= cur_global_params;
2010
set_output_file(cur_language);
2017
FREE_MEM(macrobuf,"macrobuf",mbuf_size,eight_bits);
2023
cur_state= *stck_ptr;
2026
if(cur_language!=language)
2029
set_output_file(cur_language);
2047
if(cur_byte==cur_end)
2049
cur_val= -((long)cur_mod);
2054
OUT_CHAR(module_number);
2062
return module_number;
2069
if((in_string&&!nuweb_mode)||TOKEN1(a))
2081
a= IDENTIFIER(a,*cur_byte++);
2083
switch(a/MODULE_NAME)
2089
IN_RATFOR boolean balanced;
2090
IN_RATFOR ASCII cur_delim;
2092
if(!balanced&&language==RATFOR&&
2093
(a==id_function||a==id_program||a==id_subroutine))
2096
RAT_error(ERROR,OC("Inserted missing '%c' at beginning of function"),1,XCHR(cur_delim));
2098
return OUT_CHAR(cur_delim);
2103
return OUT_CHAR(identifier);
2114
if(np->equiv!=(EQUIV)text_info)
2115
push_level(np,NULL,NULL);
2116
else if(a!=UNNAMED_MODULE)
2118
CLR_PRINTF(ERRORS_ONLY,error,("\n! Not present: "));
2119
CLR_PRINTF(ERRORS_ONLY,md_name,("<"));
2122
err0_print(ERR_NULL,OC(">. "),0);
2124
SET_COLOR(ordinary);
2127
#define TEMP_LEN 300
2129
static eight_bits temp[TEMP_LEN],temp1[TEMP_LEN];
2131
size_t n= (size_t)length(np);
2133
id_first= x__to_ASCII(OC("$STUB"));
2134
stub= ID_NUM(id_first,id_first+5);
2136
STRNCPY(temp1,np->byte_start,n);
2141
nsprintf(temp,OC("%c%c%c%c%s%c%c"),7,LEFT(stub,ID0),RIGHT(stub),050,stringg,temp1,stringg,051)>=(int)(TEMP_LEN))OVERFLW("temp","");
2142
copy_out(temp,temp+6+n,macro);
2156
cur_val= a-MODULE_NUM;
2157
if(cur_val>UNNAMED_MODULE)cur_mod= (sixteen_bits)cur_val;
2160
return OUT_CHAR(module_number);
2172
get_saved_output FCN((stck_ptr0))
2173
stack_pointer stck_ptr0 C1("")
2178
if(stck_ptr==stack||stck_ptr!=stck_ptr0)
2185
confusion(OC("get_saved_output"),OC("Shouldn't encounter top level here"));
2193
if((in_string&&!nuweb_mode)||TOKEN1(a))
2205
a= IDENTIFIER(a,*cur_byte++);
2207
switch(a/MODULE_NAME)
2213
IN_RATFOR boolean balanced;
2214
IN_RATFOR ASCII cur_delim;
2216
if(!balanced&&language==RATFOR&&
2217
(a==id_function||a==id_program||a==id_subroutine))
2220
RAT_error(ERROR,OC("Inserted missing '%c' at beginning of function"),1,XCHR(cur_delim));
2222
return OUT_CHAR(cur_delim);
2227
return OUT_CHAR(identifier);
2238
if(np->equiv!=(EQUIV)text_info)
2239
push_level(np,NULL,NULL);
2240
else if(a!=UNNAMED_MODULE)
2242
CLR_PRINTF(ERRORS_ONLY,error,("\n! Not present: "));
2243
CLR_PRINTF(ERRORS_ONLY,md_name,("<"));
2246
err0_print(ERR_NULL,OC(">. "),0);
2248
SET_COLOR(ordinary);
2251
#define TEMP_LEN 300
2253
static eight_bits temp[TEMP_LEN],temp1[TEMP_LEN];
2255
size_t n= (size_t)length(np);
2257
id_first= x__to_ASCII(OC("$STUB"));
2258
stub= ID_NUM(id_first,id_first+5);
2260
STRNCPY(temp1,np->byte_start,n);
2265
nsprintf(temp,OC("%c%c%c%c%s%c%c"),7,LEFT(stub,ID0),RIGHT(stub),050,stringg,temp1,stringg,051)>=(int)(TEMP_LEN))OVERFLW("temp","");
2266
copy_out(temp,temp+6+n,macro);
2280
cur_val= a-MODULE_NUM;
2281
if(cur_val>UNNAMED_MODULE)cur_mod= (sixteen_bits)cur_val;
2284
return OUT_CHAR(module_number);
2296
copy_out FCN((p0,p1,is_expr))
2297
CONST eight_bits HUGE*p0 C0("Start of memory buffer.")
2298
CONST eight_bits HUGE*p1 C0("End of memory buffer.")
2299
boolean is_expr C1("Flag for resetting pointer to last expression.")
2301
stack_pointer stck_ptr0;
2307
push_level(NULL,p0,p1);
2308
stck_ptr0= stck_ptr;
2310
while(get_saved_output(stck_ptr0))
2317
send_single FCN((a))
2318
sixteen_bits a C1("")
2324
case begin_language:
2326
switch(sent= *cur_byte++)
2331
a= IDENTIFIER(a,*cur_byte++);
2333
sent= new_output_file;
2338
case C:opn_output_file(C);break;
2339
case C_PLUS_PLUS:opn_output_file(C_PLUS_PLUS);break;
2341
if(!RAT_OK("(send_single)"))
2343
confusion(OC("output default"),OC("Ratfor command during output"));
2344
opn_output_file(RATFOR);
2347
if(!RAT_OK("(send_single)"))
2349
confusion(OC("output default"),OC("Ratfor command during output"));
2350
opn_output_file(RATFOR_90);
2352
case FORTRAN:opn_output_file(FORTRAN);break;
2353
case FORTRAN_90:opn_output_file(FORTRAN_90);break;
2354
case TEX:opn_output_file(TEX);break;
2355
case LITERAL:opn_output_file(LITERAL);break
2361
nuweb_mode= BOOLEAN(0x0F&sent);
2365
mac_protected= no_expand= YES;
2369
line_info= *cur_byte++;
2375
cur_val= *cur_byte++;
2388
#define TEMP_LEN (2*MAX_FILE_NAME_LENGTH)
2391
new_out FCN((global_scope,a))
2392
boolean global_scope C0("0 for local, 1 for global")
2393
sixteen_bits a C1("")
2395
name_pointer np= name_dir+a;
2396
CONST ASCII HUGE*end;
2398
outer_char temp_from[TEMP_LEN],temp_to[TEMP_LEN];
2399
outer_char temp[MAX_FILE_NAME_LENGTH];
2405
nsprintf(temp_from,OC("\n\n (This file was continued via @O from %s.)"),1,params.OUTPUT_FILE_NAME)>=(int)(TEMP_LEN))OVERFLW("temp_from","");
2411
nsprintf(temp_from,OC(" "),0)>=(int)(TEMP_LEN))OVERFLW("temp_from","");
2416
len= PTR_DIFF(size_t,end,np->byte_start);
2417
STRNCPY(temp,np->byte_start,len);
2418
TERMINATE(temp,len);
2419
to_outer((ASCII HUGE*)temp);
2420
new_fname(¶ms.OUTPUT_FILE_NAME,temp,NULL);
2425
outer_char old_name[MAX_FILE_NAME_LENGTH];
2427
STRCPY(old_name,global_params.OUTPUT_FILE_NAME);
2428
new_fname(&global_params.OUTPUT_FILE_NAME,temp,NULL);
2431
nsprintf(temp_to,OC(" (Continued via @O to %s.)"),1,params.OUTPUT_FILE_NAME)>=(int)(TEMP_LEN))OVERFLW("temp_to","");
2432
OUT_MSG(to_ASCII(temp_to),NULL);
2433
close_out(out_file,old_name);
2438
open_out(temp_from,global_scope);
2446
i_mod_name_ FCN((n,pargs))
2451
name_pointer np= cur_name;
2454
CHK_ARGS("$MODULE_NAME",0);
2457
cur_mod_no= (sixteen_bits)(np-name_dir);
2461
len= cur_mod_no?(int)length(np):STRLEN(UNNAMED_MOD);
2462
MCHECK(len,"current module name");
2465
for(p= np->byte_start;p<(np+1)->byte_start;)
2469
STRCPY(mp,UNNAMED_MOD);
2478
i_sect_num_ FCN((n,pargs))
2482
num_to_mbuf(n,pargs,"$SECTION_NUM",0,"section number",cur_mod);
2489
sixteen_bits a C1("")
2499
if(np->equiv!=(EQUIV)text_info)
2500
push_level(np,NULL,NULL);
2501
else if(a!=UNNAMED_MODULE)
2503
CLR_PRINTF(ERRORS_ONLY,error,("\n! Not present: "));
2504
CLR_PRINTF(ERRORS_ONLY,md_name,("<"));
2507
err0_print(ERR_NULL,OC(">. "),0);
2509
SET_COLOR(ordinary);
2512
#define TEMP_LEN 300
2514
static eight_bits temp[TEMP_LEN],temp1[TEMP_LEN];
2516
size_t n= (size_t)length(np);
2518
id_first= x__to_ASCII(OC("$STUB"));
2519
stub= ID_NUM(id_first,id_first+5);
2521
STRNCPY(temp1,np->byte_start,n);
2526
nsprintf(temp,OC("%c%c%c%c%s%c%c"),7,LEFT(stub,ID0),RIGHT(stub),050,stringg,temp1,stringg,051)>=(int)(TEMP_LEN))OVERFLW("temp","");
2527
copy_out(temp,temp+6+n,macro);
2553
if(msg_level>=EVERYTHING&&cur_line%100==0)
2556
{CLR_PRINTF(EVERYTHING,line_num,("%u",cur_line));}
2559
CLR_PRINTF(EVERYTHING,info,("."));
2576
params= global_params;
2578
set_output_file(global_language);
2581
rst_out(NOT_CONTINUATION);
2583
if(msg_level>=SHORT_INFO)
2585
CLR_PRINTF(SHORT_INFO,info,("\nWriting the %soutput file(s):",
2586
compare_outfiles?"temporary ":""));
2593
if(CAST(text_pointer,text_info)->text_link==0)
2595
CLR_PRINTF(WARNINGS,warning,("\n! No program text was specified."));
2611
printf("\nTruncating %u identifiers...",
2612
PTR_DIFF(unsigned,name_ptr,name_dir));
2614
for(np= name_dir+1;np<name_ptr;np++)
2617
printf("\n%u truncation(s) performed.",n);
2630
cur_repl= CAST(text_pointer,text_info)->text_link+text_info;
2631
cur_byte= cur_repl->tok_start;
2632
cur_end= cur_byte+cur_repl->nbytes;
2634
cur_mod= UNNAMED_MODULE;
2636
params= cur_params= cur_global_params= global_params;
2644
text_pointer cur_text;
2648
copying_macros= YES;
2650
for(cur_text= text_info+1;cur_text<text_ptr;cur_text++)
2651
if(cur_text->text_link==macro)
2653
cur_byte= cur_text->tok_start;
2654
cur_end= cur_byte+cur_text->nbytes;
2657
BOOLEAN(!((is_def= BOOLEAN(cur_text->nargs==OUTER_MACRO))||
2658
cur_text->nargs==OUTER_UNMACRO));
2664
see_macro(cur_byte,cur_end)
2672
T_OUTER*po= &t_style.outer_start[lan_num(language)];
2673
outer_char*outer_macro;
2675
out_state= MISCELLANEOUS;
2677
set_output_file((LANGUAGE)cur_text->Language);
2682
outer_macro= OC(is_def?po->def:po->undef);
2683
language0= language;
2685
C_sprintf(outer_macro,0);
2688
push_level(NULL,cur_byte,cur_end);
2693
if(DONE_LEVEL&&!pop_level())
2698
if(cur_byte==cur_end&&a==012)
2710
a= IDENTIFIER(a,*cur_byte++);
2715
OUT_CHAR(identifier);
2717
else if(a!=MODULE_NUM)
2720
confusion(OC("copy outer"),OC("Macros defs have strange char 0x%x"),a);
2724
cur_mod= (sixteen_bits)(a-MODULE_NUM);
2725
cur_val= (long)cur_mod;
2726
OUT_CHAR(module_number);
2734
cur_state= *stck_ptr;
2737
set_output_file(language0);
2744
FREE_MEM(cur_text->tok_start,
2745
"macro space",cur_text->nbytes,eight_bits);
2760
cur_repl= CAST(text_pointer,text_info)->text_link+text_info;
2761
cur_byte= cur_repl->tok_start;
2762
cur_end= cur_byte+cur_repl->nbytes;
2764
cur_mod= UNNAMED_MODULE;
2766
params= cur_params= cur_global_params= global_params;
2777
if(compare_outfiles)
2780
CLR_PRINTF(SHORT_INFO,info,("\nDone."));
2786
out_version FCN((msg))
2787
CONST outer_char*msg C1("")
2789
outer_char HUGE*temp= GET_MEM("version:temp",N_MSGBUF,outer_char);
2790
boolean in_string0= in_string;
2791
OUTPUT_STATE out_state0= out_state;
2795
nsprintf(temp,OC(" FTANGLE v%s,\n created with %s on \"%s, %s at %s.\" %s\n"),6,"1.61",the_system,"Friday","September 25, 1998","8:02",local_banner)>=(int)(N_MSGBUF))OVERFLW("temp","");
2796
STRCAT(temp,cmd_ln_buf);
2803
OUT_MSG(to_ASCII(temp),NULL);
2804
FREE_MEM(temp,"version:temp",N_MSGBUF,outer_char);
2807
in_string= in_string0;
2808
out_state= out_state0;
2814
rst_out(NOT_CONTINUATION);
2817
if(FORTRAN_LIKE(language))
2821
rst_out(NOT_CONTINUATION);
2828
i_version_ FCN((n,pargs))
2832
CHK_ARGS("$VERSION",0);
2840
i_tm_ FCN((n,pargs))
2854
macro_err(OC("! Argument of $TM must be numerical constant"),YES);
2868
MCHECK(2,"the_cdate");
2870
mcopy(the_cdate(t));
2880
macro_err(OC("! Invalid case in _tm_"),YES);
2889
CONST outer_char*s C1("")
2894
STRCPY(mp,x_to_ASCII(s));
2903
TRUNC HUGE*s,HUGE*HUGE*ss,HUGE*HUGE*ss0,HUGE*HUGE*ss1;
2909
boolean found_dup= NO;
2911
for(l= 0;l<NUM_LANGUAGES;l++)
2913
Language= lan_enum(l);
2918
for(s= &sh;s->next;s= s->next)
2920
if(!((boolean)s->Language&(boolean)Language))continue;
2925
unsigned len= tr_max[l];
2927
sprintf(temp,len?"%u":"*",len);
2931
printf("\n\n%c! Non-unique \
2932
%s variables (filtered with {%s}, truncated to length %s):",
2933
beep(1),languages[l],filter_char[l],temp);
2943
ss1= ss0= ss= GET_MEM("ss",n,TRUNC HUGE*);
2946
for(s= &sh;s->next;s= s->next)
2948
if(!((boolean)s->Language&(boolean)Language))continue;
2953
num_max= MAX(num_max,s->num[l]);
2958
QSORT(ss0,n,sizeof(TRUNC HUGE*),cmpr_trunc);
2961
bb0= GET_MEM("bb",num_max,BP HUGE*);
2964
see_dup(*ss1++,Language,bb0);
2966
FREE_MEM(ss0,"ss",n,TRUNC HUGE*);
2967
FREE_MEM(bb0,"bb",num_max,BP HUGE*);
2975
see_dup FCN((s,Language,bb0))
2976
CONST TRUNC HUGE*s C0("")
2977
LANGUAGE Language C0("")
2978
BP HUGE*HUGE*bb0 C1("")
2980
BP HUGE*b,HUGE*HUGE*bb,HUGE*HUGE*bb1;
2985
n= see(s->id,s->id_end);
2988
for(n= tr_max[lan_num(Language)]+1-n;n>0;n--)printf(" ");
2992
for(b= s->first,bb= bb0;b!=NULL;b= b->next)
2994
if(!((boolean)b->Language&(boolean)Language))continue;
2999
QSORT(bb0,bb-bb0,sizeof(BP HUGE*),cmpr_bp);
3001
for(bb1= bb0;bb1<bb;bb1++)
3004
see((*bb1)->byte_start,(*bb1)->byte_end);
3010
CONST ASCII HUGE*c0 C0("Beginning.")
3011
CONST ASCII HUGE*c1 C1("end.")
3013
int n= PTR_DIFF(int,c1,c0);
3016
printf("%c",XCHR(*c0++));
3024
cmpr_trunc FCN((t0,t1))
3025
TRUNC HUGE**t0 C0("")
3026
TRUNC HUGE**t1 C1("")
3028
switch(web_strcmp((*t0)->id,(*t0)->id_end,(*t1)->id,(*t1)->id_end))
3045
int cmpr_bp FCN((bb0,bb1))
3049
switch(web_strcmp((*bb0)->byte_start,(*bb0)->byte_end,
3050
(*bb1)->byte_start,(*bb1)->byte_end))
3070
BP HUGE*b_link FCN((s,Language,p0,p1))
3072
LANGUAGE Language C0("")
3073
CONST ASCII HUGE*p0 C0("")
3074
CONST ASCII HUGE*p1 C1("")
3078
bp= GET_MEM("bp",1,BP);
3083
bp->Language= Language;
3091
s->Language|= (boolean)Language;
3092
s->num[lan_num(Language)]++;
3099
TRUNC HUGE*s_link FCN((s,id,len))
3100
TRUNC HUGE*s C0("Points to the current structure, to be \
3102
CONST ASCII HUGE*id C0("Truncated identifier.")
3103
unsigned short len C1("Length of truncated identifier.")
3106
s->id= GET_MEM("s->id",len,ASCII);
3107
STRNCPY(s->id,id,len);
3108
s->id_end= s->id+len;
3111
s->next= GET_MEM("s->next",1,TRUNC);
3118
name_pointer id0_lookup FCN((start,end,l))
3119
CONST ASCII HUGE*start C0("Start of name.")
3120
CONST ASCII HUGE*end C0("end of name.")
3124
CONST ASCII HUGE*p0,HUGE*p1;
3126
for(np= name_dir+1;np<name_ptr;np++)
3128
if(!(np->Language&(boolean)l)||
3129
np->equiv!=NULL||*(p0= np->byte_start)==BP_MARKER)
3134
if(web_strcmp(p0,p1,start,end)==EQUAL)
3145
CONST name_pointer np0 C1("Points to current id structure.")
3147
CONST ASCII HUGE*p,HUGE*p0,HUGE*p1;
3148
ASCII temp[N_IDBUF];
3153
unsigned short nmax;
3158
if(np0->Language==(boolean)NO_LANGUAGE||np0->equiv!=NULL)
3161
for(l= 0;l<NUM_LANGUAGES;l++)
3163
Language= lan_enum(l);
3169
if((nmax= tr_max[l])==0||!(np->Language&(boolean)Language)
3170
||(np->reserved_word&(boolean)Language)
3171
||(np->intrinsic_word&(boolean)Language)
3172
||(np->keyword&(boolean)Language)
3173
||(np->macro_type!=NOT_DEFINED))
3185
for(p= p0,t= temp,n= 0;p<p1&&n<nmax;p++)
3186
if(STRCHR(filter_char[l],(int)XCHR(*p))==NULL)
3192
n= PTR_DIFF(unsigned short,t,temp);
3200
for(s= &sh;s->next!=NULL;s= s->next)
3201
if(s->id_end-s->id==(long)n&&
3202
web_strcmp(s->id,s->id_end,temp,t)==EQUAL)
3205
s->last= s->last->next= b_link(s,Language,p0,p1);
3207
np->byte_start= (ASCII*)s->last;
3212
s= s_link(s,temp,n);
3213
s->first= s->last= b_link(s,Language,p0,p1);
3214
np->byte_start= (ASCII*)s->first;
3218
if((np= id0_lookup(temp,t,(LANGUAGE)np->Language))!=NULL)
3220
p0= np->byte_start;PROPER_END(p1);
3233
open_out FCN((msg,global_scope))
3234
CONST outer_char*msg C0("")
3235
boolean global_scope C1("")
3237
boolean is_stdout= BOOLEAN(STRCMP(params.OUTPUT_FILE_NAME,"stdout")==0);
3238
boolean already_opened= NO;
3241
out_file= params.OUT_FILE= stdout;
3244
already_opened= was_opened(params.OUTPUT_FILE_NAME,global_scope,
3247
params.OUT_FILE= out_file;
3251
if(top_version&&!(already_opened||compare_outfiles))
3259
cur_global_params.OUT_FILE= global_params.OUT_FILE= out_file;
3264
CLR_PRINTF(SHORT_INFO,out_file,("(%s)%s",(char*)params.OUTPUT_FILE_NAME,
3265
is_stdout?"\n":""));
3272
boolean was_opened FCN((file_name,global_scope,pname,pfile_ptr))
3273
CONST outer_char HUGE*file_name C0("")
3274
boolean global_scope C0("")
3275
outer_char HUGE*HUGE*pname C0("")
3276
FILE**pfile_ptr C1("")
3282
*pname= (outer_char HUGE*)"";
3288
for(f= open_file;f<last_file;f++)
3289
if(STRCMP(f->name,file_name)==0)
3295
return f->previously_opened;
3304
if(last_file==open_file_end)
3306
OVERFLW("previously opened files","nf");
3309
last_file->name= GET_MEM("last_file",STRLEN(file_name)+1,outer_char);
3310
STRCPY(last_file->name,file_name);
3321
f->previously_opened= NO;
3322
f->global_scope= global_scope;
3328
f->previously_opened= BOOLEAN(f->previously_opened||(f->ptr!=NULL));
3330
if(f->previously_opened)
3333
f->ptr= FOPEN(compare_outfiles?f->tmp_name:f->name,"a");
3337
if(compare_outfiles)
3341
IN_COMMON outer_char wbprefix[MAX_FILE_NAME_LENGTH];
3344
extern char*tempnam();
3347
STRCPY(wbprefix,"./");
3349
buffer= tempnam((char*)wbprefix,"FTMP");
3352
buffer= tmpnam(NULL);
3355
f->tmp_name= GET_MEM("f->tmp_name",STRLEN(buffer)+1,outer_char);
3357
STRCPY(f->tmp_name,buffer);
3359
f->ptr= FOPEN(f->tmp_name,"w");
3364
f->ptr= FOPEN(f->name,"w");
3369
fatal(ERR_T,OC("ABORTING: "),OC("Can't open output file %s."),file_name);
3377
return f->previously_opened;
3383
close_out FCN((fp,name))
3385
outer_char*name C1("")
3389
for(f= open_file;f<last_file;f++)
3396
confusion(OC("close_out"),
3397
OC("Allegedly open file \"%s\" isn't in list"),name);
3407
for(f= open_file;f<last_file;f++)
3408
if(f->ptr&&!f->global_scope)
3419
f->previously_opened= YES;
3433
boolean renamed= NO;
3435
printf("\nRenaming temporary file(s): ");
3438
for(f= open_file;f<last_file;f++)
3439
if(f->previously_opened||f->ptr)
3441
FILE*old_ptr= FOPEN(f->name,"r");
3453
new_ptr= freopen((CONST char*)f->tmp_name,"r",f->ptr);
3455
new_ptr= FOPEN(f->tmp_name,"r");
3459
fatal(ERR_T,OC("ABORTING: "),OC("Can't reopen temporary file %s."),f->tmp_name);
3463
c_old= getc(old_ptr);
3464
c_new= getc(new_ptr);
3466
while(c_old==c_new&&c_old!=EOF);
3472
remove((CONST char*)f->tmp_name);
3477
remove((CONST char*)f->name);
3479
printf("(%s",(char*)f->name);
3481
if(rename((CONST char*)f->tmp_name,(CONST char*)f->name)!=0)
3490
err0_print(ERR_T,OC("Couldn't rename \"%s\" to \"%s\""),2,f->tmp_name,f->name);
3507
sprintf(temp,"%s %s %s",MV,(char*)f->tmp_name,
3514
printf(")");UPDATE_TERMINAL;
3530
remove((CONST char*)f->name);
3532
printf("(%s",(char*)f->name);
3534
if(rename((CONST char*)f->tmp_name,(CONST char*)f->name)!=0)
3543
err0_print(ERR_T,OC("Couldn't rename \"%s\" to \"%s\""),2,f->tmp_name,f->name);
3560
sprintf(temp,"%s %s %s",MV,(char*)f->tmp_name,
3567
printf(")");UPDATE_TERMINAL;
3577
printf("[no changes]");
3584
CONST outer_char HUGE*s C1("String to translate.")
3588
out_state= MISCELLANEOUS;
3591
CONST outer_char HUGE*out_str FCN((s0))
3592
CONST outer_char HUGE*s0 C1("")
3594
CONST outer_char HUGE*s;
3605
x_identifier FCN((cur_char))
3606
eight_bits cur_char C1("")
3611
boolean in_macro0= in_macro;
3612
name_pointer np= name_dir+cur_val;
3613
X_FCN(HUGE_FCN_PTR*pf)(VOID);
3615
if(np->expandable&language)
3620
pf= np->x_translate[lan_num(language)];
3626
confusion(OC("possibly expand special"),OC("Allegedly expandable keyword has no associated function"));
3628
in_macro= in_macro0;
3630
cur_char= id_keyword;
3631
goto end_identifier;
3633
else if(R77&&Fortran88&&!checking_label)
3636
case YES:goto expand_special;
3637
case-1:goto end_identifier;
3644
if(is_deferred((sixteen_bits)cur_val))
3651
if(!mac_protected&&(macro_text= MAC_LOOKUP(cur_val))!=NULL)
3662
printf("\n<<< 0x%x >>>\n",macrobuf);
3666
p1= xmacro(macro_text,&cur_byte,&cur_end,YES,macrobuf);
3671
printf("Expanded into (0x%x->0x%x) <<<%lu>>>\n",p1,mp,p1-macrobuf);
3677
copy_out(p1,mp,macro);
3689
if(C_LIKE(language)&&out_state!=VERBATIM)
3690
split_pos= pC_buffer;
3696
if(out_state==NUM_OR_ID&&!nuweb_mode)
3704
np= name_dir+cur_val;
3709
see_id(np->byte_start,(np+1)->byte_start);
3715
no_expand= mac_protected= NO;
3719
out_state= in_format?MISCELLANEOUS:NUM_OR_ID;
3727
is_deferred FCN((cur_val))
3728
sixteen_bits cur_val C1("")
3732
np= name_dir+cur_val;
3734
if(np->macro_type==DEFERRED_MACRO)
3737
eight_bits HUGE*p0,HUGE*p1;
3740
tp= (text_pointer)np->equiv;
3748
if(TOKEN1(a0= *p0++))
3753
if(*(p0+1)==MACRO_ARGUMENT)
3760
macro_err(OC("! Macro token `#!' must be followed by identifier"),YES);
3765
if((m= MAC_LOOKUP(IDENTIFIER(*p0,*(p0+1))))==NULL)
3767
macro_err(OC("! Expecting macro identifier after \"#!\""),YES);
3771
macro_err(OC("! Macro after \"#!\" can't have arguments"),YES);
3775
eight_bits HUGE*q0,HUGE*q1;
3778
q0= m->tok_start+m->moffset;
3779
q1= m->tok_start+m->nbytes;
3810
cur_text->Language= (boolean)language;
3811
cur_text->nargs= tp->nargs;
3812
cur_text->moffset= tp->moffset;
3813
cur_text->recursive= NO;
3814
cur_text->var_args= tp->var_args;
3820
np= name_dir+IDENTIFIER(tp->tok_start[0],tp->tok_start[1]);
3821
np->macro_type= IMMEDIATE_MACRO;
3822
np->equiv= (EQUIV)cur_text;
3833
out_ptrunc FCN((cur_val))
3834
sixteen_bits cur_val C1("")
3841
np= name_dir+cur_val;
3846
see_id(np->byte_start,(np+1)->byte_start);
3855
see_id FCN((start,end))
3856
CONST ASCII HUGE*start C0("Beginning of identifier name.")
3857
CONST ASCII HUGE*end C1("End of identifier name.")
3861
for(j= start;j<end;j++)C_putc(XCHR(*j));
3868
int n C1("Identifier number.")
3870
printf(_Xx("Id %d (0x%x): \"%s\"\n"),n,n,(char*)name_of((sixteen_bits)n));
3876
outer_char HUGE*name_of FCN((id0))
3877
sixteen_bits id0 C1("Identifier token whose name is sought.")
3879
static ASCII temp[MAX_ID_LENGTH];
3882
CONST ASCII HUGE*end;
3890
return(outer_char HUGE*)temp;
3896
n= MIN(end-np->byte_start,MAX_ID_LENGTH-1);
3898
if(end-np->byte_start<MAX_ID_LENGTH-1)
3899
n= PTR_DIFF(int,end,np->byte_start);
3904
STRNCPY(temp,np->byte_start,n);
3909
if(temp[k]==0134)temp[k]= 057;
3913
return to_outer(temp);
3918
CONST ASCII HUGE*proper_end FCN((np))
3919
name_pointer np C1("")
3921
CONST ASCII HUGE*end;
3929
CONST name_pointer np C1("")
3938
CONST ASCII HUGE*end;
3942
see_id((CONST ASCII HUGE*)pc,end);
3946
s= ((BP HUGE*)pc)->Root;
3947
see_id(s->id,s->id_end);
3954
prn_mod_num FCN((fmt,val))
3955
outer_char*fmt C0("")
3962
l= lan_num(R77_or_F&&!free_90?FORTRAN:language);
3969
if(FORTRAN_LIKE(language))
3971
if(out_pos>rst_pos)flush_out(YES);
3975
C_sprintf(fmt,3,begin_comment_char[l],val,end_comment_char[l]);
3982
skip_ahead FCN((last_control,skip_over_bars))
3983
eight_bits last_control C0("Last token that was seen.")
3984
boolean skip_over_bars C1("")
3992
ASCII HUGE*l1= limit+1;
4024
if(skip_bars()==new_module)return new_module;
4043
if(loc>limit)ncc= 2;
4048
for(lc= loc-1;lc>=cur_buffer;lc--)
4058
switch(cc= ccode[*(loc++)])
4086
Cpp= BOOLEAN(*loc==053);
4097
Fortran88= BOOLEAN(*loc==071);
4114
err0_print(ERR_C,OC("! Invalid language command `@L%c' ignored"),1,XCHR(l));
4124
if(module_count==0)global_params= params;
4125
set_output_file(language);
4131
nuweb_mode1= nuweb_mode= !NUWEB_MODE;
4134
global_params= params;
4139
while((c= skip_ahead(ignore,NO))==0100);
4144
err0_print(ERR_T,OC("Improper %s@%s within control text"),2,SSET_COLOR(character),SSET_COLOR(error));
4148
case compiler_directive:
4149
case Compiler_Directive:
4152
err0_print(ERR_T,OC("Compiler directives are allowed only in code"),0);
4156
case invisible_cmnt:
4161
if(ncc==1&&last_control==formatt)
4169
case big_line_break:
4170
if(loc>=limit)continue;
4179
while(isAlpha(*loc))
4182
if((mcode= is_mcmd(mcmds,id_first,loc))!=0)
4184
while(loc<limit&&(*loc==040||*loc==tab_mark))
4201
case USED_BY_NEITHER:
4203
err0_print(ERR_T,OC("Invalid `@%c' ignored"),1,XCHR(*(loc-1)));
4207
if(cc!=ignore||(*(loc-1)==076&&(ncc!=2)&&last_control!=formatt))
4214
DUMMY_RETURN(ignore);
4219
eight_bits skip_bars(VOID)
4222
LANGUAGE language0= language;
4231
if(loc>limit&&!get_line())
4234
err0_print(ERR_T,OC("Reached end of file while skipping code text %s"),1,BTRANS);
4235
ret_val= new_module;
4239
switch(next_control= get_next())
4251
case WEB_definition:
4263
err0_print(ERR_T,OC("Control code not allowed within |...|; \
4264
inserted '|' in %s"),1,MTRANS);
4271
err0_print(ERR_T,OC("Module%s ended while skipping code text; \
4272
inserted '|'"),1,MTRANS0);
4275
ret_val= next_control;
4283
set_output_file(language0);
4291
#if(part == 0 || part == 2)
4295
out_char FCN((cur_char))
4296
eight_bits cur_char C1("Token to control or be sent to the output.")
4301
if(R77_or_F&&started_vcmnt)C_putc(cur_char);
4307
return out_dflt(tab_mark);
4314
if(C_LIKE(language)&&out_state!=VERBATIM)
4315
split_pos= pC_buffer;
4323
if(!(Fortran88||in_string))cur_char= 073;
4336
return out_dflt(cur_char);
4339
in_cdir= BOOLEAN(!in_cdir);
4341
if(FORTRAN_LIKE(language))
4350
if((copying_macros||!nuweb_mode)
4351
&&(protect||out_state==VERBATIM))
4358
if(copying_macros&&protect&&!in_string)
4361
out_str(t_style.protect_chars[lan_num(language)]);
4374
if(out_state!=VERBATIM)
4375
out_state= MISCELLANEOUS;
4379
case end_format_stmt:
4382
out_state= NUM_OR_ID;
4385
case begin_format_stmt:
4388
out_state= MISCELLANEOUS;
4392
cur_char= x_identifier(cur_char);
4401
prn_mod_num(OC("%c* %ld: *%c\n"),cur_val);
4403
prn_mod_num(OC("%c* :%ld *%c\n"),cur_val);
4408
outer_char line_char;
4422
line_char= LINE_CHAR;
4430
nearest_line= (LINE_NUMBER)(BASE2*(*cur_byte++));
4431
nearest_line+= *cur_byte++;
4433
C_sprintf(OC("%cline %u \""),2,
4434
line_char,nearest_line);
4437
cur_val= BASE2*(*cur_byte++);
4438
cur_val+= *cur_byte++;
4445
np= name_dir+cur_val;
4450
see_id(np->byte_start,(np+1)->byte_start);
4454
C_sprintf(OC("\"\n"),0);
4466
if(FORTRAN_LIKE(language))
4476
out_state= MISCELLANEOUS;
4480
if(compound_assignments)
4484
if(last_xpr_overflowed)
4485
OVERFLW("last expression","lx");
4487
for(l= last_char;isdigit(*l)||!isalpha(*l);l++)
4490
if(plast_char-l>=3&&STRNCMP(last_char,"if(",3)==0)
4492
err0_print(ERR_T,OC("Sorry, can't expand compound assignment \
4493
operators correctly after simple IF; please use an IF...THEN construction"),0);
4502
fatal(ERR_T,OC("ABORTING: "),OC("Operators `++', `--', `+=', `-=', `*=', and `/=' \
4503
are not allowed; they were turned off by option `-+'."));
4507
buffer_out('+');buffer_out('1');
4508
out_state= MISCELLANEOUS;
4512
if(*(pC_buffer-1)=='+'&&!nuweb_mode)
4520
if(C_LIKE(language)&&out_state!=VERBATIM)
4521
split_pos= pC_buffer;
4529
if(FORTRAN_LIKE(language))
4539
out_state= MISCELLANEOUS;
4543
if(compound_assignments)
4547
if(last_xpr_overflowed)
4548
OVERFLW("last expression","lx");
4550
for(l= last_char;isdigit(*l)||!isalpha(*l);l++)
4553
if(plast_char-l>=3&&STRNCMP(last_char,"if(",3)==0)
4555
err0_print(ERR_T,OC("Sorry, can't expand compound assignment \
4556
operators correctly after simple IF; please use an IF...THEN construction"),0);
4565
fatal(ERR_T,OC("ABORTING: "),OC("Operators `++', `--', `+=', `-=', `*=', and `/=' \
4566
are not allowed; they were turned off by option `-+'."));
4570
buffer_out('-');buffer_out('1');
4571
out_state= MISCELLANEOUS;
4575
if(*(pC_buffer-1)=='-'&&!nuweb_mode)
4583
if(C_LIKE(language)&&out_state!=VERBATIM)
4584
split_pos= pC_buffer;
4591
case minus_gt:OUT_OP(FORTRAN_LIKE(language)?".EQV.":"->");break;
4597
if(C_LIKE(language)&&out_state!=VERBATIM)
4598
split_pos= pC_buffer;
4609
if(C_LIKE(language)&&out_state!=VERBATIM)
4610
split_pos= pC_buffer;
4615
OUT_OP(R77_or_F?F_OP(".EQ.","=="):"==");break;
4621
if(C_LIKE(language)&&out_state!=VERBATIM)
4622
split_pos= pC_buffer;
4630
if(in_string||in_format)
4634
OUT_OP(R77_or_F?F_OP(".GT.",">"):">");
4635
if(language==C_PLUS_PLUS)
4642
if(C_LIKE(language)&&out_state!=VERBATIM)
4643
split_pos= pC_buffer;
4651
OUT_OP(R77_or_F?F_OP(".GE.",">="):">=");
4655
if(C_LIKE(language)&&out_state!=VERBATIM)
4656
split_pos= pC_buffer;
4664
if(in_string||in_format)
4667
OUT_OP(R77_or_F?F_OP(".LT.","<"):"<");
4672
if(C_LIKE(language)&&out_state!=VERBATIM)
4673
split_pos= pC_buffer;
4681
OUT_OP(R77_or_F?F_OP(".LE.","<="):"<=");
4685
if(C_LIKE(language)&&out_state!=VERBATIM)
4686
split_pos= pC_buffer;
4694
OUT_OP(R77_or_F?F_OP(".NE.","/="):"!=");
4698
if(C_LIKE(language)&&out_state!=VERBATIM)
4699
split_pos= pC_buffer;
4707
OUT_OP(R77_or_F?".AND.":"&&");
4711
if(C_LIKE(language)&&out_state!=VERBATIM)
4712
split_pos= pC_buffer;
4720
if(language==TEX)meta_mode= YES;
4723
OUT_OP(R77_or_F?".OR.":"||");
4727
if(C_LIKE(language)&&out_state!=VERBATIM)
4728
split_pos= pC_buffer;
4737
if(language==TEX)meta_mode= NO;
4738
else OUT_OP(C_LIKE(language)?"^^":"**");
4745
if(C_LIKE(language)&&out_state!=VERBATIM)
4746
split_pos= pC_buffer;
4752
return out_dflt(cur_char);
4754
OUT_OP(R77_or_F?".NOT.":"!");
4757
case slash_slash:OUT_OP("//");break;
4760
if(in_string&&!nuweb_mode)
4761
return out_dflt(cur_char);
4769
OUT_OP(FORTRAN_LIKE(language)?".NEQV.":"...");
4773
if(C_LIKE(language)&&out_state!=VERBATIM)
4774
split_pos= pC_buffer;
4781
case paste:OUT_OP("##");break;
4785
STRCPY(dot_op.name+1,dots[cur_val].symbol);
4786
to_outer(dot_op.name+1);
4787
OUT_OP(OC(dot_op.name+1));
4799
if(!FORTRAN_LIKE(language)||
4800
cur_byte==cur_end||*cur_byte!=075||
4801
out_state==VERBATIM||!xpn_Ratfor)
4803
if(cur_char==052&&C_LIKE(language)&&out_state!=VERBATIM
4804
&&*(pC_buffer-1)=='/'&&!nuweb_mode)
4809
if(C_LIKE(language)&&out_state!=VERBATIM)
4810
split_pos= pC_buffer;
4815
return out_dflt(cur_char);
4827
out_state= MISCELLANEOUS;
4831
if(compound_assignments)
4835
if(last_xpr_overflowed)
4836
OVERFLW("last expression","lx");
4838
for(l= last_char;isdigit(*l)||!isalpha(*l);l++)
4841
if(plast_char-l>=3&&STRNCMP(last_char,"if(",3)==0)
4843
err0_print(ERR_T,OC("Sorry, can't expand compound assignment \
4844
operators correctly after simple IF; please use an IF...THEN construction"),0);
4853
fatal(ERR_T,OC("ABORTING: "),OC("Operators `++', `--', `+=', `-=', `*=', and `/=' \
4854
are not allowed; they were turned off by option `-+'."));
4869
if(out_state!=VERBATIM)
4871
if(C_LIKE(language)&&!nuweb_mode)
4874
out_state= MISCELLANEOUS;
4880
if(C_LIKE(language)&&out_state!=VERBATIM)
4881
split_pos= pC_buffer;
4888
case join:out_state= UNBREAKABLE;break;
4891
if(out_state==VERBATIM)
4892
out_state= in_format?MISCELLANEOUS:NUM_OR_ID;
4899
if(C_LIKE(language)&&out_state!=VERBATIM)
4900
split_pos= pC_buffer;
4906
if(out_state==NUM_OR_ID&&!nuweb_mode)
4909
out_state= VERBATIM;
4912
in_constant= BOOLEAN(!in_constant);
4917
out_state= MISCELLANEOUS;
4923
if(C_LIKE(language)&&out_state!=VERBATIM)
4924
split_pos= pC_buffer;
4930
if(out_state==NUM_OR_ID&&!nuweb_mode)
4934
out_state= VERBATIM;
4937
in_string= BOOLEAN(!in_string);
4944
pmeta= &t_style.meta[lan_num(language)];
4959
if(in_string&&!in_version)
4960
OUT_STR(t= pmeta->msg.top);
4962
OUT_OP(t= pmeta->hdr.top);
4977
out_state= MISCELLANEOUS;
4982
confusion(OC("out_char:begin_meta"),OC("Language %i is not defined"),language);
5001
if(in_string&&!in_version)
5002
OUT_OP(t= pmeta->msg.bottom);
5004
OUT_OP(t= pmeta->hdr.bottom);
5016
out_state= MISCELLANEOUS;
5021
confusion(OC("out_char:end_meta"),OC("Language %i is invalid"),language);
5040
if(C_LIKE(language)&&out_state!=VERBATIM)
5041
split_pos= pC_buffer;
5046
return out_dflt(cur_char);
5053
if(R77&&!in_string&&brace_level==0)
5055
RAT_error(WARNING,OC("Spurious '}' ignored, \
5056
or missing program, module, subroutine, or function statement"),0);
5063
if(C_LIKE(language)&&out_state!=VERBATIM)
5064
split_pos= pC_buffer;
5075
out_bracket(cur_char,050);
5079
out_bracket(cur_char,051);
5084
if(!(in_string||language==LITERAL))
5086
mac_protected= BOOLEAN(!mac_protected);
5090
return out_dflt(cur_char);
5093
if(C_LIKE(language)&&out_state!=VERBATIM
5094
&&*(pC_buffer-1)=='&'&&!nuweb_mode)
5099
if(C_LIKE(language)&&out_state!=VERBATIM)
5100
split_pos= pC_buffer;
5105
return out_dflt(cur_char);
5113
return out_dflt(cur_char);
5122
out_bracket FCN((cur_char,new_char))
5123
eight_bits cur_char C0("")
5124
eight_bits new_char C1("")
5126
if(out_state!=VERBATIM&&FORTRAN_LIKE(language)&&translate_brackets)
5128
return out_dflt(cur_char);
5139
if(out_state!=VERBATIM)
5140
out_state= MISCELLANEOUS;
5147
LANGUAGE set_output_file FCN((language0))
5148
LANGUAGE language0 C1("")
5150
language= language0;
5152
out_file= params.OUT_FILE;
5160
opn_output_file FCN((language0))
5161
LANGUAGE language0 C1("")
5163
set_output_file(language0);
5165
open_out(OC(""),LOCAL_SCOPE);
5172
boolean skip_comment(VOID)
5175
PARSING_MODE outer_mode;
5177
outer_mode= parsing_mode;
5178
parsing_mode= OUTER;
5180
if(comment_continues)
5184
else if(*(loc-1)==057)
5194
comment_continues= NO;
5201
comment_continues= YES;
5207
err0_print(ERR_T,OC("Input ended in middle of comment %s"),1,BTRANS);
5209
comment_continues= NO;
5216
if(c==052&&*loc==057)
5221
comment_continues= NO;
5230
if(ccode[*loc]==new_module)
5233
err0_print(ERR_T,OC("Section name ended in middle of comment %s"),1,BTRANS);
5238
comment_continues= NO;
5248
parsing_mode= outer_mode;
5249
return comment_continues;
5259
strt_point_cmnt= suppress_newline= NO;
5265
if(preprocessing&&at_beginning)
5271
for(;loc<limit;loc++)
5272
if(!(*loc==040||*loc==tab_mark))break;
5276
return(eight_bits)prs_regular_code(GOTO_GET_IDENTIFIER);
5282
if(*loc==cont_char&&loc==limit-1&&(preprocessing||free_Fortran))
5285
return(eight_bits)CHOICE(free_Fortran,046,cont_char);
5299
return WEB_definition;
5304
if(preprocessing&&*(limit-1)!=cont_char)
5309
id_first= id_loc= mod_text+1;
5317
return WEB_definition;
5318
else if(!get_line())
5323
eat_blank_lines= NO;
5336
at_beginning= BOOLEAN(!preprocessing);
5351
else if(!suppress_newline&&
5352
(!R77_or_F||limit==cur_buffer||free_Fortran))
5355
suppress_newline= NO;
5361
at_beginning= BOOLEAN(!preprocessing&&(loc==cur_buffer));
5366
boolean found_white_space= NO;
5370
if((c= *loc++)!=040||c!=tab_mark)
5373
found_white_space= YES;
5378
if(found_white_space)
5390
ASCII HUGE*loc0= loc;
5396
while(loc<=limit&&(c==040||c==tab_mark));
5398
if(nuweb_mode||scanning_meta)
5400
if(!(c==0100&&*loc==043))
5421
if((pcode= prs_TeX_code())==MORE_PARSE)
5425
confusion(OC("prs_TEX_code"),OC("Negative pcode %i"),pcode);
5431
if((pcode= prs_regular_code(MORE_PARSE))==MORE_PARSE)
5433
else if((int)pcode<0)
5435
confusion(OC("prs_regular_code"),OC("Negative pcode %i"),pcode);
5441
DUMMY_RETURN(ignore);
5454
if(TeX[c]==TeX_comment)
5459
if((all_cmnts_verbatim||(keep_trailing_comments&&!at_beginning))
5460
&&!(scanning_defn&&is_WEB_macro))
5467
suppress_newline= YES;
5477
icode= get_control_code();
5479
if(icode==MORE_PARSE)
5483
return prs_regular_code(icode);
5485
return(eight_bits)icode;
5487
else if(c==044&&STRNCMP(loc-1,LKWD,STRLEN(LKWD))==0)
5488
return prs_regular_code(MORE_PARSE);
5493
id_first= id_loc= mod_text+1;
5496
*id_loc++= begin_Xmeta;
5505
else if(*loc==044&&STRNCMP(loc,LKWD,STRLEN(LKWD))==0)
5507
else if(!strt_cmnt&&TeX[*loc]==TeX_comment&&*(loc-1)!=0134)
5514
*id_loc++= end_Xmeta;
5524
prs_regular_code FCN((iswitch))
5525
GOTO_CODE iswitch C1("")
5531
case MORE_PARSE:break;
5533
case GOTO_MISTAKE:goto mistake;
5534
case GOTO_GET_IDENTIFIER:goto get_identifier;
5535
case GOTO_GET_A_STRING:goto get_a_string;
5536
case GOTO_SKIP_A_COMMENT:goto skip_a_comment;
5539
if(language!=LITERAL)
5544
case(ASCII)begin_comment0:
5545
long_comment= strt_cmnt= YES;
5548
case(ASCII)begin_comment1:
5549
strt_cmnt= strt_point_cmnt= YES;
5555
long_comment= strt_cmnt= YES;
5556
else if(*loc==057&&(C_LIKE(language)||(Cpp_comments&&
5557
!in_format&&FORTRAN_LIKE(language))))
5567
if((*loc==041||point_comments)&&FORTRAN_LIKE(language))
5569
*(loc-1)= (ASCII)begin_comment1;
5571
strt_cmnt= strt_point_cmnt= YES;
5577
if(strt_cmnt&&all_cmnts_verbatim&&!(scanning_defn&&is_WEB_macro))
5582
switch(icode= get_control_code())
5584
case GOTO_MISTAKE:goto mistake;
5585
case GOTO_GET_A_STRING:goto get_a_string;
5586
case GOTO_GET_IDENTIFIER:goto get_identifier;
5587
case GOTO_SKIP_A_COMMENT:goto skip_a_comment;
5591
suppress_newline= YES;
5595
default:return icode;
5600
else if(strt_cmnt||comment_continues)
5605
if((comment_continues)&&
5606
!(scanning_defn&&is_WEB_macro))return 012;
5607
else return MORE_PARSE;
5610
if(loc==limit&&c==cont_char&&
5611
(preprocessing||(auto_semi&&R77)))
5618
if(c==056&&*loc==056&&*(loc+1)==056)
5625
else if(FORTRAN_LIKE(language)&&dot_constants&&
5626
(c==wt_style.dot_delimiter.begin)&&!isDigit(*loc))
5633
ASCII dot_end= wt_style.dot_delimiter.end;
5637
for(p0= loc,n= 0;n<MAX_DOT_LENGTH;n++,loc++)
5638
if(*loc==dot_end||!isAlpha(*loc))break;
5647
c= dot_code(dots,uppercase(p0,n),loc++,dot_const);
5661
else if(isDigit(c)||c==056||(c==0134&&language!=LITERAL))
5664
boolean decimal_point;
5667
if(loc==limit&&c==cont_char)
5669
if(preprocessing)loc++;
5670
return(eight_bits)c;
5673
starts_with_0= hex_constant= bin_constant= floating_constant= NO;
5677
if(*id_first==056&&!isDigit(*loc))
5685
while(isOdigit(*loc))
5692
starts_with_0= BOOLEAN(*id_first==060);
5695
hex_constant= BOOLEAN(*loc==0170||*loc==0130);
5701
while(isXdigit(*loc))
5706
else if((bin_constant= BOOLEAN(*loc==0142||*loc==0102))!=0)
5710
while(isBdigit(*loc))
5717
while(isDigit(*loc))loc++;
5718
decimal_point= BOOLEAN(*loc==056);
5719
if(decimal_point)loc++;
5720
while(isDigit(*loc))loc++;
5722
if(FORTRAN_LIKE(language))
5733
else if(*loc==0150||*loc==0110)
5744
for(l= 0;l<n;++l)++loc;
5751
floating_constant= BOOLEAN(*loc==0145||*loc==0105||
5752
(FORTRAN_LIKE(language)
5753
&&(*loc==0144||*loc==0104||*loc==0161||*loc==0121)));
5755
if(floating_constant)
5757
if(*++loc==053||*loc==055)loc++;
5758
while(isDigit(*loc))loc++;
5761
floating_constant|= decimal_point;
5765
if(C_LIKE(language))
5767
boolean its_long= NO,its_unsigned= NO,its_constant= NO;
5773
its_constant= its_long= YES;
5778
its_constant= its_unsigned= YES;
5793
if(its_long&&(*loc==0165||*loc==0125))
5795
else if(its_unsigned&&(*loc==0154||*loc==0114))
5802
while(is_kind(*loc))loc++;
5814
else if(is_identifier(c))
5817
IN_COMMON ASCII HUGE*pformat,HUGE*pdata;
5825
for(++loc;isAlpha(*loc)||isDigit(*loc)
5826
||*loc==0137||*loc==044||(in_format&&*loc==056);loc++)
5829
upcoming_kind= BOOLEAN(Fortran88&&(*loc=='"'||*loc=='\'')
5832
id_loc= loc-upcoming_kind;
5839
if(FORTRAN_LIKE(language))
5841
if(web_strcmp(pformat,pformat+6,id_first,id_loc)==EQUAL)
5845
return begin_format_stmt;
5847
else if(program==weave)
5849
if(web_strcmp(pdata,pdata+4,id_first,id_loc)==EQUAL)
5854
else if(at_beginning&&*loc==':'&&
5855
!is_in(non_labels,id_first,id_loc))
5860
if(is_include_like())
5861
sharp_include_line= YES;
5870
else if((c==047||c==042)
5871
||(is_RATFOR_(language)&&sharp_include_line==YES&&c==050))
5873
if(language==LITERAL)
5880
ASCII right_delim= c;
5882
boolean equal_delims;
5884
id_first= mod_text+1;
5885
id_loc= mod_text;*++id_loc= delim;
5890
sharp_include_line= NO;
5895
equal_delims= BOOLEAN(right_delim==delim);
5901
if((equal_delims||chk_ifelse)&&*(limit-1)!=cont_char)
5905
err0_print(ERR_T,OC("String %s with %s'%s%c'%s didn't end"),5,BTRANS,SSET_COLOR(character),delim==047?"\\":"",XCHR(delim),SSET_COLOR(error));
5913
err0_print(ERR_T,OC("Input ended in middle of string \
5914
%s with '%s%c'"),3,BTRANS,delim==047?"\\":"",XCHR(delim));
5921
if(C_LIKE(language)&&++id_loc<=mod_end)*id_loc= 012;
5926
if(bslash_continued_strings)
5928
for(;loc<limit;loc++)
5929
if(*loc!=040&&*loc!=tab_mark)break;
5931
if(*loc==cont_char)loc++;
5933
err0_print(ERR_T,OC("Inserted '%c' at beginning of continued \
5934
string"),1,XCHR(cont_char));
5941
if(*loc==057&&*(loc+1)==052)
5948
err0_print(ERR_T,OC("Input ended in middle of embedded comment %s"),1,BTRANS);
5953
if(*loc==052&&*(loc+1)==057)
5962
if((c= *loc++)==delim)
5966
if(++id_loc<=mod_end)*id_loc= c;
5968
if(!equal_delims)continue;
5970
if(*loc==delim&&!(C_LIKE(language)||
5971
(is_RATFOR_(language)&&Ratfor77)))
5979
if(++id_loc<=mod_end)*id_loc= c;
5985
if(++id_loc<=mod_end)*id_loc= c;
5989
if(loc>=limit&&(!is_FORTRAN_(language)||free_form_input))
5993
if(!is_FORTRAN_(language))
6003
case 060:n= '\0';break;
6004
case 0134:n= 0134;break;
6005
case 047:n= 047;break;
6006
case 042:n= 042;break;
6007
case 077:n= 077;break;
6008
case 0141:n= 07;break;
6009
case 0142:n= 010;break;
6010
case 0146:n= 014;break;
6011
case 0156:n= 012;break;
6012
case 0162:n= 015;break;
6013
case 0164:n= 011;break;
6014
case 0166:n= 013;break;
6021
if(++id_loc<=mod_end)*id_loc= c;
6024
else{if(++id_loc<=mod_end)*id_loc= 0134;}
6028
if(++id_loc<=mod_end)*id_loc= c;
6035
printf("\n! String too long: ");
6037
ASCII_write(mod_text+1,25);
6052
switch(icode= get_control_code())
6054
case GOTO_MISTAKE:goto mistake;
6055
case GOTO_GET_A_STRING:goto get_a_string;
6056
case GOTO_GET_IDENTIFIER:goto get_identifier;
6057
case GOTO_SKIP_A_COMMENT:goto skip_a_comment;
6061
suppress_newline= YES;
6065
default:return icode;
6071
else if(c==040||c==tab_mark)
6072
if(nuweb_mode||scanning_meta)
6073
return(c==tab_mark?bell:c);
6076
if(!preprocessing||loc>limit)
6084
else if(c==043&&!macro_scan&&at_beginning&&C_LIKE(language))
6091
else if(in_format&&c==073)
6094
return end_format_stmt;
6099
if(language!=LITERAL)
6104
if(FORTRAN_LIKE(language)&&!in_format&&*loc==057)
6105
compress(slash_slash);
6110
if(FORTRAN_LIKE(language)&&!in_format)
6119
compress(slash_slash);
6122
else if(*loc==075&&!compound_assignments)
6126
case 053:if(*loc==053)compress(plus_plus);break;
6128
case 055:if(*loc==055){compress(minus_minus);}
6129
else if(*loc==076)compress(minus_gt);break;
6131
case 075:if(*loc==075)compress(eq_eq);break;
6133
case 076:if(*loc==075){compress(gt_eq);}
6134
else if(*loc==076){compress(gt_gt);}
6137
case 074:if(*loc==075){compress(lt_eq);}
6138
else if(*loc==074){compress(lt_lt);}
6139
else if(*loc==076){compress(not_eq);}
6142
case 046:if(*loc==046)compress(and_and);break;
6144
case 0174:if(*loc==0174)compress(or_or);break;
6146
case 041:if(*loc==075){compress(not_eq);}break;
6149
if(FORTRAN_LIKE(language)&&(*loc==052))
6150
{compress(star_star);}
6154
if(*loc==0136){compress(star_star);}
6155
else if(FORTRAN_LIKE(language)&&(loc<limit))return star_star;
6159
if(*loc==043){compress(paste);}
6167
static ASCII ell[]= "\56\56\56";
6173
TEMPLATE arg_ptr[10];
6180
if(loc>limit&&!get_line())
6183
err0_print(ERR_T,OC("Input ended in section name %s"),1,BTRANS);
6207
if(ccode[c]==new_module)
6210
err0_print(ERR_T,OC("Section name %s didn't end"),1,BTRANS);
6249
printf("\n! Section name too long: ");
6251
ASCII_write(mod_text+1,25);
6256
if(*k==040&&k>mod_text)
6262
if(k-mod_text>3&&STRNCMP(k-2,ell,3)==0)
6263
cur_module= prefix_lookup(mod_text+1,k-3);
6265
cur_module= mod_lookup(mod_text+1,k);
6267
if(cur_module!=NULL)
6269
set_output_file(cur_module->mod_info->language);
6279
case 072:if(*loc==072&&language==C_PLUS_PLUS&&!scanning_meta)
6280
compress(colon_colon);break;
6287
return(eight_bits)c;
6293
get_control_code(VOID)
6300
if(c==(ASCII)begin_comment1||c==(ASCII)begin_comment0)
6307
if(c==076&&mod_level==0)
6310
err0_print(ERR_T,OC("Unmatched `%s@>%s' ignored"),2,SSET_COLOR(character),SSET_COLOR(error));
6314
switch(cc= ccode[c])
6316
case ignore:return MORE_PARSE;
6345
Cpp= BOOLEAN(*loc==053);
6356
Fortran88= BOOLEAN(*loc==071);
6373
err0_print(ERR_C,OC("! Invalid language command `@L%c' ignored"),1,XCHR(l));
6383
set_output_file(language);
6384
return begin_language;
6387
case control_text:while((c= skip_ahead(ignore,NO))==0100);
6392
err0_print(ERR_T,OC("Improper @ within control text %s"),1,BTRANS);
6402
static ASCII ell[]= "\56\56\56";
6408
TEMPLATE arg_ptr[10];
6415
if(loc>limit&&!get_line())
6418
err0_print(ERR_T,OC("Input ended in section name %s"),1,BTRANS);
6442
if(ccode[c]==new_module)
6445
err0_print(ERR_T,OC("Section name %s didn't end"),1,BTRANS);
6484
printf("\n! Section name too long: ");
6486
ASCII_write(mod_text+1,25);
6491
if(*k==040&&k>mod_text)
6497
if(k-mod_text>3&&STRNCMP(k-2,ell,3)==0)
6498
cur_module= prefix_lookup(mod_text+1,k-3);
6500
cur_module= mod_lookup(mod_text+1,k);
6502
if(cur_module!=NULL)
6504
set_output_file(cur_module->mod_info->language);
6519
*(limit+1)= 0100;*(limit+2)= 076;
6521
while(*loc!=0100||*(loc+1)!=076)
6526
err0_print(ERR_T,OC("Verbatim string %s didn't end"),1,BTRANS);
6540
if(strt_cmnt||*loc==052||*loc==057)
6541
if(!(scanning_defn&&is_WEB_macro)&&!deferred_macro)
6543
if(!strt_point_cmnt)long_comment=
6544
BOOLEAN(!(*loc==057));
6550
id_first= id_loc= mod_text+1;
6553
if(!C_LIKE(language))
6558
if(R66)*id_loc++= 043;
6572
if(C_LIKE(language))
6575
if(!long_comment&&!Cpp)
6577
*id_loc++= id_first[1]= 052;
6578
*id_loc++= id_first[0]= 057;
6583
if(long_comment)id_loc-= 2;
6590
else if(!get_line())
6593
err0_print(ERR_T,OC("Input ended in verbatim comment %s"),1,BTRANS);
6609
if(id_loc<mod_end-3)
6615
else if(ccode[loc[1]]==keyword_name)
6617
err0_print(ERR_T,OC("@K and @k aren't (yet) allowed in comments"),0);
6625
printf("\n! Verbatim comment too long: ");
6627
ASCII_write(mod_text,25);
6628
printf("...");mark_harmless;
6631
*id_loc++= 052;*id_loc++= 057;
6633
comment_continues= YES;
6639
if(long_comment&&*loc==057&&*(loc-1)==052)
6644
if(C_LIKE(language))
6647
if(!long_comment&&!Cpp)
6649
*id_loc++= id_first[1]= 052;
6650
*id_loc++= id_first[0]= 057;
6655
if(long_comment)id_loc-= 2;
6666
if(!C_LIKE(language))
6676
else return GOTO_SKIP_A_COMMENT;
6677
else return MORE_PARSE;
6680
case invisible_cmnt:
6686
eat_blank_lines= YES;
6690
if(auto_line&&!scanning_defn&&loc==cur_buffer+2)
6694
suppress_newline= YES;
6697
case compiler_directive:
6700
outer_char*s= t_style.cdir_start[language_num];
6702
id_first= id_loc= mod_text+1;
6708
to_ASCII((outer_char HUGE*)id_loc);
6712
STRNCPY(id_loc,loc,n= PTR_DIFF(int,limit,loc));
6722
case Compiler_Directive:
6724
outer_char*s= t_style.cdir_start[language_num];
6726
id_first= id_loc= mod_text+1;
6729
preprocessing= in_cdir= YES;
6734
to_ASCII((outer_char HUGE*)id_loc);
6740
case new_output_file:
6743
while(*loc==' '||*loc==tab_mark)
6746
if(loc>limit)return ignore;
6750
while(*loc!=' '&&*loc!=tab_mark)loc++;
6752
if(*id_first=='"')id_first++;
6753
if(*(id_loc-1)=='"')id_loc--;
6754
if(id_loc-id_first>=MAX_FILE_NAME_LENGTH)
6757
err0_print(ERR_T,OC("Output file name too long; allowed only %d characters"),1,MAX_FILE_NAME_LENGTH-1);
6758
id_loc= id_first+MAX_FILE_NAME_LENGTH-1;
6767
case ascii_constant:
6770
ASCII delim= *(loc-1);
6789
err0_print(ERR_T,OC("ASCII string %s didn't end"),1,BTRANS);
6795
return ascii_constant;
6802
return GOTO_GET_A_STRING;
6805
case big_line_break:
6807
if(loc>=limit)return MORE_PARSE;
6816
while(isAlpha(*loc))
6819
if((mcode= is_mcmd(mcmds,id_first,loc))!=0)
6821
while(loc<limit&&(*loc==040||*loc==tab_mark))
6841
outer_char c= XCHR(*loc++);
6846
err0_print(ERR_T,OC("You must say `@q0' or `@q1', not `@q%c'"),1,c);
6850
line_info= BOOLEAN((c!='0')&&global_params.Line_info);
6859
case USED_BY_NEITHER:
6861
err0_print(ERR_T,OC("Invalid `@%c' ignored"),1,XCHR(c));
6871
#if(part == 0 || part == 3)
6875
scan_repl FCN((t,stop))
6876
eight_bits t C0("Either |macro| or |module_name|.")
6877
boolean stop C1("IF |YES|, stops the scan at the end of current\
6880
eight_bits a0= ignore;
6884
boolean auto_bp= YES;
6887
macro_scan= (t==macro);
6889
language0= language;
6891
stop_the_scan= stop;
6895
ins_ln_no(column_mode);
6898
app_repl(begin_language);
6899
app_repl(NUWEB_OFF|nuweb_mode);
6919
if(loc>limit)goto done;
6928
a0= (ntoken&&nuweb_mode&&t==module_name)
6929
?begin_meta:get_next();
6935
if(loc==limit&&language!=LITERAL)
6939
fatal(ERR_T,OC("Input ended "),OC("while scanning \
6940
FWEB preprocessor statement."));
6954
if(loc==limit&&language==LITERAL)
6960
if(t==macro&&is_WEB_macro)
6968
outer_char temp[N_IDBUF];
6986
nsprintf(temp,OC("%lu"),1,max_stmt++)>=(int)(N_IDBUF))OVERFLW("temp","");
6992
for(t= (ASCII*)temp;*t!='\0';t++)app_repl(*t);
7007
if(get_next()!=identifier)
7009
err0_print(ERR_M,OC("Identifier must follow #!; command ignored"),0);
7015
a= ID_NUM(id_first,id_loc);
7019
if((m= MAC_LOOKUP(a))==NULL)
7025
app_repl(LEFT(a,ID0));
7035
err0_print(ERR_M,OC("Macro after #! may not have arguments"),0);
7039
eight_bits HUGE*q0,HUGE*q1;
7042
q0= m->tok_start+m->moffset;
7043
q1= m->tok_start+m->nbytes;
7070
if(isDigit(*loc)||*loc==054||*loc==046||*loc==052||*loc==056||
7071
*loc==0133||*loc==0173)
7075
else if(get_next()!=identifier)
7077
macro_err(OC("! '#' should be followed by identifier"),YES);
7080
a= ID_NUM(id_first,id_loc);
7085
if((MAC_LOOKUP(a))==NULL)
7090
app_repl(LEFT(a,ID0));
7100
macro_err(OC("! Immediate expansion of macro \"%s\" not implemented"),YES,name_of(a));
7103
app_repl(LEFT(a,ID0));
7128
a= ID_NUM(id_first,id_loc);
7133
language0= language;
7140
err0_print(ERR_T,OC("Missing left parenthesis"),0);
7144
if(get_next()!=stringg)
7147
err0_print(ERR_T,OC("Expected string argument to $L_KEYWORD"),0);
7154
err0_print(ERR_T,OC("Missing right parenthesis"),0);
7160
while(IS_WHITE(*id_first))
7163
while(IS_WHITE(id_loc[-1]))
7167
x_keyword(&mp,macrobuf_end,id_first,id_loc,NO,language0!=TEX,
7168
upper_case_code?WEB_FILE:CUR_FILE);
7170
divert((ASCII HUGE*)macrobuf,(ASCII HUGE*)mp,DONT_STOP);
7177
language= language0;
7184
app_repl(LEFT(a,ID0));
7197
while(IS_WHITE(*id_first))
7200
while(IS_WHITE(id_loc[-1]))
7204
x_keyword(&mp,macrobuf_end,id_first,id_loc,NO,language0!=TEX,
7205
upper_case_code?WEB_FILE:CUR_FILE);
7207
divert((ASCII HUGE*)macrobuf,(ASCII HUGE*)mp,DONT_STOP);
7217
if(t==macro&&!mac_mod_name)
7228
ASCII HUGE*try_loc= loc;
7231
while(*try_loc==040&&try_loc<limit)
7234
if(*try_loc==053&&try_loc<limit)
7237
while(*try_loc==040&&try_loc<limit)
7242
err0_print(ERR_T,OC("Nested named modules. Missing `@*' or `@ '?"),0);
7247
a= (sixteen_bits)(cur_module-name_dir);
7248
app_repl(LEFT(a,0250));
7263
if(C_LIKE(language))
7265
if(bin_constant&&a0==constant)
7268
app_converted(btoi(id_first,id_loc));
7275
else if(a0==constant)
7277
if(language==LITERAL)
7279
else if(hex_constant)
7282
app_converted(xtoi(id_first,id_loc));
7286
else if(bin_constant)
7289
app_converted(btoi(id_first,id_loc));
7293
else if(starts_with_0&&!floating_constant)
7296
app_converted(otoi(id_first,id_loc));
7303
else if(R77&&a0==stringg&&!in_format)
7306
rdc_char_constant();
7311
if(*id_first==042)*id_first= *(id_loc-1)= 047;
7322
case ascii_constant:
7335
if(FORTRAN_LIKE(language))
7351
if(FORTRAN_LIKE(language)&&!free_form_input)
7356
parsing_mode= OUTER;
7370
app_repl(dot_op.num);
7373
case begin_language:
7378
confusion(OC("scan_repl:begin_language"),OC("A language hasn't been defined yet"));
7382
if(!RAT_OK("(scan_repl)"))
7384
confusion(OC("scan_repl:begin_language"),OC("Attempting to append @Lr"));
7395
if(!(scanning_defn||free_form_input))
7401
parsing_mode= OUTER;
7410
confusion(OC("app_id"),OC("Language %i is invalid"),language);
7416
set_output_file(language);
7418
{app_repl(a0);app_repl((eight_bits)language);}
7421
store_two_bytes((sixteen_bits)(LINE_NUM+module_count));
7425
ins_ln_no(column_mode);
7429
app_repl(begin_language);
7434
app_repl(begin_language);
7436
app_repl(line_info);
7439
case new_output_file:
7446
app_repl(begin_language);
7447
app_repl(NO_LANGUAGE);
7448
app_repl(upper_case_code);
7450
a= ID_NUM_ptr(np,id_first,id_loc);
7453
app_repl(LEFT(a,ID0));
7458
np->macro_type= FILE_NAME;
7468
case WEB_definition:
7475
#define NAME_LEN 100
7478
eight_bits HUGE*tok_ptr0,HUGE*tok_m_end0;
7479
text_pointer text_ptr0,text_end0;
7480
outer_char new_name[NAME_LEN];
7481
ASCII HUGE*nn,HUGE*b;
7484
if(!deferred_macros)
7487
err0_print(ERR_T,OC("Sorry, deferred FWEB macros (defined in code part) are \
7488
prohibited; use option `-TD' to permit them"),0);
7493
tok_m_end0= tok_m_end;
7494
text_ptr0= text_ptr;
7495
text_end0= text_end;
7498
tok_m_end= tokd_end;
7500
text_end= textd_end;
7502
deferred_macro= YES;
7503
np= app_macro(WEB_definition);
7508
tok_m_end= tok_m_end0;
7511
text_ptr= text_ptr0;
7512
text_end= text_end0;
7520
nsprintf(new_name,OC("@%d"),1,n_unique++)>=(int)(NAME_LEN))OVERFLW("new_name","");
7522
for(nn= (ASCII*)new_name+STRLEN(new_name),b= np->byte_start;
7523
b<(np+1)->byte_start;)
7526
a= ID_NUM_ptr(np,(ASCII*)new_name,nn);
7529
app_repl(LEFT(a,ID0));
7535
np->macro_type= DEFERRED_MACRO;
7536
np->equiv= (EQUIV)cur_text;
7548
nuweb_mode1= nuweb_mode= !NUWEB_MODE;
7554
err0_print(ERR_T,OC("@N ignored; must appear before beginning of code part"),0);
7559
case limbo_text:case op_def:case macro_def:
7560
case definition:case undefinition:
7567
err0_print(ERR_T,OC("@d, @l, @v, @W, @u, @f, and @a \
7568
are ignored in code text"),0);
7576
case m_ifdef:case m_ifndef:
7577
case m_if:case m_else:case m_elif:case m_endif:case m_undef:case m_line:
7578
case m_for:case m_endfor:
7595
if(ntoken&&breakpoints&&t==module_name&&auto_bp)
7598
ASCII bp_cmd[BP_BUF_SIZE];
7600
if(cur_module!=NULL)
7604
nsprintf(bp_cmd,OC("_BP(%d,\"%s\")"),2,module_count,name_of((sixteen_bits)(cur_module-name_dir)))>=(int)(BP_BUF_SIZE))OVERFLW("bp_cmd","");
7605
to_ASCII(OC(bp_cmd));
7606
divert(bp_cmd,bp_cmd+STRLEN(bp_cmd),DONT_STOP);
7623
ASCII bp_cmd[BP_BUF_SIZE];
7625
if(cur_module!=NULL)
7629
nsprintf(bp_cmd,OC("_BP(%d,\"%s\")"),2,module_count,name_of((sixteen_bits)(cur_module-name_dir)))>=(int)(BP_BUF_SIZE))OVERFLW("bp_cmd","");
7630
to_ASCII(OC(bp_cmd));
7631
divert(bp_cmd,bp_cmd+STRLEN(bp_cmd),DONT_STOP);
7645
if(stop_the_scan&&!from_buffer)
7648
next_control= ignore;
7651
(eight_bits)CHOICE((from_buffer&&loc>limit)||stop,
7665
app_repl(begin_language);
7666
app_repl(NUWEB_OFF|nuweb_mode);
7671
if(text_ptr>text_end)
7672
OVERFLW("texts","x");
7675
cur_text->nbytes= tok_ptr-cur_text->tok_start;
7677
(++text_ptr)->tok_start= tok_ptr;
7681
cur_text->Language= (boolean)language0;
7687
ins_ln_no FCN((delta))
7688
int delta C1("Increment to line number")
7692
store_two_bytes((sixteen_bits)LINE_NUM);
7694
id_first= x_to_ASCII(changing?change_file_name:cur_file_name);
7695
id_loc= id_first+STRLEN(id_first);
7697
store_two_bytes((sixteen_bits)((changing?change_line:cur_line)+delta));
7699
store_two_bytes(ID_NUM_ptr(np,id_first,id_loc));
7700
np->Language= (boolean)NO_LANGUAGE;
7705
copy_string FCN((a0))
7706
eight_bits a0 C1("")
7710
for(;id_first<id_loc;id_first++)
7715
if(language==TEX&&*(id_first+1)==0100)
7721
switch(ccode[*id_first])
7743
err0_print(ERR_T,OC("RCS keywords and module names aren't \
7744
allowed inside strings"),0);
7745
for(id_first++;id_first[0]!=0100&&id_first[1]!=076;
7759
app_repl(*id_first);
7769
CONST ASCII HUGE*b C0("Beginning of string.")
7770
CONST ASCII HUGE*b1 C1("End of string.")
7787
n+= A_TO_UPPER(*b)-0101+10;
7795
app_converted FCN((n))
7796
unsigned long n C1("")
7798
ASCII temp[N_IDBUF];
7803
nsprintf((outer_char*)(temp),OC("%lu"),1,n)>=(int)(N_IDBUF))OVERFLW("(outer_char*)(temp)","");
7804
to_ASCII((outer_char*)(temp));
7807
for(b= temp;*b!='\0';b++)app_repl(*b)
7815
CONST ASCII HUGE*b C0("Beginning of string.")
7816
CONST ASCII HUGE*b1 C1("End of string.")
7838
CONST ASCII HUGE*b C0("Beginning of string.")
7839
CONST ASCII HUGE*b1 C1("End of string.")
7859
rdc_char_constant(VOID)
7863
if(*++id_first==0134)
7867
case 060:n= '\0';break;
7868
case 0134:n= 0134;break;
7869
case 047:n= 047;break;
7870
case 042:n= 042;break;
7871
case 077:n= 077;break;
7872
case 0141:n= 07;break;
7873
case 0142:n= 010;break;
7874
case 0146:n= 014;break;
7875
case 0156:n= 012;break;
7876
case 0162:n= 015;break;
7877
case 0164:n= 011;break;
7878
case 0166:n= 013;break;
7883
err0_print(ERR_T,OC("Invalid escape sequence '\\%c' \
7884
in Ratfor character constant; null assumed"),1,XCHR(*id_first));
7890
if(*(id_first+1)!=047)
7891
err0_print(ERR_T,OC("Ratfor character constant longer \
7892
than one byte; extra characters ignored"),0);
7901
if(*id_first++==047)
7903
if(C_LIKE(language))
7904
app_aconst('o',YES);
7911
ASCII temp[100],HUGE*t= temp;
7915
if(id_first[-1]==0134)
7918
while(*id_first!=047)
7924
macro_err(OC("! $A('%c') requires just one character between \
7925
the single quotes; did you mean $A(\"%s\")?"),NO,temp[0],temp);
7932
if(C_LIKE(language))
7936
while(*id_first!=042)
7947
ASCII delim= (ASCII)(is_RATFOR_(language)?042:047);
7948
int n= STRLEN(t_style.ASCII_fcn);
7951
a= ID_NUM(t_style.ASCII_fcn,t_style.ASCII_fcn+n);
7954
app_repl(LEFT(a,ID0));
7961
while(*id_first!=042)
7962
app_repl(*id_first++);
7973
while(*id_first!=042)
7988
app_aconst FCN((fmt_char,leading_zero))
7989
outer_char fmt_char C0("Either 'o' (octal) or 'd' (decimal)")
7990
boolean leading_zero C1("For octal format")
7993
outer_char value[10],*v;
8000
err0_print(ERR_T,OC("Should use double @ within \
8001
ASCII constant"),0);
8004
else if(*id_first==0134)
8009
n= esc_achar((CONST ASCII HUGE*HUGE*)&id_first);
8012
else n= *id_first++;
8022
#ifdef scramble_ASCII
8026
#ifdef unscramble_ASCII
8037
nsprintf(value,OC(fmt_char=='o'?"%s%o":"%s%d"),2,leading_zero?"0":"",n)>=(int)(10))OVERFLW("value","");
8039
for(v= value;*v;v++)
8047
if(leading_zero)app_repl(060);
8049
value[0]= 060+(n>>6);
8050
value[1]= 060+((n-0100*(n>>6))>>3);
8051
value[2]= 060+(n-010*(n>>3));
8054
if(value[l]!=060)break;
8065
i_ascii_ FCN((n,pargs))
8070
eight_bits*start= pargs[0]+1;
8076
eight_bits HUGE*tok_ptr0= tok_ptr;
8079
id_first= (ASCII HUGE*)(start+1);
8083
err0_print(ERR_T,OC("Argument of _A should be quoted; \
8084
just returning argument"),0);
8090
len= PTR_DIFF(int,tok_ptr,tok_ptr0);
8091
MCHECK(len,"_ascii_");
8092
memcpy(mp,tok_ptr0,len);
8098
len= PTR_DIFF(int,pargs[1],start);
8099
MCHECK(len,"_ascii_");
8100
STRNCPY(mp,start,len);
8111
name_pointer p= NULL;
8115
params= global_params;
8117
set_output_file(global_language);
8123
parsing_mode= INNER;
8124
nuweb_mode1= nuweb_mode;
8126
next_control= ignore;
8132
divert((ASCII HUGE*)macrobuf,(ASCII HUGE*)mp,STOP);
8141
scan_text(macro,p,EXPAND);
8146
IN_COMMON ASCII HUGE*pbp;
8149
breakpoints= BOOLEAN(MAC_LOOKUP(ID_NUM(pbp,pbp+3))!=NULL);
8157
err0_print(ERR_M,OC("Invalid preprocessor block structure (level %d). \
8158
Missing @#endif?"),1,mlevel);
8165
switch(next_control)
8169
boolean nuweb_mode0= nuweb_mode;
8171
params= global_params;
8172
nuweb_mode= nuweb_mode0;
8174
set_output_file(global_language);
8179
if(FORTRAN_LIKE(language)&&!free_form_input)
8184
parsing_mode= OUTER;
8197
params= cur_module->mod_info->params;
8202
while((next_control= skip_ahead(ignore,NO))!=new_module)
8215
while((next_control= get_next())==053)
8218
if(next_control!=075&&next_control!=eq_eq)
8221
err0_print(ERR_T,OC("Code text of %s flushed; = sign is missing"),1,MTRANS);
8224
while((next_control= skip_ahead(ignore,NO))!=new_module)
8235
if(FORTRAN_LIKE(language)&&!free_form_input)
8240
parsing_mode= OUTER;
8251
next_control= ignore;
8252
scan_text(module_name,p,EXPAND);
8262
scan_text FCN((text_type,p,expand))
8263
int text_type C0("Either |macro| or |module_name|.")
8264
CONST name_pointer p C0("Module name.")
8265
boolean expand C1("Do we expand?")
8268
boolean scanned_if= NO;
8269
boolean first_text= YES;
8273
scanning_defn= BOOLEAN(text_type==macro);
8275
if(++mlevel>=MAX_LEVEL)
8277
fatal(ERR_T,OC("Conditional nesting depth exceeded."),OC(""));
8282
if(scanning_defn&&expand)
8284
while(next_control<=ignore_defn)
8287
skip_ahead(next_control,YES))==module_name)
8289
loc-= 2;next_control= get_next();
8297
while((next_control=
8298
skip_ahead(next_control,YES))==module_name)
8299
if((next_control= skip_ahead(next_control,YES))!=ignore)
8301
err0_print(ERR_T,OC("Expected @> after @<"),0);
8307
store_two_bytes((sixteen_bits)(LINE_NUM+module_count));
8312
scan_repl(module_name,stop_the_scan);
8323
if(p==name_dir||p==NULL)
8325
cur_text->module_text= (first_text&&mlevel==1);
8330
if(cur_text->module_text)
8331
cur_text->Language= (boolean)global_language;
8333
last_unnamed->text_link= (sixteen_bits)(cur_text-text_info);
8335
last_unnamed= cur_text;
8337
else if(p->equiv==(EQUIV)text_info)
8339
cur_text->module_text= YES;
8340
p->equiv= (EQUIV)cur_text;
8346
q= (text_pointer)p->equiv;
8347
language0= (LANGUAGE)q->Language;
8354
cur_text->module_text= (first_text&&mlevel==1);
8356
if(cur_text->module_text)
8357
cur_text->Language= (boolean)language0;
8361
while(q->text_link<module_flag)q= q->text_link+text_info;
8363
q->text_link= (sixteen_bits)(cur_text-text_info);
8369
cur_text->text_link= module_flag;
8377
switch(next_control)
8382
DEF_OR_NDEF(M_TRUE);
8386
DEF_OR_NDEF(M_FALSE);
8395
goto next_macro_token;
8402
boolean scan0= scanning_defn;
8405
scan_repl(macro,STOP);
8406
scanning_defn= scan0;
8408
cur_text->nargs= UNDEFINED_MACRO;
8410
pp= xmac_text(macrobuf,cur_text->tok_start,tok_ptr);
8411
if_switch= eval(pp,mp);
8418
scan_text(text_type,p,if_switch);
8422
expand= NO;to_else();
8424
if(next_control!=m_endif)
8427
goto next_macro_token;
8431
next_control= ignore;
8452
next_control= ignore;
8454
if((mlevel==1&&!scanned_if)||found_else)
8456
OUT_OF_ORDER("elif");
8465
goto next_macro_token;
8472
boolean scan0= scanning_defn;
8475
scan_repl(macro,STOP);
8476
scanning_defn= scan0;
8478
cur_text->nargs= UNDEFINED_MACRO;
8480
pp= xmac_text(macrobuf,cur_text->tok_start,tok_ptr);
8481
if_switch= eval(pp,mp);
8488
scan_text(text_type,p,if_switch);
8492
expand= NO;to_else();
8494
if(next_control!=m_endif)
8497
goto next_macro_token;
8501
next_control= ignore;
8523
next_control= ignore;
8525
if((mlevel==1&&!scanned_if)||found_else)
8527
OUT_OF_ORDER("else");
8534
expand= BOOLEAN(!expand);
8539
scan_text(text_type,p,expand);
8544
goto next_macro_token;
8550
next_control= ignore;
8554
OUT_OF_ORDER("endif");
8565
next_control= ignore;
8568
if((next_control= get_next())!=identifier)
8570
err0_print(ERR_M,OC("Identifier must follow @#undef"),0);
8573
undef(ID_NUM(id_first,id_loc),SILENT);
8582
confusion(OC("preprocessor cases"),OC("m_line shouldn't reach here"));
8586
if(!expand)next_control= ignore;
8590
err0_print(ERR_M,OC("Sorry, preprocessor command isn't implemented yet"),0);
8596
case new_output_file:
8598
err0_print(ERR_T,OC("@O and @o are allowed only in the code \
8599
section; command ignored"),0);
8600
next_control= ignore;
8604
case definition:case undefinition:
8605
case WEB_definition:
8607
next_control= ignore;
8611
eight_bits last_control;
8613
if((np= app_macro(last_control= next_control))
8615
else if(last_control==WEB_definition
8616
&&!(IS_PROTECTED(np)&&(npq->built_in&&!redefine_builtins
8617
||!npq->built_in&&!redefine_macros)))
8618
np->equiv= (EQUIV)cur_text;
8624
if(next_control<=ignore_defn)
8636
out_of_order FCN((cmd))
8637
CONST outer_char cmd[]C1("Name of bad preprocessor command.")
8640
err0_print(ERR_M,OC("Ignored out-of-order \"@#%s\" (mlevel = %d)"),2,cmd,mlevel);
8648
int elevel= 0,elifs[MAX_LEVEL],elses[MAX_LEVEL],k;
8650
for(k= 0;k<MAX_LEVEL;k++)
8651
elifs[k]= elses[k]= 0;
8654
switch(next_control= skip_ahead(next_control,NO))
8665
err0_print(ERR_M,OC("Can't have @#elif after @#else"),0);
8667
if(elevel==0)return;
8673
err0_print(ERR_M,OC("Only one @#else allowed \
8674
(scanning to @else)"),0);
8677
if(language==TEX&&!get_line())
8685
elifs[elevel]= elses[elevel]= 0;
8690
if(language==TEX&&!get_line())
8698
err0_print(ERR_M,OC("Section ended during scan for \
8699
\"@#else\", \"@#elif\", or \"@#endif\". Inserted \"@#endif\". \
8700
(elevel = %d)"),1,elevel);
8711
to_endif FCN((m_case))
8712
int m_case C1("Case that called to_endif")
8714
int elevel= 1,elifs[MAX_LEVEL],elses[MAX_LEVEL],k;
8716
for(k= 0;k<MAX_LEVEL;k++)
8717
elifs[k]= elses[k]= 0;
8728
switch(next_control= skip_ahead(next_control,NO))
8739
err0_print(ERR_M,OC("Can't have @#elif after @#else"),0);
8746
err0_print(ERR_M,OC("Only one @#else allowed \
8747
(scanning to @endif)"),0);
8752
elifs[elevel]= elses[elevel]= 0;
8757
if(language==TEX&&!get_line())
8765
err0_print(ERR_M,OC("Section ended during scan for \
8766
\"endif\"; inserted \"endif\". (elevel = %d)"),1,elevel);
8776
app_macro FCN((last_control))
8777
eight_bits last_control C1("Last token processed.")
8780
name_pointer np= NULL;
8781
boolean make_recursive= NO;
8782
boolean make_protected= NO;
8783
ASCII insert_type[6];
8786
boolean nuweb_mode0= nuweb_mode;
8790
is_WEB_macro= BOOLEAN(last_control==WEB_definition);
8792
if(is_WEB_macro||C_LIKE(language))
8794
while((next_control= get_next())==012)
8799
if(next_control==MAKE_RECURSIVE)
8801
make_recursive= YES;
8802
next_control= get_next();
8804
else if(next_control==AUTO_INSERT)
8809
while((c= *loc++)!=END_AUTO_INSERT)
8814
err0_print(ERR_M,OC("Found space instead of ']' after automatic \
8815
insertion material"),0);
8826
err0_print(ERR_M,OC("Can't have more than 6 types of automatic \
8827
insertion material; remaining ignored"),0);
8834
STRNCPY(insert_type,"pmsfbi",insert_num= 6);
8837
case 0160:case 0120:
8838
case 0155:case 0115:
8839
case 0163:case 0123:
8840
case 0146:case 0106:
8841
case 0142:case 0102:
8842
case 0151:case 0111:
8843
insert_type[insert_num++]= c;
8848
err0_print(ERR_M,OC("Auto insertion type must be one of \
8854
next_control= get_next();
8858
else if(next_control==PROTECTED)
8860
make_protected= YES;
8861
next_control= get_next();
8864
if(next_control!=identifier)
8867
err0_print(ERR_M,OC("Definition flushed in %s; must start with \
8868
identifier"),1,MTRANS);
8874
a= ID_NUM_ptr(np,id_first,id_loc);
8877
temp[0]= LEFT(a,ID0);temp[1]= RIGHT(a);
8880
while(insert_num-->0)
8881
switch(insert_type[insert_num])
8883
case 0160:case 0120:
8884
if(insert.program.end>insert.program.start)
8886
err0_print(ERR_M,OC("Overriding previous auto insertion type %s"),1,"program");
8887
STRNCPY(insert.program.start,temp,2);
8888
insert.program.end= insert.program.start+2;
8891
case 0155:case 0115:
8892
if(insert.module.end>insert.module.start)
8894
err0_print(ERR_M,OC("Overriding previous auto insertion type %s"),1,"module");
8895
STRNCPY(insert.module.start,temp,2);
8896
insert.module.end= insert.module.start+2;
8899
case 0163:case 0123:
8900
if(insert.subroutine.end>insert.subroutine.start)
8902
err0_print(ERR_M,OC("Overriding previous auto insertion type %s"),1,"subroutine");
8903
STRNCPY(insert.subroutine.start,temp,2);
8904
insert.subroutine.end= insert.subroutine.start+2;
8907
case 0146:case 0106:
8908
if(insert.function.end>insert.function.start)
8910
err0_print(ERR_M,OC("Overriding previous auto insertion type %s"),1,"function");
8911
STRNCPY(insert.function.start,temp,2);
8912
insert.function.end= insert.function.start+2;
8915
case 0142:case 0102:
8916
if(insert.blockdata.end>insert.blockdata.start)
8918
err0_print(ERR_M,OC("Overriding previous auto insertion type %s"),1,"blockdata");
8919
STRNCPY(insert.blockdata.start,temp,2);
8920
insert.blockdata.end= insert.blockdata.start+2;
8923
case 0151:case 0111:
8924
if(insert.interface.end>insert.interface.start)
8926
err0_print(ERR_M,OC("Overriding previous auto insertion type %s"),1,"interface");
8927
STRNCPY(insert.interface.start,temp,2);
8928
insert.interface.end= insert.interface.start+2;
8939
np->macro_type= IMMEDIATE_MACRO;
8946
else if(C_LIKE(language))
8949
app_repl(stringg);app_repl(040);app_repl(stringg);
8954
nuweb_mode= nuweb_mode0;
8955
scan_repl((eight_bits)macro,(boolean)(!scanning_defn));
8963
text_ptr->tok_start=
8965
tok_ptr= argize(cur_text->tok_start,tok_ptr);
8967
cur_text->Language= (boolean)global_language;
8968
cur_text->recursive= make_recursive;
8969
cur_text->protected= make_protected;
8974
cur_text->nargs= (eight_bits)CHOICE(last_control==definition,
8975
OUTER_MACRO,OUTER_UNMACRO);
8977
if(is_WEB_macro&&IS_PROTECTED(np)&&(npq->built_in&&!redefine_builtins
8978
||!npq->built_in&&!redefine_macros))
8980
err0_print(ERR_M,OC("Can't redefine protected %s `%s'; definition \
8981
(probably on previous line) ignored. \
8982
Use command-line option `-T%c' to override"),3,npq->built_in?"built-in function":"macro",name_of(a),npq->built_in?'b':'m');
8998
cur_text->nbytes= tok_ptr-cur_text->tok_start;
8999
p= GET_MEM("macro space",cur_text->nbytes,eight_bits);
9000
memcpy(p,cur_text->tok_start,cur_text->nbytes);
9001
text_ptr->tok_start= tok_ptr= cur_text->tok_start;
9002
cur_text->tok_start= p;
9004
cur_text->text_link= macro;
9010
app_dmacro FCN((p,p1))
9011
CONST eight_bits HUGE*p C0("Start")
9012
CONST eight_bits HUGE*p1 C1("End.")
9017
boolean make_recursive= NO;
9018
boolean make_protected= NO;
9020
if(*p==MAKE_RECURSIVE)
9022
make_recursive= YES;
9029
macro_err(OC("! Invalid argument to $DEFINE"),YES);
9033
if(TOKEN1(a0= *p++))
9036
macro_err(OC("! $DEFINE flushed; must start with identifier"),YES);
9040
a= IDENTIFIER(a0,a1= *p++);
9046
np->macro_type= IMMEDIATE_MACRO;
9049
{p++;app_repl(040);}
9056
if(text_ptr>text_end)
9057
OVERFLW("texts","x");
9060
cur_text->nbytes= tok_ptr-cur_text->tok_start;
9062
(++text_ptr)->tok_start= tok_ptr;
9071
text_ptr->tok_start=
9073
tok_ptr= argize(cur_text->tok_start,tok_ptr);
9075
cur_text->Language= (boolean)global_language;
9076
cur_text->recursive= make_recursive;
9077
cur_text->protected= make_protected;
9083
np->equiv= (EQUIV)cur_text;
9089
i_define_ FCN((n,pargs))
9095
app_dmacro(pargs[0]+1,pargs[1]);
9101
i_undef_ FCN((n,pargs))
9106
eight_bits HUGE*p= pargs[0]+1;
9108
CHK_ARGS("$UNDEF",1);
9113
macro_err(OC("! Invalid argument to $UNDEF(...)"),YES);
9117
if(TOKEN1(a0= *p++))
9120
macro_err(OC("! $UNDEF(...) flushed; must start with identifier"),YES);
9124
undef(IDENTIFIER(a0,*p),NO);
9132
LANGUAGE language0= language;
9136
rst_input();rst_out(NOT_CONTINUATION);
9137
reading(web_file_name,NO);
9143
pkwd= x__to_ASCII(OC(LKWD));
9145
lkwd= ID_NUM(pkwd,pkwd+STRLEN(LKWD));
9150
while((next_control= skip_ahead(ignore,NO))!=new_module)
9153
chk_override(language0);
9155
global_params= params;
9156
set_output_file(global_language);
9159
while(!input_has_ended)
9168
for(np= name_dir;np<name_ptr;np++)
9169
if(np->equiv!=NULL&&np->equiv!=(EQUIV)text_info
9170
&&np->macro_type==NOT_DEFINED)
9171
num_distinct_modules++;
9173
num_modules= module_count;
9182
i_modules_ FCN((n,pargs))
9186
outer_char temp[50];
9188
nsprintf(temp,OC("%c%u%c"),3,XCHR(constant),*(pargs[0]+2)=='0'?num_distinct_modules:num_modules,XCHR(constant));
9190
CHK_ARGS("$MODULES",1);
9192
MCHECK(m,"_modules_");
9193
STRCPY(mp,to_ASCII(temp));
9200
see_statistics(VOID)
9202
CLR_PRINTF(ALWAYS,info,("\n\nMEMORY USAGE STATISTICS:\n"));
9203
STAT0("names",sizeof(*name_ptr),
9204
SUB_PTRS(name_ptr,name_dir),max_names,smin0(MAX_VAL("n")),"n","");
9206
STAT0("replacement texts",sizeof(*text_ptr),
9207
SUB_PTRS(text_ptr,text_info),max_texts,smin0(MAX_VAL("x")),"x","");
9209
STAT0("deferred texts",sizeof(*txt_dptr),
9210
SUB_PTRS(txt_dptr,txt_dinfo),dtexts_max,smin0(MAX_VAL("dx")),"dx",";");
9212
STAT0("bytes",sizeof(*byte_ptr),
9213
SUB_PTRS(byte_ptr,byte_mem),max_bytes,smin0(MAX_VAL("b")),"b","");
9215
STAT0("tokens",sizeof(*tok_ptr),
9216
SUB_PTRS((mx_tok_ptr>tok_ptr?mx_tok_ptr:tok_ptr),tok_mem),
9217
max_toks,smin0(MAX_VAL("tt")),"tt","");
9219
STAT0("deferred tokens",sizeof(*tok_dptr),
9220
SUB_PTRS((mx_dtok_ptr>tok_dptr?mx_dtok_ptr:tok_dptr),tok_dmem),
9221
max_dtoks,smin0(MAX_VAL("dt")),"dt",".");
9233
SAVE_MACRO("$MODULE_NAME $STRING($$MODULE_NAME)");
9238
SAVE_MACRO("_STUB(s)$IFCASE($LANGUAGE_NUM,\
9239
{missing_mod(#s);},{missing_mod(#s);},\
9240
call nomod(#s),call nomod(#s),\
9241
call nomod(#s),call nomod(#s),\
9243
%nomod(s),%nomod(s))");
9246
SAVE_MACRO("$STUB(s)$IFCASE($LANGUAGE_NUM,\
9247
missing_mod(#s);, missing_mod(#s);,\
9248
call nomod(#s), call nomod(#s),\
9249
call nomod(#s), call nomod(#s),\
9251
%nomod(s), %nomod(s))");
9255
SAVE_MACRO("$VERSION $STRING($$VERSION)");
9260
SAVE_MACRO("$DAY $TM(0)");
9261
SAVE_MACRO("$DATE $TM(1)");
9262
SAVE_MACRO("$TIME $TM(2)");
9264
SAVE_MACRO("$TM(i)$STRING($$TM(i))");
9271
SAVE_MACRO("$A(s)$$ASCII(s)");
9273
SAVE_MACRO("$ASCII(s)$$ASCII(s)");
9277
SAVE_MACRO("$INCR(N,...)$INCR0(#!N,$EVAL(N+$IFELSE(#0,0,1,#1)))");
9279
SAVE_MACRO("$DECR(N,...)$INCR0(#!N,$EVAL(N-$IFELSE(#0,0,1,#1)))");
9281
SAVE_MACRO("$INCR0(N,N1)$M(#!N N1)");
9285
SAVE_MACRO("$MODULES $$MODULES(0)");
9287
SAVE_MACRO("$SECTIONS $$MODULES(1)");
9291
SAVE_MACRO("$DO(k,kmin,kmax,...)$UNROLL(k,kmin,kmax,$IFCASE(#0,1,#.))");
9299
out_msg FCN((msg,msg1))
9300
CONST ASCII*msg C0("Start of message.")
9301
CONST ASCII*msg1 C1("See the description below.")
9303
eight_bits HUGE*temp;
9304
eight_bits HUGE*mp0= mp,
9305
HUGE*macrobuf0= macrobuf,HUGE*macrobuf_end0= macrobuf_end;
9307
boolean nuweb_mode0,in_string0,meta_mode0;
9310
mp= macrobuf= temp= GET_MEM("out_msg:temp",MSG_BUF_SIZE,eight_bits);
9311
macrobuf_end= temp+MSG_BUF_SIZE;
9316
msg1= msg+STRLEN(msg);
9318
new_msg= (char HUGE*)str_to_mb((eight_bits HUGE*)msg,
9319
(eight_bits HUGE*)msg1,NO);
9322
spcs_after_cmnt= SPCS_AFTER_CMNT;
9327
nuweb_mode0= nuweb_mode;
9328
in_string0= in_string;
9329
meta_mode0= meta_mode;
9331
meta_mode= nuweb_mode= NO;
9338
OUT_CHAR(begin_meta);
9339
OUT_CHAR(begin_meta);
9342
OUT_CHAR(*new_msg++);
9346
nuweb_mode= nuweb_mode0;
9347
in_string= in_string0;
9348
meta_mode= meta_mode0;
9352
FREE_MEM(temp,"out_msg:temp",MSG_BUF_SIZE,eight_bits);
9353
macrobuf= macrobuf0;mp= mp0;macrobuf_end= macrobuf_end0;
9358
static sixteen_bits id_unroll;
9360
SPEC univ_tokens[]= {
9361
{"_UNROLL",0,x_unroll,&id_unroll},
9362
{"$UNROLL",0,x_unroll,&id_unroll},
9367
ini_univ_tokens FCN((language0))
9368
LANGUAGE language0 C1("")
9370
ini_special_tokens(language0,univ_tokens);
9376
ini_tokens FCN((language0))
9377
LANGUAGE language0 C1("")
9400
ini_univ_tokens(language0);
9406
get_constant FCN((e))
9407
eight_bits HUGE*e C1("")
9409
boolean positive= YES;
9421
err0_print(ERR_T,OC("Invalid loop constant"),0);
9427
return(positive)?i:-i;