Skip to content

Change bool::from_ini_value logic. #106

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

Merged
merged 1 commit into from
Apr 5, 2023
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
2 changes: 1 addition & 1 deletion .rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
# See the Mulan PSL v2 for more details.

fn_args_layout = "Compressed"
fn_params_layout = "Compressed"
format_code_in_doc_comments = true
format_macro_bodies = true
format_macro_matchers = true
Expand Down
14 changes: 9 additions & 5 deletions phper/src/ini.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

//! Apis relate to [crate::sys::zend_ini_entry_def].

use crate::sys::*;
use crate::{c_str, sys::*};
use std::{
ffi::{c_int, CStr},
mem::zeroed,
Expand Down Expand Up @@ -99,10 +99,14 @@ pub trait FromIniValue {
impl FromIniValue for bool {
#[allow(clippy::useless_conversion)]
fn from_ini_value(name: &str) -> Self {
unsafe {
let name_ptr = name.as_ptr() as *mut u8 as *mut c_char;
zend_ini_long(name_ptr, name.len().try_into().unwrap(), 0) != 0
}
let s = <Option<&CStr>>::from_ini_value(name);
[
Some(c_str!("1")),
Some(c_str!("true")),
Some(c_str!("on")),
Some(c_str!("On")),
]
.contains(&s)
}
}

Expand Down