Commit Graph

3 Commits

Author SHA1 Message Date
rillig 1c89b83dd4 mkdep: avoid memory allocation in findcc
This change takes the idea of handling strings as pairs in the form
(start, len) by Robert Elz from
https://mail-index.netbsd.org/source-changes-d/2021/08/20/msg013427.html
and expands it by avoiding one more memory allocation, for iterating the
PATH environment variable.

No functional change.
2021-08-20 06:36:10 +00:00
rillig 9108d0c35f mkdep: make argument of findcc const
Previously, findcc modified its argument string, even though it had been
declared as 'const char *'.  This triggered a lint warning that "strchr
effectively discards 'const char *' from argument", in fact, this code
caused the lint check to be implemented in the first place.

The first attempt at fixing it by removing the 'const' from the
parameter type was a bad idea since it made the API of that function
more complicated.

Revert back to making the parameter a 'const char *' and duplicate that
string internally as necessary.  Add a few more tests for absolute
pathnames since these had been missing before.  There are no tests yet
for snprintf with too long strings, but the current change does not
modify that part of the code.
2021-08-20 05:45:19 +00:00
rillig e91fe367ea tests/mkdep: test findcc
This function is used by both mkdep and lint.
2021-08-11 20:42:26 +00:00