Reduce the number of arguments passed between these functions by
creating a special-purpose struct.
Patch: 7.120,7.121
Submitted by: Max Okumoto <okumoto@ucsd.edu>
Rename result variable so common code becomes more visible.
Rename freePtr to freeResult to make clear what pointer must be freed.
Patch: 7.116, 7.116a
Submitted by: Max Okumoto <okumoto@ucsd.edu>
the loop. Add a comment why the 'consumed' variable is updated.
Rename lengthPtr to consumed.
Patch: 7.115
Submitted by: Max Okumoto <okumoto@ucsd.edu>
ParseRestModifier() and ParseRestEnd(): move advancement of ptr to remove
a confusing calculation.
VarParseLong(): cleanup calculation of consumed.
Patch: 7.114
Submitted by: Max Okumoto <okumoto@ucsd.edu>
actual variable lookup. Consistently rename lengthPtr to consumed.
Update a number of comments to match the code.
Patch: 7.111-113
Submitted by: Max Okumoto <okumoto@ucsd.edu>
that is now used for both the 'M'/'N' branch and the 'S' branch of
the switch statement into a common scope.
Patch: 7.102-105
Submitted by: Max Okumoto <okumoto@ucsd.edu>
paranthesis or brace) into the loop and don't leak the buffer in this
case. Remove the check for Var_Parse returning NULL - it can't.
Patch: 7.92
Submitted by: Max Okumoto <okumoto@ucsd.edu>
Return always malloc()-ed strings from VarParseShort() to get
rid of warnings when returning string constants from a non-const char *
function.
Patch: 7.90
Submitted by: Max Okumoto <okumoto@ucsd.edu>
to VarExpand down into the branches of the if as well as cleanup code.
Eliminate code that is now obviously dead.
Patch: 7.83
Submitted by: Max Okumoto <okumoto@ucsd.edu>
an else clause. Move the assignment to the lengthPtr down to
just before the return statements.
Patch: 7.81
Submitted by: Max Okumoto <okumoto@ucsd.edu>
functions: one for the single letter variables, one for the others
and one that does the recursive expansion.
Patches: 7.68-7.79
Submitted by: Max Okumoto <okumoto@ucsd.edu>
after a return. Move assignments to {freePtr, dynamic, start} closer to the
return statements to clarify which variables are actually used for
communication between the losely coupled blocks of the code. Clear up
an if-expression to make common structures of the conditions clearer.
Use strchr instead of switch statements to check for a character beeing
a member of a set.
Patches: 7-62.2, 7-62.3, 7-64, 7-65.1, 7-65.2
Submitted by: Max Okumoto <okumoto@ucsd.edu>
it is actually needed. This makes clear in which subblocks the variables
are not needed and which can easier be split out.
Submitted by: Max Okumoto <okumoto@ucsd.edu>
use a more consistent style with regard to *str and str[0];
simplify code by introducing a temporary variable;
shift a break around and add braces where appropriate.
Submitted by: Max Okumoto <okumoto@ucsd.edu>
Move some assignments nearer to where they actually used. Convert a loop
from a for() to a while() to make it clearer and add braces to the long
body of it. Split assignment from variable declaration.
Submitted by: Max Okumoto <okumoto@ucsd.edu>
parantheses. This helps editors to find its way through the horrible
mess of Var_Parse. Rewrite a for() loop into a while() to make it clearer.
Submitted by: Max Okumoto <okumoto@ucsd.edu>
itself. This will ease constification (think of what 'const Ptr foo'
means if Ptr is a pointer to a struct).
Submitted by: Max Okumoto <okumoto@ucsd.edu>
that get included just where they are needed. All headers include the
headers that they need to compile (just with an empty .c file). Sort
includes alphabetically where apropriate and fix some duplicate commenting
for struct Job, struct GNode and struct Shell by removing one version and
inlining the comments into the structure declaration (the comments have been
somewhat outdated).
This patch does not contain functional changes (checked with md5).
Submitted by: Max Okumoto <okumoto@ucsd.edu>
now that their size is only two pointers. This eliminates a lot of calls
to Lst_Init and from there to malloc together with many calls to
Lst_Destroy (in places where the list is obviously empty). This also
reduces the chance to leave a list uninitilized so we can remove more
NULL pointer checks and probably eliminates a couple of memory leaks.
requires to make a copy of the filename in ReadMakefile and to duplicate
two small functions in suff.c. This hopefully will go away when everything
is constified.
Submitted by: Max Okumoto <okumoto@ucsd.edu> (partly)
and the sizeof operator, missing empty lines, void casts, extra empty lines.
Checked by: diff on make *.o lst.lib/*.o
Submitted by: Max Okumoto <okumoto@soe.ucsd.edu> (partly)
the .MAKEFLAGS variable so that these are also passed to sub-makes.
This makes the handling of variables in the command environment more
consistent.
PR: bin/68853
Submitted by: Martin Kamerhofer <data@sbox.tugraz.at>
variable as required by POSIX. This causes such variables to be
pushed into all sub-makes called by the make (except when the MAKEFLAGS
variable is explicitely changed in the sub-make's environment).
This makes them also mostly un-overrideable in sub-makes except on the
sub-make's command line. Therefor specifying 'make CC=icc' will cause
icc to be used as C compiler in all sub-makes no matter what the Makefiles
itself try to do to the CC variable.
This patch also corrects the handling of the MFLAGS variable. MFLAGS
contains all the command line flags but not the command line variable
assignments. The evaluation of the .MFLAGS or .MAKEFLAGS target now
changes both MFLAGS and MAKEFLAGS (they used to change MAKEFLAGS only).
Makefiles can use MFLAGS for their own purposes given that they do not
except MFLAGS to be undefined at the beginning and that they don't evaluate
.MFLAGS or .MAKEFLAGS. MFLAGS should be removed for POSIX compliance,
but it is unfortunately heavily used by the X makefiles.
This has been extensively tested by port builds (thanks to portmgr), new
worlds and kernels.
PR: standards/57295 (1st part above)
Submitted by: James E. Flemer <jflemer@alum.rpi.edu>
Approved by: portmgr
Obtained from: NetBSD (1st part above)
MFC after: 4 weeks
variable. The implementation is based upon the patch sent to
arch@, but modified to be compatible with NetBSD. The modifier
that does a reverse sort has been dropped for now, but the
ability to add one later has been preserved.
string from a silent implicit non-global substitution to a non-silent
explicit fatal error. Archored substitutions are those containing '^'
or '$'.
The problem with changing the substitution to prevent an infinite
number of matches is that it doesn't provide the necessary feedback
to the user that there's a bug in the/a makefile. Reporting the bug
without making the condition fatal makes the feedback mostly useless
due to the way that make fails to prefix the error with program name,
makefile file name and line number information.
Note that global substitutions of the empty string anchored with '^'
(start of string) or '$' (end of string) do not cause an infinite
number of matches and are therefore not reported and hence are non-
fatal.
Suggested by: bde
Tested with: buildworld
global substitution. In general it's a makefile bug to globally
substitute the empty string, but it's a bug in make(1) if a bug
in the makefile yields an infinite running time of make(1).
Not objected to by: arch@
to Fatal errors, because the logic that we use to try to continue is far
too broken, and makes things look and act weird, because we end up pointing
past the end of a buffer boundry into freed memory in the caller, as we
don't come close to setting the lengthPtr to a sane value.
Reviewed by: make@
(This only changes failure cases which would have died horrid deaths to
explicit clean death failure cases.)
to var_modify.c, for readability. constify some low hanging fruit (string
manipulation functions) and the upper layers appropriately. No longer use
the private strstr(3) implementation, while changing string code.
Tested by: lots of successful make buildworld.
data that will be modified. And do the appropriate thing now and free the
v->name buffer along with other relinquished memory.
XXX There is duplication here of destroying a Var, which is probably bogus,
and probably missed in a few places.
documentation already adequatedly existed in the description in most
cases. Where it did not, it was added. If no documentation existed
beforehand, then none was added. Some unused dummies for use in the
traversal functions were marked as __unused during the conversion.
Occasionally, local style fixes were applied to lines already being
modified or influenced.
Now make(1) should always build with WARNS=3.
renaming variables to not shadow libc functions or greater scope locals. Kinda
makes one wonder if the extern ones weren't meant in some of these places :)
The only thing I'd still like to do WRT this is possibly combine rstat and
status in compat.c -- that should be fine, as I do not think the codepaths
will want both around at once.
Sponsored by: Bright Path Solutions
in compat.c which doesn't even have preprocessor-conditional-hidden support
code, and add a debugging statement where we might end up with a nil list
somehow, but where I doubt it.
First confirmed userland kill for Flexelint.
Sponsored by: Bright Path Solutions
variable length arguments to a macro. Bump version as this makes DEBUG
statements *always* go to stderr rather than sometimes stdout. There are
a few stragglers, which I will take care of as soon as I can. Mostly these
relate to the need-for-death-of some of the remote job code.
Nearby stylistic nits and XXX added/fixed where appropriate.
seen (somewhat) in NetBSD. This catches a few extra recursion cases that
could be hidden by expanding a NIL variable causing an existing variable to
be returned (which caused infinite looping and climbing memory usage in at
least one case).
Obtained from: NetBSD (in principle)
has been determined similar to C. That is, one expects a construction
like,
.if defined(TEST) && (${TEST:L} == "test")
Never to generate an error since the second expression should never be
evaluated when TEST is undefined.
However, this was not the case. The above fails with the current
make(1) if TEST is undefined. This patch fixes the above and many
similar cases.
PR: bin/34032
Submitted by: Alan Eldridge <alane@geeksrus.net>
MFC after: 1 week
This should not affect our build process, as
find /usr/src -name Makefile | xargs grep '@[DF]'
has no matches (other than FreeBSD.org email addresses :-)
PR: bin/24377
Submitted by: Mark Valentine <mark@thuvia.demon.co.uk>
Reviewed by: Matthew Emmerton <matt@gsicomp.on.ca>
MFC after: 4 weeks