1# regression tests for the iffe command 2 3TEST 01 'command line basics' 4 5 EXEC -r -v - hdr stdio 6 OUTPUT - $'/* : : generated by iffe version 1995-03-19 : : */ 7#ifndef _REGRESS 8#define _REGRESS 1 9#define _sys_types 1 /* #include <sys/types.h> ok */ 10#define _hdr_stdio 1 /* #include <stdio.h> ok */ 11#endif' 12 ERROR - $'iffe: test: is sys/types.h a header ... yes 13iffe: test: is stdio.h a header ... yes' 14 15 EXEC -r -v -s bsh - hdr stdio 16 17 EXEC -r -v - hdr stdio,limits 18 OUTPUT - $'/* : : generated by iffe version 1995-03-19 : : */ 19#ifndef _REGRESS 20#define _REGRESS 1 21#define _sys_types 1 /* #include <sys/types.h> ok */ 22#define _hdr_stdio 1 /* #include <stdio.h> ok */ 23#define _hdr_limits 1 /* #include <limits.h> ok */ 24#endif' 25 ERROR - $'iffe: test: is sys/types.h a header ... yes 26iffe: test: is stdio.h a header ... yes 27iffe: test: is limits.h a header ... yes' 28 29 EXEC -r -v -s bsh - hdr stdio,limits 30 31 EXEC -r -v - hdr,lib no_foo_bar,no_bar_foo stdio.h 32 OUTPUT - $'/* : : generated by iffe version 1995-03-19 : : */ 33#ifndef _REGRESS 34#define _REGRESS 1 35#define _sys_types 1 /* #include <sys/types.h> ok */ 36#define _hdr_stdio 1 /* #include <stdio.h> ok */ 37#endif' 38 ERROR - $'iffe: test: is sys/types.h a header ... yes 39iffe: test: is stdio.h a header ... yes 40iffe: test: is no_foo_bar.h a header ... no 41iffe: test: is no_bar_foo.h a header ... no 42iffe: test: is no_foo_bar a library function ... no 43iffe: test: is no_bar_foo a library function ... no' 44 45 EXEC -r -v -s bsh - hdr,lib no_foo_bar,no_bar_foo stdio.h 46 47 EXEC -r -v - hdr no_foo_bar,no_bar_foo stdio.h : lib no_foo_bar,no_bar_foo stdio.h 48 49 EXEC -r -v -s bsh - hdr no_foo_bar,no_bar_foo stdio.h : lib no_foo_bar,no_bar_foo stdio.h 50 51TEST 02 'file input basics' 52 53 EXEC -r -v - t1.iffe 54 INPUT t1.iffe $'hdr stdio' 55 OUTPUT - $'/* : : generated from t1.iffe by iffe version 1995-03-19 : : */ 56#ifndef _REGRESS 57#define _REGRESS 1 58#define _sys_types 1 /* #include <sys/types.h> ok */ 59#define _hdr_stdio 1 /* #include <stdio.h> ok */ 60#endif' 61 ERROR - $'iffe: test: is sys/types.h a header ... yes 62iffe: test: is stdio.h a header ... yes' 63 64 EXEC -r -v -s bsh - t1.iffe 65 66 EXEC -r -v - t2.iffe 67 INPUT t2.iffe $'hdr stdio,limits' 68 OUTPUT - $'/* : : generated from t2.iffe by iffe version 1995-03-19 : : */ 69#ifndef _REGRESS 70#define _REGRESS 1 71#define _sys_types 1 /* #include <sys/types.h> ok */ 72#define _hdr_stdio 1 /* #include <stdio.h> ok */ 73#define _hdr_limits 1 /* #include <limits.h> ok */ 74#endif' 75 ERROR - $'iffe: test: is sys/types.h a header ... yes 76iffe: test: is stdio.h a header ... yes 77iffe: test: is limits.h a header ... yes' 78 79 EXEC -r -v -s bsh - t2.iffe 80 81 EXEC -r -v - t3.iffe 82 INPUT t3.iffe $'hdr,lib no_foo_bar,no_bar_foo stdio.h' 83 OUTPUT - $'/* : : generated from t3.iffe by iffe version 1995-03-19 : : */ 84#ifndef _REGRESS 85#define _REGRESS 1 86#define _sys_types 1 /* #include <sys/types.h> ok */ 87#define _hdr_stdio 1 /* #include <stdio.h> ok */ 88#endif' 89 ERROR - $'iffe: test: is sys/types.h a header ... yes 90iffe: test: is stdio.h a header ... yes 91iffe: test: is no_foo_bar.h a header ... no 92iffe: test: is no_bar_foo.h a header ... no 93iffe: test: is no_foo_bar a library function ... no 94iffe: test: is no_bar_foo a library function ... no' 95 96 EXEC -r -v -s bsh - t3.iffe 97 98 EXEC -r -v - t3.iffe 99 INPUT t3.iffe $'hdr no_foo_bar,no_bar_foo stdio.h 100lib no_foo_bar,no_bar_foo stdio.h' 101 102 EXEC -r -v -s bsh - t3.iffe 103 104TEST 03 'nested if' 105 106 EXEC -r -v - t.iffe 107 INPUT t.iffe $'iff ifelse 108if hdr stdio 109 if lib open { 110 HIT 1 111 } 112 elif lib close { 113 HIT 2 114 } 115 else { 116 HIT 3 117 } 118 endif 119elif hdr limits { 120 HIT 4 121} 122else { 123 HIT 5 124} 125endif' 126 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 127#ifndef _ifelse_H 128#define _ifelse_H 1 129#define _sys_types 1 /* #include <sys/types.h> ok */ 130#define _hdr_stdio 1 /* #include <stdio.h> ok */ 131#define _lib_open 1 /* open() in default lib(s) */ 132 HIT 1 133 134#endif' 135 ERROR - $'iffe: test: is sys/types.h a header ... yes 136iffe: test: is stdio.h a header ... yes 137iffe: test: is open a library function ... yes' 138 139 EXEC -r -v -s bsh - t.iffe 140 141 EXEC -r -v - t.iffe 142 INPUT t.iffe $'iff ifelse 143if hdr _XXX_stdio 144 if lib open { 145 HIT 1 146 } 147 elif lib close { 148 HIT 2 149 } 150 else { 151 HIT 3 152 } 153 endif 154elif hdr limits { 155 HIT 4 156} 157else { 158 HIT 5 159} 160endif' 161 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 162#ifndef _ifelse_H 163#define _ifelse_H 1 164#define _sys_types 1 /* #include <sys/types.h> ok */ 165#define _hdr_limits 1 /* #include <limits.h> ok */ 166HIT 4 167 168#endif' 169 ERROR - $'iffe: test: is sys/types.h a header ... yes 170iffe: test: is _XXX_stdio.h a header ... no 171iffe: test: is limits.h a header ... yes' 172 173 EXEC -r -v -s bsh - t.iffe 174 175 EXEC -r -v - t.iffe 176 INPUT t.iffe $'iff ifelse 177if hdr _XXX_stdio 178 if lib open { 179 HIT 1 180 } 181 elif lib close { 182 HIT 2 183 } 184 else { 185 HIT 3 186 } 187 endif 188elif hdr _XXX_limits { 189 HIT 4 190} 191else { 192 HIT 5 193} 194endif' 195 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 196#ifndef _ifelse_H 197#define _ifelse_H 1 198#define _sys_types 1 /* #include <sys/types.h> ok */ 199HIT 5 200 201#endif' 202 ERROR - $'iffe: test: is sys/types.h a header ... yes 203iffe: test: is _XXX_stdio.h a header ... no 204iffe: test: is _XXX_limits.h a header ... no' 205 206 EXEC -r -v -s bsh - t.iffe 207 208 EXEC -r -v - t.iffe 209 INPUT t.iffe $'iff ifelse 210if hdr stdio 211 if lib _XXX_open { 212 HIT 1 213 } 214 elif lib close { 215 HIT 2 216 } 217 else { 218 HIT 3 219 } 220 endif 221elif hdr limits { 222 HIT 4 223} 224else { 225 HIT 5 226} 227endif' 228 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 229#ifndef _ifelse_H 230#define _ifelse_H 1 231#define _sys_types 1 /* #include <sys/types.h> ok */ 232#define _hdr_stdio 1 /* #include <stdio.h> ok */ 233#define _lib_close 1 /* close() in default lib(s) */ 234 HIT 2 235 236#endif' 237 ERROR - $'iffe: test: is sys/types.h a header ... yes 238iffe: test: is stdio.h a header ... yes 239iffe: test: is _XXX_open a library function ... no 240iffe: test: is close a library function ... yes' 241 242 EXEC -r -v -s bsh - t.iffe 243 244 EXEC -r -v - t.iffe 245 INPUT t.iffe $'iff ifelse 246if hdr stdio 247 if lib _XXX_open { 248 HIT 1 249 } 250 elif lib _XXX_close { 251 HIT 2 252 } 253 else { 254 HIT 3 255 } 256 endif 257elif hdr limits { 258 HIT 4 259} 260else { 261 HIT 5 262} 263endif' 264 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 265#ifndef _ifelse_H 266#define _ifelse_H 1 267#define _sys_types 1 /* #include <sys/types.h> ok */ 268#define _hdr_stdio 1 /* #include <stdio.h> ok */ 269 HIT 3 270 271#endif' 272 ERROR - $'iffe: test: is sys/types.h a header ... yes 273iffe: test: is stdio.h a header ... yes 274iffe: test: is _XXX_open a library function ... no 275iffe: test: is _XXX_close a library function ... no' 276 277 EXEC -r -v -s bsh - t.iffe 278 279 EXEC -r -v - t.iffe 280 INPUT t.iffe $'iff ifelse 281if mem stat.st_atime sys/types.h sys/stat.h { 282 #define ATIME 1 283} 284elif mem stat.st_ctime sys/types.h sys/stat.h { 285 #define CTIME 1 286} 287elif mem stat.st_mtime sys/types.h sys/stat.h { 288 #define MTIME 1 289} 290else pass{ no_stat_time=1 }end { 291 #define NOTIME 1 292} 293endif 294if ( !no_stat_time ) { 295 #define YESTIME 1 296} 297endif' 298 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 299#ifndef _ifelse_H 300#define _ifelse_H 1 301#define _sys_types 1 /* #include <sys/types.h> ok */ 302#define _sys_stat 1 /* #include <sys/stat.h> ok */ 303#define _mem_st_atime_stat 1 /* st_atime is a member of struct stat */ 304#define ATIME 1 305 306#define YESTIME 1 307 308#endif' 309 ERROR - $'iffe: test: is sys/types.h a header ... yes 310iffe: test: is sys/stat.h a header ... yes 311iffe: test: is stat a type or typedef ... no 312iffe: test: is st_atime a member of struct stat ... yes 313iffe: test: is ( !no_stat_time ) true ... yes' 314 315 EXEC -r -v -s bsh - t.iffe 316 317 EXEC -r -v - t.iffe 318 INPUT t.iffe $'iff ifelse 319if mem foo_stat.st_atime sys/types.h sys/stat.h { 320 #define ATIME 1 321} 322elif mem stat.st_ctime sys/types.h sys/stat.h { 323 #define CTIME 1 324} 325elif mem stat.st_mtime sys/types.h sys/stat.h { 326 #define MTIME 1 327} 328else pass{ no_stat_time=1 }end { 329 #define NOTIME 1 330} 331endif 332if ( !no_stat_time ) { 333 #define YESTIME 1 334} 335endif' 336 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 337#ifndef _ifelse_H 338#define _ifelse_H 1 339#define _sys_types 1 /* #include <sys/types.h> ok */ 340#define _sys_stat 1 /* #include <sys/stat.h> ok */ 341#define _mem_st_ctime_stat 1 /* st_ctime is a member of struct stat */ 342#define CTIME 1 343 344#define YESTIME 1 345 346#endif' 347 ERROR - $'iffe: test: is sys/types.h a header ... yes 348iffe: test: is sys/stat.h a header ... yes 349iffe: test: is foo_stat a type or typedef ... no 350iffe: test: is st_atime a member of struct foo_stat ... no 351iffe: test: is stat a type or typedef ... no 352iffe: test: is st_ctime a member of struct stat ... yes 353iffe: test: is ( !no_stat_time ) true ... yes' 354 355 EXEC -r -v -s bsh - t.iffe 356 357 EXEC -r -v - t.iffe 358 INPUT t.iffe $'iff ifelse 359if mem foo_stat.st_atime sys/types.h sys/stat.h { 360 #define ATIME 1 361} 362elif mem foo_stat.st_ctime sys/types.h sys/stat.h { 363 #define CTIME 1 364} 365elif mem stat.st_mtime sys/types.h sys/stat.h { 366 #define MTIME 1 367} 368else pass{ no_stat_time=1 }end { 369 #define NOTIME 1 370} 371endif 372if ( !no_stat_time ) { 373 #define YESTIME 1 374} 375endif' 376 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 377#ifndef _ifelse_H 378#define _ifelse_H 1 379#define _sys_types 1 /* #include <sys/types.h> ok */ 380#define _sys_stat 1 /* #include <sys/stat.h> ok */ 381#define _mem_st_mtime_stat 1 /* st_mtime is a member of struct stat */ 382#define MTIME 1 383 384#define YESTIME 1 385 386#endif' 387 ERROR - $'iffe: test: is sys/types.h a header ... yes 388iffe: test: is sys/stat.h a header ... yes 389iffe: test: is foo_stat a type or typedef ... no 390iffe: test: is st_atime a member of struct foo_stat ... no 391iffe: test: is st_ctime a member of struct foo_stat ... no 392iffe: test: is stat a type or typedef ... no 393iffe: test: is st_mtime a member of struct stat ... yes 394iffe: test: is ( !no_stat_time ) true ... yes' 395 396 EXEC -r -v -s bsh - t.iffe 397 398 EXEC -r -v - t.iffe 399 INPUT t.iffe $'iff ifelse 400if mem foo_stat.st_atime sys/types.h sys/stat.h { 401 #define ATIME 1 402} 403elif mem foo_stat.st_ctime sys/types.h sys/stat.h { 404 #define CTIME 1 405} 406elif mem foo_stat.st_mtime sys/types.h sys/stat.h { 407 #define MTIME 1 408} 409else pass{ no_stat_time=1 }end { 410 #define NOTIME 1 411} 412endif 413if ( !no_stat_time ) { 414 #define YESTIME 1 415} 416endif' 417 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 418#ifndef _ifelse_H 419#define _ifelse_H 1 420#define _sys_types 1 /* #include <sys/types.h> ok */ 421#define _sys_stat 1 /* #include <sys/stat.h> ok */ 422#define NOTIME 1 423 424#endif' 425 ERROR - $'iffe: test: is sys/types.h a header ... yes 426iffe: test: is sys/stat.h a header ... yes 427iffe: test: is foo_stat a type or typedef ... no 428iffe: test: is st_atime a member of struct foo_stat ... no 429iffe: test: is st_ctime a member of struct foo_stat ... no 430iffe: test: is st_mtime a member of struct foo_stat ... no 431iffe: test: is ( !no_stat_time ) true ... no' 432 433 EXEC -r -v -s bsh - t.iffe 434 435 EXEC -r -v - t.iffe 436 INPUT t.iffe $'set explicit 437iff previous 438hdr stdio 439if hdr stdio { 440 OK 441} 442else { 443 OK 444} 445endif' 446 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 447#ifndef _previous_H 448#define _previous_H 1 449#define _hdr_stdio 1 /* #include <stdio.h> ok */ 450OK 451 452#endif' 453 ERROR - $'iffe: test: is sys/types.h a header ... yes 454iffe: test: is stdio.h a header ... yes' 455 456 EXEC -r -v -s bsh - t.iffe 457 458TEST 04 'test variable/macro override' 459 460 EXEC -r -v - t.iffe 461 INPUT t.iffe $'iff macro 462HAVE_STDIO = hdr stdio' 463 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 464#ifndef _macro_H 465#define _macro_H 1 466#define _sys_types 1 /* #include <sys/types.h> ok */ 467#define HAVE_STDIO 1 /* #include <stdio.h> ok */ 468#endif' 469 ERROR - $'iffe: test: is sys/types.h a header ... yes 470iffe: test: is stdio.h a header ... yes' 471 472 EXEC -r -v -s bsh - t.iffe 473 474 EXEC -r -v - t.iffe 475 INPUT t.iffe $'iff macro 476if hdr - stdio { 477 #define HIT 1 478} 479endif' 480 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 481#ifndef _macro_H 482#define _macro_H 1 483#define _sys_types 1 /* #include <sys/types.h> ok */ 484#define HIT 1 485 486#endif' 487 488 EXEC -r -v -s bsh - t.iffe 489 490 EXEC -r -v - t.iffe 491 INPUT t.iffe $'iff macro 492if - hdr stdio { 493 #define HIT 1 494} 495endif' 496 497 EXEC -r -v -s bsh - t.iffe 498 499 EXEC -r -v - t.iffe 500 INPUT t.iffe $'iff macro 501if ? hdr stdio { 502 #define HIT 1 503} 504endif' 505 506 EXEC -r -v -s bsh - t.iffe 507 508 EXEC -r -v - t.iffe 509 INPUT t.iffe $'iff macro 510if hdr - stdio { 511 #define HIT 1 512} 513endif' 514 515 EXEC -r -v -s bsh - t.iffe 516 517 EXEC -r -v - t.iffe 518 INPUT t.iffe $'iff macro 519if HAVE_STDIO = hdr stdio { 520 #define HIT 1 521} 522endif 523if ( HAVE_STDIO ) { 524 #define TOO ALSO 525} 526endif' 527 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 528#ifndef _macro_H 529#define _macro_H 1 530#define _sys_types 1 /* #include <sys/types.h> ok */ 531#define HAVE_STDIO 1 /* #include <stdio.h> ok */ 532#define HIT 1 533 534#define TOO ALSO 535 536#endif' 537 ERROR - $'iffe: test: is sys/types.h a header ... yes 538iffe: test: is stdio.h a header ... yes 539iffe: test: is ( HAVE_STDIO ) true ... yes' 540 541 EXEC -r -v -s bsh - t.iffe 542 543 EXEC -r -v - t.iffe 544 INPUT t.iffe $'iff macro 545if HAVE_STDIO = hdr stdio { 546 #define HIT 1 547} 548endif 549exp ALSO HAVE_STDIO' 550 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 551#ifndef _macro_H 552#define _macro_H 1 553#define _sys_types 1 /* #include <sys/types.h> ok */ 554#define HAVE_STDIO 1 /* #include <stdio.h> ok */ 555#define HIT 1 556 557#define ALSO 1 /* HAVE_STDIO is true */ 558#endif' 559 ERROR - $'iffe: test: is sys/types.h a header ... yes 560iffe: test: is stdio.h a header ... yes 561iffe: test: is HAVE_STDIO true ... yes' 562 563 EXEC -r -v -s bsh - t.iffe 564 565 EXEC -r -v - t.iffe 566 INPUT t.iffe $'iff macro 567if HAVE_STDIO = hdr stdio { 568 #define HIT 1 569} 570endif 571ALSO = ( HAVE_STDIO )' 572 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 573#ifndef _macro_H 574#define _macro_H 1 575#define _sys_types 1 /* #include <sys/types.h> ok */ 576#define HAVE_STDIO 1 /* #include <stdio.h> ok */ 577#define HIT 1 578 579#define ALSO 1 /* ( HAVE_STDIO ) is true */ 580#endif' 581 ERROR - $'iffe: test: is sys/types.h a header ... yes 582iffe: test: is stdio.h a header ... yes 583iffe: test: is ( HAVE_STDIO ) true ... yes' 584 585 EXEC -r -v -s bsh - t.iffe 586 587TEST 05 'test code option sequence' 588 589 EXEC -r -v - t.iffe 590 INPUT t.iffe $'iff macro 591tst seq - -DA=1 - -DB=1 note{ long int type }end compile{ 592 #if A == 1 && B == 0 593 #define t long 594 #else 595 #define t error 596 #endif 597 t n = 0; 598}end' 599 OUTPUT - '/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 600#ifndef _macro_H 601#define _macro_H 1 602#define _sys_types 1 /* #include <sys/types.h> ok */ 603#define _seq 1 /* long int type */ 604#endif' 605 ERROR - 'iffe: test: is sys/types.h a header ... yes 606iffe: test: long int type ... yes' 607 608 EXEC -r -v -s bsh - t.iffe 609 610 EXEC -r -v - t.iffe 611 INPUT t.iffe $'iff macro 612tst seq -DG=1 - -DN=1 - -DN=2 note{ long int type }end compile{ 613 #if G == 1 && N == 1 614 #define t long 615 #else 616 #define t error 617 #endif 618 t n = 0; 619}end' 620 621 EXEC -r -v -s bsh - t.iffe 622 623 EXEC -r -v - t.iffe 624 INPUT t.iffe $'iff macro 625tst seq - -DA=1 - -DB=1 note{ long int type }end compile{ 626 #if A == 0 && B == 1 627 #define t long 628 #else 629 #define t error 630 #endif 631 t n = 0; 632}end' 633 ERROR - 'iffe: test: is sys/types.h a header ... yes 634iffe: test: long int type ... 635iffe: test: long int type ... yes' 636 637 EXEC -r -v -s bsh - t.iffe 638 639 EXEC -r -v - t.iffe 640 INPUT t.iffe $'iff macro 641tst seq -DG=1 - -DN=1 - -DN=2 note{ long int type }end compile{ 642 #if G == 1 && N == 2 643 #define t long 644 #else 645 #define t error 646 #endif 647 t n = 0; 648}end' 649 650 EXEC -r -v -s bsh - t.iffe 651 652 EXEC -r -v - t.iffe 653 INPUT t.iffe $'iff macro 654tst seq - -DA=1 - -DB=1 note{ long int type }end compile{ 655 #if A == 0 && B == 0 656 #define t long 657 #else 658 #define t error 659 #endif 660 t n = 0; 661}end' 662 OUTPUT - '/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 663#ifndef _macro_H 664#define _macro_H 1 665#define _sys_types 1 /* #include <sys/types.h> ok */ 666#endif' 667 ERROR - 'iffe: test: is sys/types.h a header ... yes 668iffe: test: long int type ... 669iffe: test: long int type ... no' 670 671 EXEC -r -v -s bsh - t.iffe 672 673 EXEC -r -v - t.iffe 674 INPUT t.iffe $'iff macro 675tst seq -DG=1 - -DN=1 - -DN=2 note{ long int type }end compile{ 676 #if G == 1 && N == 0 677 #define t long 678 #else 679 #define t error 680 #endif 681 t n = 0; 682}end' 683 684 EXEC -r -v -s bsh - t.iffe 685 686 EXEC -r -v - t.iffe 687 INPUT t.iffe $'iff macro 688if tst - -DA=1 - -DB=1 note{ long int type }end compile{ 689 #if A == 1 && B == 0 690 #define t long 691 #else 692 #define t error 693 #endif 694 t n = 0; 695}end { 696 #define seq 1 697} 698endif' 699 OUTPUT - '/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 700#ifndef _macro_H 701#define _macro_H 1 702#define _sys_types 1 /* #include <sys/types.h> ok */ 703/* long int type */ 704#define seq 1 705 706#endif' 707 ERROR - 'iffe: test: is sys/types.h a header ... yes 708iffe: test: long int type ... yes' 709 710 EXEC -r -v -s bsh - t.iffe 711 712 EXEC -r -v - t.iffe 713 INPUT t.iffe $'iff macro 714if tst -DG=1 - -DN=1 - -DN=2 note{ long int type }end compile{ 715 #if G == 1 && N == 1 716 #define t long 717 #else 718 #define t error 719 #endif 720 t n = 0; 721}end { 722 #define seq 1 723} 724endif' 725 726 EXEC -r -v -s bsh - t.iffe 727 728 EXEC -r -v - t.iffe 729 INPUT t.iffe $'iff macro 730if tst - -DA=1 - -DB=1 note{ long int type }end compile{ 731 #if A == 0 && B == 1 732 #define t long 733 #else 734 #define t error 735 #endif 736 t n = 0; 737}end { 738 #define seq 1 739} 740endif' 741 ERROR - 'iffe: test: is sys/types.h a header ... yes 742iffe: test: long int type ... 743iffe: test: long int type ... yes' 744 745 EXEC -r -v -s bsh - t.iffe 746 747 EXEC -r -v - t.iffe 748 INPUT t.iffe $'iff macro 749if tst -DG=1 - -DN=1 - -DN=2 note{ long int type }end compile{ 750 #if G == 1 && N == 2 751 #define t long 752 #else 753 #define t error 754 #endif 755 t n = 0; 756}end { 757 #define seq 1 758} 759endif' 760 761 EXEC -r -v -s bsh - t.iffe 762 763 EXEC -r -v - t.iffe 764 INPUT t.iffe $'iff macro 765if tst - -DA=1 - -DB=1 note{ long int type }end compile{ 766 #if A == 0 && B == 0 767 #define t long 768 #else 769 #define t error 770 #endif 771 t n = 0; 772}end { 773 #define seq 1 774} 775endif' 776 OUTPUT - '/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 777#ifndef _macro_H 778#define _macro_H 1 779#define _sys_types 1 /* #include <sys/types.h> ok */ 780#endif' 781 ERROR - 'iffe: test: is sys/types.h a header ... yes 782iffe: test: long int type ... 783iffe: test: long int type ... no' 784 785 EXEC -r -v -s bsh - t.iffe 786 787 EXEC -r -v - t.iffe 788 INPUT t.iffe $'iff macro 789if tst -DG=1 - -DN=1 - -DN=2 note{ long int type }end compile{ 790 #if G == 1 && N == 0 791 #define t long 792 #else 793 #define t error 794 #endif 795 t n = 0; 796}end { 797 #define seq 1 798} 799endif' 800 801 EXEC -r -v -s bsh - t.iffe 802 803 EXEC -r -v - t.iffe 804 INPUT t.iffe $'iff macro 805if tst - -DN=1 - -DN=2 - -DN=3 note{ long int type }end compile{ 806 #if N == 1 807 #define t long 808 #else 809 #define t error 810 #endif 811 t n = 0; 812}end { 813 #define seq 1 814} 815endif' 816 OUTPUT - '/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 817#ifndef _macro_H 818#define _macro_H 1 819#define _sys_types 1 /* #include <sys/types.h> ok */ 820/* long int type */ 821#define seq 1 822 823#endif' 824 ERROR - 'iffe: test: is sys/types.h a header ... yes 825iffe: test: long int type ... yes' 826 827 EXEC -r -v -s bsh - t.iffe 828 829 EXEC -r -v - t.iffe 830 INPUT t.iffe $'iff macro 831if tst - -DN=1 - -DN=2 - -DN=3 note{ long int type }end compile{ 832 #if N == 2 833 #define t long 834 #else 835 #define t error 836 #endif 837 t n = 0; 838}end { 839 #define seq 1 840} 841endif' 842 ERROR - 'iffe: test: is sys/types.h a header ... yes 843iffe: test: long int type ... 844iffe: test: long int type ... yes' 845 846 EXEC -r -v -s bsh - t.iffe 847 848 EXEC -r -v - t.iffe 849 INPUT t.iffe $'iff macro 850if tst - -DN=1 - -DN=2 - -DN=3 note{ long int type }end compile{ 851 #if N == 3 852 #define t long 853 #else 854 #define t error 855 #endif 856 t n = 0; 857}end { 858 #define seq 1 859} 860endif' 861 ERROR - 'iffe: test: is sys/types.h a header ... yes 862iffe: test: long int type ... 863iffe: test: long int type ... 864iffe: test: long int type ... yes' 865 866 EXEC -r -v -s bsh - t.iffe 867 868 EXEC -r -v - t.iffe 869 INPUT t.iffe $'iff macro 870if tst - -DN=1 - -DN=2 - -DN=3 note{ long int type }end compile{ 871 #if N == 0 872 #define t long 873 #else 874 #define t error 875 #endif 876 t n = 0; 877}end { 878 #define seq 1 879} 880endif' 881 OUTPUT - '/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 882#ifndef _macro_H 883#define _macro_H 1 884#define _sys_types 1 /* #include <sys/types.h> ok */ 885#endif' 886 ERROR - 'iffe: test: is sys/types.h a header ... yes 887iffe: test: long int type ... 888iffe: test: long int type ... 889iffe: test: long int type ... no' 890 891 EXEC -r -v -s bsh - t.iffe 892 893TEST 06 'block side effects' 894 895 EXEC -r - t.iffe 896 INPUT t.iffe $'iff - 897tst output{ 898 int 899 main() 900 { 901 printf("HIT\\n"); 902 return 0; 903 } 904}end' 905 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 906#define _sys_types 1 /* #include <sys/types.h> ok */ 907HIT' 908 909 EXEC -r -s bsh - t.iffe 910 911 EXEC -r - t.iffe 912 INPUT t.iffe $'iff 913tst - output{ 914 int 915 main() 916 { 917 printf("HIT\\n"); 918 return 0; 919 } 920}end' 921 922 EXEC -r -s bsh - t.iffe 923 924 EXEC -r - t.iffe 925 INPUT t.iffe $'iff 926tst - output{ 927 int 928 main() 929 { 930 printf("HIT\\n"); 931 return 1; 932 } 933}end' 934 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 935#define _sys_types 1 /* #include <sys/types.h> ok */' 936 937 EXEC -r -s bsh - t.iffe 938 939 EXEC -r - t.iffe 940 INPUT t.iffe $'iff 941tst - nooutput{ 942 int 943 main() 944 { 945 printf("HIT\\n"); 946 return 1; 947 } 948}end' 949 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 950#define _sys_types 1 /* #include <sys/types.h> ok */ 951HIT' 952 953 EXEC -r -s bsh - t.iffe 954 955TEST 07 'diagnostics' 956 957 EXEC -r - t.iffe 958 INPUT t.iffe $'tst foo' 959 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 960#ifndef _REGRESS 961#define _REGRESS 1 962#define _sys_types 1 /* #include <sys/types.h> ok */ 963#endif' 964 ERROR - $'iffe: t.iffe:1: tst: unknown feature test' 965 EXIT 1 966 967 EXEC -r -s bsh - t.iffe 968 969 EXEC -r - t.iffe 970 INPUT t.iffe $'if (1)' 971 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 972#ifndef _REGRESS 973#define _REGRESS 1 974#define _sys_types 1 /* #include <sys/types.h> ok */' 975 ERROR - $'iffe: t.iffe:1: missing endif' 976 EXIT 1 977 978 EXEC -r -s bsh - t.iffe 979 980 EXEC -r - t.iffe 981 INPUT t.iffe $'if' 982 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 983#ifndef _REGRESS 984#define _REGRESS 1 985#define _sys_types 1 /* #include <sys/types.h> ok */' 986 ERROR - $'iffe: t.iffe:1: missing endif' 987 988 EXEC -r -s bsh - t.iffe 989 990 EXEC -r - t.iffe 991 INPUT t.iffe $'endif' 992 ERROR - $'iffe: t.iffe:1: endif: no matching if' 993 994 EXEC -r -s bsh - t.iffe 995 996 EXEC -r - t.iffe 997 INPUT t.iffe $'if { 998}end' 999 ERROR - $'iffe: t.iffe:2: missing }' 1000 1001 EXEC -r -s bsh - t.iffe 1002 1003TEST 08 'negation consternation' 1004 1005 EXEC -r - t.iffe 1006 INPUT t.iffe $'npt fopen,fooon stdio.h' 1007 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1008#ifndef _REGRESS 1009#define _REGRESS 1 1010#define _sys_types 1 /* #include <sys/types.h> ok */ 1011#define _hdr_stdlib 1 /* #include <stdlib.h> ok */ 1012#define _hdr_unistd 1 /* #include <unistd.h> ok */ 1013#define _hdr_stdio 1 /* #include <stdio.h> ok */ 1014#define _npt_fooon 1 /* fooon() needs a prototype */ 1015#endif' 1016 1017 EXEC -r -u - t.iffe 1018 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1019#ifndef _REGRESS 1020#define _REGRESS 1 1021#define _sys_types 1 /* #include <sys/types.h> ok */ 1022#define _hdr_stdlib 1 /* #include <stdlib.h> ok */ 1023#define _hdr_unistd 1 /* #include <unistd.h> ok */ 1024#define _hdr_stdio 1 /* #include <stdio.h> ok */ 1025#undef _npt_fopen /* fopen() does not need a prototype */ 1026#define _npt_fooon 1 /* fooon() needs a prototype */ 1027#endif' 1028 1029 EXEC -r -a - t.iffe 1030 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1031#ifndef _REGRESS 1032#define _REGRESS 1 1033#define _sys_types 1 /* #include <sys/types.h> ok */ 1034#define _hdr_stdlib 1 /* #include <stdlib.h> ok */ 1035#define _hdr_unistd 1 /* #include <unistd.h> ok */ 1036#define _hdr_stdio 1 /* #include <stdio.h> ok */ 1037#define _npt_fopen 0 /* fopen() does not need a prototype */ 1038#define _npt_fooon 1 /* fooon() needs a prototype */ 1039#endif' 1040 1041 EXEC -r -C - t.iffe 1042 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1043#ifndef _REGRESS 1044#define _REGRESS 1 1045#define HAVE_SYS_TYPES_H 1 /* #include <sys/types.h> ok */ 1046#define HAVE_STDLIB_H 1 /* #include <stdlib.h> ok */ 1047#define HAVE_UNISTD_H 1 /* #include <unistd.h> ok */ 1048#define HAVE_STDIO_H 1 /* #include <stdio.h> ok */ 1049#define HAVE_FOPEN_DECL 1 /* fopen() does not need a prototype */ 1050#undef HAVE_FOOON_DECL /* fooon() needs a prototype */ 1051#endif' 1052 1053 EXEC -r - t.iffe 1054 INPUT t.iffe $'NEED_FOPEN = npt fopen stdio.h 1055HAVE_FOPEN = ! npt fopen stdio.h 1056NEED_FOOON = npt fooon stdio.h 1057HAVE_FOOON = ! npt fooon stdio.h' 1058 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1059#ifndef _REGRESS 1060#define _REGRESS 1 1061#define _sys_types 1 /* #include <sys/types.h> ok */ 1062#define _hdr_stdlib 1 /* #include <stdlib.h> ok */ 1063#define _hdr_unistd 1 /* #include <unistd.h> ok */ 1064#define _hdr_stdio 1 /* #include <stdio.h> ok */ 1065#define HAVE_FOPEN 1 /* fopen() does not need a prototype */ 1066#define NEED_FOOON 1 /* fooon() needs a prototype */ 1067#endif' 1068 1069 EXEC -r -u - t.iffe 1070 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1071#ifndef _REGRESS 1072#define _REGRESS 1 1073#define _sys_types 1 /* #include <sys/types.h> ok */ 1074#define _hdr_stdlib 1 /* #include <stdlib.h> ok */ 1075#define _hdr_unistd 1 /* #include <unistd.h> ok */ 1076#define _hdr_stdio 1 /* #include <stdio.h> ok */ 1077#undef NEED_FOPEN /* fopen() does not need a prototype */ 1078#define HAVE_FOPEN 1 /* fopen() does not need a prototype */ 1079#define NEED_FOOON 1 /* fooon() needs a prototype */ 1080#undef HAVE_FOOON /* fooon() needs a prototype */ 1081#endif' 1082 1083 EXEC -r -C - t.iffe 1084 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1085#ifndef _REGRESS 1086#define _REGRESS 1 1087#define HAVE_SYS_TYPES_H 1 /* #include <sys/types.h> ok */ 1088#define HAVE_STDLIB_H 1 /* #include <stdlib.h> ok */ 1089#define HAVE_UNISTD_H 1 /* #include <unistd.h> ok */ 1090#define HAVE_STDIO_H 1 /* #include <stdio.h> ok */ 1091#undef NEED_FOPEN /* fopen() does not need a prototype */ 1092#define HAVE_FOPEN 1 /* fopen() does not need a prototype */ 1093#define NEED_FOOON 1 /* fooon() needs a prototype */ 1094#undef HAVE_FOOON /* fooon() needs a prototype */ 1095#endif' 1096 1097TEST 09 'exp vs. if' 1098 1099 EXEC -r - t.iffe 1100 INPUT t.iffe $'_tst_false = ( 0 ) 1101_tst_true = ( 1 ) 1102exp _tst_hit !_tst_false { 1103 ONE 1104} 1105exp _tst_hit !_tst_hit&_tst_true pass{ 1106cat <<! 1107 TWO $_tst_false $_tst_true 1108! 1109}end 1110exp _tst_hit !_tst_hit&_tst_true { 1111 THREE 1112}' 1113 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1114#ifndef _REGRESS 1115#define _REGRESS 1 1116#define _sys_types 1 /* #include <sys/types.h> ok */ 1117#define _tst_true 1 /* ( 1 ) is true */ 1118#define _tst_hit 1 /* !_tst_false is true */ 1119/* !_tst_false */ 1120ONE 1121 1122#endif' 1123 1124 EXEC -r -s bsh - t.iffe 1125 1126 EXEC -r - t.iffe 1127 INPUT t.iffe $'_tst_false = ( 0 ) 1128_tst_true = ( 1 ) 1129exp _tst_hit !_tst_true { 1130 ONE 1131} 1132exp _tst_hit !_tst_hit&_tst_true pass{ 1133cat <<! 1134 TWO $_tst_false $_tst_true 1135! 1136}end 1137exp _tst_hit !_tst_hit&_tst_true { 1138 THREE 1139}' 1140 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1141#ifndef _REGRESS 1142#define _REGRESS 1 1143#define _sys_types 1 /* #include <sys/types.h> ok */ 1144#define _tst_true 1 /* ( 1 ) is true */ 1145#define _tst_hit 1 /* !_tst_hit&_tst_true is true */ 1146TWO 0 1 1147#endif' 1148 1149 EXEC -r -s bsh - t.iffe 1150 1151 EXEC -r - t.iffe 1152 INPUT t.iffe $'_tst_false = ( 0 ) 1153_tst_true = ( 1 ) 1154exp _tst_hit !_tst_true { 1155 ONE 1156} 1157exp _tst_hit !_tst_hit&_tst_false pass{ 1158cat <<! 1159 TWO $_tst_false $_tst_true 1160! 1161}end 1162exp _tst_hit !_tst_hit&_tst_true { 1163 THREE 1164}' 1165 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1166#ifndef _REGRESS 1167#define _REGRESS 1 1168#define _sys_types 1 /* #include <sys/types.h> ok */ 1169#define _tst_true 1 /* ( 1 ) is true */ 1170#define _tst_hit 1 /* !_tst_hit&_tst_true is true */ 1171/* !_tst_hit&_tst_true */ 1172THREE 1173 1174#endif' 1175 1176 EXEC -r -s bsh - t.iffe 1177 1178 EXEC -r - t.iffe 1179 INPUT t.iffe $'_tst_false = ( 0 ) 1180_tst_true = ( 1 ) 1181exp _tst_hit !_tst_true { 1182 ONE 1183} 1184exp _tst_hit !_tst_hit&_tst_false pass{ 1185cat <<! 1186 TWO $_tst_false $_tst_true 1187! 1188}end 1189exp _tst_hit !_tst_hit&_tst_false { 1190 THREE 1191}' 1192 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1193#ifndef _REGRESS 1194#define _REGRESS 1 1195#define _sys_types 1 /* #include <sys/types.h> ok */ 1196#define _tst_true 1 /* ( 1 ) is true */ 1197#endif' 1198 1199 EXEC -r -s bsh - t.iffe 1200 1201 EXEC -r - t.iffe 1202 INPUT t.iffe $'_tst_false = ( 0 ) 1203_tst_true = ( 1 ) 1204exp _tst_hit !_tst_false { 1205 ONE 1206} 1207exp _tst_hit !_tst_hit&&_tst_true pass{ 1208cat <<! 1209 TWO $_tst_false $_tst_true 1210! 1211}end 1212exp _tst_hit !_tst_hit&&_tst_true { 1213 THREE 1214}' 1215 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1216#ifndef _REGRESS 1217#define _REGRESS 1 1218#define _sys_types 1 /* #include <sys/types.h> ok */ 1219#define _tst_true 1 /* ( 1 ) is true */ 1220#define _tst_hit 1 /* !_tst_false is true */ 1221/* !_tst_false */ 1222ONE 1223 1224#endif' 1225 1226 EXEC -r -s bsh - t.iffe 1227 1228 EXEC -r - t.iffe 1229 INPUT t.iffe $'_tst_false = ( 0 ) 1230_tst_true = ( 1 ) 1231exp _tst_hit !_tst_true { 1232 ONE 1233} 1234exp _tst_hit !_tst_hit&&_tst_true pass{ 1235cat <<! 1236 TWO $_tst_false $_tst_true 1237! 1238}end 1239exp _tst_hit !_tst_hit&&_tst_true { 1240 THREE 1241}' 1242 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1243#ifndef _REGRESS 1244#define _REGRESS 1 1245#define _sys_types 1 /* #include <sys/types.h> ok */ 1246#define _tst_true 1 /* ( 1 ) is true */ 1247#define _tst_hit 1 /* !_tst_hit&&_tst_true is true */ 1248TWO 0 1 1249#endif' 1250 1251 EXEC -r -s bsh - t.iffe 1252 1253 EXEC -r - t.iffe 1254 INPUT t.iffe $'_tst_false = ( 0 ) 1255_tst_true = ( 1 ) 1256exp _tst_hit !_tst_true { 1257 ONE 1258} 1259exp _tst_hit !_tst_hit&&_tst_false pass{ 1260cat <<! 1261 TWO $_tst_false $_tst_true 1262! 1263}end 1264exp _tst_hit !_tst_hit&&_tst_true { 1265 THREE 1266}' 1267 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1268#ifndef _REGRESS 1269#define _REGRESS 1 1270#define _sys_types 1 /* #include <sys/types.h> ok */ 1271#define _tst_true 1 /* ( 1 ) is true */ 1272#define _tst_hit 1 /* !_tst_hit&&_tst_true is true */ 1273/* !_tst_hit&&_tst_true */ 1274THREE 1275 1276#endif' 1277 1278 EXEC -r -s bsh - t.iffe 1279 1280 EXEC -r - t.iffe 1281 INPUT t.iffe $'_tst_false = ( 0 ) 1282_tst_true = ( 1 ) 1283exp _tst_hit !_tst_true { 1284 ONE 1285} 1286exp _tst_hit !_tst_hit&&_tst_false pass{ 1287cat <<! 1288 TWO $_tst_false $_tst_true 1289! 1290}end 1291exp _tst_hit !_tst_hit&&_tst_false { 1292 THREE 1293}' 1294 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1295#ifndef _REGRESS 1296#define _REGRESS 1 1297#define _sys_types 1 /* #include <sys/types.h> ok */ 1298#define _tst_true 1 /* ( 1 ) is true */ 1299#endif' 1300 1301 EXEC -r -s bsh - t.iffe 1302 1303 EXEC -r - t.iffe 1304 INPUT t.iffe $'_tst_false = ( 0 ) 1305_tst_true = ( 1 ) 1306if ( ! _tst_false ) { 1307 ONE 1308} 1309elif ( _tst_true ) pass{ 1310cat <<! 1311 TWO 1312! 1313}end 1314else { 1315 THREE 1316} 1317endif' 1318 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1319#ifndef _REGRESS 1320#define _REGRESS 1 1321#define _sys_types 1 /* #include <sys/types.h> ok */ 1322#define _tst_true 1 /* ( 1 ) is true */ 1323ONE 1324 1325#endif' 1326 1327 EXEC -r -s bsh - t.iffe 1328 1329 EXEC -r - t.iffe 1330 INPUT t.iffe $'_tst_false = ( 0 ) 1331_tst_true = ( 1 ) 1332if ( ! _tst_true ) { 1333 ONE 1334} 1335elif ( _tst_true ) pass{ 1336cat <<! 1337 TWO 1338! 1339}end 1340else { 1341 THREE 1342} 1343endif' 1344 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1345#ifndef _REGRESS 1346#define _REGRESS 1 1347#define _sys_types 1 /* #include <sys/types.h> ok */ 1348#define _tst_true 1 /* ( 1 ) is true */ 1349TWO 1350#endif' 1351 1352 EXEC -r -s bsh - t.iffe 1353 1354 EXEC -r - t.iffe 1355 INPUT t.iffe $'_tst_false = ( 0 ) 1356_tst_true = ( 1 ) 1357if ( ! _tst_true ) { 1358 ONE 1359} 1360elif ( _tst_false ) pass{ 1361cat <<! 1362 TWO 1363! 1364}end 1365else { 1366 THREE 1367} 1368endif' 1369 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1370#ifndef _REGRESS 1371#define _REGRESS 1 1372#define _sys_types 1 /* #include <sys/types.h> ok */ 1373#define _tst_true 1 /* ( 1 ) is true */ 1374THREE 1375 1376#endif' 1377 1378 EXEC -r -s bsh - t.iffe 1379 1380 EXEC -r - t.iffe 1381 INPUT t.iffe $'_tst_false = ( 0 ) 1382_tst_true = ( 1 ) 1383if ( ! _tst_true ) yes{ 1384 typedef struct 1385 { 1386 int dd_fd; /* file descriptor */ 1387 } DIR; 1388}end 1389endif' 1390 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1391#ifndef _REGRESS 1392#define _REGRESS 1 1393#define _sys_types 1 /* #include <sys/types.h> ok */ 1394#define _tst_true 1 /* ( 1 ) is true */ 1395#endif' 1396 1397 EXEC -r -s bsh - t.iffe 1398 1399 EXEC -r - t.iffe 1400 INPUT t.iffe $'_tst_false = ( 0 ) 1401_tst_true = ( 1 ) 1402if ( ! _tst_true ) { 1403 typedef struct 1404 { 1405 int dd_fd; /* file descriptor */ 1406 } DIR; 1407} 1408else { 1409 OK 1410} 1411endif' 1412 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1413#ifndef _REGRESS 1414#define _REGRESS 1 1415#define _sys_types 1 /* #include <sys/types.h> ok */ 1416#define _tst_true 1 /* ( 1 ) is true */ 1417OK 1418 1419#endif' 1420 1421 EXEC -r -s bsh - t.iffe 1422 1423 EXEC -r - t.iffe 1424 INPUT t.iffe $'_tst_false = ( 0 ) 1425_tst_true = ( 1 ) 1426if ( ! _tst_true ) { 1427 typedef struct 1428 { 1429 int dd_fd; /* file descriptor */ 1430 }; 1431} 1432else { 1433 OK 1434} 1435endif' 1436 1437 EXEC -r -s bsh - t.iffe 1438 1439TEST 10 'exp details' 1440 1441 EXEC -r -v - t.iffe 1442 INPUT t.iffe $'_str = "string" 1443_hdr = <header> 1444_aaa = ( 0 ) 1445_zzz = ( 1 ) 1446( _str ) 1447( ! _str ) 1448( _hdr ) 1449( ! _hdr ) 1450( _aaa ) 1451( ! _aaa ) 1452( _zzz ) 1453( ! _zzz )' 1454 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1455#ifndef _REGRESS 1456#define _REGRESS 1 1457#define _sys_types 1 /* #include <sys/types.h> ok */ 1458#define _str "string" 1459#define _hdr <header> 1460#define _zzz 1 /* ( 1 ) is true */ 1461#endif' 1462 ERROR - $'iffe: test: is sys/types.h a header ... yes 1463iffe: test: is ( 0 ) true ... no 1464iffe: test: is ( 1 ) true ... yes 1465iffe: test: is ( _str ) true ... yes 1466iffe: test: is ( ! _str ) true ... no 1467iffe: test: is ( _hdr ) true ... yes 1468iffe: test: is ( ! _hdr ) true ... no 1469iffe: test: is ( _aaa ) true ... no 1470iffe: test: is ( ! _aaa ) true ... yes 1471iffe: test: is ( _zzz ) true ... yes 1472iffe: test: is ( ! _zzz ) true ... no' 1473 1474 EXEC -r -v -s bsh - t.iffe 1475 1476TEST 11 'set [no]define' 1477 1478 EXEC -r -v - t.iffe 1479 INPUT t.iffe $'set nodefine 1480mem stat.st_mtime sys/types.h sys/stat.h 1481set define 1482mem stat.st_mode sys/types.h sys/stat.h 1483if ( _mem_st_mtime_stat ) { 1484 1 1485} 1486endif 1487if ( _mem_st_mode_stat ) { 1488 2 1489} 1490endif' 1491 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1492#ifndef _REGRESS 1493#define _REGRESS 1 1494#define _mem_st_mode_stat 1 /* st_mode is a member of struct stat */ 14951 1496 14972 1498 1499#endif' 1500 ERROR - $'iffe: test: is sys/types.h a header ... yes 1501iffe: test: is sys/stat.h a header ... yes 1502iffe: test: is stat a type or typedef ... no 1503iffe: test: is st_mtime a member of struct stat ... yes 1504iffe: test: is st_mode a member of struct stat ... yes 1505iffe: test: is ( _mem_st_mtime_stat ) true ... yes 1506iffe: test: is ( _mem_st_mode_stat ) true ... yes' 1507 1508 EXEC -r -v -s bsh - t.iffe 1509 1510TEST 12 'non-opaque mem' 1511 1512 EXEC -r -v - mem OPAQUE -I. t.h 1513 INPUT t.h $'typedef struct opaque OPAQUE;' 1514 OUTPUT - $'/* : : generated by iffe version 1995-03-19 : : */ 1515#ifndef _REGRESS 1516#define _REGRESS 1 1517#define _sys_types 1 /* #include <sys/types.h> ok */ 1518#define _hdr_t 1 /* #include <t.h> ok */ 1519#endif' 1520 ERROR - $'iffe: test: is sys/types.h a header ... yes 1521iffe: test: is t.h a header ... yes 1522iffe: test: is OPAQUE a type or typedef ... no 1523iffe: test: is struct OPAQUE a non-opaque struct ... no' 1524 1525 EXEC -r -v - mem NONOPAQUE -I. t.h 1526 INPUT t.h $'struct nonopaque { int pad; }; 1527typedef struct nonopaque NONOPAQUE;' 1528 OUTPUT - $'/* : : generated by iffe version 1995-03-19 : : */ 1529#ifndef _REGRESS 1530#define _REGRESS 1 1531#define _sys_types 1 /* #include <sys/types.h> ok */ 1532#define _hdr_t 1 /* #include <t.h> ok */ 1533#define _mem_NONOPAQUE 1 /* NONOPAQUE is a non-opaque struct */ 1534#endif' 1535 ERROR - $'iffe: test: is sys/types.h a header ... yes 1536iffe: test: is t.h a header ... yes 1537iffe: test: is NONOPAQUE a type or typedef ... yes 1538iffe: test: is NONOPAQUE a non-opaque struct ... yes' 1539 1540TEST 13 'key states' 1541 1542 EXEC -r -v - t.iffe 1543 INPUT t.iffe $'key int 1544key const = 1545key foo 1546key bar = 1547key aha = huh = int 1548key chr = char = int' 1549 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1550#ifndef _REGRESS 1551#define _REGRESS 1 1552#define _sys_types 1 /* #include <sys/types.h> ok */ 1553#define _key_int 1 /* int is a reserved keyword */ 1554#define _key_const 1 /* const is a reserved keyword */ 1555#define bar /* default for reserved keyword bar */ 1556#define aha int /* default for reserved keyword aha */ 1557#define _key_char 1 /* char is a reserved keyword */ 1558#define chr char /* alternate for reserved keyword chr */ 1559#endif' 1560 ERROR - $'iffe: test: is sys/types.h a header ... yes 1561iffe: test: is int a reserved keyword ... yes 1562iffe: test: is const a reserved keyword ... yes 1563iffe: test: is foo a reserved keyword ... no 1564iffe: test: is bar a reserved keyword ... no 1565iffe: test: is aha a reserved keyword ... no 1566iffe: test: is huh a reserved keyword ... no 1567iffe: test: is chr a reserved keyword ... no 1568iffe: test: is char a reserved keyword ... yes' 1569 1570 EXEC -r -v -s bsh - t.iffe 1571 1572 EXEC -u -r -v - t.iffe 1573 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1574#ifndef _REGRESS 1575#define _REGRESS 1 1576#define _sys_types 1 /* #include <sys/types.h> ok */ 1577#define _key_int 1 /* int is a reserved keyword */ 1578#define _key_const 1 /* const is a reserved keyword */ 1579#undef _key_foo /* foo is not a reserved keyword */ 1580#undef _key_bar /* bar is not a reserved keyword */ 1581#define bar /* default for reserved keyword bar */ 1582#undef _key_huh /* huh is not a reserved keyword */ 1583#define aha int /* default for reserved keyword aha */ 1584#define _key_char 1 /* char is a reserved keyword */ 1585#define chr char /* alternate for reserved keyword chr */ 1586#endif' 1587 1588 EXEC -u -r -v -s bsh - t.iffe 1589 1590 EXEC -a -r -v - t.iffe 1591 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1592#ifndef _REGRESS 1593#define _REGRESS 1 1594#define _sys_types 1 /* #include <sys/types.h> ok */ 1595#define _key_int 1 /* int is a reserved keyword */ 1596#define _key_const 1 /* const is a reserved keyword */ 1597#define _key_foo 0 /* foo is not a reserved keyword */ 1598#define _key_bar 0 /* bar is not a reserved keyword */ 1599#define bar /* default for reserved keyword bar */ 1600#define _key_huh 0 /* huh is not a reserved keyword */ 1601#define aha int /* default for reserved keyword aha */ 1602#define _key_char 1 /* char is a reserved keyword */ 1603#define chr char /* alternate for reserved keyword chr */ 1604#endif' 1605 1606 EXEC -a -r -v -s bsh - t.iffe 1607 1608 EXEC -C -r -v - t.iffe 1609 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1610#ifndef _REGRESS 1611#define _REGRESS 1 1612#define HAVE_SYS_TYPES_H 1 /* #include <sys/types.h> ok */ 1613#define HAVE_INT_RESERVED 1 /* int is a reserved keyword */ 1614#define HAVE_CONST_RESERVED 1 /* const is a reserved keyword */ 1615#undef HAVE_FOO_RESERVED /* foo is not a reserved keyword */ 1616#undef HAVE_BAR_RESERVED /* bar is not a reserved keyword */ 1617#define bar /* default for reserved keyword bar */ 1618#undef HAVE_HUH_RESERVED /* huh is not a reserved keyword */ 1619#define aha int /* default for reserved keyword aha */ 1620#define HAVE_CHAR_RESERVED 1 /* char is a reserved keyword */ 1621#define chr char /* alternate for reserved keyword chr */ 1622#endif' 1623 1624 EXEC -C -r -v -s bsh - t.iffe 1625 1626TEST 14 'inc file' 1627 1628 EXEC -r -v - t.iffe 1629 INPUT t.iffe $'inc t_lib.h 1630if ( bar_foo ) { 1631 #define all 1 1632} 1633elif ( _foo_bar ) { 1634 #define some 1 1635} 1636endif' 1637 INPUT t_lib.h '#define bar_foo ALL 1638#define _foo_bar SOME' 1639 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1640#ifndef _REGRESS 1641#define _REGRESS 1 1642#define _sys_types 1 /* #include <sys/types.h> ok */ 1643#define some 1 1644 1645#endif' 1646 ERROR - $'iffe: test: is sys/types.h a header ... yes 1647iffe: test: is ( bar_foo ) true ... no 1648iffe: test: is ( _foo_bar ) true ... yes' 1649 1650 EXEC -r -v - t.iffe 1651 INPUT t.iffe $'inc t_lib.h . 1652if ( bar_foo ) { 1653 #define all 1 1654} 1655elif ( _foo_bar ) { 1656 #define ok 1 1657} 1658endif' 1659 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1660#ifndef _REGRESS 1661#define _REGRESS 1 1662#define _sys_types 1 /* #include <sys/types.h> ok */ 1663#define all 1 1664 1665#endif' 1666 ERROR - $'iffe: test: is sys/types.h a header ... yes 1667iffe: test: is ( bar_foo ) true ... yes' 1668 1669 EXEC -r -v - t.iffe 1670 INPUT t.iffe $'inc t_lib.h . ? 1671if ( bar_foo ) { 1672 #define all 1 1673} 1674elif ( _foo_bar ) { 1675 #define ok 1 1676} 1677endif' 1678 ERROR - $'iffe: test: is sys/types.h a header ... yes 1679iffe: t.iffe:1: warning: ?: operands ignored 1680iffe: test: is ( bar_foo ) true ... yes' 1681 1682 EXEC -r -v - t.iffe 1683 INPUT t.iffe $'inc foo_lib.h' 1684 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1685#ifndef _REGRESS 1686#define _REGRESS 1 1687#define _sys_types 1 /* #include <sys/types.h> ok */' 1688 ERROR - $'iffe: test: is sys/types.h a header ... yes 1689iffe: t.iffe:1: foo_lib.h: file not found' 1690 EXIT 1 1691 1692 EXEC -r -v - t.iffe 1693 INPUT t.iffe $'inc' 1694 ERROR - $'iffe: test: is sys/types.h a header ... yes 1695iffe: t.iffe:1: path expected' 1696 1697TEST 15 'KnR compatibility' 1698 1699 EXEC -r -v - t.iffe 1700 INPUT t.iffe $' 1701if ( 1 ) { 1702 #define all 1 1703} 1704endif 1705if ( 2 ) { 1706 #define some 1 1707} 1708endif 1709cat{ 1710#define a 1 1711 #define b 2 1712 #define c 3 1713 #define d 4 1714}end' 1715#define _foo_bar SOME' 1716 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1717#ifndef _REGRESS 1718#define _REGRESS 1 1719#define _sys_types 1 /* #include <sys/types.h> ok */ 1720#define some 1 1721 1722#endif' 1723 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1724#ifndef _REGRESS 1725#define _REGRESS 1 1726#define _sys_types 1 /* #include <sys/types.h> ok */ 1727#define all 1 1728 1729#define some 1 1730 1731#define a 1 1732#define b 2 1733#define c 3 1734#define d 4 1735 1736#endif' 1737 ERROR - $'iffe: test: is sys/types.h a header ... yes 1738iffe: test: is ( 1 ) true ... yes 1739iffe: test: is ( 2 ) true ... yes 1740iffe: test: cat{ ... }end ... yes' 1741 1742 EXEC -r -v -s bsh - t.iffe 1743 1744 EXEC -r -v -s osh - t.iffe 1745 1746TEST 16 '{ define extern include print }' 1747 1748 EXEC -r -v - t.iffe 1749 INPUT t.iffe $' 1750print /* test header */ 1751header stdio.h 1752define EOF -1 1753define FoobaR (a,b) ((a)+(b)) 1754define FoomaC -1 1755extern fopen FILE* (char*, char*) 1756extern BarfoO struct barfoo* (int) 1757extern Tab_lE struct barfoo* [10]' 1758 OUTPUT - $'/* test header */ 1759/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1760#ifndef _REGRESS 1761#define _REGRESS 1 1762#define _sys_types 1 /* #include <sys/types.h> ok */ 1763#include <stdio.h> 1764#define FoobaR(a,b) ((a)+(b)) 1765#define FoomaC -1 1766extern struct barfoo* BarfoO(int); 1767extern struct barfoo* Tab_lE[10]; 1768#endif' 1769 ERROR - $'iffe: test: is sys/types.h a header ... yes 1770iffe: test: is stdio.h a header ... yes 1771iffe: test: is EOF a macro ... yes 1772iffe: test: is FoobaR a macro ... no 1773iffe: test: is FoomaC a macro ... no 1774iffe: test: is fopen a symbol that needs a prototype ... no 1775iffe: test: is BarfoO a symbol that needs a prototype ... yes 1776iffe: test: is Tab_lE a symbol that needs a prototype ... yes' 1777 1778TEST 17 'features/* => FEATURE/*' 1779 1780 EXEC -r -v run features/stdio 1781 INPUT features/stdio $'set prototyped 1782header stdio.h' 1783 OUTPUT FEATURE/stdio $' 1784/* : : generated by proto : : */ 1785/* : : generated from features/stdio by iffe version 1995-03-19 : : */ 1786 1787#ifndef _REGRESS 1788#if !defined(__PROTO__) 1789# if defined(__STDC__) || defined(__cplusplus) || defined(_proto) || defined(c_plusplus) 1790# if defined(__cplusplus) 1791# define __LINKAGE__ "C" 1792# else 1793# define __LINKAGE__ 1794# endif 1795# define __STDARG__ 1796# define __PROTO__(x) x 1797# define __OTORP__(x) 1798# define __PARAM__(n,o) n 1799# if !defined(__STDC__) && !defined(__cplusplus) 1800# if !defined(c_plusplus) 1801# define const 1802# endif 1803# define signed 1804# define void int 1805# define volatile 1806# define __V_ char 1807# else 1808# define __V_ void 1809# endif 1810# else 1811# define __PROTO__(x) () 1812# define __OTORP__(x) x 1813# define __PARAM__(n,o) o 1814# define __LINKAGE__ 1815# define __V_ char 1816# define const 1817# define signed 1818# define void int 1819# define volatile 1820# endif 1821# define __MANGLE__ __LINKAGE__ 1822# if defined(__cplusplus) || defined(c_plusplus) 1823# define __VARARG__ ... 1824# else 1825# define __VARARG__ 1826# endif 1827# if defined(__STDARG__) 1828# define __VA_START__(p,a) va_start(p,a) 1829# else 1830# define __VA_START__(p,a) va_start(p) 1831# endif 1832# if !defined(__INLINE__) 1833# if defined(__cplusplus) 1834# define __INLINE__ extern __MANGLE__ inline 1835# else 1836# if defined(_WIN32) && !defined(__GNUC__) 1837# define __INLINE__ __inline 1838# endif 1839# endif 1840# endif 1841#endif 1842#if !defined(__LINKAGE__) 1843#define __LINKAGE__ /* 2004-08-11 transition */ 1844#endif 1845 1846#define _REGRESS 1 1847#define _sys_types 1 /* #include <sys/types.h> ok */ 1848#include <stdio.h> 1849#endif' 1850 ERROR - $'iffe: test: is sys/types.h a header ... yes 1851iffe: test: is stdio.h a header ... yes' 1852 1853TEST 18 'api + ver' 1854 EXEC -r -v - t.iffe 1855 INPUT t.iffe $'iff api 1856ver foo 20100606 1857ver bar 19840919 1858 1859api foo 19991231 dis dat tother 1860api foo 20100601 dat 1861api foo 20100606 dis 1862api bar 19991231 moe larry shemp 1863api bar 20020202 curly 1864api bar 20030303 shemp 1865api bar 20040404 joe_b 1866api bar 20050505 joe_d 1867' 1868 OUTPUT - $'/* : : generated from t.iffe by iffe version 1995-03-19 : : */ 1869#ifndef _api_H 1870#define _api_H 1 1871#define _sys_types 1 /* #include <sys/types.h> ok */ 1872 1873#define FOO_VERSION 20100606 1874#define BAR_VERSION 19840919 1875#define FOOAPI(rel) ( _BLD_foo || !_API_foo || _API_foo >= rel ) 1876 1877#if !defined(_API_foo) && defined(_API_DEFAULT) 1878#define _API_foo _API_DEFAULT 1879#endif 1880 1881#if FOOAPI(20100601) 1882#undef dat 1883#define dat dat_20100601 1884#elif _API_foo >= 19991231 1885#undef dat 1886#define dat dat_19991231 1887#endif 1888 1889#if FOOAPI(20100606) 1890#undef dis 1891#define dis dis_20100606 1892#elif _API_foo >= 19991231 1893#undef dis 1894#define dis dis_19991231 1895#endif 1896 1897#if FOOAPI(19991231) 1898#undef tother 1899#define tother tother_19991231 1900#endif 1901 1902#define _API_foo_MAP "dat_20100601 dat_19991231 dis_20100606 dis_19991231 tother_19991231" 1903#define BARAPI(rel) ( _BLD_bar || !_API_bar || _API_bar >= rel ) 1904 1905#if !defined(_API_bar) && defined(_API_DEFAULT) 1906#define _API_bar _API_DEFAULT 1907#endif 1908 1909#if BARAPI(20020202) 1910#undef curly 1911#define curly curly_20020202 1912#endif 1913 1914#if BARAPI(20040404) 1915#undef joe_b 1916#define joe_b joe_b_20040404 1917#endif 1918 1919#if BARAPI(20050505) 1920#undef joe_d 1921#define joe_d joe_d_20050505 1922#endif 1923 1924#if BARAPI(19991231) 1925#undef larry 1926#define larry larry_19991231 1927#endif 1928 1929#if BARAPI(19991231) 1930#undef moe 1931#define moe moe_19991231 1932#endif 1933 1934#if BARAPI(20030303) 1935#undef shemp 1936#define shemp shemp_20030303 1937#elif _API_bar >= 19991231 1938#undef shemp 1939#define shemp shemp_19991231 1940#endif 1941 1942#define _API_bar_MAP "curly_20020202 joe_b_20040404 joe_d_20050505 larry_19991231 moe_19991231 shemp_20030303 shemp_19991231" 1943 1944#endif' 1945 ERROR - $'iffe: test: is sys/types.h a header ... yes' 1946