void Compiler::setInputFile( std::string& name ) { std::wstring* wname( new std::wstring() ); mbtowstring( name, *wname ); wname = addFileName( wname ); inFiles.push_back( new IpfFile( wname ) ); }
std::wstring* Document::prepNameitName( const std::wstring& key ) { std::wstring* name( new std::wstring( L"Expansion of .nameit " ) ); name->append( key ); name = addFileName( name ); return name; }
int SymbolData::addAddress(int address) { SymDataModule& module = modules[currentModule]; for (size_t i = 0; i < module.addressInfo.size(); i++) { if (module.addressInfo[i].address == address) return i; } SymDataAddressInfo info; info.address = address; info.fileIndex = addFileName(Global.FileInfo.FileList.GetEntry(Global.FileInfo.FileNum)); info.lineNumber = Global.FileInfo.LineNumber; module.addressInfo.push_back(info); return module.addressInfo.size()-1; }
//-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RiuRecentFileActionProvider::slotOpenRecentFile() { QAction* action = qobject_cast<QAction *>(sender()); if (action) { QString filename = action->data().toString(); bool loadingSucceded = RiaApplication::instance()->openFile(filename); if (loadingSucceded) { addFileName(filename); } else { QMessageBox::warning(NULL, "File open", "Failed to import file located at\n" + filename); removeFileName(filename); } } }
/***************************************************************************** * First character of command id should be second char of line * Lexer returns a full line of data, needs to be parsed if .ce * In version 1.0, valid commands are: * .* (comment) followed by text to '\n' * .br (new line), nothing else allowed on line * .im (include file) 'filename' * .nameit (define text macro) symbol=[a-zA-Z0-9]+ (10 max) text='text string' * text may contain entity references, nameit references and tags * .ce (center) no tags, but text and both entity types * Version 2.0 only supports .*, .br, .im */ Lexer::Token Document::processCommand( Lexer* lexer, Tag* parent ) { if( lexer->cmdId() == Lexer::COMMENT ) ;//do nothing else if( lexer->cmdId() == Lexer::BREAK ) parent->appendChild( new BrCmd( this, parent, dataName(), dataLine(), dataCol() ) ); else if( lexer->cmdId() == Lexer::CENTER ) { CeCmd* cecmd( new CeCmd( this, parent, dataName(), dataLine(), dataCol() ) ); parent->appendChild( cecmd ); return cecmd->parse( lexer ); } else if( lexer->cmdId() == Lexer::IMBED ) { std::string env( Environment.value( "IPFCIMBED" ) ); std::vector< std::wstring > paths; std::wstring cwd; //empty string for current directory paths.push_back( cwd ); #ifdef __UNIX__ std::string separators( ":;" ); char slash( '/' ); #else std::string separators( ";" ); char slash( '\\' ); #endif std::string::size_type idx1( 0 ); std::string::size_type idx2( env.find_first_of( separators, idx1 ) ); std::wstring fbuffer; mbtowstring( env.substr( idx1, idx2 - idx1 ), fbuffer ); paths.push_back( fbuffer ); while( idx2 != std::string::npos ) { idx1 = idx2 + 1; idx2 = env.find_first_of( separators, idx1 ); fbuffer.clear(); mbtowstring( env.substr( idx1, idx2 - idx1 ), fbuffer ); paths.push_back( fbuffer ); } for( size_t count = 0; count < paths.size(); ++count ) { std::wstring* fname( new std::wstring( paths[ count ] ) ); if( !fname->empty() ) *fname += slash; *fname += lexer->text(); #ifndef __UNIX__ if( fname->size() > PATH_MAX ) { throw FatalError( ERR_PATH_MAX ); } #endif try { IpfFile* ipff( new IpfFile( fname ) ); fname = addFileName( fname ); pushInput( ipff ); break; } catch( FatalError& e ) { delete fname; if( count == paths.size() - 1 ) throw e; } catch( FatalIOError& e ) { delete fname; if( count == paths.size() - 1 ) throw e; } } } else if( lexer->cmdId() == Lexer::NAMEIT ) { std::wstring::size_type idx1( lexer->text().find( L"symbol=" ) ); std::wstring::size_type idx2( lexer->text().find( L' ', idx1 ) ); std::wstring sym( lexer->text().substr( idx1 + 7, idx2 - idx1 - 7 ) ); killQuotes( sym ); sym.insert( sym.begin(), L'&' ); sym += L'.'; std::wstring::size_type idx3( lexer->text().find( L"text=" ) ); //check for single quotes std::wstring::size_type idx4( lexer->text()[ idx3 + 5 ] == L'\'' ? \ lexer->text().find( L'\'', idx3 + 6 ) : \ lexer->text().find( L' ', idx3 + 5 ) ); std::wstring txt( lexer->text().substr( idx3 + 5, idx4 - idx3 - 5 ) ); killQuotes( txt ); if( !nls->isEntity( sym ) && nameIts.find( sym ) == nameIts.end() ) //add it to the list nameIts.insert( std::map< std::wstring, std::wstring >::value_type( sym, txt ) ); else printError( ERR3_DUPSYMBOL ); } else printError( ERR1_CMDNOTDEF ); return getNextToken(); }