home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / dev / c / cweb / wmerge.c < prev    next >
C/C++ Source or Header  |  1994-08-12  |  15KB  |  808 lines

  1. #define buf_size 1024 \
  2.  
  3. #define max_include_depth 10 \
  4.  \
  5.  
  6. #define max_file_name_length 256 \
  7.  
  8. #define cur_file file[include_depth]
  9. #define cur_file_name file_name[include_depth]
  10. #define cur_line line[include_depth]
  11. #define web_file file[0]
  12. #define web_file_name file_name[0] \
  13.  
  14. #define lines_dont_match (change_limit-change_buffer!=limit-buffer|| \
  15. strncmp(buffer,change_buffer,(size_t) (limit-buffer) ) )  \
  16.  
  17. #define too_long() {include_depth--; \
  18. err_print("! Include file name too long") ;goto restart;} \
  19.  
  20. #define spotless 0
  21. #define harmless_message 1
  22. #define error_message 2
  23. #define fatal_message 3
  24. #define mark_harmless {if(history==spotless) history= harmless_message;}
  25. #define mark_error history= error_message \
  26.  
  27. #define fatal(s,t) { \
  28. fprintf(stderr,s) ;err_print(t) ; \
  29. history= fatal_message;exit(wrap_up() ) ; \
  30. } \
  31.  \
  32.  
  33. #define RETURN_OK 0
  34. #define RETURN_WARN 5
  35. #define RETURN_ERROR 10
  36. #define RETURN_FAIL 20 \
  37.  
  38. #define show_banner flags['b']
  39. #define show_happiness flags['h'] \
  40.  
  41. #define update_terminal fflush(stderr)  \
  42.  \
  43.  
  44. #define max_path_length 4095 \
  45.  
  46. /*1:*/
  47. #line 13 "wmerge.w"
  48.  
  49. #line 73 "wmerge.ch"
  50. #include <stdio.h>
  51. #include <string.h>
  52. #line 15 "wmerge.w"
  53. #include <stdlib.h> 
  54. #include <ctype.h> 
  55. /*2:*/
  56. #line 35 "wmerge.w"
  57.  
  58. typedef short boolean;
  59. typedef unsigned char eight_bits;
  60. typedef char ASCII;
  61.  
  62. /*:2*//*5:*/
  63. #line 68 "wmerge.w"
  64.  
  65. ASCII buffer[buf_size];
  66. ASCII*buffer_end= buffer+buf_size-2;
  67. ASCII*limit;
  68. ASCII*loc;
  69.  
  70. /*:5*//*7:*/
  71. #line 134 "wmerge.w"
  72.  
  73. int include_depth;
  74. FILE*file[max_include_depth];
  75. FILE*change_file;
  76. char file_name[max_include_depth][max_file_name_length];
  77.  
  78. char change_file_name[max_file_name_length];
  79. char alt_web_file_name[max_file_name_length];
  80. int line[max_include_depth];
  81. int change_line;
  82. int change_depth;
  83. boolean input_has_ended;
  84. boolean changing;
  85. boolean web_file_open= 0;
  86.  
  87. /*:7*//*8:*/
  88. #line 160 "wmerge.w"
  89.  
  90. char change_buffer[buf_size];
  91. char*change_limit;
  92.  
  93. /*:8*//*23:*/
  94. #line 478 "wmerge.w"
  95.  
  96. int history= spotless;
  97.  
  98. /*:23*//*30:*/
  99. #line 575 "wmerge.w"
  100.  
  101. int argc;
  102. char**argv;
  103. char out_file_name[max_file_name_length];
  104. #line 366 "wmerge.ch"
  105. boolean flags[256];
  106. #line 580 "wmerge.w"
  107.  
  108. /*:30*//*40:*/
  109. #line 692 "wmerge.w"
  110.  
  111. FILE*out_file;
  112.  
  113. /*:40*//*44:*/
  114. #line 462 "wmerge.ch"
  115.  
  116. char include_path[max_path_length+1]= CWEBINPUTS;
  117. char*p,*path_prefix,*next_path_prefix;
  118.  
  119. /*:44*//*46:*/
  120. #line 487 "wmerge.ch"
  121.  
  122. #ifdef _AMIGA
  123. const unsigned char*Version= "$VER: WMerge 3.2 [p10] "__AMIGADATE__;
  124. #endif
  125.  
  126. /*:46*/
  127. #line 17 "wmerge.w"
  128.  
  129. /*4:*/
  130. #line 51 "wmerge.w"
  131.  
  132. #line 52 "wmerge.w"
  133.  
  134. /*:4*//*24:*/
  135. #line 291 "wmerge.ch"
  136.  
  137. #line 292 "wmerge.ch"
  138. void err_print(char*);
  139.  
  140. /*:24*//*32:*/
  141. #line 387 "wmerge.ch"
  142.  
  143. #line 388 "wmerge.ch"
  144. void scan_args(void);
  145.  
  146. /*:32*//*45:*/
  147. #line 469 "wmerge.ch"
  148.  
  149. int get_line(void);
  150. int input_ln(FILE*fp);
  151. int main(int argc,char**argv);
  152. int wrap_up(void);
  153. void check_change(void);
  154. void check_complete(void);
  155. void err_print(char*s);
  156. void prime_the_change_buffer(void);
  157. void put_line(void);
  158. void reset_input(void);
  159. void scan_args(void);
  160. static boolean set_path(char*ptr,char*override);
  161.  
  162. /*:45*/
  163. #line 18 "wmerge.w"
  164.  
  165. /*6:*/
  166. #line 93 "wmerge.w"
  167.  
  168. #line 96 "wmerge.ch"
  169. int input_ln(FILE*fp)
  170.  
  171. #line 96 "wmerge.w"
  172. {
  173. register int c= EOF;
  174. register char*k;
  175. if(feof(fp))return(0);
  176. limit= k= buffer;
  177. while(k<=buffer_end&&(c= getc(fp))!=EOF&&c!='\n')
  178. if((*(k++)= c)!=' ')limit= k;
  179. if(k>buffer_end)
  180. if((c= getc(fp))!=EOF&&c!='\n'){
  181. ungetc(c,fp);loc= buffer;err_print("! Input line too long");
  182.  
  183. }
  184. if(c==EOF&&limit==buffer)return(0);
  185.  
  186. return(1);
  187. }
  188.  
  189. /*:6*//*9:*/
  190. #line 171 "wmerge.w"
  191.  
  192. #line 122 "wmerge.ch"
  193. void prime_the_change_buffer(void)
  194. #line 174 "wmerge.w"
  195. {
  196. change_limit= change_buffer;
  197. /*10:*/
  198. #line 185 "wmerge.w"
  199.  
  200. while(1){
  201. change_line++;
  202. if(!input_ln(change_file))return;
  203. if(limit<buffer+2)continue;
  204. if(buffer[0]!='@')continue;
  205. if(isupper(buffer[1]))buffer[1]= tolower(buffer[1]);
  206. if(buffer[1]=='x')break;
  207. if(buffer[1]=='y'||buffer[1]=='z'||buffer[1]=='i'){
  208. loc= buffer+2;
  209. err_print("! Missing @x in change file");
  210.  
  211. }
  212. }
  213.  
  214. /*:10*/
  215. #line 176 "wmerge.w"
  216. ;
  217. /*11:*/
  218. #line 202 "wmerge.w"
  219.  
  220. do{
  221. change_line++;
  222. if(!input_ln(change_file)){
  223. err_print("! Change file ended after @x");
  224.  
  225. return;
  226. }
  227. }while(limit==buffer);
  228.  
  229. /*:11*/
  230. #line 177 "wmerge.w"
  231. ;
  232. /*12:*/
  233. #line 212 "wmerge.w"
  234.  
  235. {
  236. change_limit= change_buffer-buffer+limit;
  237. #line 129 "wmerge.ch"
  238. strncpy(change_buffer,buffer,(size_t)(limit-buffer+1));
  239. #line 216 "wmerge.w"
  240. }
  241.  
  242. /*:12*/
  243. #line 178 "wmerge.w"
  244. ;
  245. }
  246.  
  247. /*:9*//*13:*/
  248. #line 230 "wmerge.w"
  249.  
  250. #line 137 "wmerge.ch"
  251. void check_change(void)
  252. #line 233 "wmerge.w"
  253. {
  254. int n= 0;
  255. if(lines_dont_match)return;
  256. while(1){
  257. changing= 1;change_line++;
  258. if(!input_ln(change_file)){
  259. err_print("! Change file ended before @y");
  260.  
  261. change_limit= change_buffer;changing= 0;
  262. return;
  263. }
  264. if(limit>buffer+1&&buffer[0]=='@'){
  265. if(isupper(buffer[1]))buffer[1]= tolower(buffer[1]);
  266. /*14:*/
  267. #line 263 "wmerge.w"
  268.  
  269. if(buffer[1]=='x'||buffer[1]=='z'){
  270. loc= buffer+2;err_print("! Where is the matching @y?");
  271.  
  272. }
  273. else if(buffer[1]=='y'){
  274. if(n>0){
  275. loc= buffer+2;
  276. fprintf(stderr,"\n! Hmm... %d ",n);
  277. err_print("of the preceding lines failed to match");
  278.  
  279. }
  280. change_depth= include_depth;
  281. return;
  282. }
  283.  
  284. /*:14*/
  285. #line 247 "wmerge.w"
  286. ;
  287. }
  288. /*12:*/
  289. #line 212 "wmerge.w"
  290.  
  291. {
  292. change_limit= change_buffer-buffer+limit;
  293. #line 129 "wmerge.ch"
  294. strncpy(change_buffer,buffer,(size_t)(limit-buffer+1));
  295. #line 216 "wmerge.w"
  296. }
  297.  
  298. /*:12*/
  299. #line 249 "wmerge.w"
  300. ;
  301. changing= 0;cur_line++;
  302. while(!input_ln(cur_file)){
  303. if(include_depth==0){
  304. err_print("! CWEB file ended during a change");
  305.  
  306. input_has_ended= 1;return;
  307. }
  308. include_depth--;cur_line++;
  309. }
  310. if(lines_dont_match)n++;
  311. }
  312. }
  313.  
  314. /*:13*//*15:*/
  315. #line 282 "wmerge.w"
  316.  
  317. #line 145 "wmerge.ch"
  318. void reset_input(void)
  319. #line 285 "wmerge.w"
  320. {
  321. limit= buffer;loc= buffer+1;buffer[0]= ' ';
  322. /*16:*/
  323. #line 297 "wmerge.w"
  324.  
  325. if((web_file= fopen(web_file_name,"r"))==NULL){
  326. strcpy(web_file_name,alt_web_file_name);
  327. if((web_file= fopen(web_file_name,"r"))==NULL)
  328. fatal("! Cannot open input file ",web_file_name);
  329. }
  330.  
  331.  
  332. web_file_open= 1;
  333. if((change_file= fopen(change_file_name,"r"))==NULL)
  334. fatal("! Cannot open change file ",change_file_name);
  335.  
  336. /*:16*/
  337. #line 287 "wmerge.w"
  338. ;
  339. include_depth= 0;cur_line= 0;change_line= 0;
  340. change_depth= include_depth;
  341. changing= 1;prime_the_change_buffer();changing= !changing;
  342. limit= buffer;loc= buffer+1;buffer[0]= ' ';input_has_ended= 0;
  343. }
  344.  
  345. /*:15*//*17:*/
  346. #line 315 "wmerge.w"
  347.  
  348. get_line()
  349. {
  350. restart:
  351. if(changing&&include_depth==change_depth)
  352. /*21:*/
  353. #line 423 "wmerge.w"
  354. {
  355. change_line++;
  356. if(!input_ln(change_file)){
  357. err_print("! Change file ended without @z");
  358.  
  359. buffer[0]= '@';buffer[1]= 'z';limit= buffer+2;
  360. }
  361. if(limit>buffer){
  362. *limit= ' ';
  363. if(buffer[0]=='@'){
  364. if(isupper(buffer[1]))buffer[1]= tolower(buffer[1]);
  365. if(buffer[1]=='x'||buffer[1]=='y'){
  366. loc= buffer+2;
  367. err_print("! Where is the matching @z?");
  368.  
  369. }
  370. else if(buffer[1]=='z'){
  371. prime_the_change_buffer();changing= !changing;
  372. }
  373. }
  374. }
  375. }
  376.  
  377. /*:21*/
  378. #line 320 "wmerge.w"
  379. ;
  380. if(!changing||include_depth>change_depth){
  381. /*20:*/
  382. #line 407 "wmerge.w"
  383. {
  384. cur_line++;
  385. while(!input_ln(cur_file)){
  386. if(include_depth==0){input_has_ended= 1;break;}
  387. else{
  388. fclose(cur_file);include_depth--;
  389. if(changing&&include_depth==change_depth)break;
  390. cur_line++;
  391. }
  392. }
  393. if(!changing&&!input_has_ended)
  394. if(limit-buffer==change_limit-change_buffer)
  395. if(buffer[0]==change_buffer[0])
  396. if(change_limit>change_buffer)check_change();
  397. }
  398.  
  399. /*:20*/
  400. #line 322 "wmerge.w"
  401. ;
  402. if(changing&&include_depth==change_depth)goto restart;
  403. }
  404. loc= buffer;*limit= ' ';
  405. if(*buffer=='@'&&(*(buffer+1)=='i'||*(buffer+1)=='I')){
  406. loc= buffer+2;
  407. while(loc<=limit&&(*loc==' '||*loc=='\t'||*loc=='"'))loc++;
  408. if(loc>=limit){
  409. err_print("! Include file name not given");
  410.  
  411. goto restart;
  412. }
  413. if(include_depth>=max_include_depth-1){
  414. err_print("! Too many nested includes");
  415.  
  416. goto restart;
  417. }
  418. include_depth++;
  419. /*19:*/
  420. #line 366 "wmerge.w"
  421. {
  422. char temp_file_name[max_file_name_length];
  423. char*cur_file_name_end= cur_file_name+max_file_name_length-1;
  424. char*k= cur_file_name,*kk;
  425. int l;
  426.  
  427. while(*loc!=' '&&*loc!='\t'&&*loc!='"'&&k<=cur_file_name_end)*k++= *loc++;
  428. if(k>cur_file_name_end)too_long();
  429.  
  430. *k= '\0';
  431. if((cur_file= fopen(cur_file_name,"r"))!=NULL){
  432. cur_line= 0;
  433. goto restart;
  434. }
  435. #line 225 "wmerge.ch"
  436.  
  437. #ifdef _AMIGA
  438. #define PATH_SEPARATOR   ','
  439. #define DIR_SEPARATOR    '/'
  440. #define DEVICE_SEPARATOR ':'
  441. #else
  442. #ifdef __TURBOC__
  443. #define PATH_SEPARATOR   ';'
  444. #define DIR_SEPARATOR    '\\'
  445. #define DEVICE_SEPARATOR ':'
  446. #else
  447. #define PATH_SEPARATOR   ':'
  448. #define DIR_SEPARATOR    '/'
  449. #define DEVICE_SEPARATOR '/'
  450. #endif
  451. #endif
  452.  
  453. if(0==set_path(include_path,getenv("CWEBINPUTS"))){
  454. include_depth--;goto restart;
  455. }
  456. path_prefix= include_path;
  457. while(path_prefix){
  458. for(kk= temp_file_name,p= path_prefix,l= 0;
  459. p&&*p&&*p!=PATH_SEPARATOR;
  460. *kk++= *p++,l++);
  461. if(path_prefix&&*path_prefix&&*path_prefix!=PATH_SEPARATOR&&
  462. *--p!=DEVICE_SEPARATOR&&*p!=DIR_SEPARATOR){
  463. *kk++= DIR_SEPARATOR;l++;
  464. }
  465. if(k+l+2>=cur_file_name_end)too_long();
  466. strcpy(kk,cur_file_name);
  467. if(cur_file= fopen(temp_file_name,"r")){
  468. cur_line= 0;goto restart;
  469. }
  470. if(next_path_prefix= strchr(path_prefix,PATH_SEPARATOR))
  471. path_prefix= next_path_prefix+1;
  472. else break;
  473. }
  474. #line 404 "wmerge.w"
  475. include_depth--;err_print("! Cannot open include file");goto restart;
  476. }
  477.  
  478. /*:19*/
  479. #line 340 "wmerge.w"
  480. ;
  481. }
  482. return(!input_has_ended);
  483. }
  484.  
  485. #line 159 "wmerge.ch"
  486. void put_line(void)
  487. {
  488. char*ptr= buffer;
  489. while(ptr<limit)
  490. {
  491. putc(*ptr,out_file);
  492. *ptr++;
  493. }
  494. putc('\n',out_file);
  495. }
  496. #line 351 "wmerge.w"
  497.  
  498. #line 183 "wmerge.ch"
  499. /*:17*//*22:*/
  500. #line 449 "wmerge.w"
  501.  
  502. #line 270 "wmerge.ch"
  503. void check_complete(void){
  504. #line 452 "wmerge.w"
  505. if(change_limit!=change_buffer){
  506. #line 277 "wmerge.ch"
  507. strncpy(buffer,change_buffer,(size_t)(change_limit-change_buffer+1));
  508. #line 454 "wmerge.w"
  509. limit= buffer+(int)(change_limit-change_buffer);
  510. changing= 1;change_depth= include_depth;loc= buffer;
  511. err_print("! Change file entry did not match");
  512.  
  513. }
  514. }
  515.  
  516. /*:22*//*25:*/
  517. #line 295 "wmerge.ch"
  518.  
  519. void err_print(char*s)
  520. #line 498 "wmerge.w"
  521. {
  522. char*k,*l;
  523. fprintf(stderr,*s=='!'?"\n%s":"%s",s);
  524. if(web_file_open)/*26:*/
  525. #line 514 "wmerge.w"
  526.  
  527. {if(changing&&include_depth==change_depth)
  528. printf(". (l. %d of change file)\n",change_line);
  529. else if(include_depth==0)fprintf(stderr,". (l. %d)\n",cur_line);
  530. else fprintf(stderr,". (l. %d of include file %s)\n",cur_line,cur_file_name);
  531. l= (loc>=limit?limit:loc);
  532. if(l>buffer){
  533. for(k= buffer;k<l;k++)
  534. if(*k=='\t')putc(' ',stderr);
  535. else putc(*k,stderr);
  536. putchar('\n');
  537. for(k= buffer;k<l;k++)putc(' ',stderr);
  538. }
  539. for(k= l;k<limit;k++)putc(*k,stderr);
  540. putc('\n',stderr);
  541. }
  542.  
  543. /*:26*/
  544. #line 501 "wmerge.w"
  545. ;
  546. update_terminal;mark_error;
  547. }
  548.  
  549. /*:25*//*28:*/
  550. #line 330 "wmerge.ch"
  551.  
  552. #ifndef __TURBOC__
  553. int wrap_up(void){
  554. /*29:*/
  555. #line 553 "wmerge.w"
  556.  
  557. switch(history){
  558. case spotless:if(show_happiness)fprintf(stderr,"(No errors were found.)\n");break;
  559. case harmless_message:
  560. fprintf(stderr,"(Did you see the warning message above?)\n");break;
  561. case error_message:
  562. fprintf(stderr,"(Pardon me, but I think I spotted something wrong.)\n");break;
  563. case fatal_message:fprintf(stderr,"(That was a fatal error, my friend.)\n");
  564. }
  565.  
  566. /*:29*/
  567. #line 333 "wmerge.ch"
  568. ;
  569. switch(history){
  570. case harmless_message:return(RETURN_WARN);break;
  571. case error_message:return(RETURN_ERROR);break;
  572. case fatal_message:return(RETURN_FAIL);break;
  573. default:return(RETURN_OK);
  574. }
  575. }
  576. #else
  577. int wrap_up(void){
  578. int return_val;
  579.  
  580. /*29:*/
  581. #line 553 "wmerge.w"
  582.  
  583. switch(history){
  584. case spotless:if(show_happiness)fprintf(stderr,"(No errors were found.)\n");break;
  585. case harmless_message:
  586. fprintf(stderr,"(Did you see the warning message above?)\n");break;
  587. case error_message:
  588. fprintf(stderr,"(Pardon me, but I think I spotted something wrong.)\n");break;
  589. case fatal_message:fprintf(stderr,"(That was a fatal error, my friend.)\n");
  590. }
  591.  
  592. /*:29*/
  593. #line 345 "wmerge.ch"
  594. ;
  595. switch(history){
  596. case harmless_message:return_val= RETURN_WARN;break;
  597. case error_message:return_val= RETURN_ERROR;break;
  598. case fatal_message:return_val= RETURN_FAIL;break;
  599. default:return_val= RETURN_OK;
  600. }
  601. return(return_val);
  602. }
  603. #endif
  604. #line 552 "wmerge.w"
  605.  
  606. /*:28*//*33:*/
  607. #line 391 "wmerge.ch"
  608.  
  609. void scan_args(void)
  610. #line 606 "wmerge.w"
  611. {
  612. char*dot_pos;
  613. char*name_pos;
  614. register char*s;
  615. boolean found_web= 0,found_change= 0,found_out= 0;
  616.  
  617. boolean flag_change;
  618.  
  619. while(--argc>0){
  620. if(**(++argv)=='-'||**argv=='+')/*37:*/
  621. #line 674 "wmerge.w"
  622.  
  623. {
  624. if(**argv=='-')flag_change= 0;
  625. else flag_change= 1;
  626. for(dot_pos= *argv+1;*dot_pos>'\0';dot_pos++)
  627. flags[*dot_pos]= flag_change;
  628. }
  629.  
  630. /*:37*/
  631. #line 615 "wmerge.w"
  632.  
  633. else{
  634. s= name_pos= *argv;dot_pos= NULL;
  635. while(*s){
  636. #line 400 "wmerge.ch"
  637. #ifdef __TURBOC__
  638. if(*s=='.')dot_pos= s++;
  639. else if(*s=='/'||*s==':'||*s=='\\')dot_pos= NULL,name_pos= ++s;
  640. else s++;
  641. #else
  642. #ifdef _AMIGA
  643. if(*s=='.')dot_pos= s++;
  644. else if(*s=='/'||*s==':')dot_pos= NULL,name_pos= ++s;
  645. else s++;
  646. #else
  647. if(*s=='.')dot_pos= s++;
  648. else if(*s=='/')dot_pos= NULL,name_pos= ++s;
  649. else s++;
  650. #endif
  651. #endif
  652. #line 622 "wmerge.w"
  653. }
  654. if(!found_web)/*34:*/
  655. #line 640 "wmerge.w"
  656.  
  657. {
  658. if(s-*argv>max_file_name_length-5)
  659. /*39:*/
  660. #line 687 "wmerge.w"
  661. fatal("! Filename too long\n",*argv);
  662.  
  663. /*:39*/
  664. #line 643 "wmerge.w"
  665. ;
  666. if(dot_pos==NULL)
  667. sprintf(web_file_name,"%s.w",*argv);
  668. else{
  669. strcpy(web_file_name,*argv);
  670. *dot_pos= 0;
  671. }
  672. sprintf(alt_web_file_name,"%s.web",*argv);
  673. *out_file_name= '\0';
  674. found_web= 1;
  675. }
  676.  
  677. /*:34*/
  678. #line 623 "wmerge.w"
  679.  
  680. else if(!found_change)/*35:*/
  681. #line 655 "wmerge.w"
  682.  
  683. {
  684. if(s-*argv>max_file_name_length-4)
  685. /*39:*/
  686. #line 687 "wmerge.w"
  687. fatal("! Filename too long\n",*argv);
  688.  
  689. /*:39*/
  690. #line 658 "wmerge.w"
  691. ;
  692. if(dot_pos==NULL)
  693. sprintf(change_file_name,"%s.ch",*argv);
  694. else strcpy(change_file_name,*argv);
  695. found_change= 1;
  696. }
  697.  
  698. /*:35*/
  699. #line 624 "wmerge.w"
  700.  
  701. else if(!found_out)/*36:*/
  702. #line 665 "wmerge.w"
  703.  
  704. {
  705. if(s-*argv>max_file_name_length-5)
  706. /*39:*/
  707. #line 687 "wmerge.w"
  708. fatal("! Filename too long\n",*argv);
  709.  
  710. /*:39*/
  711. #line 668 "wmerge.w"
  712. ;
  713. if(dot_pos==NULL)sprintf(out_file_name,"%s.out",*argv);
  714. else strcpy(out_file_name,*argv);
  715. found_out= 1;
  716. }
  717.  
  718. /*:36*/
  719. #line 625 "wmerge.w"
  720.  
  721. else/*38:*/
  722. #line 682 "wmerge.w"
  723.  
  724. {
  725. fatal("! Usage: wmerge webfile[.w] [changefile[.ch] [outfile[.out]]]\n","")
  726. }
  727.  
  728. /*:38*/
  729. #line 626 "wmerge.w"
  730. ;
  731. }
  732. }
  733. if(!found_web)/*38:*/
  734. #line 682 "wmerge.w"
  735.  
  736. {
  737. fatal("! Usage: wmerge webfile[.w] [changefile[.ch] [outfile[.out]]]\n","")
  738. }
  739.  
  740. /*:38*/
  741. #line 629 "wmerge.w"
  742. ;
  743. #line 420 "wmerge.ch"
  744. #if defined( __TURBOC__ )
  745. if(!found_change)strcpy(change_file_name,"nul");
  746. #else
  747. #if defined( _AMIGA )
  748. if(!found_change)strcpy(change_file_name,"NIL:");
  749. #else
  750. if(!found_change)strcpy(change_file_name,"/dev/null");
  751. #endif
  752. #endif
  753. #line 631 "wmerge.w"
  754. }
  755.  
  756. /*:33*//*43:*/
  757. #line 441 "wmerge.ch"
  758.  
  759. static boolean set_path(char*ptr,char*override)
  760. {
  761. if(override){
  762. if(strlen(override)>=max_path_length){
  763. err_print("! Include path too long");return(0);
  764.  
  765. }
  766. else strcpy(ptr,override);
  767. }
  768. return(1);
  769. }
  770.  
  771. /*:43*/
  772. #line 19 "wmerge.w"
  773.  
  774. main(ac,av)
  775. int ac;char**av;
  776. {
  777. argc= ac;argv= av;
  778. /*31:*/
  779. #line 583 "wmerge.w"
  780.  
  781. show_banner= show_happiness= 1;
  782.  
  783. /*:31*/
  784. #line 24 "wmerge.w"
  785. ;
  786. /*41:*/
  787. #line 695 "wmerge.w"
  788.  
  789. scan_args();
  790. if(out_file_name[0]=='\0')out_file= stdout;
  791. else if((out_file= fopen(out_file_name,"w"))==NULL)
  792. fatal("! Cannot open output file ",out_file_name);
  793.  
  794.  
  795. /*:41*/
  796. #line 25 "wmerge.w"
  797. ;
  798. reset_input();
  799. while(get_line())
  800. put_line();
  801. fflush(out_file);
  802. check_complete();
  803. fflush(out_file);
  804. return wrap_up();
  805. }
  806.  
  807. /*:1*/
  808.