@@ -153,29 +153,32 @@ auto lwg::parse_issue_from_file(std::string tx, std::string const & filename,
153153 issue is;
154154
155155 // Get issue number
156- auto k = tx.find (" <issue num=\" " );
156+ std::string_view match = " <issue num=\" " ;
157+ auto k = tx.find (match);
157158 if (k == std::string::npos) {
158159 throw bad_issue_file{filename, " Unable to find issue number" };
159160 }
160- k += sizeof ( " <issue num= \" " ) - 1 ;
161+ k += match. size () ;
161162 auto l = tx.find (' \" ' , k);
162163 is.num = std::stoi (tx.substr (k, l-k));
163164
164165 // Get issue status
165- k = tx.find (" status=\" " , l);
166+ match = " status=\" " ;
167+ k = tx.find (match, l);
166168 if (k == std::string::npos) {
167169 throw bad_issue_file{filename, " Unable to find issue status" };
168170 }
169- k += sizeof ( " status= \" " ) - 1 ;
171+ k += match. size () ;
170172 l = tx.find (' \" ' , k);
171173 is.stat = tx.substr (k, l-k);
172174
173175 // Get issue title
174- k = tx.find (" <title>" , l);
176+ match = " <title>" ;
177+ k = tx.find (match, l);
175178 if (k == std::string::npos) {
176179 throw bad_issue_file{filename, " Unable to find issue title" };
177180 }
178- k += sizeof ( " <title> " ) - 1 ;
181+ k += match. size () ;
179182 l = tx.find (" </title>" , k);
180183 is.title = tx.substr (k, l-k);
181184
@@ -190,11 +193,12 @@ auto lwg::parse_issue_from_file(std::string tx, std::string const & filename,
190193 }
191194
192195 // Get issue sections
193- k = tx.find (" <section>" , l);
196+ match = " <section>" ;
197+ k = tx.find (match, l);
194198 if (k == std::string::npos) {
195199 throw bad_issue_file{filename, " Unable to find issue section" };
196200 }
197- k += sizeof ( " <section> " ) - 1 ;
201+ k += match. size () ;
198202 l = tx.find (" </section>" , k);
199203 while (k < l) {
200204 k = tx.find (' \" ' , k);
@@ -227,20 +231,22 @@ auto lwg::parse_issue_from_file(std::string tx, std::string const & filename,
227231 }
228232
229233 // Get submitter
230- k = tx.find (" <submitter>" , l);
234+ match = " <submitter>" ;
235+ k = tx.find (match, l);
231236 if (k == std::string::npos) {
232237 throw bad_issue_file{filename, " Unable to find issue submitter" };
233238 }
234- k += sizeof ( " <submitter> " ) - 1 ;
239+ k += match. size () ;
235240 l = tx.find (" </submitter>" , k);
236241 is.submitter = tx.substr (k, l-k);
237242
238243 // Get date
239- k = tx.find (" <date>" , l);
244+ match = " <date>" ;
245+ k = tx.find (match, l);
240246 if (k == std::string::npos) {
241247 throw bad_issue_file{filename, " Unable to find issue date" };
242248 }
243- k += sizeof ( " <date> " ) - 1 ;
249+ k += match. size () ;
244250 l = tx.find (" </date>" , k);
245251
246252 try {
@@ -255,9 +261,10 @@ auto lwg::parse_issue_from_file(std::string tx, std::string const & filename,
255261 }
256262
257263 // Get priority - this element is optional
258- k = tx.find (" <priority>" , l);
264+ match = " <priority>" ;
265+ k = tx.find (match, l);
259266 if (k != std::string::npos) {
260- k += sizeof ( " <priority> " ) - 1 ;
267+ k += match. size () ;
261268 l = tx.find (" </priority>" , k);
262269 if (l == std::string::npos) {
263270 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,
274281
275282 // Find out if issue has a proposed resolution
276283 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 );
278286 if (k2 == std::string::npos) {
279287 is.has_resolution = false ;
280288 }
281289 else {
282- k2 += sizeof ( " <resolution> " ) - 1 ;
290+ k2 += match. size () ;
283291 auto l2 = tx.find (" </resolution>" , k2);
284292 is.resolution = tx.substr (k2, l2 - k2);
285293 if (is.resolution .length () < 15 ) {
0 commit comments