@@ -16,8 +16,8 @@ use std::fmt;
16
16
17
17
pub use config:: ReportTactic ;
18
18
19
- const TO_DO_CHARS : & [ char ] = & [ 'T ' , 'O ' , 'D ' , 'O ' ] ;
20
- const FIX_ME_CHARS : & [ char ] = & [ 'F ' , 'I ' , 'X ' , 'M ' , 'E ' ] ;
19
+ const TO_DO_CHARS : & [ char ] = & [ 't ' , 'o ' , 'd ' , 'o ' ] ;
20
+ const FIX_ME_CHARS : & [ char ] = & [ 'f ' , 'i ' , 'x ' , 'm ' , 'e ' ] ;
21
21
22
22
// Enabled implementation detail is here because it is
23
23
// irrelevant outside the issues module
@@ -127,44 +127,45 @@ impl BadIssueSeeker {
127
127
}
128
128
129
129
fn inspect_issue ( & mut self , c : char , mut todo_idx : usize , mut fixme_idx : usize ) -> Seeking {
130
- // FIXME: Should we also check for lower case characters?
131
- if self . report_todo . is_enabled ( ) && c == TO_DO_CHARS [ todo_idx] {
132
- todo_idx += 1 ;
133
- if todo_idx == TO_DO_CHARS . len ( ) {
134
- return Seeking :: Number {
135
- issue : Issue {
136
- issue_type : IssueType :: Todo ,
137
- missing_number : if let ReportTactic :: Unnumbered = self . report_todo {
138
- true
139
- } else {
140
- false
130
+ if let Some ( lower_case_c) = c. to_lowercase ( ) . next ( ) {
131
+ if self . report_todo . is_enabled ( ) && lower_case_c == TO_DO_CHARS [ todo_idx] {
132
+ todo_idx += 1 ;
133
+ if todo_idx == TO_DO_CHARS . len ( ) {
134
+ return Seeking :: Number {
135
+ issue : Issue {
136
+ issue_type : IssueType :: Todo ,
137
+ missing_number : if let ReportTactic :: Unnumbered = self . report_todo {
138
+ true
139
+ } else {
140
+ false
141
+ } ,
141
142
} ,
142
- } ,
143
- part : NumberPart :: OpenParen ,
144
- } ;
145
- }
146
- fixme_idx = 0 ;
147
- } else if self . report_fixme . is_enabled ( ) && c == FIX_ME_CHARS [ fixme_idx ] {
148
- // Exploit the fact that the character sets of todo and fixme
149
- // are disjoint by adding else.
150
- fixme_idx += 1 ;
151
- if fixme_idx == FIX_ME_CHARS . len ( ) {
152
- return Seeking :: Number {
153
- issue : Issue {
154
- issue_type : IssueType :: Fixme ,
155
- missing_number : if let ReportTactic :: Unnumbered = self . report_fixme {
156
- true
157
- } else {
158
- false
143
+ part : NumberPart :: OpenParen ,
144
+ } ;
145
+ }
146
+ fixme_idx = 0 ;
147
+ } else if self . report_fixme . is_enabled ( ) && lower_case_c == FIX_ME_CHARS [ fixme_idx ] {
148
+ // Exploit the fact that the character sets of todo and fixme
149
+ // are disjoint by adding else.
150
+ fixme_idx += 1 ;
151
+ if fixme_idx == FIX_ME_CHARS . len ( ) {
152
+ return Seeking :: Number {
153
+ issue : Issue {
154
+ issue_type : IssueType :: Fixme ,
155
+ missing_number : if let ReportTactic :: Unnumbered = self . report_fixme {
156
+ true
157
+ } else {
158
+ false
159
+ } ,
159
160
} ,
160
- } ,
161
- part : NumberPart :: OpenParen ,
162
- } ;
161
+ part : NumberPart :: OpenParen ,
162
+ } ;
163
+ }
164
+ todo_idx = 0 ;
165
+ } else {
166
+ todo_idx = 0 ;
167
+ fixme_idx = 0 ;
163
168
}
164
- todo_idx = 0 ;
165
- } else {
166
- todo_idx = 0 ;
167
- fixme_idx = 0 ;
168
169
}
169
170
170
171
Seeking :: Issue {
@@ -268,12 +269,24 @@ fn find_issue() {
268
269
ReportTactic :: Always ,
269
270
) ) ;
270
271
272
+ assert ! ( !is_bad_issue(
273
+ "Todo: mixed case\n " ,
274
+ ReportTactic :: Never ,
275
+ ReportTactic :: Always ,
276
+ ) ) ;
277
+
271
278
assert ! ( is_bad_issue(
272
279
"This is a FIXME(#1)\n " ,
273
280
ReportTactic :: Never ,
274
281
ReportTactic :: Always ,
275
282
) ) ;
276
283
284
+ assert ! ( is_bad_issue(
285
+ "This is a FixMe(#1) mixed case\n " ,
286
+ ReportTactic :: Never ,
287
+ ReportTactic :: Always ,
288
+ ) ) ;
289
+
277
290
assert ! ( !is_bad_issue(
278
291
"bad FIXME\n " ,
279
292
ReportTactic :: Always ,
0 commit comments