/* Routines related to conditional compilation. Ignore_flag is * a global external that controls input. If ignore_flag is TRUE * input is ignored. File inclusion stuff is also here. */ #include "prep.h" int ifdef_list[NESTING], ifdef_count ; /* Function IFDEF_PROC * * #ifdef name1 name2 name3....namen * * Different from the cpp conditional compilation directive, since * in PREP the symbols | and & (and nearly anything) are legal macro * names. Here the instructions in the #if block will be kept if * ANY of the names are defined. The names must be separated by * blanks or tabs. */ ifdef_proc() { int i ; char *name, *pntr ; /* keep track of the nesting */ ifdef_count++ ; if ( ifdef_count >= NESTING ) { sprintf( errline, "#Ifdef: nesting too deep: %s", in_buff ) ; abort( errline ) ; } /* see if any of the tokens is a macro name */ i = ifdef_count - 1 ; ifdef_list[i] = FALSE ; for (pntr = first_nonblank + name_length;; pntr = NULL ) { if ( NULL == ( name = strtok( pntr, " \t" ) ) ) break ; if ( mac_query(name) >= 0 ) { ifdef_list[i] = TRUE ; break ; } } /* set a flag to inhibit input if any ifdef flags are FALSE */ ignore_flag = FALSE ; for ( i=0; i= NESTING ) { sprintf( errline, "#Ifdef: nesting too deep: %s", in_buff ) ; abort( errline ) ; } /* see if any of the tokens is not a macro name */ i = ifdef_count - 1 ; ifdef_list[i] = FALSE ; for (pntr = first_nonblank + name_length;; pntr = NULL ) { if ( NULL == ( name = strtok( pntr, " \t" ) ) ) break ; if ( mac_query(name) < 0 ) { ifdef_list[i] = TRUE ; break ; } } /* set a flag to inhibit input if any ifdef flags are FALSE */ ignore_flag = FALSE ; for ( i=0; i= NESTING ) return(NULL) ; filestack[include_count] = *handleaddress ; include_count++ ; return(1) ; } /* pop a file handle from the filestack. return NULL on error */ int popfile(handleaddress) FILE *(*handleaddress) ; { if ( include_count <= 0 ) return(NULL) ; include_count-- ; *handleaddress = filestack[include_count] ; return(1) ; }