@@ -65,7 +65,7 @@ impl Commands {
65
65
info ! ( "Adding command {}" , & command) ;
66
66
let mut state = 0 ;
67
67
68
- let mut opt_lambda_state = None ;
68
+ let mut reused_space_state = None ;
69
69
let mut opt_final_states = vec ! [ ] ;
70
70
71
71
let handler = Arc :: new ( Command {
@@ -79,21 +79,31 @@ impl Commands {
79
79
. enumerate ( )
80
80
. for_each ( |( i, segment) | {
81
81
if let Some ( name) = key_value_pair ( segment) {
82
- if let Some ( lambda) = opt_lambda_state {
82
+ if let Some ( lambda) = reused_space_state {
83
83
state = self . add_key_value ( name, lambda) ;
84
84
self . state_machine . add_next_state ( state, lambda) ;
85
85
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) ;
86
90
} else {
87
91
opt_final_states. push ( state) ;
88
92
state = self . add_space ( state, i) ;
89
- opt_lambda_state = Some ( state) ;
93
+ reused_space_state = Some ( state) ;
94
+
90
95
state = self . add_key_value ( name, state) ;
91
96
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 ( ) ) ;
93
103
opt_final_states. push ( state) ;
94
104
}
95
105
} else {
96
- opt_lambda_state = None ;
106
+ reused_space_state = None ;
97
107
opt_final_states. truncate ( 0 ) ;
98
108
let last_state = state;
99
109
state = self . add_space ( state, i) ;
@@ -122,7 +132,7 @@ impl Commands {
122
132
}
123
133
} ) ;
124
134
125
- if opt_lambda_state . is_some ( ) {
135
+ if reused_space_state . is_some ( ) {
126
136
opt_final_states. iter ( ) . for_each ( |state| {
127
137
self . state_machine . set_final_state ( * state) ;
128
138
self . state_machine . set_handler ( * state, handler. clone ( ) ) ;
@@ -322,12 +332,31 @@ impl Commands {
322
332
state = self . state_machine . add ( state, CharacterSet :: from_char ( '=' ) ) ;
323
333
324
334
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 ( & [ '"' ] ) ;
326
353
state = self . state_machine . add ( state, char_set) ;
327
354
self . state_machine . add_next_state ( state, state) ;
328
355
self . state_machine . start_parse ( state, name) ;
329
356
self . state_machine . end_parse ( state) ;
330
357
358
+ state = self . state_machine . add ( state, CharacterSet :: from_char ( '"' ) ) ;
359
+
331
360
state
332
361
}
333
362
}
0 commit comments