| 1 |
#define banner "This is TIE, CWEB Version 2.4." |
| 2 |
#define copyright \ |
| 3 |
"Copyright (c) 1989,1992 by THD/ITI. All rights reserved." \ |
| 4 |
\ |
| 5 |
|
| 6 |
#define incr(v)v+= 1 |
| 7 |
#define decr(v)v-= 1 |
| 8 |
#define loop while(1) |
| 9 |
#define do_nothing |
| 10 |
#define false 0 |
| 11 |
#define true 1 |
| 12 |
#define spotless 0 |
| 13 |
#define troublesome 1 |
| 14 |
#define fatal 2 \ |
| 15 |
|
| 16 |
#define first_text_char 0 |
| 17 |
#define last_text_char 255 \ |
| 18 |
|
| 19 |
#define map_xchr(c)(text_char)(c) \ |
| 20 |
|
| 21 |
#define map_xord(c)(ASCII_Code)(c) \ |
| 22 |
\ |
| 23 |
|
| 24 |
#define tab_mark 9 |
| 25 |
#define nl_mark 10 |
| 26 |
#define form_feed 12 \ |
| 27 |
\ |
| 28 |
|
| 29 |
#define term_out stdout |
| 30 |
#define print(a)fprintf(term_out,a) |
| 31 |
#define print2(a,b)fprintf(term_out,a,b) |
| 32 |
#define print3(a,b,c)fprintf(term_out,a,b,c) |
| 33 |
#define print_c(v)fputc(v,term_out); |
| 34 |
#define new_line(v)fputc('\n',v) |
| 35 |
#define term_new_line new_line(term_out) \ |
| 36 |
|
| 37 |
#define print_ln(v){fprintf(term_out,v);term_new_line;} \ |
| 38 |
|
| 39 |
#define print2_ln(a,b){print2(a,b);term_new_line;} |
| 40 |
#define print3_ln(a,b,c){print3(a,b,c);term_new_line;} \ |
| 41 |
|
| 42 |
#define print_nl(v){term_new_line;print(v);} \ |
| 43 |
|
| 44 |
#define print2_nl(a,b){term_new_line;print2(a,b);} \ |
| 45 |
\ |
| 46 |
|
| 47 |
#define update_terminal fflush(term_out) \ |
| 48 |
\ |
| 49 |
\ |
| 50 |
\ |
| 51 |
\ |
| 52 |
|
| 53 |
#define error_loc(m)err_loc(m);history= troublesome;} |
| 54 |
#define err_print(m){print_nl(m);error_loc \ |
| 55 |
|
| 56 |
#define fatal_error(m){ \ |
| 57 |
print(m);print_c('.');history= fatal; \ |
| 58 |
term_new_line;jump_out(); \ |
| 59 |
} \ |
| 60 |
\ |
| 61 |
|
| 62 |
#define jump_out()exit(1) \ |
| 63 |
\ |
| 64 |
\ |
| 65 |
\ |
| 66 |
\ |
| 67 |
|
| 68 |
#define none (max_file_index+1) \ |
| 69 |
|
| 70 |
/*2:*/ |
| 71 |
#line 112 "tie.w" |
| 72 |
|
| 73 |
/*15:*/ |
| 74 |
#line 478 "tie.w" |
| 75 |
|
| 76 |
#include <stdio.h> |
| 77 |
|
| 78 |
|
| 79 |
/*:15*//*16:*/ |
| 80 |
#line 486 "tie.w" |
| 81 |
|
| 82 |
#ifdef __STDC__ |
| 83 |
#include <stdlib.h> |
| 84 |
#else |
| 85 |
#include <malloc.h> |
| 86 |
#endif |
| 87 |
|
| 88 |
/*:16*/ |
| 89 |
#line 113 "tie.w" |
| 90 |
|
| 91 |
/*5:*/ |
| 92 |
#line 142 "tie.w" |
| 93 |
|
| 94 |
#define buf_size 512 |
| 95 |
#define max_file_index 9 |
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
/*:5*/ |
| 101 |
#line 114 "tie.w" |
| 102 |
|
| 103 |
/*4:*/ |
| 104 |
#line 133 "tie.w" |
| 105 |
|
| 106 |
typedef int boolean; |
| 107 |
typedef char*string; |
| 108 |
|
| 109 |
|
| 110 |
/*:4*//*7:*/ |
| 111 |
#line 224 "tie.w" |
| 112 |
|
| 113 |
#define max_ASCII (126+1) |
| 114 |
typedef unsigned char ASCII_Code; |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
/*:7*//*8:*/ |
| 119 |
#line 250 "tie.w" |
| 120 |
|
| 121 |
typedef unsigned char text_char; |
| 122 |
typedef FILE*text_file; |
| 123 |
|
| 124 |
|
| 125 |
/*:8*//*18:*/ |
| 126 |
#line 529 "tie.w" |
| 127 |
|
| 128 |
#define search 0 |
| 129 |
#define test 1 |
| 130 |
#define reading 2 |
| 131 |
#define ignore 3 |
| 132 |
typedef int in_file_modes; |
| 133 |
#define unknown 0 |
| 134 |
#define master 1 |
| 135 |
#define chf 2 |
| 136 |
typedef int file_types; |
| 137 |
|
| 138 |
|
| 139 |
/*:18*//*19:*/ |
| 140 |
#line 547 "tie.w" |
| 141 |
|
| 142 |
#define normal 0 |
| 143 |
#define pre 1 |
| 144 |
#define post 2 |
| 145 |
typedef int out_md_type; |
| 146 |
|
| 147 |
|
| 148 |
/*:19*//*20:*/ |
| 149 |
#line 557 "tie.w" |
| 150 |
|
| 151 |
typedef int buffer_index; |
| 152 |
typedef int file_index; |
| 153 |
|
| 154 |
|
| 155 |
/*:20*//*21:*/ |
| 156 |
#line 566 "tie.w" |
| 157 |
|
| 158 |
typedef struct _idsc{ |
| 159 |
string name_of_file; |
| 160 |
ASCII_Code buffer[buf_size]; |
| 161 |
in_file_modes mode; |
| 162 |
long line; |
| 163 |
file_types type_of_file; |
| 164 |
buffer_index limit; |
| 165 |
text_file the_file; |
| 166 |
}input_description; |
| 167 |
|
| 168 |
|
| 169 |
/*:21*/ |
| 170 |
#line 115 "tie.w" |
| 171 |
|
| 172 |
/*6:*/ |
| 173 |
#line 159 "tie.w" |
| 174 |
|
| 175 |
static int history= spotless; |
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
/*:6*//*9:*/ |
| 180 |
#line 270 "tie.w" |
| 181 |
|
| 182 |
static ASCII_Code xord[last_text_char+1]; |
| 183 |
|
| 184 |
static text_char xchr[max_ASCII+1]; |
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
/*:9*//*22:*/ |
| 189 |
#line 582 "tie.w" |
| 190 |
|
| 191 |
static file_index actual_input,test_input,no_ch; |
| 192 |
static file_types prod_chf= unknown; |
| 193 |
static out_md_type out_mode; |
| 194 |
|
| 195 |
|
| 196 |
/*:22*//*23:*/ |
| 197 |
#line 594 "tie.w" |
| 198 |
|
| 199 |
static input_description*input_organization[max_file_index+1]; |
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
/*:23*//*26:*/ |
| 206 |
#line 641 "tie.w" |
| 207 |
|
| 208 |
static boolean input_has_ended= false; |
| 209 |
|
| 210 |
|
| 211 |
/*:26*//*35:*/ |
| 212 |
#line 801 "tie.w" |
| 213 |
|
| 214 |
static text_file out_file; |
| 215 |
static string out_name; |
| 216 |
|
| 217 |
|
| 218 |
/*:35*/ |
| 219 |
#line 116 "tie.w" |
| 220 |
|
| 221 |
/*31:*/ |
| 222 |
#line 744 "tie.w" |
| 223 |
|
| 224 |
void err_loc(i) |
| 225 |
int i; |
| 226 |
{ |
| 227 |
print3_ln(" (file %s, l.%ld).", |
| 228 |
input_organization[i]->name_of_file, |
| 229 |
input_organization[i]->line); |
| 230 |
} |
| 231 |
|
| 232 |
|
| 233 |
/*:31*/ |
| 234 |
#line 117 "tie.w" |
| 235 |
|
| 236 |
/*24:*/ |
| 237 |
#line 616 "tie.w" |
| 238 |
|
| 239 |
void get_line(i) |
| 240 |
file_index i; |
| 241 |
{register input_description*inp_desc= input_organization[i]; |
| 242 |
if(inp_desc->mode==ignore)return; |
| 243 |
if(feof(inp_desc->the_file)) |
| 244 |
/*25:*/ |
| 245 |
#line 630 "tie.w" |
| 246 |
|
| 247 |
{ |
| 248 |
inp_desc->mode= ignore; |
| 249 |
inp_desc->limit= -1; |
| 250 |
if(inp_desc->type_of_file==master)input_has_ended= true; |
| 251 |
return; |
| 252 |
} |
| 253 |
|
| 254 |
|
| 255 |
/*:25*/ |
| 256 |
#line 622 "tie.w" |
| 257 |
|
| 258 |
/*27:*/ |
| 259 |
#line 655 "tie.w" |
| 260 |
|
| 261 |
{int final_limit; |
| 262 |
int c; |
| 263 |
/*28:*/ |
| 264 |
#line 679 "tie.w" |
| 265 |
|
| 266 |
incr(inp_desc->line); |
| 267 |
if(inp_desc->type_of_file==master&&inp_desc->line%100==0){ |
| 268 |
if(inp_desc->line%500==0)print2("%ld",inp_desc->line); |
| 269 |
else print_c('.'); |
| 270 |
update_terminal; |
| 271 |
} |
| 272 |
|
| 273 |
|
| 274 |
/*:28*/ |
| 275 |
#line 659 "tie.w" |
| 276 |
|
| 277 |
inp_desc->limit= final_limit= 0; |
| 278 |
while(inp_desc->limit<buf_size){ |
| 279 |
c= fgetc(inp_desc->the_file); |
| 280 |
/*29:*/ |
| 281 |
#line 696 "tie.w" |
| 282 |
|
| 283 |
if(c==EOF){ |
| 284 |
if(inp_desc->limit<=0){ |
| 285 |
inp_desc->mode= ignore; |
| 286 |
inp_desc->limit= -1; |
| 287 |
if(inp_desc->type_of_file==master)input_has_ended= true; |
| 288 |
return; |
| 289 |
}else{ |
| 290 |
c= nl_mark; |
| 291 |
break; |
| 292 |
} |
| 293 |
} |
| 294 |
|
| 295 |
|
| 296 |
/*:29*/ |
| 297 |
#line 664 "tie.w" |
| 298 |
|
| 299 |
inp_desc->buffer[inp_desc->limit++]= c= map_xord(c); |
| 300 |
if(c==nl_mark)break; |
| 301 |
if(c!=32&&c!=tab_mark) |
| 302 |
final_limit= inp_desc->limit; |
| 303 |
} |
| 304 |
/*30:*/ |
| 305 |
#line 712 "tie.w" |
| 306 |
|
| 307 |
if(c!=nl_mark){ |
| 308 |
err_print("! Input line too long")(i); |
| 309 |
|
| 310 |
while((c= fgetc(inp_desc->the_file))!=EOF&&map_xord(c)!=nl_mark) |
| 311 |
do_nothing; |
| 312 |
} |
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
/*:30*/ |
| 319 |
#line 670 "tie.w" |
| 320 |
|
| 321 |
inp_desc->limit= final_limit; |
| 322 |
} |
| 323 |
|
| 324 |
|
| 325 |
/*:27*/ |
| 326 |
#line 623 "tie.w" |
| 327 |
|
| 328 |
} |
| 329 |
|
| 330 |
|
| 331 |
/*:24*//*38:*/ |
| 332 |
#line 850 "tie.w" |
| 333 |
|
| 334 |
boolean lines_dont_match(i,j) |
| 335 |
file_index i,j; |
| 336 |
{ |
| 337 |
buffer_index k,lmt; |
| 338 |
if(input_organization[i]->limit!=input_organization[j]->limit) |
| 339 |
return(true); |
| 340 |
lmt= input_organization[i]->limit; |
| 341 |
for(k= 0;k<lmt;k++) |
| 342 |
if(input_organization[i]->buffer[k]!=input_organization[j]->buffer[k]) |
| 343 |
return(true); |
| 344 |
return(false); |
| 345 |
} |
| 346 |
|
| 347 |
|
| 348 |
/*:38*//*39:*/ |
| 349 |
#line 871 "tie.w" |
| 350 |
|
| 351 |
void init_change_file(i,b) |
| 352 |
file_index i;boolean b; |
| 353 |
{register input_description*inp_desc= input_organization[i]; |
| 354 |
/*40:*/ |
| 355 |
#line 885 "tie.w" |
| 356 |
|
| 357 |
loop{ASCII_Code c; |
| 358 |
get_line(i); |
| 359 |
if(inp_desc->mode==ignore)return; |
| 360 |
if(inp_desc->limit<2)continue; |
| 361 |
if(inp_desc->buffer[0]!=64)continue; |
| 362 |
c= inp_desc->buffer[1]; |
| 363 |
if(c>=88&&c<=90) |
| 364 |
c+= 122-90; |
| 365 |
if(c==120)break; |
| 366 |
if(c==121||c==122) |
| 367 |
if(b) |
| 368 |
err_print("! Where is the matching @x?")(i); |
| 369 |
|
| 370 |
} |
| 371 |
|
| 372 |
|
| 373 |
/*:40*/ |
| 374 |
#line 875 "tie.w" |
| 375 |
|
| 376 |
/*41:*/ |
| 377 |
#line 904 "tie.w" |
| 378 |
|
| 379 |
do{ |
| 380 |
get_line(i); |
| 381 |
if(inp_desc->mode==ignore){ |
| 382 |
err_print("! Change file ended after @x")(i); |
| 383 |
|
| 384 |
return; |
| 385 |
} |
| 386 |
}while(inp_desc->limit<=0); |
| 387 |
|
| 388 |
|
| 389 |
/*:41*/ |
| 390 |
#line 876 "tie.w" |
| 391 |
|
| 392 |
} |
| 393 |
|
| 394 |
|
| 395 |
/*:39*//*42:*/ |
| 396 |
#line 918 "tie.w" |
| 397 |
|
| 398 |
void put_line(j) |
| 399 |
file_index j; |
| 400 |
{buffer_index i; |
| 401 |
buffer_index lmt; |
| 402 |
ASCII_Code*p; |
| 403 |
lmt= input_organization[j]->limit; |
| 404 |
p= input_organization[j]->buffer; |
| 405 |
for(i= 0;i<lmt;i++)fputc(map_xchr(*p++),out_file); |
| 406 |
new_line(out_file); |
| 407 |
} |
| 408 |
|
| 409 |
|
| 410 |
/*:42*//*43:*/ |
| 411 |
#line 934 "tie.w" |
| 412 |
|
| 413 |
boolean e_of_ch_module(i) |
| 414 |
file_index i; |
| 415 |
{register input_description*inp_desc= input_organization[i]; |
| 416 |
if(inp_desc->limit<0){ |
| 417 |
print_nl("! At the end of change file missing @z "); |
| 418 |
|
| 419 |
print2("%s",input_organization[i]->name_of_file); |
| 420 |
term_new_line; |
| 421 |
return(true); |
| 422 |
}else if(inp_desc->limit>=2)if(inp_desc->buffer[0]==64&& |
| 423 |
(inp_desc->buffer[1]==90||inp_desc->buffer[1]==122)) |
| 424 |
return(true); |
| 425 |
return(false); |
| 426 |
} |
| 427 |
|
| 428 |
|
| 429 |
/*:43*//*44:*/ |
| 430 |
#line 954 "tie.w" |
| 431 |
|
| 432 |
boolean e_of_ch_preamble(i) |
| 433 |
file_index i; |
| 434 |
{register input_description*inp_desc= input_organization[i]; |
| 435 |
if(inp_desc->limit>=2&&inp_desc->buffer[0]==64) |
| 436 |
if(inp_desc->buffer[1]==89||inp_desc->buffer[1]==121)return(true); |
| 437 |
return(false); |
| 438 |
} |
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
/*:44*//*55:*/ |
| 443 |
#line 1157 "tie.w" |
| 444 |
|
| 445 |
void usage() |
| 446 |
{ |
| 447 |
print("Usage: tie -[mc] outfile master changefile(s)"); |
| 448 |
term_new_line; |
| 449 |
jump_out(); |
| 450 |
} |
| 451 |
|
| 452 |
|
| 453 |
/*:55*/ |
| 454 |
#line 118 "tie.w" |
| 455 |
|
| 456 |
/*59:*/ |
| 457 |
#line 1235 "tie.w" |
| 458 |
|
| 459 |
main(argc,argv) |
| 460 |
int argc;string*argv; |
| 461 |
{{/*12:*/ |
| 462 |
#line 408 "tie.w" |
| 463 |
|
| 464 |
int i; |
| 465 |
|
| 466 |
|
| 467 |
/*:12*/ |
| 468 |
#line 1238 "tie.w" |
| 469 |
|
| 470 |
/*10:*/ |
| 471 |
#line 296 "tie.w" |
| 472 |
|
| 473 |
xchr[32]= ' '; |
| 474 |
xchr[33]= '!'; |
| 475 |
xchr[34]= '\"'; |
| 476 |
xchr[35]= '#'; |
| 477 |
xchr[36]= '$'; |
| 478 |
xchr[37]= '%'; |
| 479 |
xchr[38]= '&'; |
| 480 |
xchr[39]= '\''; |
| 481 |
xchr[40]= '('; |
| 482 |
xchr[41]= ')'; |
| 483 |
xchr[42]= '*'; |
| 484 |
xchr[43]= '+'; |
| 485 |
xchr[44]= ','; |
| 486 |
xchr[45]= '-'; |
| 487 |
xchr[46]= '.'; |
| 488 |
xchr[47]= '/'; |
| 489 |
xchr[48]= '0'; |
| 490 |
xchr[49]= '1'; |
| 491 |
xchr[50]= '2'; |
| 492 |
xchr[51]= '3'; |
| 493 |
xchr[52]= '4'; |
| 494 |
xchr[53]= '5'; |
| 495 |
xchr[54]= '6'; |
| 496 |
xchr[55]= '7'; |
| 497 |
xchr[56]= '8'; |
| 498 |
xchr[57]= '9'; |
| 499 |
xchr[58]= ':'; |
| 500 |
xchr[59]= ';'; |
| 501 |
xchr[60]= '<'; |
| 502 |
xchr[61]= '='; |
| 503 |
xchr[62]= '>'; |
| 504 |
xchr[63]= '?'; |
| 505 |
xchr[64]= '@'; |
| 506 |
xchr[65]= 'A'; |
| 507 |
xchr[66]= 'B'; |
| 508 |
xchr[67]= 'C'; |
| 509 |
xchr[68]= 'D'; |
| 510 |
xchr[69]= 'E'; |
| 511 |
xchr[70]= 'F'; |
| 512 |
xchr[71]= 'G'; |
| 513 |
xchr[72]= 'H'; |
| 514 |
xchr[73]= 'I'; |
| 515 |
xchr[74]= 'J'; |
| 516 |
xchr[75]= 'K'; |
| 517 |
xchr[76]= 'L'; |
| 518 |
xchr[77]= 'M'; |
| 519 |
xchr[78]= 'N'; |
| 520 |
xchr[79]= 'O'; |
| 521 |
xchr[80]= 'P'; |
| 522 |
xchr[81]= 'Q'; |
| 523 |
xchr[82]= 'R'; |
| 524 |
xchr[83]= 'S'; |
| 525 |
xchr[84]= 'T'; |
| 526 |
xchr[85]= 'U'; |
| 527 |
xchr[86]= 'V'; |
| 528 |
xchr[87]= 'W'; |
| 529 |
xchr[88]= 'X'; |
| 530 |
xchr[89]= 'Y'; |
| 531 |
xchr[90]= 'Z'; |
| 532 |
xchr[91]= '['; |
| 533 |
xchr[92]= '\\'; |
| 534 |
xchr[93]= ']'; |
| 535 |
xchr[94]= '^'; |
| 536 |
xchr[95]= '_'; |
| 537 |
xchr[96]= '`'; |
| 538 |
xchr[97]= 'a'; |
| 539 |
xchr[98]= 'b'; |
| 540 |
xchr[99]= 'c'; |
| 541 |
xchr[100]= 'd'; |
| 542 |
xchr[101]= 'e'; |
| 543 |
xchr[102]= 'f'; |
| 544 |
xchr[103]= 'g'; |
| 545 |
xchr[104]= 'h'; |
| 546 |
xchr[105]= 'i'; |
| 547 |
xchr[106]= 'j'; |
| 548 |
xchr[107]= 'k'; |
| 549 |
xchr[108]= 'l'; |
| 550 |
xchr[109]= 'm'; |
| 551 |
xchr[110]= 'n'; |
| 552 |
xchr[111]= 'o'; |
| 553 |
xchr[112]= 'p'; |
| 554 |
xchr[113]= 'q'; |
| 555 |
xchr[114]= 'r'; |
| 556 |
xchr[115]= 's'; |
| 557 |
xchr[116]= 't'; |
| 558 |
xchr[117]= 'u'; |
| 559 |
xchr[118]= 'v'; |
| 560 |
xchr[119]= 'w'; |
| 561 |
xchr[120]= 'x'; |
| 562 |
xchr[121]= 'y'; |
| 563 |
xchr[122]= 'z'; |
| 564 |
xchr[123]= '{'; |
| 565 |
xchr[124]= '|'; |
| 566 |
xchr[125]= '}'; |
| 567 |
xchr[126]= '~'; |
| 568 |
xchr[0]= ' ';xchr[0x7F]= ' '; |
| 569 |
|
| 570 |
|
| 571 |
/*:10*//*13:*/ |
| 572 |
#line 429 "tie.w" |
| 573 |
|
| 574 |
for(i= 1;i<32;xchr[i++]= ' '); |
| 575 |
xchr[tab_mark]= '\t'; |
| 576 |
xchr[form_feed]= '\f'; |
| 577 |
xchr[nl_mark]= '\n'; |
| 578 |
|
| 579 |
|
| 580 |
/*:13*//*14:*/ |
| 581 |
#line 440 "tie.w" |
| 582 |
|
| 583 |
for(i= first_text_char;i<=last_text_char;xord[i++]= 32)do_nothing; |
| 584 |
for(i= 1;i<=126;i++)xord[xchr[i]]= i; |
| 585 |
|
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
/*:14*/ |
| 591 |
#line 1239 "tie.w" |
| 592 |
|
| 593 |
} |
| 594 |
print_ln(banner); |
| 595 |
print_ln(copyright); |
| 596 |
actual_input= 0; |
| 597 |
out_mode= normal; |
| 598 |
/*56:*/ |
| 599 |
#line 1177 "tie.w" |
| 600 |
|
| 601 |
{int act_arg; |
| 602 |
if(argc<5||argc>max_file_index+4-1)usage(); |
| 603 |
no_ch= -1; |
| 604 |
for(act_arg= 1;act_arg<argc;act_arg++){ |
| 605 |
if(argv[act_arg][0]=='-')/*57:*/ |
| 606 |
#line 1195 "tie.w" |
| 607 |
|
| 608 |
if(prod_chf!=unknown)usage(); |
| 609 |
else |
| 610 |
switch(argv[act_arg][1]){ |
| 611 |
case'c': |
| 612 |
case'C':prod_chf= chf;break; |
| 613 |
case'm': |
| 614 |
case'M':prod_chf= master;break; |
| 615 |
default:usage(); |
| 616 |
} |
| 617 |
|
| 618 |
|
| 619 |
/*:57*/ |
| 620 |
#line 1182 "tie.w" |
| 621 |
|
| 622 |
else/*58:*/ |
| 623 |
#line 1211 "tie.w" |
| 624 |
|
| 625 |
{if(no_ch==(-1)){ |
| 626 |
out_name= argv[act_arg]; |
| 627 |
}else{register input_description*inp_desc; |
| 628 |
inp_desc= (input_description*) |
| 629 |
malloc(sizeof(input_description)); |
| 630 |
if(inp_desc==NULL) |
| 631 |
fatal_error("! No memory for descriptor"); |
| 632 |
|
| 633 |
inp_desc->mode= search; |
| 634 |
inp_desc->line= 0; |
| 635 |
inp_desc->type_of_file= chf; |
| 636 |
inp_desc->limit= 0; |
| 637 |
inp_desc->name_of_file= argv[act_arg]; |
| 638 |
input_organization[no_ch]= inp_desc; |
| 639 |
} |
| 640 |
incr(no_ch); |
| 641 |
} |
| 642 |
|
| 643 |
|
| 644 |
/*:58*/ |
| 645 |
#line 1183 "tie.w" |
| 646 |
|
| 647 |
} |
| 648 |
if(no_ch<=0||prod_chf==unknown)usage(); |
| 649 |
} |
| 650 |
|
| 651 |
|
| 652 |
/*:56*/ |
| 653 |
#line 1245 "tie.w" |
| 654 |
|
| 655 |
/*34:*/ |
| 656 |
#line 788 "tie.w" |
| 657 |
|
| 658 |
{ |
| 659 |
out_file= fopen(out_name,"w"); |
| 660 |
if(out_file==NULL){ |
| 661 |
fatal_error("! Could not open/create output file"); |
| 662 |
|
| 663 |
} |
| 664 |
} |
| 665 |
|
| 666 |
|
| 667 |
/*:34*/ |
| 668 |
#line 1246 "tie.w" |
| 669 |
|
| 670 |
/*36:*/ |
| 671 |
#line 809 "tie.w" |
| 672 |
|
| 673 |
{input_organization[0]->the_file= |
| 674 |
fopen(input_organization[0]->name_of_file,"r"); |
| 675 |
if(input_organization[0]->the_file==NULL) |
| 676 |
fatal_error("! Could not open master file"); |
| 677 |
|
| 678 |
print2("(%s)",input_organization[0]->name_of_file); |
| 679 |
term_new_line; |
| 680 |
input_organization[0]->type_of_file= master; |
| 681 |
get_line(0); |
| 682 |
} |
| 683 |
|
| 684 |
/*:36*/ |
| 685 |
#line 1247 "tie.w" |
| 686 |
|
| 687 |
/*37:*/ |
| 688 |
#line 825 "tie.w" |
| 689 |
|
| 690 |
{file_index i; |
| 691 |
i= 1; |
| 692 |
while(i<no_ch){ |
| 693 |
input_organization[i]->the_file= |
| 694 |
fopen(input_organization[i]->name_of_file,"r"); |
| 695 |
if(input_organization[i]->the_file==NULL) |
| 696 |
fatal_error("!Could not open change file"); |
| 697 |
|
| 698 |
print2("(%s)",input_organization[i]->name_of_file); |
| 699 |
term_new_line; |
| 700 |
init_change_file(i,true); |
| 701 |
incr(i); |
| 702 |
} |
| 703 |
} |
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
/*:37*/ |
| 710 |
#line 1248 "tie.w" |
| 711 |
|
| 712 |
/*53:*/ |
| 713 |
#line 1128 "tie.w" |
| 714 |
|
| 715 |
actual_input= 0; |
| 716 |
input_has_ended= false; |
| 717 |
while(input_has_ended==false||actual_input!=0) |
| 718 |
/*45:*/ |
| 719 |
#line 970 "tie.w" |
| 720 |
|
| 721 |
{file_index test_file; |
| 722 |
/*46:*/ |
| 723 |
#line 985 "tie.w" |
| 724 |
|
| 725 |
{register input_description*inp_desc; |
| 726 |
while(actual_input>0&&e_of_ch_module(actual_input)){ |
| 727 |
inp_desc= input_organization[actual_input]; |
| 728 |
if(inp_desc->type_of_file==master){ |
| 729 |
|
| 730 |
fatal_error("! This can't happen: change file is master file"); |
| 731 |
|
| 732 |
} |
| 733 |
inp_desc->mode= search; |
| 734 |
init_change_file(actual_input,true); |
| 735 |
while((input_organization[actual_input]->mode!=reading |
| 736 |
&&actual_input>0))decr(actual_input); |
| 737 |
} |
| 738 |
} |
| 739 |
|
| 740 |
|
| 741 |
/*:46*/ |
| 742 |
#line 972 "tie.w" |
| 743 |
|
| 744 |
if(input_has_ended&&actual_input==0)break; |
| 745 |
/*47:*/ |
| 746 |
#line 1009 "tie.w" |
| 747 |
|
| 748 |
test_input= none; |
| 749 |
test_file= actual_input; |
| 750 |
while(test_input==none&&test_file<no_ch-1){ |
| 751 |
incr(test_file); |
| 752 |
switch(input_organization[test_file]->mode){ |
| 753 |
case search:if(lines_dont_match(actual_input,test_file)==false){ |
| 754 |
input_organization[test_file]->mode= test; |
| 755 |
test_input= test_file; |
| 756 |
} |
| 757 |
break; |
| 758 |
case test:if(lines_dont_match(actual_input,test_file)==true){ |
| 759 |
|
| 760 |
input_organization[test_file]->mode= search; |
| 761 |
err_print("! Sections do not match")(actual_input); |
| 762 |
|
| 763 |
err_loc(test_file); |
| 764 |
init_change_file(test_file,false); |
| 765 |
}else test_input= test_file; |
| 766 |
break; |
| 767 |
case reading:do_nothing; |
| 768 |
break; |
| 769 |
case ignore:do_nothing; |
| 770 |
break; |
| 771 |
} |
| 772 |
} |
| 773 |
|
| 774 |
|
| 775 |
/*:47*/ |
| 776 |
#line 974 "tie.w" |
| 777 |
|
| 778 |
/*48:*/ |
| 779 |
#line 1043 "tie.w" |
| 780 |
|
| 781 |
if(prod_chf==chf){ |
| 782 |
loop{ |
| 783 |
/*49:*/ |
| 784 |
#line 1057 "tie.w" |
| 785 |
|
| 786 |
if(out_mode==normal){ |
| 787 |
if(test_input!=none){ |
| 788 |
fputc(map_xchr(64),out_file);fputc(map_xchr(120),out_file); |
| 789 |
new_line(out_file); |
| 790 |
out_mode= pre; |
| 791 |
}else break; |
| 792 |
} |
| 793 |
|
| 794 |
|
| 795 |
/*:49*/ |
| 796 |
#line 1046 "tie.w" |
| 797 |
|
| 798 |
/*50:*/ |
| 799 |
#line 1071 "tie.w" |
| 800 |
|
| 801 |
|
| 802 |
if(out_mode==pre){ |
| 803 |
if(test_input==none){ |
| 804 |
fputc(map_xchr(64),out_file);fputc(map_xchr(121),out_file); |
| 805 |
new_line(out_file); |
| 806 |
out_mode= post; |
| 807 |
}else{ |
| 808 |
if(input_organization[actual_input]->type_of_file==master) |
| 809 |
put_line(actual_input); |
| 810 |
break; |
| 811 |
} |
| 812 |
} |
| 813 |
|
| 814 |
|
| 815 |
/*:50*/ |
| 816 |
#line 1047 "tie.w" |
| 817 |
|
| 818 |
/*51:*/ |
| 819 |
#line 1092 "tie.w" |
| 820 |
|
| 821 |
if(out_mode==post){ |
| 822 |
if(input_organization[actual_input]->type_of_file==chf){ |
| 823 |
if(test_input==none)put_line(actual_input); |
| 824 |
break; |
| 825 |
}else{ |
| 826 |
fputc(map_xchr(64),out_file);fputc(map_xchr(122),out_file); |
| 827 |
new_line(out_file); |
| 828 |
new_line(out_file); |
| 829 |
out_mode= normal; |
| 830 |
} |
| 831 |
} |
| 832 |
|
| 833 |
|
| 834 |
/*:51*/ |
| 835 |
#line 1048 "tie.w" |
| 836 |
|
| 837 |
} |
| 838 |
}else |
| 839 |
if(test_input==none)put_line(actual_input); |
| 840 |
|
| 841 |
|
| 842 |
/*:48*/ |
| 843 |
#line 975 "tie.w" |
| 844 |
|
| 845 |
/*52:*/ |
| 846 |
#line 1109 "tie.w" |
| 847 |
|
| 848 |
get_line(actual_input); |
| 849 |
if(test_input!=none){ |
| 850 |
get_line(test_input); |
| 851 |
if(e_of_ch_preamble(test_input)==true){ |
| 852 |
get_line(test_input); |
| 853 |
input_organization[test_input]->mode= reading; |
| 854 |
actual_input= test_input; |
| 855 |
test_input= none; |
| 856 |
} |
| 857 |
} |
| 858 |
|
| 859 |
|
| 860 |
/*:52*/ |
| 861 |
#line 976 "tie.w" |
| 862 |
|
| 863 |
} |
| 864 |
|
| 865 |
|
| 866 |
/*:45*/ |
| 867 |
#line 1132 "tie.w" |
| 868 |
|
| 869 |
if(out_mode==post){ |
| 870 |
fputc(map_xchr(64),out_file);fputc(map_xchr(122),out_file); |
| 871 |
new_line(out_file); |
| 872 |
} |
| 873 |
|
| 874 |
|
| 875 |
/*:53*/ |
| 876 |
#line 1249 "tie.w" |
| 877 |
|
| 878 |
/*54:*/ |
| 879 |
#line 1143 "tie.w" |
| 880 |
|
| 881 |
{file_index i; |
| 882 |
for(i= 1;i<no_ch;i++){ |
| 883 |
if(input_organization[i]->mode!=ignore) |
| 884 |
err_print("! Change file entry did not match")(i); |
| 885 |
|
| 886 |
} |
| 887 |
} |
| 888 |
|
| 889 |
|
| 890 |
/*:54*/ |
| 891 |
#line 1250 "tie.w" |
| 892 |
|
| 893 |
/*60:*/ |
| 894 |
#line 1261 "tie.w" |
| 895 |
|
| 896 |
{string msg; |
| 897 |
switch(history){ |
| 898 |
case spotless:msg= "No errors were found";break; |
| 899 |
case troublesome:msg= "Pardon me, but I think I spotted something wrong."; |
| 900 |
break; |
| 901 |
case fatal:msg= "That was a fatal error, my friend";break; |
| 902 |
} |
| 903 |
print2_nl("(%s.)",msg);term_new_line; |
| 904 |
exit(history==spotless?0:1); |
| 905 |
} |
| 906 |
|
| 907 |
|
| 908 |
|
| 909 |
|
| 910 |
|
| 911 |
/*:60*/ |
| 912 |
#line 1251 "tie.w" |
| 913 |
|
| 914 |
} |
| 915 |
|
| 916 |
/*:59*/ |
| 917 |
#line 119 "tie.w" |
| 918 |
|
| 919 |
|
| 920 |
/*:2*/ |