static void dumpCheckData( char *include_file ) { SRCFILE src; time_t stamp; auto char buff[_MAX_PATH]; PCHWriteVar( GenSwitches ); PCHWriteVar( TargetSwitches ); PCHWriteUInt( ErrPCHVersion() ); PCHWriteUInt( TYPC_LAST ); PCHWriteUInt( sizeof( COMP_FLAGS ) ); PCHWriteVar( CompFlags ); dumpFileString( WholeFName ); include_file = IoSuppFullPath( include_file, buff, sizeof( buff ) ); dumpFileString( include_file ); getcwd( buff, sizeof( buff ) ); dumpFileString( buff ); HFileListStart(); for( ; ; ) { HFileListNext( buff ); dumpFileString( buff ); if( buff[0] == '\0' ) break; } src = SrcFileNotReadOnly( SrcFileWalkInit() ); for( ; src != NULL; ) { if( ! IsSrcFilePrimary( src ) ) { dumpFileString( SrcFileName( src ) ); stamp = SrcFileTimeStamp( src ); PCHWriteVar( stamp ); } src = SrcFileNotReadOnly( SrcFileWalkNext( src ) ); } buff[0] = '\0'; dumpFileString( buff ); PCHDumpMacroCheck(); }
static boolean doIoSuppOpenSrc( // OPEN A SOURCE FILE (PRIMARY,HEADER) struct path_descr *fd, // - descriptor for file name enum file_type typ ) // - type of search path to use { char **paths; // - optional paths to prepend char **exts; // - optional extensions to append boolean retn; // - return: TRUE ==> opened char *path; // - next path char bufpth[ _MAX_PATH ]; // - buffer for next path SRCFILE curr; // - current included file SRCFILE stdin_srcfile; // - srcfile for stdin struct path_descr idescr; // - descriptor for included file LINE_NO dummy; // - dummy line number holder char prevpth[ _MAX_PATH ]; // - buffer for previous path switch( typ ) { case FT_SRC: if( fd->fnm[0] == '\0' && fd->ext[0] == '.' && fd->ext[1] == '\0' ) { if( ErrCount != 0 ) { // command line errors may result in "." as the input name // so the user thinks that the compiler is hung! return( FALSE ); } WholeFName = FNameAdd( "stdin" ); stdin_srcfile = SrcFileOpen( stdin, WholeFName ); SrcFileNotAFile( stdin_srcfile ); goto file_was_found; } paths = pathSrc; exts = extsSrc; break; case FT_HEADER: case FT_LIBRARY: if( !CompFlags.ignore_current_dir ) { paths = pathHdr; } else { paths = NULL; } exts = extsHdr; break; case FT_CMD: paths = pathCmd; exts = extsCmd; break; } switch( typ ) { case FT_LIBRARY: if( fd->drv[0] != '\0' || IS_DIR_SEP( fd->dir[0] ) ) { retn = openSrcPath( "", exts, fd, typ ); if( retn ) goto file_was_found; } break; case FT_HEADER: // even if ignoreing current dir, have to look for absolute paths if( !CompFlags.ignore_current_dir || fd->drv[0] != '\0' ) { // look in current directory retn = openSrcPath( "", exts, fd, typ ); if( retn ) goto file_was_found; } /* check directories of currently included files */ if( !IS_PATH_SEP( fd->dir[0] ) ) { prevpth[0] = '\xff'; /* to make it not compare with anything else */ prevpth[1] = '\0'; curr = SrcFileCurrent(); for( ;; ) { if( curr == NULL ) break; splitFileName( SrcFileName( curr ), &idescr ); _makepath( bufpth, idescr.drv, idescr.dir, NULL, NULL ); /*optimization: don't try and open if in previously checked dir*/ if( strcmp( bufpth, prevpth ) != 0 ) { retn = openSrcPath( bufpth, exts, fd, FT_HEADER ); if( retn ) goto file_was_found; } curr = SrcFileIncluded( curr, &dummy ); strcpy( prevpth, bufpth ); } } break; case FT_SRC: case FT_CMD: retn = openSrcPath( "", exts, fd, typ ); if( retn ) goto file_was_found; break; } switch( typ ) { case FT_HEADER: case FT_LIBRARY: HFileListStart(); for( ; ; ) { HFileListNext( bufpth ); if( *bufpth == '\0' ) break; retn = openSrcPath( bufpth, exts, fd, typ ); if( retn ) goto file_was_found; } break; } switch( typ ) { case FT_HEADER: case FT_CMD: case FT_SRC: if( IS_PATH_SEP( fd->dir[0] ) ) { // absolute path break; } if( paths != NULL ) { for( ; ; ) { path = *paths++; if( path == NULL ) break; retn = openSrcPath( path, exts, fd, typ ); if( retn ) goto file_was_found; } } break; } return FALSE; file_was_found: switch( typ ) { case FT_CMD: SrcFileCommand(); break; case FT_LIBRARY: SrcFileLibrary(); break; } return TRUE; }
extern dw_client DwarfInit( void ) /********************************/ { dw_init_info info; dw_cu_info cu; char dir[_MAX_PATH2]; char fname[_MAX_PATH]; char * full_fname; int i; char * incbuf; char * inccurr; unsigned incsize; dw_client client; DwioInit(); for( i = 0 ; i < DW_DEBUG_MAX ; i++ ) { dw_sections[i].file = DwioCreateFile(); dw_sections[i].offset = 0; dw_sections[i].length = 0; } HFileListStart(); incsize = HFileListSize(); if( incsize != 0 ) { incbuf = CMemAlloc( incsize ); inccurr = incbuf; for(;;) { HFileListNext( inccurr ); if( *inccurr == '\0' ) break; inccurr = strend( inccurr ) + 1; } incsize = inccurr - incbuf; } info.language = DWLANG_CPP; info.compiler_options = DW_CM_BROWSER; info.producer_name = "WATCOM C++ V1"; memcpy( info.exception_handler, Environment, sizeof( jmp_buf ) ); info.funcs.reloc = &dw_reloc; info.funcs.write = &dw_write; info.funcs.seek = &dw_seek; info.funcs.tell = &dw_tell; info.funcs.alloc = &dw_alloc; info.funcs.free = &dw_free; client = DWInit( &info ); if( client == NULL ) { CFatal( "dwarf: error in DWInit()" ); } getcwd( dir, sizeof( dir ) ), full_fname = IoSuppFullPath( WholeFName, fname, sizeof( fname ) ); cu.source_filename = full_fname; cu.directory = dir; cu.flags = 1; cu.offset_size = TARGET_NEAR_POINTER; cu.segment_size = 0; cu.model = DW_MODEL_NONE; cu.inc_list = incbuf; cu.inc_list_len = incsize; cu.dbg_pch = 0; DWBeginCompileUnit( client, &cu ); if( incsize != 0 ) { CMemFree( incbuf ); } return( client ); }
static bool stalePCH( char *include_file ) { time_t stamp; cg_switches test_gen; cg_target_switches test_target; auto char buff1[_MAX_PATH]; auto char buff2[_MAX_PATH]; auto COMP_FLAGS testflags; PCHReadVar( test_gen ); PCHReadVar( test_target ); if( test_gen != GenSwitches || test_target != TargetSwitches ) { pchWarn( WARN_PCH_CONTENTS_OPTIONS ); return( true ); } if( PCHReadUInt() != ErrPCHVersion() ) { pchWarn( WARN_PCH_CONTENTS_HEADER_ERROR ); return( true ); } if( PCHReadUInt() != TYPC_LAST ) { pchWarn( WARN_PCH_CONTENTS_HEADER_ERROR ); return( true ); } if( PCHReadUInt() != sizeof( COMP_FLAGS ) ) { pchWarn( WARN_PCH_CONTENTS_HEADER_ERROR ); return( true ); } PCHReadVar( testflags ); if( checkCompFlags( &testflags ) ) { pchWarn( WARN_PCH_CONTENTS_OPTIONS ); return( true ); } readFileString( buff1 ); if( FNAMECMPSTR( buff1, WholeFName ) == 0 ) { if( CompFlags.pch_debug_info_opt ) { // this source file created the PCH but it is being recompiled // so we have to recreate the PCH along with the debug info pchWarn( WARN_PCH_DEBUG_OPTIMIZE ); return( true ); } } readFileString( buff1 ); include_file = IoSuppFullPath( include_file, buff2, sizeof( buff2 ) ); if( FNAMECMPSTR( buff1, include_file ) != 0 ) { pchWarn( WARN_PCH_CONTENTS_INCFILE ); return( true ); } readFileString( buff1 ); getcwd( buff2, sizeof( buff2 ) ); if( stringIsDifferent( buff1, buff2, WARN_PCH_CONTENTS_CWD ) ) { return( true ); } if( CompFlags.pch_min_check ) { flushUntilNullString( buff2 ); } else { HFileListStart(); for(;;) { HFileListNext( buff1 ); readFileString( buff2 ); if( stringIsDifferent( buff1, buff2, WARN_PCH_CONTENTS_INCLUDE ) ) { return( true ); } if( buff1[0] == '\0' ) break; } } for( ; *readFileString( buff1 ) != '\0'; ) { PCHReadVar( stamp ); if( ! sameStamp( buff1, stamp ) ) { PCHWarn2p( WARN_PCH_CONTENTS_HFILE, buff1 ); return( true ); } } if( ! PCHVerifyMacroCheck() ) { return( true ); } transferCompFlags( &testflags ); return( false ); }