From 959ab1f66ec90de03b5baea1f7256fd233b4c604 Mon Sep 17 00:00:00 2001 From: Jonathan 'theJPster' Pallant Date: Mon, 26 Aug 2024 17:08:17 +0100 Subject: [PATCH 1/2] Ensure doc comments have short summary. --- src/ctype.rs | 11 +++++++---- src/signal.rs | 5 +++-- src/strcat.rs | 5 +++-- src/strcpy.rs | 5 +++-- src/strncasecmp.rs | 5 +++-- src/strncmp.rs | 5 +++-- src/strncpy.rs | 5 +++-- 7 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/ctype.rs b/src/ctype.rs index 20e2599..e3655c0 100644 --- a/src/ctype.rs +++ b/src/ctype.rs @@ -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 @@ -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 } } diff --git a/src/signal.rs b/src/signal.rs index a7e4561..ec83fec 100644 --- a/src/signal.rs +++ b/src/signal.rs @@ -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. diff --git a/src/strcat.rs b/src/strcat.rs index 7731067..aa61021 100644 --- a/src/strcat.rs +++ b/src/strcat.rs @@ -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); diff --git a/src/strcpy.rs b/src/strcpy.rs index 1c11d16..a9ed875 100644 --- a/src/strcpy.rs +++ b/src/strcpy.rs @@ -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; diff --git a/src/strncasecmp.rs b/src/strncasecmp.rs index d8cc45b..3420e8f 100644 --- a/src/strncasecmp.rs +++ b/src/strncasecmp.rs @@ -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 { diff --git a/src/strncmp.rs b/src/strncmp.rs index d081a52..9912e4a 100644 --- a/src/strncmp.rs +++ b/src/strncmp.rs @@ -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 { diff --git a/src/strncpy.rs b/src/strncpy.rs index a2fe929..147f409 100644 --- a/src/strncpy.rs +++ b/src/strncpy.rs @@ -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, From 27daed51dacff4bb4f98c489198c7317b616d294 Mon Sep 17 00:00:00 2001 From: Jonathan 'theJPster' Pallant Date: Mon, 26 Aug 2024 17:10:00 +0100 Subject: [PATCH 2/2] Sort features alphabetically. --- Cargo.toml | 79 +++++++++++++++++++++++++++--------------------------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ed937e8..3a4e29b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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"]