home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / dec93 / dev / misc / cweb.lha / CWeb / common.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-12-21  |  28.8 KB  |  1,525 lines

  1. /*1:*/
  2. #line 57 "common.w"
  3.  
  4. #line 140 "common-p.ch"
  5. /*5:*/
  6. #line 101 "common.w"
  7.  
  8. #include <ctype.h>
  9.  
  10. /*:5*//*8:*/
  11. #line 161 "common.w"
  12.  
  13. #include <stdio.h>
  14.  
  15. /*:8*//*22:*/
  16. #line 466 "common.w"
  17.  
  18. #include <stdlib.h> 
  19.  
  20. /*:22*//*81:*/
  21. #line 808 "common-p.ch"
  22.  
  23. #line 809 "common-p.ch"
  24. #include <string.h>
  25.  
  26. /*:81*//*86:*/
  27. #line 874 "common-p.ch"
  28.  
  29. #ifdef __TURBOC__
  30. #include <alloc.h> 
  31. #include <io.h> 
  32. #endif
  33.  
  34.  
  35. /*:86*//*90:*/
  36. #line 925 "common-p.ch"
  37.  
  38. #include <stdlib.h>
  39.  
  40. /*:90*/
  41. #line 140 "common-p.ch"
  42.  
  43. /*87:*/
  44. #line 881 "common-p.ch"
  45.  
  46. #ifdef __TURBOC__
  47. #define HUGE huge
  48. #else
  49. #define HUGE
  50. #endif
  51.  
  52.  
  53. /*:87*/
  54. #line 141 "common-p.ch"
  55.  
  56. #line 59 "common.w"
  57. #define ctangle 0
  58. #define cweave 1 \
  59.  
  60. #define and_and 04
  61. #define lt_lt 020
  62. #define gt_gt 021
  63. #define plus_plus 013
  64. #define minus_minus 01
  65. #define minus_gt 031
  66. #define not_eq 032
  67. #define lt_eq 034
  68. #define gt_eq 035
  69. #define eq_eq 036
  70. #define or_or 037
  71. #define dot_dot_dot 016
  72. #define colon_colon 06
  73. #define period_ast 026
  74. #define minus_gt_ast 027 \
  75.  
  76. #define buf_size 100
  77. #define long_buf_size 500 \
  78.  
  79. #define max_include_depth 10 \
  80.  \
  81.  
  82. #define max_file_name_length 256 \
  83.  
  84. #define cur_file file[include_depth]
  85. #define cur_file_name file_name[include_depth]
  86. #define cur_line line[include_depth]
  87. #define web_file file[0]
  88. #define web_file_name file_name[0] \
  89.  
  90. #define lines_dont_match (change_limit-change_buffer!=limit-buffer|| \
  91. strncmp(buffer,change_buffer,limit-buffer) )  \
  92.  
  93. #define if_section_start_make_pending(b) {*limit= '!'; \
  94. for(loc= buffer;isspace(*loc) ;loc++) ; \
  95. *limit= ' '; \
  96. if(*loc=='@'&&(isspace(*(loc+1) ) ||*(loc+1) =='*') ) change_pending= b; \
  97. } \
  98.  
  99. #define max_sections 2000 \
  100.  \
  101.  
  102. #define PATH_SEPARATOR ','
  103. #define DIR_SEPARATOR '/'
  104. #define DEVICE_SEPARATOR ':' \
  105.  
  106. #define too_long() {include_depth--; \
  107. err_print("! Include file name too long") ;goto restart;} \
  108.  
  109. #define max_bytes 90000 \
  110.  
  111. #define max_names 4000 \
  112.  \
  113.  
  114. #define length(c) (c+1) ->byte_start-(c) ->byte_start
  115. #define print_id(c) term_write((c) ->byte_start,length((c) ) )  \
  116.  
  117. #define hash_size 353 \
  118.  
  119. #define llink link
  120. #define rlink dummy.Rlink
  121. #define root name_dir->rlink \
  122.  \
  123.  
  124. #define first_chunk(p) ((p) ->byte_start+2) 
  125. #define prefix_length(p) (int) ((unsigned char) *((p) ->byte_start) *256+ \
  126. (unsigned char) *((p) ->byte_start+1) ) 
  127. #define set_prefix_length(p,m) (*((p) ->byte_start) = (m) /256, \
  128. *((p) ->byte_start+1) = (m) %256)  \
  129.  
  130. #define less 0
  131. #define equal 1
  132. #define greater 2
  133. #define prefix 3
  134. #define extension 4 \
  135.  
  136. #define bad_extension 5 \
  137.  \
  138.  
  139. #define spotless 0
  140. #define harmless_message 1
  141. #define error_message 2
  142. #define fatal_message 3
  143. #define mark_harmless {if(history==spotless) history= harmless_message;}
  144. #define mark_error history= error_message \
  145.  
  146. #define RETURN_OK 0
  147. #define RETURN_WARN 5
  148. #define RETURN_ERROR 10
  149. #define RETURN_FAIL 20 \
  150.  
  151. #define confusion(s) fatal("! This can't happen: ",s)  \
  152.  \
  153.  
  154. #define show_banner flags['b']
  155. #define show_progress flags['p']
  156. #define show_stats flags['s']
  157. #define show_happiness flags['h']
  158. #define use_amiga_keywords flags['a']
  159. #define use_german_macros flags['g']
  160. #define indent_param_decl flags['i'] \
  161.  
  162. #define update_terminal fflush(stdout)  \
  163.  
  164. #define new_line putchar('\n') 
  165. #define putxchar putchar
  166. #define term_write(a,b) fflush(stdout) ,fwrite(a,sizeof(char) ,b,stdout) 
  167. #define C_printf(c,a) fprintf(C_file,c,a) 
  168. #define C_putc(c) putc(c,C_file)  \
  169.  
  170. #define MAXPATHLENGTH 4095
  171. #define CWEBINPUTS ",CWeb:,CWeb:include,CWeb:inputs" \
  172.  
  173.  
  174. #line 59 "common.w"
  175.  
  176. /*2:*/
  177. #line 72 "common.w"
  178.  
  179. typedef short boolean;
  180. boolean program;
  181.  
  182. /*:2*//*7:*/
  183. #line 155 "common.w"
  184.  
  185. char buffer[long_buf_size];
  186. char*buffer_end= buffer+buf_size-2;
  187. char*limit= buffer;
  188. char*loc= buffer;
  189.  
  190. /*:7*//*10:*/
  191. #line 210 "common.w"
  192.  
  193. int include_depth;
  194. FILE*file[max_include_depth];
  195. FILE*change_file;
  196. char file_name[max_include_depth][max_file_name_length];
  197.  
  198. char change_file_name[max_file_name_length];
  199. char alt_web_file_name[max_file_name_length];
  200. int line[max_include_depth];
  201. int change_line;
  202. int change_depth;
  203. boolean input_has_ended;
  204. boolean changing;
  205. boolean web_file_open= 0;
  206.  
  207. #line 177 "common-p.ch"
  208. /*:10*//*20:*/
  209. #line 414 "common.w"
  210.  
  211. typedef unsigned short sixteen_bits;
  212. sixteen_bits section_count;
  213. boolean changed_section[max_sections];
  214. boolean change_pending;
  215.  
  216. boolean print_where= 0;
  217.  
  218. /*:20*//*27:*/
  219. #line 584 "common.w"
  220.  
  221. typedef struct name_info{
  222. #line 298 "common-p.ch"
  223. char HUGE*byte_start;
  224. #line 587 "common.w"
  225. /*31:*/
  226. #line 621 "common.w"
  227.  
  228. #line 343 "common-p.ch"
  229. struct name_info HUGE*link;
  230. #line 623 "common.w"
  231.  
  232. /*:31*//*40:*/
  233. #line 720 "common.w"
  234.  
  235. union{
  236. #line 381 "common-p.ch"
  237. struct name_info HUGE*Rlink;
  238.  
  239. #line 724 "common.w"
  240. char Ilk;
  241. }dummy;
  242.  
  243. /*:40*//*55:*/
  244. #line 1052 "common.w"
  245.  
  246. #line 550 "common-p.ch"
  247. char HUGE*equiv_or_xref;
  248. #line 1054 "common.w"
  249.  
  250. /*:55*/
  251. #line 587 "common.w"
  252.  
  253. }name_info;
  254. #line 308 "common-p.ch"
  255. typedef name_info HUGE*name_pointer;
  256. #ifdef __TURBOC__
  257. char HUGE*byte_mem;
  258. char HUGE*byte_mem_end;
  259. name_info HUGE*name_dir;
  260. name_pointer name_dir_end;
  261. #else
  262. char byte_mem[max_bytes];
  263. char*byte_mem_end= byte_mem+max_bytes-1;
  264. name_info name_dir[max_names];
  265. name_pointer name_dir_end= name_dir+max_names-1;
  266. #endif
  267. #line 594 "common.w"
  268.  
  269. /*:27*//*29:*/
  270. #line 607 "common.w"
  271.  
  272. name_pointer name_ptr;
  273. #line 325 "common-p.ch"
  274. char HUGE*byte_ptr;
  275. #line 610 "common.w"
  276.  
  277. /*:29*//*32:*/
  278. #line 634 "common.w"
  279.  
  280. typedef name_pointer*hash_pointer;
  281. name_pointer hash[hash_size];
  282. hash_pointer hash_end= hash+hash_size-1;
  283. hash_pointer h;
  284.  
  285. #line 350 "common-p.ch"
  286. /*:32*//*56:*/
  287. #line 1072 "common.w"
  288.  
  289. int history= spotless;
  290.  
  291. /*:56*//*67:*/
  292. #line 1210 "common.w"
  293.  
  294. int argc;
  295. char**argv;
  296. char C_file_name[max_file_name_length];
  297. char tex_file_name[max_file_name_length];
  298. char idx_file_name[max_file_name_length];
  299. char scn_file_name[max_file_name_length];
  300. #line 678 "common-p.ch"
  301. boolean flags[256];
  302. #line 1218 "common.w"
  303.  
  304. /*:67*//*77:*/
  305. #line 1361 "common.w"
  306.  
  307. FILE*C_file;
  308. FILE*tex_file;
  309. FILE*idx_file;
  310. FILE*scn_file;
  311. FILE*active_file;
  312.  
  313. /*:77*/
  314. #line 60 "common.w"
  315.  
  316. /*3:*/
  317. #line 82 "common.w"
  318. int phase;
  319.  
  320. /*:3*//*11:*/
  321. #line 236 "common.w"
  322.  
  323. char change_buffer[buf_size];
  324. char*change_limit;
  325.  
  326. /*:11*//*83:*/
  327. #line 840 "common-p.ch"
  328.  
  329. char include_path[MAXPATHLENGTH+1]= CWEBINPUTS;
  330. char*p,*path_prefix,*next_path_prefix;
  331.  
  332. /*:83*//*88:*/
  333. #line 893 "common-p.ch"
  334.  
  335. #ifdef _AMIGA 
  336. typedef unsigned char eight_bits;
  337. #else
  338. typedef char unsigned eight_bits;
  339. #endif
  340. void common_init(void);
  341. void reset_input(void);
  342. int get_line(void);
  343. void check_complete(void);
  344. name_pointer id_lookup(char*first,char*last,char t);
  345. void print_section_name(name_pointer);
  346. void sprint_section_name(char*,name_pointer);
  347. void print_prefix_name(name_pointer);
  348. name_pointer add_section_name(name_pointer par,int c,
  349. char*first,char*last,int ispref);
  350. void extend_section_name(name_pointer p,char*first,char*last,int ispref);
  351. name_pointer section_lookup(char*first,char*last,int ispref);
  352.  
  353. /*:88*//*89:*/
  354. #line 914 "common-p.ch"
  355.  
  356. static int input_ln(FILE*fp);
  357. static void prime_the_change_buffer(void);
  358. static void check_change(void);
  359. static int web_strcmp(char HUGE*j,int j_len,char HUGE*k,int k_len);
  360. static boolean set_path(char*ptr,char*override);
  361.  
  362. /*:89*/
  363. #line 61 "common.w"
  364.  
  365. /*33:*/
  366. #line 350 "common-p.ch"
  367.  
  368. extern int names_match(name_pointer,char*,int,eight_bits);
  369. #line 642 "common.w"
  370.  
  371. /*:33*//*38:*/
  372. #line 374 "common-p.ch"
  373.  
  374. #line 375 "common-p.ch"
  375. extern void init_p(name_pointer,eight_bits);
  376. #line 695 "common.w"
  377.  
  378. /*:38*//*46:*/
  379. #line 451 "common-p.ch"
  380.  
  381. #line 452 "common-p.ch"
  382. extern void init_node(name_pointer);
  383. #line 844 "common.w"
  384.  
  385. /*:46*//*53:*/
  386. #line 524 "common-p.ch"
  387.  
  388. static int section_name_cmp(char**,int,name_pointer);
  389. #line 1009 "common.w"
  390.  
  391. /*:53*//*57:*/
  392. #line 564 "common-p.ch"
  393.  
  394. #line 565 "common-p.ch"
  395. extern void err_print(char*);
  396. #line 1084 "common.w"
  397.  
  398. /*:57*//*60:*/
  399. #line 581 "common-p.ch"
  400.  
  401. #line 582 "common-p.ch"
  402. int wrap_up(void);
  403. extern void print_stats(void);
  404. #line 1133 "common.w"
  405.  
  406. #line 606 "common-p.ch"
  407. /*:60*//*63:*/
  408. #line 638 "common-p.ch"
  409.  
  410. #line 639 "common-p.ch"
  411. extern void fatal(char*,char*);
  412. extern void overflow(char*);
  413. #line 1165 "common.w"
  414.  
  415. /*:63*//*69:*/
  416. #line 706 "common-p.ch"
  417.  
  418. #line 707 "common-p.ch"
  419. static void scan_args(void);
  420. #line 1243 "common.w"
  421.  
  422. /*:69*//*84:*/
  423. #line 858 "common-p.ch"
  424.  
  425. extern void far*allocsafe(unsigned long,unsigned long);
  426.  
  427.  
  428. /*:84*/
  429. #line 62 "common.w"
  430.  
  431.  
  432. /*:1*//*4:*/
  433. #line 88 "common.w"
  434.  
  435. #line 148 "common-p.ch"
  436. void common_init(void)
  437. #line 91 "common.w"
  438. {
  439. /*30:*/
  440. #line 611 "common.w"
  441.  
  442. #line 331 "common-p.ch"
  443. #ifdef __TURBOC__
  444. byte_mem= allocsafe(max_bytes,sizeof(*byte_mem));
  445. byte_mem_end= byte_mem+max_bytes-1;
  446. name_dir= allocsafe(max_names,sizeof(*name_dir));
  447. name_dir_end= name_dir+max_names-1;
  448. #endif
  449. name_dir->byte_start= byte_ptr= byte_mem;
  450. #line 613 "common.w"
  451. name_ptr= name_dir+1;
  452. name_ptr->byte_start= byte_mem;
  453.  
  454. /*:30*//*34:*/
  455. #line 645 "common.w"
  456.  
  457. for(h= hash;h<=hash_end;*h++= NULL);
  458.  
  459. /*:34*//*41:*/
  460. #line 727 "common.w"
  461.  
  462. root= NULL;
  463.  
  464. /*:41*/
  465. #line 92 "common.w"
  466. ;
  467. /*68:*/
  468. #line 685 "common-p.ch"
  469.  
  470. #line 686 "common-p.ch"
  471. show_banner= show_happiness= show_progress= 1;
  472. #ifdef _AMIGA
  473. use_amiga_keywords= 
  474. #endif
  475. use_german_macros= indent_param_decl= 1;
  476. #line 1225 "common.w"
  477.  
  478. /*:68*/
  479. #line 93 "common.w"
  480. ;
  481. /*78:*/
  482. #line 1368 "common.w"
  483.  
  484. scan_args();
  485. if(program==ctangle){
  486. if((C_file= fopen(C_file_name,"w"))==NULL)
  487. fatal("! Cannot open output file ",C_file_name);
  488.  
  489. }
  490. else{
  491. if((tex_file= fopen(tex_file_name,"w"))==NULL)
  492. fatal("! Cannot open output file ",tex_file_name);
  493. }
  494.  
  495. /*:78*/
  496. #line 94 "common.w"
  497. ;
  498. }
  499.  
  500. /*:4*//*9:*/
  501. #line 168 "common.w"
  502.  
  503. #line 162 "common-p.ch"
  504. static int input_ln(FILE*fp)
  505.  
  506. #line 171 "common.w"
  507. {
  508. register int c= EOF;
  509. register char*k;
  510. if(feof(fp))return(0);
  511. limit= k= buffer;
  512. while(k<=buffer_end&&(c= getc(fp))!=EOF&&c!='\n')
  513. if((*(k++)= c)!=' ')limit= k;
  514. if(k>buffer_end)
  515. if((c= getc(fp))!=EOF&&c!='\n'){
  516. ungetc(c,fp);loc= buffer;err_print("! Input line too long");
  517.  
  518. }
  519. if(c==EOF&&limit==buffer)return(0);
  520.  
  521. return(1);
  522. }
  523.  
  524. /*:9*//*12:*/
  525. #line 247 "common.w"
  526.  
  527. #line 184 "common-p.ch"
  528. static void prime_the_change_buffer(void)
  529. #line 250 "common.w"
  530. {
  531. change_limit= change_buffer;
  532. /*13:*/
  533. #line 261 "common.w"
  534.  
  535. while(1){
  536. change_line++;
  537. if(!input_ln(change_file))return;
  538. if(limit<buffer+2)continue;
  539. if(buffer[0]!='@')continue;
  540. if(isupper(buffer[1]))buffer[1]= tolower(buffer[1]);
  541. if(buffer[1]=='x')break;
  542. if(buffer[1]=='y'||buffer[1]=='z'||buffer[1]=='i'){
  543. loc= buffer+2;
  544. err_print("! Missing @x in change file");
  545.  
  546. }
  547. }
  548.  
  549. /*:13*/
  550. #line 252 "common.w"
  551. ;
  552. /*14:*/
  553. #line 278 "common.w"
  554.  
  555. do{
  556. change_line++;
  557. if(!input_ln(change_file)){
  558. err_print("! Change file ended after @x");
  559.  
  560. return;
  561. }
  562. }while(limit==buffer);
  563.  
  564. /*:14*/
  565. #line 253 "common.w"
  566. ;
  567. /*15:*/
  568. #line 288 "common.w"
  569.  
  570. {
  571. change_limit= change_buffer-buffer+limit;
  572. strncpy(change_buffer,buffer,limit-buffer+1);
  573. }
  574.  
  575. /*:15*/
  576. #line 254 "common.w"
  577. ;
  578. }
  579.  
  580. /*:12*//*16:*/
  581. #line 316 "common.w"
  582.  
  583. #line 191 "common-p.ch"
  584. static void check_change(void)
  585. #line 319 "common.w"
  586. {
  587. int n= 0;
  588. if(lines_dont_match)return;
  589. change_pending= 0;
  590. if(!changed_section[section_count]){
  591. if_section_start_make_pending(1);
  592. if(!change_pending)changed_section[section_count]= 1;
  593. }
  594. while(1){
  595. changing= 1;print_where= 1;change_line++;
  596. if(!input_ln(change_file)){
  597. err_print("! Change file ended before @y");
  598.  
  599. change_limit= change_buffer;changing= 0;
  600. return;
  601. }
  602. if(limit>buffer+1&&buffer[0]=='@'){
  603. if(isupper(buffer[1]))buffer[1]= tolower(buffer[1]);
  604. /*17:*/
  605. #line 354 "common.w"
  606.  
  607. if(buffer[1]=='x'||buffer[1]=='z'){
  608. loc= buffer+2;err_print("! Where is the matching @y?");
  609.  
  610. }
  611. else if(buffer[1]=='y'){
  612. if(n>0){
  613. loc= buffer+2;
  614. printf("\n! Hmm... %d ",n);
  615. err_print("of the preceding lines failed to match");
  616.  
  617. }
  618. change_depth= include_depth;
  619. return;
  620. }
  621.  
  622. /*:17*/
  623. #line 338 "common.w"
  624. ;
  625. }
  626. /*15:*/
  627. #line 288 "common.w"
  628.  
  629. {
  630. change_limit= change_buffer-buffer+limit;
  631. strncpy(change_buffer,buffer,limit-buffer+1);
  632. }
  633.  
  634. /*:15*/
  635. #line 340 "common.w"
  636. ;
  637. changing= 0;cur_line++;
  638. while(!input_ln(cur_file)){
  639. if(include_depth==0){
  640. err_print("! CWEB file ended during a change");
  641.  
  642. input_has_ended= 1;return;
  643. }
  644. include_depth--;cur_line++;
  645. }
  646. if(lines_dont_match)n++;
  647. }
  648. }
  649.  
  650. /*:16*//*18:*/
  651. #line 374 "common.w"
  652.  
  653. #line 198 "common-p.ch"
  654. void reset_input(void)
  655. #line 377 "common.w"
  656. {
  657. limit= buffer;loc= buffer+1;buffer[0]= ' ';
  658. /*19:*/
  659. #line 389 "common.w"
  660.  
  661. if((web_file= fopen(web_file_name,"r"))==NULL){
  662. strcpy(web_file_name,alt_web_file_name);
  663. if((web_file= fopen(web_file_name,"r"))==NULL)
  664. fatal("! Cannot open input file ",web_file_name);
  665. }
  666.  
  667.  
  668. web_file_open= 1;
  669. if((change_file= fopen(change_file_name,"r"))==NULL)
  670. fatal("! Cannot open change file ",change_file_name);
  671.  
  672. /*:19*/
  673. #line 379 "common.w"
  674. ;
  675. include_depth= 0;cur_line= 0;change_line= 0;
  676. change_depth= include_depth;
  677. changing= 1;prime_the_change_buffer();changing= !changing;
  678. limit= buffer;loc= buffer+1;buffer[0]= ' ';input_has_ended= 0;
  679. }
  680.  
  681. /*:18*//*21:*/
  682. #line 422 "common.w"
  683.  
  684. #line 204 "common-p.ch"
  685. int get_line(void)
  686. #line 424 "common.w"
  687. {
  688. restart:
  689. if(changing&&include_depth==change_depth)
  690. /*25:*/
  691. #line 527 "common.w"
  692. {
  693. change_line++;
  694. if(!input_ln(change_file)){
  695. err_print("! Change file ended without @z");
  696.  
  697. buffer[0]= '@';buffer[1]= 'z';limit= buffer+2;
  698. }
  699. if(limit>buffer){
  700. if(change_pending){
  701. if_section_start_make_pending(0);
  702. if(change_pending){
  703. changed_section[section_count]= 1;change_pending= 0;
  704. }
  705. }
  706. *limit= ' ';
  707. if(buffer[0]=='@'){
  708. if(isupper(buffer[1]))buffer[1]= tolower(buffer[1]);
  709. if(buffer[1]=='x'||buffer[1]=='y'){
  710. loc= buffer+2;
  711. err_print("! Where is the matching @z?");
  712.  
  713. }
  714. else if(buffer[1]=='z'){
  715. prime_the_change_buffer();changing= !changing;print_where= 1;
  716. }
  717. }
  718. }
  719. }
  720.  
  721. /*:25*/
  722. #line 427 "common.w"
  723. ;
  724. if(!changing||include_depth>change_depth){
  725. /*24:*/
  726. #line 510 "common.w"
  727. {
  728. cur_line++;
  729. while(!input_ln(cur_file)){
  730. print_where= 1;
  731. if(include_depth==0){input_has_ended= 1;break;}
  732. else{
  733. fclose(cur_file);include_depth--;
  734. if(changing&&include_depth==change_depth)break;
  735. cur_line++;
  736. }
  737. }
  738. if(!changing&&!input_has_ended)
  739. if(limit-buffer==change_limit-change_buffer)
  740. if(buffer[0]==change_buffer[0])
  741. if(change_limit>change_buffer)check_change();
  742. }
  743.  
  744. /*:24*/
  745. #line 429 "common.w"
  746. ;
  747. if(changing&&include_depth==change_depth)goto restart;
  748. }
  749. loc= buffer;*limit= ' ';
  750. if(*buffer=='@'&&(*(buffer+1)=='i'||*(buffer+1)=='I')){
  751. loc= buffer+2;
  752. while(loc<=limit&&(*loc==' '||*loc=='\t'||*loc=='"'))loc++;
  753. if(loc>=limit){
  754. err_print("! Include file name not given");
  755.  
  756. goto restart;
  757. }
  758. if(include_depth>=max_include_depth-1){
  759. err_print("! Too many nested includes");
  760.  
  761. goto restart;
  762. }
  763. include_depth++;
  764. /*23:*/
  765. #line 469 "common.w"
  766. {
  767. char temp_file_name[max_file_name_length];
  768. char*cur_file_name_end= cur_file_name+max_file_name_length-1;
  769. char*k= cur_file_name,*kk;
  770. int l;
  771.  
  772. while(*loc!=' '&&*loc!='\t'&&*loc!='"'&&k<=cur_file_name_end)*k++= *loc++;
  773. if(k>cur_file_name_end)too_long();
  774.  
  775. *k= '\0';
  776. if((cur_file= fopen(cur_file_name,"r"))!=NULL){
  777. cur_line= 0;print_where= 1;
  778. goto restart;
  779. }
  780. #line 265 "common-p.ch"
  781. if(0==set_path(include_path,getenv("CWEBINPUTS"))){
  782. include_depth--;goto restart;
  783. }
  784. path_prefix= include_path;
  785. while(path_prefix){
  786. for(kk= temp_file_name,p= path_prefix,l= 0;
  787. p&&*p&&*p!=PATH_SEPARATOR;
  788. *kk++= *p++,l++);
  789. if(path_prefix&&*path_prefix&&*path_prefix!=PATH_SEPARATOR&&
  790. *--p!=DEVICE_SEPARATOR&&*p!=DIR_SEPARATOR){
  791. *kk++= DIR_SEPARATOR;l++;
  792. }
  793. if(k+l+2>=cur_file_name_end)too_long();
  794. strcpy(kk,cur_file_name);
  795. if(cur_file= fopen(temp_file_name,"r")){
  796. cur_line= 0;print_where= 1;goto restart;
  797. }
  798. if(next_path_prefix= strchr(path_prefix,PATH_SEPARATOR))
  799. path_prefix= next_path_prefix+1;
  800. else break;
  801. }
  802. #line 507 "common.w"
  803. include_depth--;err_print("! Cannot open include file");goto restart;
  804. }
  805.  
  806. /*:23*/
  807. #line 447 "common.w"
  808. ;
  809. }
  810. return(!input_has_ended);
  811. }
  812.  
  813. #line 219 "common-p.ch"
  814. /*:21*//*26:*/
  815. #line 559 "common.w"
  816.  
  817. #line 292 "common-p.ch"
  818. void check_complete(void){
  819. #line 562 "common.w"
  820. if(change_limit!=change_buffer){
  821. strncpy(buffer,change_buffer,change_limit-change_buffer+1);
  822. limit= buffer+(int)(change_limit-change_buffer);
  823. changing= 1;change_depth= include_depth;loc= buffer;
  824. err_print("! Change file entry did not match");
  825.  
  826. }
  827. }
  828.  
  829. /*:26*//*35:*/
  830. #line 650 "common.w"
  831.  
  832. #line 363 "common-p.ch"
  833. name_pointer id_lookup(char*first,char*last,char t)
  834.  
  835.  
  836.  
  837.  
  838. #line 656 "common.w"
  839. {
  840. char*i= first;
  841. int h;
  842. int l;
  843. name_pointer p;
  844. if(last==NULL)for(last= first;*last!='\0';last++);
  845. l= last-first;
  846. /*36:*/
  847. #line 673 "common.w"
  848.  
  849. h= (unsigned char)*i;
  850. while(++i<last)h= (h+h+(int)((unsigned char)*i))%hash_size;
  851.  
  852.  
  853. /*:36*/
  854. #line 663 "common.w"
  855. ;
  856. /*37:*/
  857. #line 681 "common.w"
  858.  
  859. p= hash[h];
  860. while(p&&!names_match(p,first,l,t))p= p->link;
  861. if(p==NULL){
  862. p= name_ptr;
  863. p->link= hash[h];hash[h]= p;
  864. }
  865.  
  866. /*:37*/
  867. #line 664 "common.w"
  868. ;
  869. if(p==name_ptr)/*39:*/
  870. #line 696 "common.w"
  871. {
  872. if(byte_ptr+l>byte_mem_end)overflow("byte memory");
  873. if(name_ptr>=name_dir_end)overflow("name");
  874. strncpy(byte_ptr,first,l);
  875. (++name_ptr)->byte_start= byte_ptr+= l;
  876. if(program==cweave)init_p(p,t);
  877. }
  878.  
  879. /*:39*/
  880. #line 665 "common.w"
  881. ;
  882. return(p);
  883. }
  884.  
  885. /*:35*//*42:*/
  886. #line 754 "common.w"
  887.  
  888. #line 389 "common-p.ch"
  889. void print_section_name(name_pointer p)
  890. #line 758 "common.w"
  891. {
  892. #line 395 "common-p.ch"
  893. char HUGE*ss;
  894. char HUGE*s= first_chunk(p);
  895. #line 760 "common.w"
  896. name_pointer q= p+1;
  897. while(p!=name_dir){
  898. ss= (p+1)->byte_start-1;
  899. if(*ss==' '&&ss>=s){
  900. term_write(s,ss-s);p= q->link;q= p;
  901. }else{
  902. term_write(s,ss+1-s);p= name_dir;q= NULL;
  903. }
  904. s= p->byte_start;
  905. }
  906. if(q)term_write("...",3);
  907. }
  908.  
  909. /*:42*//*43:*/
  910. #line 773 "common.w"
  911.  
  912. #line 405 "common-p.ch"
  913. void sprint_section_name(char*dest,name_pointer p)
  914. #line 778 "common.w"
  915. {
  916. #line 411 "common-p.ch"
  917. char HUGE*ss;
  918. char HUGE*s= first_chunk(p);
  919. #line 780 "common.w"
  920. name_pointer q= p+1;
  921. while(p!=name_dir){
  922. ss= (p+1)->byte_start-1;
  923. if(*ss==' '&&ss>=s){
  924. p= q->link;q= p;
  925. }else{
  926. ss++;p= name_dir;
  927. }
  928. strncpy(dest,s,ss-s),dest+= ss-s;
  929. s= p->byte_start;
  930. }
  931. *dest= '\0';
  932. }
  933.  
  934. /*:43*//*44:*/
  935. #line 794 "common.w"
  936.  
  937. #line 420 "common-p.ch"
  938. void print_prefix_name(name_pointer p)
  939. #line 798 "common.w"
  940. {
  941. #line 426 "common-p.ch"
  942. char HUGE*s= first_chunk(p);
  943. #line 800 "common.w"
  944. int l= prefix_length(p);
  945. term_write(s,l);
  946. if(s+l<(p+1)->byte_start)term_write("...",3);
  947. }
  948.  
  949. /*:44*//*45:*/
  950. #line 815 "common.w"
  951.  
  952. #line 436 "common-p.ch"
  953. static int web_strcmp(char HUGE*j,int j_len,char HUGE*k,int k_len)
  954.  
  955.  
  956.  
  957.  
  958.  
  959. {
  960. char HUGE*j1= j+j_len;
  961. char HUGE*k1= k+k_len;
  962. #line 821 "common.w"
  963. while(k<k1&&j<j1&&*j==*k)k++,j++;
  964. if(k==k1)if(j==j1)return equal;
  965. else return extension;
  966. else if(j==j1)return prefix;
  967. else if(*j<*k)return less;
  968. else return greater;
  969. }
  970.  
  971. /*:45*//*47:*/
  972. #line 845 "common.w"
  973.  
  974. #line 464 "common-p.ch"
  975. name_pointer add_section_name(name_pointer par,int c,
  976. char*first,char*last,int ispref)
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983. #line 853 "common.w"
  984. {
  985. name_pointer p= name_ptr;
  986. #line 477 "common-p.ch"
  987. char HUGE*s= first_chunk(p);
  988. #line 856 "common.w"
  989. int name_len= last-first+ispref;
  990. if(s+name_len>byte_mem_end)overflow("byte memory");
  991. if(name_ptr+1>=name_dir_end)overflow("name");
  992. (++name_ptr)->byte_start= byte_ptr= s+name_len;
  993. if(ispref){
  994. *(byte_ptr-1)= ' ';
  995. name_len--;
  996. name_ptr->link= name_dir;
  997. (++name_ptr)->byte_start= byte_ptr;
  998. }
  999. set_prefix_length(p,name_len);
  1000. strncpy(s,first,name_len);
  1001. p->llink= NULL;
  1002. p->rlink= NULL;
  1003. init_node(p);
  1004. return par==NULL?(root= p):c==less?(par->llink= p):(par->rlink= p);
  1005. }
  1006.  
  1007. /*:47*//*48:*/
  1008. #line 874 "common.w"
  1009.  
  1010. #line 488 "common-p.ch"
  1011. void extend_section_name(name_pointer p,char*first,char*last,int ispref)
  1012.  
  1013.  
  1014.  
  1015.  
  1016. #line 881 "common.w"
  1017. {
  1018. #line 498 "common-p.ch"
  1019. char HUGE*s;
  1020. #line 883 "common.w"
  1021. name_pointer q= p+1;
  1022. int name_len= last-first+ispref;
  1023. if(name_ptr>=name_dir_end)overflow("name");
  1024. while(q->link!=name_dir)q= q->link;
  1025. q->link= name_ptr;
  1026. s= name_ptr->byte_start;
  1027. name_ptr->link= name_dir;
  1028. if(s+name_len>byte_mem_end)overflow("byte memory");
  1029. (++name_ptr)->byte_start= byte_ptr= s+name_len;
  1030. strncpy(s,first,name_len);
  1031. if(ispref)*(byte_ptr-1)= ' ';
  1032. }
  1033.  
  1034. /*:48*//*49:*/
  1035. #line 902 "common.w"
  1036.  
  1037. #line 514 "common-p.ch"
  1038. name_pointer section_lookup(char*first,char*last,int ispref)
  1039.  
  1040.  
  1041.  
  1042. #line 907 "common.w"
  1043. {
  1044. int c= 0;
  1045. name_pointer p= root;
  1046. name_pointer q= NULL;
  1047. name_pointer r= NULL;
  1048. name_pointer par= NULL;
  1049.  
  1050. int name_len= last-first+1;
  1051. /*50:*/
  1052. #line 926 "common.w"
  1053.  
  1054. while(p){
  1055. c= web_strcmp(first,name_len,first_chunk(p),prefix_length(p));
  1056. if(c==less||c==greater){
  1057. if(r==NULL)
  1058. par= p;
  1059. p= (c==less?p->llink:p->rlink);
  1060. }else{
  1061. if(r!=NULL){
  1062. printf("\n! Ambiguous prefix: matches <");
  1063.  
  1064. print_prefix_name(p);
  1065. printf(">\n and <");
  1066. print_prefix_name(r);
  1067. err_print(">");
  1068. return name_dir;
  1069. }
  1070. r= p;
  1071. p= p->llink;
  1072. q= r->rlink;
  1073. }
  1074. if(p==NULL)
  1075. p= q,q= NULL;
  1076. }
  1077.  
  1078. /*:50*/
  1079. #line 916 "common.w"
  1080. ;
  1081. /*51:*/
  1082. #line 951 "common.w"
  1083.  
  1084. if(r==NULL)
  1085. return add_section_name(par,c,first,last+1,ispref);
  1086.  
  1087. /*:51*/
  1088. #line 917 "common.w"
  1089. ;
  1090. /*52:*/
  1091. #line 959 "common.w"
  1092.  
  1093. switch(section_name_cmp(&first,name_len,r)){
  1094.  
  1095. case prefix:
  1096. if(!ispref){
  1097. printf("\n! New name is a prefix of <");
  1098.  
  1099. print_section_name(r);
  1100. err_print(">");
  1101. }
  1102. else if(name_len<prefix_length(r))set_prefix_length(r,name_len);
  1103.  
  1104. case equal:return r;
  1105. case extension:if(!ispref||first<=last)
  1106. extend_section_name(r,first,last+1,ispref);
  1107. return r;
  1108. case bad_extension:
  1109. printf("\n! New name extends <");
  1110.  
  1111. print_section_name(r);
  1112. err_print(">");
  1113. return r;
  1114. default:
  1115. printf("\n! Section name incompatible with <");
  1116.  
  1117. print_prefix_name(r);
  1118. printf(">,\n which abbreviates <");
  1119. print_section_name(r);
  1120. err_print(">");
  1121. return r;
  1122. }
  1123.  
  1124. /*:52*/
  1125. #line 918 "common.w"
  1126. ;
  1127. }
  1128.  
  1129. /*:49*//*54:*/
  1130. #line 1010 "common.w"
  1131.  
  1132. #line 534 "common-p.ch"
  1133. static int section_name_cmp(char**pfirst,int len,name_pointer r)
  1134.  
  1135.  
  1136.  
  1137. #line 1015 "common.w"
  1138. {
  1139. char*first= *pfirst;
  1140. name_pointer q= r+1;
  1141. #line 543 "common-p.ch"
  1142. char HUGE*ss;
  1143. char HUGE*s= first_chunk(r);
  1144. #line 1019 "common.w"
  1145. int c;
  1146. int ispref;
  1147. while(1){
  1148. ss= (r+1)->byte_start-1;
  1149. if(*ss==' '&&ss>=r->byte_start)ispref= 1,q= q->link;
  1150. else ispref= 0,ss++,q= name_dir;
  1151. switch(c= web_strcmp(first,len,s,ss-s)){
  1152. case equal:if(q==name_dir)
  1153. if(ispref){
  1154. *pfirst= first+(ss-s);
  1155. return extension;
  1156. }else return equal;
  1157. else return(q->byte_start==(q+1)->byte_start)?equal:prefix;
  1158. case extension:
  1159. if(!ispref)return bad_extension;
  1160. first+= ss-s;
  1161. if(q!=name_dir){len-= ss-s;s= q->byte_start;r= q;continue;}
  1162. *pfirst= first;return extension;
  1163. default:return c;
  1164. }
  1165. }
  1166. }
  1167.  
  1168. /*:54*//*58:*/
  1169. #line 1085 "common.w"
  1170.  
  1171. #line 573 "common-p.ch"
  1172. void err_print(char*s)
  1173. #line 1089 "common.w"
  1174. {
  1175. char*k,*l;
  1176. printf(*s=='!'?"\n%s":"%s",s);
  1177. if(web_file_open)/*59:*/
  1178. #line 1105 "common.w"
  1179.  
  1180. {if(changing&&include_depth==change_depth)
  1181. printf(". (l. %d of change file)\n",change_line);
  1182. else if(include_depth==0)printf(". (l. %d)\n",cur_line);
  1183. else printf(". (l. %d of include file %s)\n",cur_line,cur_file_name);
  1184. l= (loc>=limit?limit:loc);
  1185. if(l>buffer){
  1186. for(k= buffer;k<l;k++)
  1187. if(*k=='\t')putchar(' ');
  1188. else putchar(*k);
  1189. putchar('\n');
  1190. for(k= buffer;k<l;k++)putchar(' ');
  1191. }
  1192. for(k= l;k<limit;k++)putchar(*k);
  1193. if(*limit=='|')putchar('|');
  1194. putchar(' ');
  1195. }
  1196.  
  1197. /*:59*/
  1198. #line 1092 "common.w"
  1199. ;
  1200. update_terminal;mark_error;
  1201. }
  1202.  
  1203. /*:58*//*61:*/
  1204. #line 620 "common-p.ch"
  1205.  
  1206. int wrap_up(void){
  1207. putchar('\n');
  1208. if(show_stats)print_stats();
  1209. /*62:*/
  1210. #line 1150 "common.w"
  1211.  
  1212. switch(history){
  1213. case spotless:if(show_happiness)printf("(No errors were found.)\n");break;
  1214. case harmless_message:
  1215. printf("(Did you see the warning message above?)\n");break;
  1216. case error_message:
  1217. printf("(Pardon me, but I think I spotted something wrong.)\n");break;
  1218. case fatal_message:printf("(That was a fatal error, my friend.)\n");
  1219. }
  1220.  
  1221. /*:62*/
  1222. #line 624 "common-p.ch"
  1223. ;
  1224. switch(history){
  1225. case harmless_message:return(RETURN_WARN);break;
  1226. case error_message:return(RETURN_ERROR);break;
  1227. case fatal_message:return(RETURN_FAIL);break;
  1228. default:return(RETURN_OK);
  1229. }
  1230. }
  1231. #line 1149 "common.w"
  1232.  
  1233. /*:61*//*64:*/
  1234. #line 1169 "common.w"
  1235. void
  1236. fatal(s,t)
  1237. char*s,*t;
  1238. {
  1239. if(*s)printf(s);
  1240. err_print(t);
  1241. history= fatal_message;exit(wrap_up());
  1242. }
  1243.  
  1244. /*:64*//*65:*/
  1245. #line 1180 "common.w"
  1246. void
  1247. overflow(t)
  1248. char*t;
  1249. {
  1250. printf("\n! Sorry, %s capacity exceeded",t);fatal("","");
  1251. }
  1252.  
  1253.  
  1254. /*:65*//*70:*/
  1255. #line 1244 "common.w"
  1256.  
  1257. #line 714 "common-p.ch"
  1258. static void scan_args(void)
  1259. #line 1247 "common.w"
  1260. {
  1261. char*dot_pos;
  1262. char*name_pos;
  1263. register char*s;
  1264. boolean found_web= 0,found_change= 0,found_out= 0;
  1265.  
  1266. boolean flag_change;
  1267.  
  1268. while(--argc>0){
  1269. if(**(++argv)=='-'||**argv=='+')/*74:*/
  1270. #line 1335 "common.w"
  1271.  
  1272. {
  1273. if(**argv=='-')flag_change= 0;
  1274. else flag_change= 1;
  1275. for(dot_pos= *argv+1;*dot_pos>'\0';dot_pos++)
  1276. flags[*dot_pos]= flag_change;
  1277. }
  1278.  
  1279. /*:74*/
  1280. #line 1256 "common.w"
  1281.  
  1282. else{
  1283. s= name_pos= *argv;dot_pos= NULL;
  1284. #line 727 "common-p.ch"
  1285. while(*s){
  1286. if(*s=='.')dot_pos= s++;
  1287. #ifdef _AMIGA
  1288. else if((*s=='/')||(*s==':'))dot_pos= NULL,name_pos= ++s;
  1289. #else
  1290. else if(*s=='/')dot_pos= NULL,name_pos= ++s;
  1291. #endif
  1292. else s++;
  1293. }
  1294. #line 1264 "common.w"
  1295. if(!found_web)/*71:*/
  1296. #line 1282 "common.w"
  1297.  
  1298. {
  1299. if(s-*argv>max_file_name_length-5)
  1300. /*76:*/
  1301. #line 1355 "common.w"
  1302. fatal("! Filename too long\n",*argv);
  1303.  
  1304.  
  1305. /*:76*/
  1306. #line 1285 "common.w"
  1307. ;
  1308. if(dot_pos==NULL)
  1309. sprintf(web_file_name,"%s.w",*argv);
  1310. else{
  1311. strcpy(web_file_name,*argv);
  1312. *dot_pos= 0;
  1313. }
  1314. sprintf(alt_web_file_name,"%s.web",*argv);
  1315. sprintf(tex_file_name,"%s.tex",name_pos);
  1316. sprintf(idx_file_name,"%s.idx",name_pos);
  1317. sprintf(scn_file_name,"%s.scn",name_pos);
  1318. sprintf(C_file_name,"%s.c",name_pos);
  1319. found_web= 1;
  1320. }
  1321.  
  1322. /*:71*/
  1323. #line 1265 "common.w"
  1324.  
  1325. else if(!found_change)/*72:*/
  1326. #line 1300 "common.w"
  1327.  
  1328. {
  1329. if(s-*argv>max_file_name_length-4)
  1330. /*76:*/
  1331. #line 1355 "common.w"
  1332. fatal("! Filename too long\n",*argv);
  1333.  
  1334.  
  1335. /*:76*/
  1336. #line 1303 "common.w"
  1337. ;
  1338. if(dot_pos==NULL)
  1339. sprintf(change_file_name,"%s.ch",*argv);
  1340. else strcpy(change_file_name,*argv);
  1341. found_change= 1;
  1342. }
  1343.  
  1344. /*:72*/
  1345. #line 1266 "common.w"
  1346.  
  1347. else if(!found_out)/*73:*/
  1348. #line 1310 "common.w"
  1349.  
  1350. {
  1351. if(s-*argv>max_file_name_length-5)
  1352. /*76:*/
  1353. #line 1355 "common.w"
  1354. fatal("! Filename too long\n",*argv);
  1355.  
  1356.  
  1357. /*:76*/
  1358. #line 1313 "common.w"
  1359. ;
  1360. if(dot_pos==NULL){
  1361. sprintf(tex_file_name,"%s.tex",*argv);
  1362. sprintf(idx_file_name,"%s.idx",*argv);
  1363. sprintf(scn_file_name,"%s.scn",*argv);
  1364. sprintf(C_file_name,"%s.c",*argv);
  1365. }else{
  1366. strcpy(tex_file_name,*argv);
  1367. if(flags['x']){
  1368. if(program==cweave&&strcmp(*argv+strlen(*argv)-4,".tex")!=0)
  1369. fatal("! Output file name should end with .tex\n",*argv);
  1370.  
  1371. strcpy(idx_file_name,*argv);
  1372. strcpy(idx_file_name+strlen(*argv)-4,".idx");
  1373. strcpy(scn_file_name,*argv);
  1374. strcpy(scn_file_name+strlen(*argv)-4,".scn");
  1375. }
  1376. strcpy(C_file_name,*argv);
  1377. }
  1378. found_out= 1;
  1379. }
  1380.  
  1381. /*:73*/
  1382. #line 1267 "common.w"
  1383.  
  1384. else/*75:*/
  1385. #line 1343 "common.w"
  1386.  
  1387. {
  1388. if(program==ctangle)
  1389. #line 759 "common-p.ch"
  1390. fatal(
  1391. "! Usage: ctangle [options] webfile[.w] [changefile[.ch] [outfile[.c]]]\n"
  1392. "Options are (+ turns on, - turns off, default in brackets):\n"
  1393. "b print banner line [+]\n"
  1394. "h print happy message [+]\n"
  1395. "p give progress reports [+]\n"
  1396. "s show statistics [-]\n"
  1397. ,"");
  1398.  
  1399. #ifdef _AMIGA
  1400. else fatal(
  1401. "! Usage: cweave [options] webfile[.w] [changefile[.ch] [outfile[.tex]]]\n"
  1402. "Options are (+ turns on, - turns off, default in brackets):\n"
  1403. "a use AMIGA specific keywords [+]\n"
  1404. "b print banner line [+]\n"
  1405. "f force line breaks [+]\n"
  1406. "g use German macros as of gcwebmac.tex [+]\n"
  1407. "h print happy message [+]\n"
  1408. "i indent parameter declarations [+]\n"
  1409. "p give progress reports [+]\n"
  1410. "s show statistics [-]\n"
  1411. "x include indexes and table of contents [+]\n"
  1412. ,"");
  1413. #else
  1414. else fatal(
  1415. "! Usage: cweave [options] webfile[.w] [changefile[.ch] [outfile[.tex]]]\n"
  1416. "Options are (+ turns on, - turns off, default in brackets):\n"
  1417. "b print banner line [+]\n"
  1418. "f force line breaks [+]\n"
  1419. "g use German macros as of gcwebmac.tex [+]\n"
  1420. "h print happy message [+]\n"
  1421. "i indent parameter declarations [+]\n"
  1422. "p give progress reports [+]\n"
  1423. "s show statistics [-]\n"
  1424. "x include indexes and table of contents [+]\n"
  1425. ,"");
  1426. #endif
  1427. #line 1353 "common.w"
  1428. }
  1429.  
  1430. /*:75*/
  1431. #line 1268 "common.w"
  1432. ;
  1433. }
  1434. }
  1435. if(!found_web)/*75:*/
  1436. #line 1343 "common.w"
  1437.  
  1438. {
  1439. if(program==ctangle)
  1440. #line 759 "common-p.ch"
  1441. fatal(
  1442. "! Usage: ctangle [options] webfile[.w] [changefile[.ch] [outfile[.c]]]\n"
  1443. "Options are (+ turns on, - turns off, default in brackets):\n"
  1444. "b print banner line [+]\n"
  1445. "h print happy message [+]\n"
  1446. "p give progress reports [+]\n"
  1447. "s show statistics [-]\n"
  1448. ,"");
  1449.  
  1450. #ifdef _AMIGA
  1451. else fatal(
  1452. "! Usage: cweave [options] webfile[.w] [changefile[.ch] [outfile[.tex]]]\n"
  1453. "Options are (+ turns on, - turns off, default in brackets):\n"
  1454. "a use AMIGA specific keywords [+]\n"
  1455. "b print banner line [+]\n"
  1456. "f force line breaks [+]\n"
  1457. "g use German macros as of gcwebmac.tex [+]\n"
  1458. "h print happy message [+]\n"
  1459. "i indent parameter declarations [+]\n"
  1460. "p give progress reports [+]\n"
  1461. "s show statistics [-]\n"
  1462. "x include indexes and table of contents [+]\n"
  1463. ,"");
  1464. #else
  1465. else fatal(
  1466. "! Usage: cweave [options] webfile[.w] [changefile[.ch] [outfile[.tex]]]\n"
  1467. "Options are (+ turns on, - turns off, default in brackets):\n"
  1468. "b print banner line [+]\n"
  1469. "f force line breaks [+]\n"
  1470. "g use German macros as of gcwebmac.tex [+]\n"
  1471. "h print happy message [+]\n"
  1472. "i indent parameter declarations [+]\n"
  1473. "p give progress reports [+]\n"
  1474. "s show statistics [-]\n"
  1475. "x include indexes and table of contents [+]\n"
  1476. ,"");
  1477. #endif
  1478. #line 1353 "common.w"
  1479. }
  1480.  
  1481. /*:75*/
  1482. #line 1271 "common.w"
  1483. ;
  1484. #line 741 "common-p.ch"
  1485. #if defined( __TURBOC__ )
  1486. if(!found_change)strcpy(change_file_name,"nul");
  1487. #elif defined( _AMIGA )
  1488. if(!found_change)strcpy(change_file_name,"NIL:");
  1489. #else
  1490. if(!found_change)strcpy(change_file_name,"/dev/null");
  1491. #endif
  1492. #line 1273 "common.w"
  1493. }
  1494.  
  1495. /*:70*//*82:*/
  1496. #line 818 "common-p.ch"
  1497.  
  1498. static boolean set_path(char*ptr,char*override)
  1499. {
  1500. if(override){
  1501. if(strlen(override)>=MAXPATHLENGTH){
  1502. err_print("! Include path too long");return(0);
  1503.  
  1504. }
  1505. else strcpy(ptr,override);
  1506. }
  1507. return(1);
  1508. }
  1509.  
  1510. /*:82*//*85:*/
  1511. #line 862 "common-p.ch"
  1512.  
  1513. #ifdef __TURBOC__
  1514. void far*allocsafe(unsigned long nunits,unsigned long unitsz)
  1515. {
  1516. void far*p= farcalloc(nunits,unitsz);
  1517. if(p==NULL)fatal("","! Memory allocation failure");
  1518.  
  1519. return p;
  1520. }
  1521. #endif
  1522.  
  1523.  
  1524. /*:85*/
  1525.