mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-28 13:53:10 +00:00
Disallow using set
outside of tests, minor fixes
This commit is contained in:
parent
726819e8ee
commit
f1cd43d58b
2 changed files with 9 additions and 10 deletions
|
@ -180,10 +180,10 @@ const LONG_OPTIONS: &[woption] = &[
|
||||||
fn print_features(streams: &mut io_streams_t) {
|
fn print_features(streams: &mut io_streams_t) {
|
||||||
// TODO: move this to features.rs
|
// TODO: move this to features.rs
|
||||||
let mut max_len = i32::MIN;
|
let mut max_len = i32::MIN;
|
||||||
for md in &features::METADATA {
|
for md in features::METADATA {
|
||||||
max_len = max_len.max(md.name.len() as i32);
|
max_len = max_len.max(md.name.len() as i32);
|
||||||
}
|
}
|
||||||
for md in &features::METADATA {
|
for md in features::METADATA {
|
||||||
let set = if feature_test(md.flag) {
|
let set = if feature_test(md.flag) {
|
||||||
L!("on")
|
L!("on")
|
||||||
} else {
|
} else {
|
||||||
|
@ -433,7 +433,7 @@ pub fn status(
|
||||||
}
|
}
|
||||||
use TestFeatureRetVal::*;
|
use TestFeatureRetVal::*;
|
||||||
let mut retval = Some(TEST_FEATURE_NOT_RECOGNIZED as c_int);
|
let mut retval = Some(TEST_FEATURE_NOT_RECOGNIZED as c_int);
|
||||||
for md in &features::METADATA {
|
for md in features::METADATA {
|
||||||
if md.name == args[0] {
|
if md.name == args[0] {
|
||||||
retval = match feature_test(md.flag) {
|
retval = match feature_test(md.flag) {
|
||||||
true => Some(TEST_FEATURE_ON as c_int),
|
true => Some(TEST_FEATURE_ON as c_int),
|
||||||
|
|
|
@ -71,7 +71,7 @@ pub struct FeatureMetadata {
|
||||||
|
|
||||||
/// The metadata, indexed by flag.
|
/// The metadata, indexed by flag.
|
||||||
#[widestrs]
|
#[widestrs]
|
||||||
pub const METADATA: [FeatureMetadata; 4] = [
|
pub const METADATA: &[FeatureMetadata] = &[
|
||||||
FeatureMetadata {
|
FeatureMetadata {
|
||||||
flag: FeatureFlag::stderr_nocaret,
|
flag: FeatureFlag::stderr_nocaret,
|
||||||
name: "stderr-nocaret"L,
|
name: "stderr-nocaret"L,
|
||||||
|
@ -114,12 +114,11 @@ pub fn test(flag: FeatureFlag) -> bool {
|
||||||
FEATURES.test(flag)
|
FEATURES.test(flag)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn feature_test(flag: FeatureFlag) -> bool {
|
pub use test as feature_test;
|
||||||
test(flag)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Set a flag.
|
/// Set a flag.
|
||||||
pub fn set(flag: FeatureFlag, value: bool) {
|
#[cfg(any(test, feature = "fish-ffi-tests"))]
|
||||||
|
pub(self) fn set(flag: FeatureFlag, value: bool) {
|
||||||
FEATURES.set(flag, value);
|
FEATURES.set(flag, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +181,7 @@ impl Features {
|
||||||
self.set(md.flag, value);
|
self.set(md.flag, value);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for md in &METADATA {
|
for md in METADATA {
|
||||||
if md.groups == name || name == "all"L {
|
if md.groups == name || name == "all"L {
|
||||||
if !md.read_only {
|
if !md.read_only {
|
||||||
self.set(md.flag, value);
|
self.set(md.flag, value);
|
||||||
|
@ -205,7 +204,7 @@ fn test_feature_flags() {
|
||||||
|
|
||||||
// Ensure every metadata is represented once.
|
// Ensure every metadata is represented once.
|
||||||
let mut counts: [usize; METADATA.len()] = [0; METADATA.len()];
|
let mut counts: [usize; METADATA.len()] = [0; METADATA.len()];
|
||||||
for md in &METADATA {
|
for md in METADATA {
|
||||||
counts[md.flag.repr as usize] += 1;
|
counts[md.flag.repr as usize] += 1;
|
||||||
}
|
}
|
||||||
for count in counts {
|
for count in counts {
|
||||||
|
|
Loading…
Reference in a new issue