===========================================================================
| 553 | |
| 554 | //=========================================================================== |
| 555 | int ParseSymbolTable(const std::string & pPathFileName, SymbolTable_Index_e eSymbolTableWrite, int nSymbolOffset ) |
| 556 | { |
| 557 | bool bFileDisplayed = false; |
| 558 | |
| 559 | const int nMaxLen = std::min<int>(DISASM_DISPLAY_MAX_TARGET_LEN, MAX_SYMBOLS_LEN); |
| 560 | |
| 561 | int nSymbolsLoaded = 0; |
| 562 | |
| 563 | if (pPathFileName.empty()) |
| 564 | return nSymbolsLoaded; |
| 565 | |
| 566 | std::string sFormat1 = StrFormat( "%%x %%%ds", MAX_SYMBOLS_LEN ); // i.e. "%x %51s" |
| 567 | std::string sFormat2 = StrFormat( "%%%ds %%x", MAX_SYMBOLS_LEN ); // i.e. "%51s %x" |
| 568 | |
| 569 | FILE *hFile = fopen( pPathFileName.c_str(), "rt" ); |
| 570 | |
| 571 | if ( !hFile && g_bSymbolsDisplayMissingFile ) |
| 572 | { |
| 573 | // TODO: print filename! Bug #242 Help file (.chm) description for "Symbols" #242 |
| 574 | ConsoleDisplayError( "Symbol File not found:" ); |
| 575 | _PrintCurrentPath(); |
| 576 | nSymbolsLoaded = -1; // HACK: ERROR: FILE NOT EXIST |
| 577 | } |
| 578 | |
| 579 | bool bDupSymbolHeader = false; |
| 580 | if ( hFile ) |
| 581 | { |
| 582 | while ( !feof(hFile) ) |
| 583 | { |
| 584 | // Support 2 types of symbols files: |
| 585 | // 1) AppleWin: |
| 586 | // . 0000 SYMBOL |
| 587 | // . FFFF SYMBOL |
| 588 | // 2) ACME: |
| 589 | // . SYMBOL =$0000; Comment |
| 590 | // . SYMBOL =$FFFF; Comment |
| 591 | // |
| 592 | uint32_t nAddress = _6502_MEM_END + 1; // default to invalid address |
| 593 | char sName[ MAX_SYMBOLS_LEN+1 ] = ""; |
| 594 | |
| 595 | const int MAX_LINE = 256; |
| 596 | char szLine[ MAX_LINE ] = ""; |
| 597 | |
| 598 | if ( !fgets(szLine, MAX_LINE-1, hFile) ) // Get next line |
| 599 | { |
| 600 | //ConsolePrint("<<EOF"); |
| 601 | break; |
| 602 | } |
| 603 | |
| 604 | if (strstr(szLine, "$") == NULL) |
| 605 | { |
| 606 | sscanf(szLine, sFormat1.c_str(), &nAddress, sName); |
| 607 | } |
| 608 | else |
| 609 | { |
| 610 | char* p = strstr(szLine, "="); // Optional |
| 611 | if (p) *p = ' '; |
| 612 | p = strstr(szLine, "$"); |
no test coverage detected