Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup docs #29

Merged
merged 2 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 40 additions & 39 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,60 +21,61 @@ cc = "1.0"
default = ["all"]
all = [
"abs",
"atoi",
"isalpha",
"isdigit",
"isspace",
"isupper",
"itoa",
"memchr",
"qsort",
"snprintf",
"strcat",
"strchr",
"strcmp",
"strncmp",
"strncasecmp",
"strcpy",
"strcat",
"strncpy",
"strlen",
"strncasecmp",
"strncmp",
"strncpy",
"strrchr",
"strstr",
"strtoimax",
"strtol",
"strtoul",
"strtoll",
"strtoul",
"strtoull",
"strtoimax",
"strtoumax",
"strstr",
"strchr",
"strrchr",
"atoi",
"utoa",
"itoa",
"snprintf",
"isspace",
"isdigit",
"isalpha",
"isupper",
"memchr",
"qsort",
]

abs = []
alloc = []
atoi = []
isalpha = []
isdigit = []
isspace = []
isupper = []
itoa = []
memchr = []
qsort = []
signal = ["dep:portable-atomic"]
signal-cs = ["portable-atomic/critical-section"]
snprintf = []
strcat = []
strchr = []
strcmp = []
strncmp = []
strncasecmp = []
strcpy = []
strcat = []
strncpy = []
strlen = []
strncasecmp = []
strncmp = []
strncpy = []
strrchr = []
strstr = []
strtoimax = []
strtol = []
strtoul = []
strtoll = []
strtoul = []
strtoull = []
strtoimax = []
strtoumax = []
strstr = []
strchr = []
strrchr = []
atoi = []
utoa = []
itoa = []
snprintf = []
isspace = []
isdigit = []
isalpha = []
isupper = []
alloc = []
memchr = []
qsort = []
signal = ["dep:portable-atomic"]
signal-cs = ["portable-atomic/critical-section"]
11 changes: 7 additions & 4 deletions src/ctype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,10 @@ pub type CInt = ::core::ffi::c_int;
/// `unsigned int`
pub type CUInt = ::core::ffi::c_uint;

/// Represents an 8-bit `char`. Rust does not (and will never) support
/// platforms where `char` is not 8-bits long.
/// Represents an 8-bit `char`.
///
/// Rust does not (and will never) support platforms where `char` is not 8-bits
/// long.
pub type CChar = u8;

/// This allows you to iterate a null-terminated string in a relatively simple
Expand All @@ -49,8 +51,9 @@ pub struct CStringIter {
}

impl CStringIter {
/// Create a new iterator from a pointer to a null-terminated string. The
/// behaviour is undefined if the string is not null-terminated.
/// Create a new iterator from a pointer to a null-terminated string.
///
/// The behaviour is undefined if the string is not null-terminated.
pub fn new(s: *const CChar) -> CStringIter {
CStringIter { ptr: s, idx: 0 }
}
Expand Down
5 changes: 3 additions & 2 deletions src/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ const SIG_DFL_ATOMIC: AtomicUsize = AtomicUsize::new(SIG_DFL);

/// Our array of registered signal handlers.
///
/// Signals in C are either 0, 1, -1, or a function pointer. We cast function
/// pointers into `usize` so they can be stored in this array.
/// Signals in C are either 0, 1, -1, or a function pointer.
///
/// We cast function pointers into `usize` so they can be stored in this array.
static SIGNAL_HANDLERS: [AtomicUsize; 16] = [SIG_DFL_ATOMIC; 16];

/// A signal handler - either a function pointer or a magic integer.
Expand Down
5 changes: 3 additions & 2 deletions src/strcat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

use crate::CChar;

/// Rust implementation of C library function `strcat`. Passing NULL
/// (core::ptr::null()) gives undefined behaviour.
/// Rust implementation of C library function `strcat`.
///
/// Passing NULL (core::ptr::null()) gives undefined behaviour.
#[cfg_attr(feature = "strcat", no_mangle)]
pub unsafe extern "C" fn strcat(dest: *mut CChar, src: *const CChar) -> *const CChar {
crate::strcpy::strcpy(dest.add(crate::strlen::strlen(dest)), src);
Expand Down
5 changes: 3 additions & 2 deletions src/strcpy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

use crate::CChar;

/// Rust implementation of C library function `strcpy`. Passing NULL
/// (core::ptr::null()) gives undefined behaviour.
/// Rust implementation of C library function `strcpy`.
///
/// Passing NULL (core::ptr::null()) gives undefined behaviour.
#[cfg_attr(feature = "strcpy", no_mangle)]
pub unsafe extern "C" fn strcpy(dest: *mut CChar, src: *const CChar) -> *const CChar {
let mut i = 0;
Expand Down
5 changes: 3 additions & 2 deletions src/strncasecmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

use crate::{CChar, CInt};

/// Rust implementation of C library function `strncasecmp`. Passing NULL
/// (core::ptr::null()) gives undefined behaviour.
/// Rust implementation of C library function `strncasecmp`.
///
/// Passing NULL (core::ptr::null()) gives undefined behaviour.
#[cfg_attr(feature = "strncasecmp", no_mangle)]
pub unsafe extern "C" fn strncasecmp(s1: *const CChar, s2: *const CChar, n: usize) -> CInt {
for i in 0..n {
Expand Down
5 changes: 3 additions & 2 deletions src/strncmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

use crate::{CChar, CInt};

/// Rust implementation of C library function `strncmp`. Passing NULL
/// (core::ptr::null()) gives undefined behaviour.
/// Rust implementation of C library function `strncmp`.
///
/// Passing NULL (core::ptr::null()) gives undefined behaviour.
#[cfg_attr(feature = "strncmp", no_mangle)]
pub unsafe extern "C" fn strncmp(s1: *const CChar, s2: *const CChar, n: usize) -> crate::CInt {
for i in 0..n as isize {
Expand Down
5 changes: 3 additions & 2 deletions src/strncpy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@

use crate::CChar;

/// Rust implementation of C library function `strncmp`. Passing NULL
/// (core::ptr::null()) gives undefined behaviour.
/// Rust implementation of C library function `strncmp`.
///
/// Passing NULL (core::ptr::null()) gives undefined behaviour.
#[cfg_attr(feature = "strncpy", no_mangle)]
pub unsafe extern "C" fn strncpy(
dest: *mut CChar,
Expand Down
Loading