1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * Test header file for h2ph 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * Try to test as many constructs as possible 5*0Sstevel@tonic-gate * For example, the multi-line comment :) 6*0Sstevel@tonic-gate */ 7*0Sstevel@tonic-gate 8*0Sstevel@tonic-gate /* And here's a single line comment :) */ 9*0Sstevel@tonic-gate 10*0Sstevel@tonic-gate /* Test #define with no indenting, over multiple lines */ 11*0Sstevel@tonic-gate #define SQUARE(x) \ 12*0Sstevel@tonic-gate ((x)*(x)) 13*0Sstevel@tonic-gate 14*0Sstevel@tonic-gate /* Test #ifndef and parameter interpretation*/ 15*0Sstevel@tonic-gate #ifndef ERROR 16*0Sstevel@tonic-gate #define ERROR(x) fprintf(stderr, "%s\n", x[2][3][0]) 17*0Sstevel@tonic-gate #endif /* ERROR */ 18*0Sstevel@tonic-gate 19*0Sstevel@tonic-gate #ifndef _H2PH_H_ 20*0Sstevel@tonic-gate #define _H2PH_H_ 21*0Sstevel@tonic-gate 22*0Sstevel@tonic-gate /* #ident - doesn't really do anything, but I think it always gets included anyway */ 23*0Sstevel@tonic-gate #ident "$Revision h2ph.h,v 1.0 98/05/04 20:42:14 billy $" 24*0Sstevel@tonic-gate 25*0Sstevel@tonic-gate /* Test #undef */ 26*0Sstevel@tonic-gate #undef MAX 27*0Sstevel@tonic-gate #define MAX(a,b) ((a) > (b) ? (a) : (b)) 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gate /* Test #ifdef */ 30*0Sstevel@tonic-gate #ifdef __SOME_UNIMPORTANT_PROPERTY 31*0Sstevel@tonic-gate #define MIN(a,b) ((a) < (b) ? (a) : (b)) 32*0Sstevel@tonic-gate #endif /* __SOME_UNIMPORTANT_PROPERTY */ 33*0Sstevel@tonic-gate 34*0Sstevel@tonic-gate /* 35*0Sstevel@tonic-gate * Test #if, #elif, #else, #endif, #warn and #error, and `!' 36*0Sstevel@tonic-gate * Also test whitespace between the `#' and the command 37*0Sstevel@tonic-gate */ 38*0Sstevel@tonic-gate #if !(defined __SOMETHING_MORE_IMPORTANT) 39*0Sstevel@tonic-gate # warn Be careful... 40*0Sstevel@tonic-gate #elif !(defined __SOMETHING_REALLY_REALLY_IMPORTANT) 41*0Sstevel@tonic-gate # error "Nup, can't go on" /* ' /* stupid font-lock-mode */ 42*0Sstevel@tonic-gate #else /* defined __SOMETHING_MORE_IMPORTANT && defined __SOMETHING_REALLY_REALLY_IMPORTANT */ 43*0Sstevel@tonic-gate # define EVERYTHING_IS_OK 44*0Sstevel@tonic-gate #endif 45*0Sstevel@tonic-gate 46*0Sstevel@tonic-gate /* Test && and || */ 47*0Sstevel@tonic-gate #undef WHATEVER 48*0Sstevel@tonic-gate #if (!((defined __SOMETHING_TRIVIAL && defined __SOMETHING_LESS_SO)) \ 49*0Sstevel@tonic-gate || defined __SOMETHING_OVERPOWERING) 50*0Sstevel@tonic-gate # define WHATEVER 6 51*0Sstevel@tonic-gate #elif !(defined __SOMETHING_TRIVIAL) /* defined __SOMETHING_LESS_SO */ 52*0Sstevel@tonic-gate # define WHATEVER 7 53*0Sstevel@tonic-gate #elif !(defined __SOMETHING_LESS_SO) /* defined __SOMETHING_TRIVIAL */ 54*0Sstevel@tonic-gate # define WHATEVER 8 55*0Sstevel@tonic-gate #else /* defined __SOMETHING_TRIVIAL && defined __SOMETHING_LESS_SO */ 56*0Sstevel@tonic-gate # define WHATEVER 1000 57*0Sstevel@tonic-gate #endif 58*0Sstevel@tonic-gate 59*0Sstevel@tonic-gate /* 60*0Sstevel@tonic-gate * Test #include, #import and #include_next 61*0Sstevel@tonic-gate * #include_next is difficult to test, it really depends on the actual 62*0Sstevel@tonic-gate * circumstances - for example, `#include_next <limits.h>' on a Linux system 63*0Sstevel@tonic-gate * with `use lib qw(/opt/perl5/lib/site_perl/i586-linux/linux);' or whatever 64*0Sstevel@tonic-gate * your equivalent is... 65*0Sstevel@tonic-gate */ 66*0Sstevel@tonic-gate #include <sys/socket.h> 67*0Sstevel@tonic-gate #import "sys/ioctl.h" 68*0Sstevel@tonic-gate #include_next <sys/fcntl.h> 69*0Sstevel@tonic-gate 70*0Sstevel@tonic-gate /* typedefs should be ignored */ 71*0Sstevel@tonic-gate typedef struct a_struct { 72*0Sstevel@tonic-gate int typedefs_should; 73*0Sstevel@tonic-gate char be_ignored; 74*0Sstevel@tonic-gate long as_well; 75*0Sstevel@tonic-gate } a_typedef; 76*0Sstevel@tonic-gate 77*0Sstevel@tonic-gate /* 78*0Sstevel@tonic-gate * however, typedefs of enums and just plain enums should end up being treated 79*0Sstevel@tonic-gate * like a bunch of #defines... 80*0Sstevel@tonic-gate */ 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gate typedef enum _days_of_week { sun, mon, tue, wed, thu, fri, sat, Sun=0, Mon, 83*0Sstevel@tonic-gate Tue, Wed, Thu, Fri, Sat } days_of_week; 84*0Sstevel@tonic-gate 85*0Sstevel@tonic-gate /* 86*0Sstevel@tonic-gate * Some moderate flexing of tri-graph pre substitution. 87*0Sstevel@tonic-gate */ 88*0Sstevel@tonic-gate ??=ifndef _SOMETHING_TRIGRAPHIC 89*0Sstevel@tonic-gate ??=define _SOMETHING_TRIGRAPHIC 90*0Sstevel@tonic-gate ??= define SOMETHING_ELSE_TRIGRAPHIC_0 "??!" /* | ??!| || */ 91*0Sstevel@tonic-gate ??=define SOMETHING_ELSE_TRIGRAPHIC_1 "??'" /* | ??'| ^| */ 92*0Sstevel@tonic-gate ??= define SOMETHING_ELSE_TRIGRAPHIC_2 "??(" /* | ??(| [| */ 93*0Sstevel@tonic-gate ??= define SOMETHING_ELSE_TRIGRAPHIC_3 "??)" /* | ??)| ]| */ 94*0Sstevel@tonic-gate ??=define SOMETHING_ELSE_TRIGRAPHIC_4 "??-0" /* | ??-| ~| */ 95*0Sstevel@tonic-gate ??= define SOMETHING_ELSE_TRIGRAPHIC_5 "??/ " /* | ??/| \| */ 96*0Sstevel@tonic-gate ??= define SOMETHING_ELSE_TRIGRAPHIC_6 "??<" /* | ??<| {| */ 97*0Sstevel@tonic-gate ??=define SOMETHING_ELSE_TRIGRAPHIC_7 "??=" /* | ??=| #| */ 98*0Sstevel@tonic-gate ??= define SOMETHING_ELSE_TRIGRAPHIC_8 "??>" /* | ??>| }| */ 99*0Sstevel@tonic-gate ??=endif 100*0Sstevel@tonic-gate 101*0Sstevel@tonic-gate // test C++-style comment 102*0Sstevel@tonic-gate 103*0Sstevel@tonic-gate #if 1 104*0Sstevel@tonic-gate typdef struct empty_struct { 105*0Sstevel@tonic-gate } // trailing C++-style comment should not force continuation 106*0Sstevel@tonic-gate #endif 107*0Sstevel@tonic-gate 108*0Sstevel@tonic-gate /* comments (that look like string) inside enums... */ 109*0Sstevel@tonic-gate 110*0Sstevel@tonic-gate enum { 111*0Sstevel@tonic-gate /* foo; 112*0Sstevel@tonic-gate can't 113*0Sstevel@tonic-gate */ 114*0Sstevel@tonic-gate }; 115*0Sstevel@tonic-gate 116*0Sstevel@tonic-gate enum flimflam { 117*0Sstevel@tonic-gate flim, 118*0Sstevel@tonic-gate /* foo; 119*0Sstevel@tonic-gate can't 120*0Sstevel@tonic-gate */ 121*0Sstevel@tonic-gate flam 122*0Sstevel@tonic-gate } flamflim; 123*0Sstevel@tonic-gate 124*0Sstevel@tonic-gate /* Handle multi-line quoted strings: */ 125*0Sstevel@tonic-gate __asm__ __volatile__(" 126*0Sstevel@tonic-gate this 127*0Sstevel@tonic-gate produces 128*0Sstevel@tonic-gate no 129*0Sstevel@tonic-gate output 130*0Sstevel@tonic-gate "); 131*0Sstevel@tonic-gate 132*0Sstevel@tonic-gate #define multiline "multiline 133*0Sstevel@tonic-gate string" 134*0Sstevel@tonic-gate 135*0Sstevel@tonic-gate #endif /* _H2PH_H_ */ 136