Skip to content

Commit

Permalink
Support also hex literals (starting with 0x)
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-opp committed Jun 21, 2019
1 parent 319aa3c commit 1b79648
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,14 @@ fn main() {
Err(env::VarError::NotUnicode(_)) => panic!(
"The `BOOTLOADER_PHYSICAL_MEMORY_OFFSET` environment variable must be valid unicode"
),
Ok(s) => s.parse().expect(&format!(
"The `BOOTLOADER_PHYSICAL_MEMORY_OFFSET` environment variable must be an\
integer (is `{}`).",
Ok(s) => if s.starts_with("0x") {
u64::from_str_radix(&s[2..], 16)
} else {
u64::from_str_radix(&s, 10)
}
.expect(&format!(
"The `BOOTLOADER_PHYSICAL_MEMORY_OFFSET` environment variable must be an integer\
(is `{}`).",
s
)),
};
Expand Down

0 comments on commit 1b79648

Please sign in to comment.