[parser] fix unwanted removal of lines that don't match a token

* In replace_in_token_data() when looking for lines starting with a specific
  token but finding lines containing a larger version of the token (e.g. looking
  for 'linux' but finding 'linux16') we would forget to output the non matching
  line as we rejected it.
* This produced issues such as the one described at:
  https://ubuntuforums.org/showthread.php?t=2465291&page=10&p=14052629#post14052629
* Fix this by ensuring that we always output the lines that we reject.
This commit is contained in:
Pete Batard 2021-09-20 16:11:47 +01:00
parent deee38d4e5
commit 2761c72187
No known key found for this signature in database
GPG key ID: 38E0CF5E69EDD671
3 changed files with 9 additions and 7 deletions

View file

@ -1187,8 +1187,10 @@ char* replace_in_token_data(const char* filename, const char* token, const char*
// Skip whitespaces after token (while making sure there's at least one)
ns = wcsspn(&buf[i], wspace);
if (ns == 0)
if (ns == 0) {
fputws(buf, fd_out);
continue;
}
i += ns;
// p[x] = starting position of the fragment with the replaceable string