MCPcopy Create free account
hub / github.com/KDE/kdevelop / cmListFileLexer_SetFileName

Function cmListFileLexer_SetFileName

plugins/cmake/parser/cmListFileLexer.c:2577–2600  ·  view source on GitHub ↗

--------------------------------------------------------------------------*/

Source from the content-addressed store, hash-verified

2575
2576/*--------------------------------------------------------------------------*/
2577int cmListFileLexer_SetFileName(cmListFileLexer* lexer, const char* name,
2578 cmListFileLexer_BOM* bom)
2579{
2580 int result = 1;
2581 cmListFileLexerDestroy(lexer);
2582 if (name) {
2583#ifdef _WIN32
2584 wchar_t* wname = cmsysEncoding_DupToWide(name);
2585 lexer->file = _wfopen(wname, L"rb");
2586 free(wname);
2587#else
2588 lexer->file = fopen(name, "rb");
2589#endif
2590 if (lexer->file) {
2591 if (bom) {
2592 *bom = cmListFileLexer_ReadBOM(lexer->file);
2593 }
2594 } else {
2595 result = 0;
2596 }
2597 }
2598 cmListFileLexerInit(lexer);
2599 return result;
2600}
2601
2602/*--------------------------------------------------------------------------*/
2603int cmListFileLexer_SetString(cmListFileLexer* lexer, const char* text)

Callers 4

readCMakeFileFunction · 0.85
cmListFileLexer_DeleteFunction · 0.85
cmListFileLexer_ScanFunction · 0.85
testLexerWithFileMethod · 0.85

Calls 3

cmListFileLexerDestroyFunction · 0.85
cmListFileLexer_ReadBOMFunction · 0.85
cmListFileLexerInitFunction · 0.85

Tested by 1

testLexerWithFileMethod · 0.68