@@ -65,7 +65,7 @@ impl Commands {
6565 info ! ( "Adding command {}" , & command) ;
6666 let mut state = 0 ;
6767
68- let mut opt_lambda_state = None ;
68+ let mut reused_space_state = None ;
6969 let mut opt_final_states = vec ! [ ] ;
7070
7171 let handler = Arc :: new ( Command {
@@ -79,21 +79,31 @@ impl Commands {
7979 . enumerate ( )
8080 . for_each ( |( i, segment) | {
8181 if let Some ( name) = key_value_pair ( segment) {
82- if let Some ( lambda) = opt_lambda_state {
82+ if let Some ( lambda) = reused_space_state {
8383 state = self . add_key_value ( name, lambda) ;
8484 self . state_machine . add_next_state ( state, lambda) ;
8585 opt_final_states. push ( state) ;
86+
87+ state = self . add_quoted_key_value ( name, lambda) ;
88+ self . state_machine . add_next_state ( state, lambda) ;
89+ opt_final_states. push ( state) ;
8690 } else {
8791 opt_final_states. push ( state) ;
8892 state = self . add_space ( state, i) ;
89- opt_lambda_state = Some ( state) ;
93+ reused_space_state = Some ( state) ;
94+
9095 state = self . add_key_value ( name, state) ;
9196 self . state_machine
92- . add_next_state ( state, opt_lambda_state. unwrap ( ) ) ;
97+ . add_next_state ( state, reused_space_state. unwrap ( ) ) ;
98+ opt_final_states. push ( state) ;
99+
100+ state = self . add_quoted_key_value ( name, reused_space_state. unwrap ( ) ) ;
101+ self . state_machine
102+ . add_next_state ( state, reused_space_state. unwrap ( ) ) ;
93103 opt_final_states. push ( state) ;
94104 }
95105 } else {
96- opt_lambda_state = None ;
106+ reused_space_state = None ;
97107 opt_final_states. truncate ( 0 ) ;
98108 let last_state = state;
99109 state = self . add_space ( state, i) ;
@@ -122,7 +132,7 @@ impl Commands {
122132 }
123133 } ) ;
124134
125- if opt_lambda_state . is_some ( ) {
135+ if reused_space_state . is_some ( ) {
126136 opt_final_states. iter ( ) . for_each ( |state| {
127137 self . state_machine . set_final_state ( * state) ;
128138 self . state_machine . set_handler ( * state, handler. clone ( ) ) ;
@@ -322,12 +332,31 @@ impl Commands {
322332 state = self . state_machine . add ( state, CharacterSet :: from_char ( '=' ) ) ;
323333
324334 let mut char_set = CharacterSet :: any ( ) ;
325- char_set. remove ( & [ ' ' , '\n' ] ) ;
335+ char_set. remove ( & [ ' ' , '\n' , '"' ] ) ;
336+ state = self . state_machine . add ( state, char_set) ;
337+ self . state_machine . add_next_state ( state, state) ;
338+ self . state_machine . start_parse ( state, name) ;
339+ self . state_machine . end_parse ( state) ;
340+
341+ state
342+ }
343+
344+ fn add_quoted_key_value ( & mut self , name : & ' static str , mut state : usize ) -> usize {
345+ name. chars ( ) . for_each ( |c| {
346+ state = self . state_machine . add ( state, CharacterSet :: from_char ( c) ) ;
347+ } ) ;
348+ state = self . state_machine . add ( state, CharacterSet :: from_char ( '=' ) ) ;
349+ state = self . state_machine . add ( state, CharacterSet :: from_char ( '"' ) ) ;
350+
351+ let mut char_set = CharacterSet :: any ( ) ;
352+ char_set. remove ( & [ '"' ] ) ;
326353 state = self . state_machine . add ( state, char_set) ;
327354 self . state_machine . add_next_state ( state, state) ;
328355 self . state_machine . start_parse ( state, name) ;
329356 self . state_machine . end_parse ( state) ;
330357
358+ state = self . state_machine . add ( state, CharacterSet :: from_char ( '"' ) ) ;
359+
331360 state
332361 }
333362}
0 commit comments