From 2b4c2f9ddf64b430895507a2106afb5632eef00f Mon Sep 17 00:00:00 2001 From: auronandace Date: Fri, 12 Dec 2025 21:06:15 +0000 Subject: [PATCH 1/2] update and add spec links to regex --- src/header/regex/mod.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/header/regex/mod.rs b/src/header/regex/mod.rs index f0abbe7089..c76eba7256 100644 --- a/src/header/regex/mod.rs +++ b/src/header/regex/mod.rs @@ -1,12 +1,16 @@ -//! regex.h implementation, following http://pubs.opengroup.org/onlinepubs/7908799/xsh/regex.h.html +//! `regex.h` implementation. +//! +//! See . use crate::{header::string::strlen, platform::types::*}; use alloc::{borrow::Cow, boxed::Box}; use core::{mem, ptr, slice}; use posix_regex::{PosixRegex, PosixRegexBuilder, compile::Error as CompileError, tree::Tree}; +/// See . pub type regoff_t = size_t; +/// See . #[repr(C)] pub struct regex_t { // Points to a posix_regex::Tree @@ -15,6 +19,7 @@ pub struct regex_t { re_nsub: size_t, } +/// See . #[repr(C)] pub struct regmatch_t { rm_so: regoff_t, @@ -43,6 +48,7 @@ pub const REG_ERANGE: c_int = 12; pub const REG_ESPACE: c_int = 13; pub const REG_BADRPT: c_int = 14; +/// See . #[unsafe(no_mangle)] #[linkage = "weak"] // redefined in GIT pub unsafe extern "C" fn regcomp(out: *mut regex_t, pat: *const c_char, cflags: c_int) -> c_int { @@ -74,12 +80,14 @@ pub unsafe extern "C" fn regcomp(out: *mut regex_t, pat: *const c_char, cflags: } } +/// See . #[unsafe(no_mangle)] #[linkage = "weak"] // redefined in GIT pub unsafe extern "C" fn regfree(regex: *mut regex_t) { Box::from_raw((*regex).ptr); } +/// See . #[unsafe(no_mangle)] #[linkage = "weak"] // redefined in GIT pub unsafe extern "C" fn regexec( @@ -120,6 +128,7 @@ pub unsafe extern "C" fn regexec( if matches.is_empty() { REG_NOMATCH } else { 0 } } +/// See . #[unsafe(no_mangle)] #[linkage = "weak"] // redefined in GIT pub extern "C" fn regerror( From db82136fe4a4e9956685368e907aa861f4528a34 Mon Sep 17 00:00:00 2001 From: auronandace Date: Fri, 12 Dec 2025 21:08:31 +0000 Subject: [PATCH 2/2] only import needed types in regex --- src/header/regex/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/header/regex/mod.rs b/src/header/regex/mod.rs index c76eba7256..4127fa6f06 100644 --- a/src/header/regex/mod.rs +++ b/src/header/regex/mod.rs @@ -2,7 +2,10 @@ //! //! See . -use crate::{header::string::strlen, platform::types::*}; +use crate::{ + header::string::strlen, + platform::types::{c_char, c_int, c_void, size_t}, +}; use alloc::{borrow::Cow, boxed::Box}; use core::{mem, ptr, slice}; use posix_regex::{PosixRegex, PosixRegexBuilder, compile::Error as CompileError, tree::Tree};