Skip to content

Commit

Permalink
Fix not recognizing file entries which are splited in two lines becau…
Browse files Browse the repository at this point in the history
…se its section name was too long to fit.
  • Loading branch information
AngheloAlf committed Feb 25, 2024
1 parent 1d3b5da commit c702599
Show file tree
Hide file tree
Showing 17 changed files with 102,072 additions and 25,315 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Fix not recognizing file entries which are splited in two lines because its
section name was too long to fit.

## [2.3.6] - 2024-02-23

### Added
Expand Down
37 changes: 28 additions & 9 deletions src/rs/mapfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ impl MapFile {
*/
pub fn parse_map_contents_gnu(&mut self, map_contents: String) {
// TODO: maybe move somewhere else?
let regex_file_data_entry = Regex::new(r"^\s+(?P<section>[^*][^\s]+)\s+(?P<vram>0x[^\s]+)\s+(?P<size>0x[^\s]+)\s+(?P<name>[^\s]+)$").unwrap();
let regex_section_alone_entry = Regex::new(r"^\s+(?P<section>[^*][^\s]+)\s*$").unwrap();
let regex_file_data_entry = Regex::new(r"^\s+(?P<section>([^*][^\s]+)?)\s+(?P<vram>0x[^\s]+)\s+(?P<size>0x[^\s]+)\s+(?P<name>[^\s]+)$").unwrap();
let regex_function_entry =
Regex::new(r"^\s+(?P<vram>0x[^\s]+)\s+(?P<name>[^\s]+)$").unwrap();
// regex_function_entry = re.compile(r"^\s+(?P<vram>0x[^\s]+)\s+(?P<name>[^\s]+)((\s*=\s*(?P<expression>.+))?)$")
Expand Down Expand Up @@ -141,15 +142,33 @@ impl MapFile {
let section_type = &file_entry_match["section"];

if size > 0 {
in_file = true;
let current_segment = temp_segment_list.last_mut().unwrap();
// TODO: de-duplicate the following code:

if !section_type.is_empty() {
in_file = true;
let current_segment = temp_segment_list.last_mut().unwrap();

current_segment.files_list.push(file::File::new_default(
filepath,
vram,
size,
section_type,
));
} else if let Some(section_alone_match) = regex_section_alone_entry.captures(prev_line) {
// Some sections may be too large, making the entry be splitted between two lines, making the section name be in one line and the rest of the info in the next one

current_segment.files_list.push(file::File::new_default(
filepath,
vram,
size,
section_type,
));
let section_type = &section_alone_match["section"];

in_file = true;
let current_segment = temp_segment_list.last_mut().unwrap();

current_segment.files_list.push(file::File::new_default(
filepath,
vram,
size,
section_type,
));
}
}
} else if let Some(segment_entry_match) = regex_segment_entry.captures(line) {
let mut name = &segment_entry_match["name"];
Expand Down
Loading

0 comments on commit c702599

Please sign in to comment.