@@ -153,29 +153,32 @@ auto lwg::parse_issue_from_file(std::string tx, std::string const & filename,
153
153
issue is;
154
154
155
155
// Get issue number
156
- auto k = tx.find (" <issue num=\" " );
156
+ std::string_view match = " <issue num=\" " ;
157
+ auto k = tx.find (match);
157
158
if (k == std::string::npos) {
158
159
throw bad_issue_file{filename, " Unable to find issue number" };
159
160
}
160
- k += sizeof ( " <issue num= \" " ) - 1 ;
161
+ k += match. size () ;
161
162
auto l = tx.find (' \" ' , k);
162
163
is.num = std::stoi (tx.substr (k, l-k));
163
164
164
165
// Get issue status
165
- k = tx.find (" status=\" " , l);
166
+ match = " status=\" " ;
167
+ k = tx.find (match, l);
166
168
if (k == std::string::npos) {
167
169
throw bad_issue_file{filename, " Unable to find issue status" };
168
170
}
169
- k += sizeof ( " status= \" " ) - 1 ;
171
+ k += match. size () ;
170
172
l = tx.find (' \" ' , k);
171
173
is.stat = tx.substr (k, l-k);
172
174
173
175
// Get issue title
174
- k = tx.find (" <title>" , l);
176
+ match = " <title>" ;
177
+ k = tx.find (match, l);
175
178
if (k == std::string::npos) {
176
179
throw bad_issue_file{filename, " Unable to find issue title" };
177
180
}
178
- k += sizeof ( " <title> " ) - 1 ;
181
+ k += match. size () ;
179
182
l = tx.find (" </title>" , k);
180
183
is.title = tx.substr (k, l-k);
181
184
@@ -190,11 +193,12 @@ auto lwg::parse_issue_from_file(std::string tx, std::string const & filename,
190
193
}
191
194
192
195
// Get issue sections
193
- k = tx.find (" <section>" , l);
196
+ match = " <section>" ;
197
+ k = tx.find (match, l);
194
198
if (k == std::string::npos) {
195
199
throw bad_issue_file{filename, " Unable to find issue section" };
196
200
}
197
- k += sizeof ( " <section> " ) - 1 ;
201
+ k += match. size () ;
198
202
l = tx.find (" </section>" , k);
199
203
while (k < l) {
200
204
k = tx.find (' \" ' , k);
@@ -227,20 +231,22 @@ auto lwg::parse_issue_from_file(std::string tx, std::string const & filename,
227
231
}
228
232
229
233
// Get submitter
230
- k = tx.find (" <submitter>" , l);
234
+ match = " <submitter>" ;
235
+ k = tx.find (match, l);
231
236
if (k == std::string::npos) {
232
237
throw bad_issue_file{filename, " Unable to find issue submitter" };
233
238
}
234
- k += sizeof ( " <submitter> " ) - 1 ;
239
+ k += match. size () ;
235
240
l = tx.find (" </submitter>" , k);
236
241
is.submitter = tx.substr (k, l-k);
237
242
238
243
// Get date
239
- k = tx.find (" <date>" , l);
244
+ match = " <date>" ;
245
+ k = tx.find (match, l);
240
246
if (k == std::string::npos) {
241
247
throw bad_issue_file{filename, " Unable to find issue date" };
242
248
}
243
- k += sizeof ( " <date> " ) - 1 ;
249
+ k += match. size () ;
244
250
l = tx.find (" </date>" , k);
245
251
246
252
try {
@@ -255,9 +261,10 @@ auto lwg::parse_issue_from_file(std::string tx, std::string const & filename,
255
261
}
256
262
257
263
// Get priority - this element is optional
258
- k = tx.find (" <priority>" , l);
264
+ match = " <priority>" ;
265
+ k = tx.find (match, l);
259
266
if (k != std::string::npos) {
260
- k += sizeof ( " <priority> " ) - 1 ;
267
+ k += match. size () ;
261
268
l = tx.find (" </priority>" , k);
262
269
if (l == std::string::npos) {
263
270
throw bad_issue_file{filename, " Corrupt 'priority' element: no closing tag" };
@@ -274,12 +281,13 @@ auto lwg::parse_issue_from_file(std::string tx, std::string const & filename,
274
281
275
282
// Find out if issue has a proposed resolution
276
283
if (is_active (is.stat ) or " Pending WP" == is.stat ) {
277
- auto k2 = tx.find (" <resolution>" , 0 );
284
+ match = " <resolution>" ;
285
+ auto k2 = tx.find (match, 0 );
278
286
if (k2 == std::string::npos) {
279
287
is.has_resolution = false ;
280
288
}
281
289
else {
282
- k2 += sizeof ( " <resolution> " ) - 1 ;
290
+ k2 += match. size () ;
283
291
auto l2 = tx.find (" </resolution>" , k2);
284
292
is.resolution = tx.substr (k2, l2 - k2);
285
293
if (is.resolution .length () < 15 ) {
0 commit comments