Skip to content

Commit

Permalink
Ignore comments in linker script.
Browse files Browse the repository at this point in the history
  • Loading branch information
BriocheBerlin committed Nov 1, 2023
1 parent d4098b3 commit 5be81b3
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,22 +321,20 @@ fn perform_addition(line: &str) -> u64 {
let (number, unit) = match segment.find(['K', 'M']) {
Some(unit_pos) => {
let (number, unit) = segment.split_at(unit_pos);
(number, Some(unit))
(number, unit.chars().next())
}
None => (segment, None),
};

// Parse number
let (number, radix) = match number.strip_prefix("0x") {
Some(s) => (s, 16),
None => (number, 10),
};
let length = tryc!(u64::from_str_radix(number, radix));

// Handle unit
let multiplier = match unit {
Some("K") => 1024,
Some("M") => 1024 * 1024,
Some('K') => 1024,
Some('M') => 1024 * 1024,
None => 1,
_ => unreachable!(),
};
Expand Down Expand Up @@ -402,7 +400,7 @@ mod tests {
}

#[test]
fn parse_comment() {
fn ingore_comment() {
const LINKER_SCRIPT: &str = "MEMORY
{
FLASH : ORIGIN = 0x00000000, LENGTH = 256K
Expand Down

0 comments on commit 5be81b3

Please sign in to comment.