Skip to content

Commit 4d253d5

Browse files
authored
Change bool::from_ini_value logic. (#106)
1 parent a6b3355 commit 4d253d5

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

.rustfmt.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
99
# See the Mulan PSL v2 for more details.
1010

11-
fn_args_layout = "Compressed"
11+
fn_params_layout = "Compressed"
1212
format_code_in_doc_comments = true
1313
format_macro_bodies = true
1414
format_macro_matchers = true

phper/src/ini.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
//! Apis relate to [crate::sys::zend_ini_entry_def].
1212
13-
use crate::sys::*;
13+
use crate::{c_str, sys::*};
1414
use std::{
1515
ffi::{c_int, CStr},
1616
mem::zeroed,
@@ -99,10 +99,14 @@ pub trait FromIniValue {
9999
impl FromIniValue for bool {
100100
#[allow(clippy::useless_conversion)]
101101
fn from_ini_value(name: &str) -> Self {
102-
unsafe {
103-
let name_ptr = name.as_ptr() as *mut u8 as *mut c_char;
104-
zend_ini_long(name_ptr, name.len().try_into().unwrap(), 0) != 0
105-
}
102+
let s = <Option<&CStr>>::from_ini_value(name);
103+
[
104+
Some(c_str!("1")),
105+
Some(c_str!("true")),
106+
Some(c_str!("on")),
107+
Some(c_str!("On")),
108+
]
109+
.contains(&s)
106110
}
107111
}
108112

0 commit comments

Comments
 (0)