Skip to content

Commit

Permalink
Clean
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuichiueda committed Oct 22, 2024
1 parent 7d90aec commit 09692e9
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions src/elements/subword/braced_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,7 @@ impl Subword for BracedParam {
fn boxed_clone(&self) -> Box<dyn Subword> {Box::new(self.clone())}

fn substitute(&mut self, core: &mut ShellCore) -> bool {
if self.name.len() == 0 || ! is_param(&self.name) {
eprintln!("sush: {}: bad substitution", &self.text);
return false;
}
if self.unknown.len() > 0
&& ! self.unknown.starts_with(",") {
eprintln!("sush: {}: bad substitution", &self.text);
if ! self.check() {
return false;
}

Expand Down Expand Up @@ -104,18 +98,17 @@ impl Subword for BracedParam {
}

impl BracedParam {
fn new() -> BracedParam {
BracedParam {
text: String::new(),
name: String::new(),
unknown: String::new(),
subscript: None,
alternative_symbol: None,
alternative_value: None,
num: false,
has_offset: false,
offset: None,
fn check(&mut self) -> bool {
if self.name.len() == 0 || ! is_param(&self.name) {
eprintln!("sush: {}: bad substitution", &self.text);
return false;
}
if self.unknown.len() > 0
&& ! self.unknown.starts_with(",") {
eprintln!("sush: {}: bad substitution", &self.text);
return false;
}
true
}

fn offset(&mut self, core: &mut ShellCore) -> bool {
Expand Down Expand Up @@ -197,6 +190,20 @@ impl BracedParam {
return false;
}

fn new() -> BracedParam {
BracedParam {
text: String::new(),
name: String::new(),
unknown: String::new(),
subscript: None,
alternative_symbol: None,
alternative_value: None,
num: false,
has_offset: false,
offset: None,
}
}

fn eat_subscript(feeder: &mut Feeder, ans: &mut Self, core: &mut ShellCore) -> bool {
if let Some(s) = Subscript::parse(feeder, core) {
ans.text += &s.text;
Expand Down

0 comments on commit 09692e9

Please sign in to comment.