This linter will check for code accidentally introducing locale dependencies. Unnecessary locale dependence can cause bugs that are very tricky to isolate and fix. We should avoid using locale dependent functions if possible.
Backport of core PR13041
There are several differences from the original PR:
- Updated shebang to /usr/bin/env bash.
- Remove known violations that don't exist in our codebase.
- Allow for fprintf. Core only allows it if it targets stdout or
stderr, but the original regex is inefficient due to our code
formatting. As there currently is a single occurence which doesn't match
the rule (and is safe because it only outputs digits), then I choose to
ignore it at the moment. It can be reworked later if needed.
- Make the script run from everywhere in the source tree (note the
:/ notation in the git grep call).
- Fix a bug: grep'ing for strtol will shadow strtoll, the same
with strtoul and strtoull. Appending an opening parenthesis to
grep for strtol( instead fixes the issue. A comment is added to
explain the meaning of the parenthesis.
- Exclude the seeder from the linter.
- Include changes from PR14115 to fix a BSD grep issue with empty
subexpressions