Commit Graph

7 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
jmmv cdcce7d462 Add a new "-P prefix" option to mkdep(1).
This option prepends the string given in prefix to every target
filename.  This is useful for programs that have source files in
multiple subdirectories and a single Makefile that references all of
them explicitly (without using the VPATH functionality because there
can be files with the same name in each subdirectory).
2012-08-26 22:37:19 +00:00
njoly 6e845fb5bc mkdep(1) needs cc(1). Make testcase check for them. 2011-06-14 11:44:25 +00:00
njoly 15f57fb06f Adjust testcase for recent changes.
- suffixes output order is now reversed.
- remove expected failure for empty list.
2011-05-31 13:22:56 +00:00
njoly 3fa42f3842 Add testcase for PR bin/45004, to exercize suffixes lists for
mkdep(1).
2011-05-30 18:14:11 +00:00