Skip to content

Commit

Permalink
Merge pull request #1 from 42-technology-ltd/add_strchr
Browse files Browse the repository at this point in the history
Add strchr
  • Loading branch information
thejpster authored Nov 6, 2019
2 parents 66890fb + 52e3189 commit 962ede5
Show file tree
Hide file tree
Showing 13 changed files with 578 additions and 511 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This crate basically came about so that the [nrfxlib](https://github.com/NordicP
* strlen
* strtol
* strstr
* strchr
* snprintf
* vsnprintf

Expand Down
12 changes: 6 additions & 6 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use cc;

fn main() {
// Build our snprintf substitute (which has to be C as Rust doesn't do varargs)
cc::Build::new()
.warnings(true)
.extra_warnings(true)
.file("./src/snprintf.c")
.compile("clocal");
// Build our snprintf substitute (which has to be C as Rust doesn't do varargs)
cc::Build::new()
.warnings(true)
.extra_warnings(true)
.file("./src/snprintf.c")
.compile("clocal");
}
3 changes: 3 additions & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
hard_tabs = true


16 changes: 8 additions & 8 deletions src/atoi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ use crate::{strtol, CChar, CInt, CLong};
/// ```
#[no_mangle]
pub unsafe extern "C" fn atoi(s: *const CChar) -> CInt {
let result = strtol(s);
if result > CInt::max_value() as CLong {
CInt::max_value()
} else if result < CInt::min_value() as CLong {
CInt::min_value()
} else {
result as CInt
}
let result = strtol(s);
if result > CInt::max_value() as CLong {
CInt::max_value()
} else if result < CInt::min_value() as CLong {
CInt::min_value()
} else {
result as CInt
}
}
Loading

0 comments on commit 962ede5

Please sign in to comment.