static void PP_Include( const char *ptr ) { const char *filename; char delim; int incl_type; size_t len; while( *ptr == ' ' || *ptr == '\t' ) ++ptr; filename = ptr + 1; if( *ptr == '<' ) { delim = '>'; incl_type = PPINCLUDE_SYS; } else if( *ptr == '"' ) { delim = '"'; incl_type = PPINCLUDE_USR; } else { PP_GenError( "Unrecognized INCLUDE directive" ); return; } ++ptr; while( *ptr != delim && *ptr != '\0' ) ++ptr; len = ptr - filename; if( PP_OpenInclude( filename, len, incl_type ) == NULL ) { sprintf( PPLineBuf + 1, "%cerror Unable to open '%*s'\n", PreProcChar, (int)len, filename ); PPNextTokenPtr = PPLineBuf + 1; } else { PP_GenLine(); } }
void PP_Include( char *ptr ) { char *filename; char delim; int incl_type; while( *ptr == ' ' || *ptr == '\t' ) ++ptr; filename = ptr+1; if( *ptr == '<' ) { delim = '>'; incl_type = PPINCLUDE_SYS; } else if( *ptr == '"' ) { delim = '"'; incl_type = PPINCLUDE_USR; } else { PP_GenError( "Unrecognized INCLUDE directive" ); return; } ++ptr; while( *ptr != delim && *ptr != '\0' ) ++ptr; *ptr = '\0'; if( PP_OpenInclude( filename, incl_type ) == NULL ) { filename = doStrDup( filename ); // want to reuse buffer PPCharPtr = &PPLineBuf[1]; sprintf( PPCharPtr, "%cerror Unable to open '%s'\n", PreProcChar, filename ); PP_Free( filename ); } else { PP_GenLine(); } }