(config: &[u8], name: &str)
| 207 | |
| 208 | #[cfg(feature = "system")] |
| 209 | fn is_linux_kernel_config_item_enabled(config: &[u8], name: &str) -> io::Result<bool> { |
| 210 | for line in io::Cursor::new(config).lines() { |
| 211 | let line = line?; |
| 212 | let line = line.trim(); |
| 213 | if line.is_empty() || line.starts_with('#') { |
| 214 | continue; |
| 215 | } |
| 216 | |
| 217 | let mut iter = line.splitn(2, '='); |
| 218 | if let Some(current_name) = iter.next().map(str::trim) { |
| 219 | if current_name == name { |
| 220 | if let Some(mut value) = iter.next().map(str::trim) { |
| 221 | if value.starts_with('"') && value.ends_with('"') { |
| 222 | // Just remove the quotes, but don't bother unescaping the inner string |
| 223 | // because we are only trying to find out if the option is a true boolean. |
| 224 | value = &value[1..(value.len() - 2)]; |
| 225 | } |
| 226 | |
| 227 | return Ok(value == "y" || value == "m"); |
| 228 | } |
| 229 | } |
| 230 | } |
| 231 | } |
| 232 | Ok(false) |
| 233 | } |
| 234 | |
| 235 | #[cfg(feature = "system")] |
| 236 | fn linux_kernel_config_item_is_enabled(name: &str) -> io::Result<bool> { |
no test coverage detected