STATIC bool checkMacro( STRM_T s ) /********************************* * returns: true if the line WAS a macro defn * false if it wasn't * recognizes: {macc}+{ws}*"="{ws}*{defn}*"\n" * {macc}+{ws}*"+="{ws}*{defn}*"\n" * second gets translated from "macro += defn" to "macro=$+$(macro)$- defn" */ { char mac[MAX_MAC_NAME]; unsigned pos; bool ws; pos = 0; while( pos < MAX_MAC_NAME && sismacc( s ) ) { mac[pos++] = s; s = PreGetCHR(); } if( pos == MAX_MAC_NAME ) { PrtMsg( FTL | LOC | MAXIMUM_TOKEN_IS, MAX_MAC_NAME - 1 ); ExitFatal(); // never return } mac[pos] = NULLCHAR; ws = sisws( s ); while( sisws( s ) ) { s = PreGetCHR(); } if( s == '=' ) { DefMacro( mac ); return( true ); /* go around again */ } else if( s == '+' ) { s = PreGetCHR(); if( s == '=' ) { InsString( ")$-", false ); InsString( mac, false ); InsString( "$+$(", false ); DefMacro( mac ); return( true ); /* go around again */ } UnGetCHR( s ); s = '+'; } UnGetCHR( s ); /* not a macro line, put everything back*/ if( ws ) { UnGetCHR( ' ' ); } InsString( StrDupSafe( mac + 1 ), true ); return( false ); }
STATIC BOOLEAN checkMacro( STRM_T s ) /************************************* * returns: TRUE if the line WAS a macro defn * FALSE if it wasn't * recognizes: {macc}+{ws}*"="{ws}*{defn}*"\n" * {macc}+{ws}*"+="{ws}*{defn}*"\n" * second gets translated from "macro += defn" to "macro=$+$(macro)$- defn" */ { char mac[MAX_MAC_NAME]; unsigned pos; BOOLEAN ws; pos = 0; while( pos < MAX_MAC_NAME && ismacc( s ) ) { mac[pos++] = s; s = PreGetCH(); } if( pos == MAX_MAC_NAME ) { PrtMsgExit(( FTL | LOC | MAXIMUM_TOKEN_IS, MAX_MAC_NAME - 1 )); } mac[pos] = NULLCHAR; ws = isws( s ); while( isws( s ) ) { s = PreGetCH(); } if( s == '=' ) { DefMacro( mac ); return( TRUE ); /* go around again */ } else if( s == '+' ) { s = PreGetCH(); if( s == '=' ) { InsString( ")$-", FALSE ); InsString( mac, FALSE ); InsString( "$+$(", FALSE ); DefMacro( mac ); return( TRUE ); /* go around again */ } UnGetCH( s ); s = '+'; } UnGetCH( s ); /* not a macro line, put everything back*/ if( ws ) { UnGetCH( SPACE ); } InsString( StrDupSafe( mac + 1 ), TRUE ); return( FALSE ); }
RET_T InsFile( const char *name, BOOLEAN envsearch ) /********************************************************** * Open file named name, and push it into stream. If can't find name, it * tries an implicit suffix search (possibly using the env variable PATH) */ { SENT *tmp; int fh; char path[_MAX_PATH]; assert( name != NULL ); if( TrySufPath( path, name, NULL, envsearch ) == RET_SUCCESS ) { PrtMsg( DBG | INF | LOC | ENTERING_FILE, path ); fh = sopen3( path, O_RDONLY | O_BINARY, SH_DENYWR ); if( fh == -1 ) { return( RET_ERROR ); } tmp = getSENT( SENT_FILE ); tmp->free = TRUE; tmp->data.file.name = StrDupSafe( path ); pushFH( tmp, fh ); if( !Glob.overide ) { UnGetCH( EOL ); InsString( path, FALSE ); InsString( "$+$(__MAKEFILES__)$- ", FALSE ); DefMacro( "__MAKEFILES__" ); } return( RET_SUCCESS ); } return( RET_ERROR ); }