History log of /freebsd-10-stable/usr.bin/make/var.c
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
# 256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation

# 241280 06-Oct-2012 avg

make: report :M or :N pattern in debug mode

MFC after: 12 days


# 239071 05-Aug-2012 dim

In usr.bin/make/var.c, function ParseModifier(), initialize the 'error'
variable to NULL, to avoid using it uninitialized in certain cases.

This fixes the following clang 3.2 warning:

usr.bin/make/var.c:1770:10: error: variable 'error' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized]
if (vp->execute) {
^~~~~~~~~~~
usr.bin/make/var.c:1777:10: note: uninitialized use occurs here
if (error)
^~~~~
usr.bin/make/var.c:1770:6: note: remove the 'if' if its condition is always true
if (vp->execute) {
^~~~~~~~~~~~~~~~~
usr.bin/make/var.c:1768:23: note: initialize the variable 'error' to silence this warning
const char *error;
^
= NULL

MFC after: 1 week


# 236346 30-May-2012 obrien

Add "-V '${VAR}'" variable expansion from Portable Berkeley Make.

Submitted by: Simon Gerraty <sjg@juniper.net>


# 236338 30-May-2012 obrien

Deprecate the FreeBSD make's ":U" (to-upper case) and ":L" (to-lower case)
modifiers for ":tu" and ":tl" from OSF's ODE, which made its way into
NetBSD's make, which is the source for the Portable Berkeley Make.

Submitted by: Simon Gerraty <sjg@juniper.net>


# 228992 30-Dec-2011 uqs

Spelling fixes for usr.bin/


# 200417 11-Dec-2009 delphij

Remove unnecessary includes.

Reviewed by: rodrigc


# 186831 06-Jan-2009 obrien

Note that r186713 also contained a change to VarAdd where we propagate the
newly created 'Var' back to the caller.
Also, back out an accidentally commented WIP comment.


# 186713 03-Jan-2009 obrien

+ Add the -Q be-quiet flag for parallel jobs.
- Enable -Q by default for the moment - there is something weird
going on in the rescue build.


# 160450 17-Jul-2006 obrien

VarAdd() already does the debug printing, so Var_Set() only needs to do it
in the case the var already exists.


# 157589 08-Apr-2006 fjoe

Update comment about var modifiers (add 'N' and 'O' descriptions).


# 157588 08-Apr-2006 fjoe

Add :u var modifier (remove adjacent duplicate words like uniq(1).

Reviewed by: harti
Obtained from: NetBSD (mostly)


# 152969 30-Nov-2005 fjoe

- match_var: do not address memory at invalid address (`len' can be greater
than strlen(var) + 1)
- ReadMakeFile: prevent `fname' memory leak
- ReadMakeFile: prevent double free (caused by double fclose) --
ParsePopInput() closes input file

Reviewed by: harti


# 146581 24-May-2005 harti

The caller of Var_Value() should not change the variable value. Make
this clear by constifying the return value.

Obtained from: DragonFlyBSD


# 146580 24-May-2005 harti

Get rid of the third argument to Var_Value() the pointer it pointed
to has always been set to NULL for some time now.

Obtained from: DragonFlyBSD


# 146345 18-May-2005 harti

Get rid of global variables for argument vectors produced by brk_string()
introduce a struct that holds all the information about an argument
vector and pass that around.

Author: Max Okumoto <okumoto@ucsd.edu>
Obtained from: DragonFlyBSD


# 146145 12-May-2005 harti

Replace a lot of Var_Set(..., VAR_GLOBAL) by Var_SetGlobal().

Submitted by: Max Okumoto <okumoto@ucsd.edu> (7.237)


# 146141 12-May-2005 harti

Move variable printing from main.c to var.c

Submitted by: Max Okumoto <okumoto@ucsd.edu> (7.233)


# 146134 12-May-2005 harti

Move some global variables to the correct files.

Submitted by: Max Okumoto <okumoto@ucsd.edu> (7.232)


# 146060 10-May-2005 harti

Move the remaining two prototypes from nonints.h to make.h and
remove nonints.h.

Patch: 7.204
Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 146054 10-May-2005 harti

Move Cmd_Exec() from main.c to job.c and fix its prototype. This
results in a warning that will go away soon.

Patch: 7.198
Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 146048 10-May-2005 harti

Var_SubstOnly() is only used to subsitute a variable from the global
context (and only in one place to substitute the .for variable). Therefor
there is no need to pass the context as a parameter.

Patch: 7.197
Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 146046 10-May-2005 harti

Clean up comments. No code changes.

Patch: 7.195
Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 146045 10-May-2005 harti

Merge var_modify.c into var.c and move types and function declarations
that are now used only in var.c from var.h to var.c

Patches: 7.193,7.194
Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 146039 10-May-2005 harti

Move some debugging code from targ.c to var.c where it actually belongs.

Patch: 7.192
Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 146038 10-May-2005 harti

Make make a little bit more POSIXish with regard to option parsing:
take everything after -- as either a macro assignment or a target.
Note that make still reorders arguments before --: anything starting
with a dash is considered an option, anything which contains an equal
sign is considered a macro assignment and everything else a target.
This still is not POSIX with regard to the options, but it will probably
not change because it has been make's behaviour for ages.
Add a new function Var_Match() that correctly skips a macro call by just
doing the same as Var_Subst() but without producing output. This will help
making the parser more robust.

Patches: 7.190,7.191
Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 146027 09-May-2005 harti

Split Var_Subst() into two functions: Var_SubstOnly() which substitutes
only one variable and Var_Subst() which substitutes all. Split out the
test whether a variable should not be expanded into match_var().
Make access to the input string consistently using str[]. Remove two
unused functions: Var_GetTail() and Var_GetHead().

Patches: 7.184-7.189
Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 145971 06-May-2005 harti

Introduce a new pseudo-target .EXPORTVAR which allows to put a
make macro into the environment of programs executed by make. This
has approximately the same function as gmake's export directive.
The form of a pseudo target was deliberately choosen to minimize work
for POSIX compatibility (Makefiles are not allowed to use any targets
starting with a dot and consisting only of uppercase letters except those
specified in the standard when they want POSIX compatible behaviour, so
such a Makefile can never contain .EXPORTVAR.)
Change the handling of macros coming from the environment: instead
of asking the environment for each variable we could not find otherwise
put all the environment variables in a special variable environment just
at start up.

This has been tested on the ports cluster by kris.

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 145007 13-Apr-2005 harti

Split VarFind() into a series of functions tailored for the different sets
of flags originally passed to VarFind(). This eliminates the code by
removing a bunch of tests.

Patch: 7.173

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 144340 30-Mar-2005 harti

Fix a bug introduced in a previous commit: ParseModifier() consumes
characters so it is not safe to move around code from
before it to after it. This should fix problems with building the
documentation.

Patch: 7.170

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143975 22-Mar-2005 harti

Remove the last two instances of Lst_Find() calls.


# 143970 22-Mar-2005 harti

Use VarParse() inside var.c instead of Var_Parse().

Patch: 7.163

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143969 22-Mar-2005 harti

Unify callers to Var_Parse() with regard to variable names.

Patch: 7.162

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143968 22-Mar-2005 harti

Make some callers of VarFind using the same code structure.

Patch: 7.161

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143967 22-Mar-2005 harti

De-lispify some if()-expressions by removing extra parantheses.

Patch: 7.160
Requested by: harti

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143966 22-Mar-2005 harti

Return a Buf object from VarGetPattern() instead of a char * and a size_t.
Store a Buf object in struct VarPattern instead of a char * and a length.

Patch: 7.158

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143965 22-Mar-2005 harti

Use the struct VarPattern's lhs field instead of using an extra variable
to store the left expression of a C modificator.

Patch: 7.157

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143964 22-Mar-2005 harti

Merge struct VarREPattern into struct VarPattern. This will help sorting
out common code.

Patch: 7.156

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143961 22-Mar-2005 harti

Delete an extra empty line.

Patch: 7.153

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143959 22-Mar-2005 harti

Simplify buffer access by using Buf_Data() and Buf_Peel() where
appropriate.

Patch: 7.147-7.151

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143955 22-Mar-2005 harti

Remove a temporary variable. Rename pattern to patt to be consistent.
Remove unreachable code for VAR_NOSUBST - it was never set.
Replace redundant code with calls to VarGetPattern().

Patch: 7.143-7.145

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143920 21-Mar-2005 harti

Remove unneeded temporary variables in modifier_S() and modifier_C().
Change the parsing of the C modifier flags so that specifying both
'1' and 'g' gives an error.

Patch: 7.141,7.142

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143919 21-Mar-2005 harti

Remove comment about Var_Parse assuming that the first character
is always a '$'. This is not always correct, for example for
conditionals: .if defined(foobar).

Clean up some comments.

Move common code out of if-statements.

Patch: 7.140

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143918 21-Mar-2005 harti

Split out SysV variable substitution into its own function.

Patch: 7.139

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143917 21-Mar-2005 harti

Rename freePtr to freeResult to make it more obvious about what
pointer we're talking.

Patch: 7.138

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143916 21-Mar-2005 harti

Move some code from ParseModifier() into the calling function to
simplify things. Correct a number comments.

Patch: 7.137

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143915 21-Mar-2005 harti

Cleanup the VAR_JUNK handling.

Patch: 7.136

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143914 21-Mar-2005 harti

Don't pass 'consumed' through all the parsing routines where it can be computed
by the caller. Don't pass 'endc' - it can be computed from 'startc'.
Remove unneccessary temporary variables. Remove constant if-expressions
and remove code before call Fatal() - there is no point to cleanup before
aborting.

Patch: 7.134,7.135

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143913 21-Mar-2005 harti

Change one occurence of 'delim' to the correct type. Delete another
occurence which actually holds always the same constant value.
Shorten the name pattern to patt.

Patch: 7.133

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143910 21-Mar-2005 harti

Reduce number of parameters passed between the parsing routines
by putting them into struct VarParser or computing them (consumed).
Change the loop termination condition in VarParseLong from endc to \0.

Patch: 7.128-7.132

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143904 21-Mar-2005 harti

Reduce the number of explicit parameters passed to VarParse()
by passing them through struct VarParser.

Patch: 7.127

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143816 18-Mar-2005 harti

Cleanup handling of colons in variable substitutions.

Patch: 7.126

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143814 18-Mar-2005 harti

Unfold parsing of single letter modifiers from multi-letter ones.

Patch: 7.125

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143813 18-Mar-2005 harti

Style: fix indentation and <space><tab>.

Patch: 7.124

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143812 18-Mar-2005 harti

Split out the 'S' modifier into its own function.

Patch: 7.122,7.123

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143811 18-Mar-2005 harti

Convert Var_Parse to a wrapper function.
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>


# 143656 15-Mar-2005 harti

modifier_M: instead of going through the string twice to compute the
size of the buffer we need, just allocate the possible maximum.

Patch: 7.117

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143653 15-Mar-2005 harti

Style: Move a variable from a local scope up to the begin of the function.
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>


# 143649 15-Mar-2005 harti

VarParseLong: move the detection of the modifier separator ':' into
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>


# 143599 14-Mar-2005 harti

ParseModifier(): rename rw_str to value and reindent cleanup section.
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>


# 143566 14-Mar-2005 harti

Split off two function from VarParseLong to handle modifiers and the
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>


# 143377 10-Mar-2005 harti

Constify Var_Dump and simplify it by inlining VarPrintVar.


# 143276 08-Mar-2005 harti

Finish constification of Var_Parse() and Var_Subst().

Patch: 0.18, 0.8, 7.110

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143255 07-Mar-2005 harti

Constify the callers of brk_string in this file.

Patch: 7.108

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143254 07-Mar-2005 harti

Style: fix indendation of VarModify().

Patch: 7.107

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143252 07-Mar-2005 harti

Factor out the 'S' modifier into its own function. Move a variable
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>


# 143240 07-Mar-2005 harti

Move the 'M' and 'N' modifiers into their own function.

Patch: 7.101

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143104 03-Mar-2005 harti

Constify the code paths for the 'M' and 'N' modifiers.

Patch: 7.100

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143097 03-Mar-2005 harti

Transform VarParseLong() so that the lifetime and the constness of
variables gets clearer. Transform if() conditions to make the flow
clearer.

Patch: 7.93-99

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143040 02-Mar-2005 harti

Move the check for the error case (variable ends without a closing
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>


# 143037 02-Mar-2005 harti

Fix indentation on a block of code.

Patch: 7.91

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 143036 02-Mar-2005 harti

Push the length computation down into VarParseShort().
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>


# 142937 01-Mar-2005 harti

Make sure the length variable is initialized to 0 before passing
it to Var_Parse().

Patch: 7.85

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 142910 01-Mar-2005 harti

Split out ParseModifiers from VarParseLong.

Patch: 7.84
Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 142908 01-Mar-2005 harti

VarParseLong: Create new else block for haveModifier. Move the call
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>


# 142881 01-Mar-2005 harti

Reverse a condition so that the else clause can be changed
to a fallthrough.

Patch: 7.82

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 142809 28-Feb-2005 harti

VarParseLong: Move the initialisation of dynamic up which saves
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>


# 142796 28-Feb-2005 harti

Don't modify the input string in VarParseLong(). It is not
necessary to NUL-terminated it, because we know the lengths
from the pointers.

Patch: 7.80

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 142557 26-Feb-2005 harti

Major clean up and split the Var_Parse monster function into three
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>


# 142457 25-Feb-2005 harti

Change the return value of Var_Subst to return a Buffer instead
of a char *.

Patch: 7.49

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 142382 24-Feb-2005 harti

Var_Parse: Separate different error states by introducing an else block
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>


# 142377 24-Feb-2005 harti

Push assignments to just before the returns from the function to
get it clearer what variables are actually needed.

Patches: 7.62.2, 7.62.3
Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 142376 24-Feb-2005 harti

Fix wording of a comment.

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 142166 21-Feb-2005 harti

Forgot to set *freePtr to FALSE in another place.

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 142044 18-Feb-2005 harti

Push the assignments of some variables down into the sub-blocks where
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>


# 142038 18-Feb-2005 harti

Push down variables into local scope in Var_Parse to make their
liveness clear for splitting up this monster function.

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 142014 17-Feb-2005 harti

Whitespace cleanup: substitute mixed tabs and spaces by canonical
whitespace and line up some variable definitions.


# 142013 17-Feb-2005 harti

Move error case to begin of if-else chain. Do not needless initialize
startc, but only at the place where the initialisation is needed. Remove
a needless else.

Submitted by: Max Okumoto <okumoto@ucsd.edu> (partly)


# 142007 17-Feb-2005 harti

Sort out the error case that a single '$' was passed a little bit
earlier instead of mixing its handling with other cases.

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 141686 11-Feb-2005 harti

Convert several instances of negative logic to positive logic.

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 141661 10-Feb-2005 harti

Buffers are already NUL-terminated so there is no need to explicitely add
a NULL.

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 141659 10-Feb-2005 harti

Mostly stylistic nits in preparation for splitting up Var_Parse:
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>


# 141654 10-Feb-2005 harti

Let the buffer just use the default size by specifying 0 as the size
instead of specifying the default size explicitely.

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 141653 10-Feb-2005 harti

Mark the modification of the input string (which should really be const)
with a comment.

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 141652 10-Feb-2005 harti

Style nits:
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>


# 141650 10-Feb-2005 harti

Describe a pre-condition of Var_Parse().

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 141649 10-Feb-2005 harti

Remove a comment that's not actual anymore.

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 141648 10-Feb-2005 harti

Fix spacing by converting mixes of space and tab to tab. Also add a number
of empty lines in appropriate places.

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 141583 09-Feb-2005 harti

Use defines for character constants for open and closing braces and
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>


# 141572 09-Feb-2005 harti

Untangle VarFind and, while rewriting most of the function, fix the
intendation. (A large part of the function was already at intendation 8).


# 141564 09-Feb-2005 harti

Introduce VarCreate and VarDestroy functions and used them where
appropriate.

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 141461 07-Feb-2005 harti

Remove an unneeded check.


# 141460 07-Feb-2005 harti

Introduce a typedef for variable value modifation functions and use it
where appropriate.

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 141459 07-Feb-2005 harti

Make the intention of a loop clearer.

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 141454 07-Feb-2005 harti

Introduce Buf_StripNewLines() and use it where appropriate.

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 141437 07-Feb-2005 harti

Invent a Buf_AppendRange function that appends a non-NUL-terminated string
given by a pointer to the start of the string and a pointer one behind
the end.

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 141436 07-Feb-2005 harti

Invent a Buf_Append function to append a NUL-terminated string
and use it thoughout the code.

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 141275 04-Feb-2005 harti

None of the users of Buf_Discard used it to get rid of only a part of
the buffer. So replace Buf_Discard by Buf_Clear which just gets rid
of the entire contents.

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 141270 04-Feb-2005 harti

General whitespace cleanup: remove mixes of tabs and spaces, remove
space after function names, remove spaces on emtpy lines.

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 141268 04-Feb-2005 harti

Further constification. Use a temporary hack (copying the input string)
until Var_Subst is fixed.

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 141260 04-Feb-2005 harti

Use an extra variable to assign to instead of missusing an input
parameter. This will help in constification.

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 141252 04-Feb-2005 harti

Some more easy constification.

Submitted by: Max Okumoto <okumoto@ucsd.edu>


# 141133 02-Feb-2005 harti

Convert several typedefs from beeing pointers to structs to be the structs
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>


# 141104 01-Feb-2005 harti

Clean up include files and file including. Split nonints.h into pieces
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>


# 138972 17-Dec-2004 harti

Remove all the cleanup functions. There is no reason to free memory
just before exiting (especially given the number of memory leaks) -
it just costs time.


# 138916 16-Dec-2004 harti

Instead of dynamically allocating list heads allocated them statically
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.


# 138656 10-Dec-2004 harti

Remove a list that was just used to free all variables just before exiting.


# 138561 08-Dec-2004 harti

Constify the arguments to the list compare function. This temporarily
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)


# 138512 07-Dec-2004 harti

Typedefs of pointers to structs are evil. Make Lst and LstNode typedef of
the structs itself not of pointers to them. This will simplify constification.

Checked by: diff on the object files


# 138510 07-Dec-2004 harti

Make needs no circular lists so remove them from the list code.


# 138346 03-Dec-2004 harti

Fix breakage introduced on 64-bit platforms with my last commit. Need
to change to size_t in a couple of other places too.


# 138343 03-Dec-2004 harti

Plug a memory leak.


# 138264 01-Dec-2004 harti

Style: remove a lot of unnecessary casts, add some and spell the null
pointer constant as NULL.

Checked by: diff -r on the object files before and after


# 138232 30-Nov-2004 harti

Stylification: missing spaces, extra space after function names, casts
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)


# 133562 12-Aug-2004 harti

Put variable assignments on .MAKEFLAGS and .MFLAGS targets into
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>


# 133085 03-Aug-2004 harti

Put variable assignments from the command line into the MAKEFLAGS
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


# 124420 12-Jan-2004 harti

Allow variable substitutions in SYSV variable substitutions like
$(SRC:.c=$O). This brings us closer to other makes.

Reviewed by: ru
Obtained from: NetBSD


# 124344 10-Jan-2004 ru

Moved the code for :U and :L modifiers where it belongs, so that
the fallback for SysV (now in POSIX) variable substitution works
for old_string arguments starting with 'U' or 'L'.


# 120859 06-Oct-2003 ru

Fix a bug in variable parsing code that could cause a segfault.

PR: bin/46203
Submitted by: Stefan Farfeleder <stefan@fafoe.dyndns.org>


# 120184 18-Sep-2003 marcel

Implement the O modifier. The O modifier sorts the words in a
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.


# 109337 15-Jan-2003 marcel

Change the handling of non-anchored global substitutions of the empty
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


# 109209 13-Jan-2003 marcel

Prevent infinite substitution of the empty string by forcing non-
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@


# 106642 08-Nov-2002 jmallett

Convert some broken cases where Error is called, but we try to continue,
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.)


# 106106 28-Oct-2002 jmallett

Split var.c into var.c and var_modify.c and move all the modification funcs
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.


# 105895 24-Oct-2002 jmallett

Fix problem with my ability to tell the difference between 'r' and 'l'... We
want to check var[1], not val[1].

Submitted by: Mark Valentine <mark@thuvia.demon.co.uk>
Pointed out by: sam
Pointy hat to: jmallett


# 105865 24-Oct-2002 jmallett

When expanding a specific [1-char] variable, only expand said specific
[1-char] variable. Don't just automatically expand something which
starts with that character.

Obtained from: OpenBSD [3 years ago!]


# 105846 24-Oct-2002 jmallett

Duplicate the variable name in the v->name field, as otherwise it points to
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.


# 104696 09-Oct-2002 jmallett

Convert make(1) to use ANSI style function declarations. Variable
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.


# 104121 28-Sep-2002 jmallett

Make make(1) WARNS=6 clean except for const issues. This mostly involves
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


# 104108 28-Sep-2002 jmallett

Add empty default cases where they should be, remove non-local execution stuff
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


# 103545 18-Sep-2002 jmallett

Make the DEBUGF() macro portable by (ugh) adding a Debug() function, which
is merely printf() but to stderr. This takes care of the caveat which lead
to the use of a vararg macro -- getting everything to stderr.


# 103508 17-Sep-2002 jmallett

Move common use of if (DEBUG(FOO)) printf... to DEBUGF(FOO, ...), using
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.


# 103503 17-Sep-2002 jmallett

#define<space> -> #define<tab>


# 103502 17-Sep-2002 jmallett

Print debugging from DEBUG(VAR) level to stderr. About to macroise this.
(Read: More commits to come).

MFC in: 4 days.


# 98441 19-Jun-2002 jmallett

Fix a memory leak from previous commit by freeing the possibly expanded
string at the first opportunity, being sure to now always allocate the
new string from VarPossiblyExpand. Oops.


# 98439 19-Jun-2002 jmallett

Possibly expand the variable name's embedded variables before using it, as
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)


# 94587 13-Apr-2002 obrien

Update SCM ID method.


# 94584 13-Apr-2002 obrien

De'register.


# 92921 21-Mar-2002 imp

remove __P


# 90965 20-Feb-2002 cjc

make(1) claims to ignore the remainder of a conditional once its value
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


# 89282 12-Jan-2002 schweikh

Make substitutions in internal macros like $(@F:.o=.c) work.
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


# 69531 02-Dec-2000 will

There's also no point in #typedef'ing void/char pointers. Accordingly,
rip out ClientData/Address pointers and use standard types.

Obtained from: OpenBSD


# 69527 02-Dec-2000 will

There's no reason to use fancy forms of NULL. Replace all instances
of NIL, NILLST, NILLGNODE, etc. with NULL.

Obtained from: OpenBSD


# 66854 09-Oct-2000 will

Add :L and :U variable modifiers. These convert the variable's value to
all-lower or all-upper case characters, respectively. These were added
to further reduce differences between NetBSD/OpenBSD and FreeBSD make(1)
to propagate OpenPackages.

PR: 19959
Submitted by: Gaspar Chilingarav <nm@web.am>


# 66853 09-Oct-2000 will

Add :C/// variable modifier, which is similar to :S/// in functionality
but allows for regex. I removed NO_REGEX since no one could give a reason
to have it, and since we don't use make in bootstrap tools, it's not needed.

This is mostly added to synch up with NetBSD/OpenBSD so as to eliminate
roadblocks in the OpenPackages project (see http://www.openpackages.org/).
It's also quite useful, and costs us only about 3 kilobytes of space.

PR: 21605
Submitted by: Hubert Feyrer <hubertf@NetBSD.org>
Reviewed by: silence on -arch
Obtained from: NetBSD


# 62833 09-Jul-2000 wsanchez

Use __RCSID()


# 51150 11-Sep-1999 hoek

Unduplicate IDs from comments, do $Id -> $FreeBSD$ (submitted-by: bde)


# 50477 27-Aug-1999 peter

$Id$ -> $FreeBSD$


# 49938 16-Aug-1999 hoek

Merge style- and trivial- only changes from OpenBSD (dated 1999/07/29-19:55+1).

Obtained from: OpenBSD, sometimes indirected from NetBSD; myself


# 49332 31-Jul-1999 hoek

Add a -E flag, similar to -e (overide variables from environment) except
that -E only operates for a specified variable. Useful since the -e option
will often pull-in many unwanted variable overrides (esp. in a make world
situation). Uses include overriding BINOWN (which cannot be done by normal
methods or through abuses of MAKEFLAGS) or likely for ports to honour CFLAGS
(provided they're running on a system whose make(1) has this option).


# 45806 19-Apr-1999 imp

Add :Q to quote variable expansion to all proper expansion of
variables for recursive makes. This makes it less painful to cross
build recent NetBSD kernels on FreeBSD.

Obtained from: NetBSD


# 36588 02-Jun-1998 thepish

PR: bin/6828
Submitted by: njs3@doc.ic.ac.uk
Obtained from: NetBSD

Implement embedded variable expansion


# 29957 29-Sep-1997 imp

Add #include <stdlib.h> to pick up prototypes for getenv and friends.


# 23006 22-Feb-1997 peter

Revert $FreeBSD$ to $Id$


# 21673 14-Jan-1997 jkh

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


# 18804 08-Oct-1996 steve

O' to be bitten by CVS. Cleanup after import
of Christos' version of make(1) and add Id's.

Set straight by: Bruce Evans and Peter Wemm :)


# 18730 06-Oct-1996 steve

Merge in NetBSD's changes to make(1). Changes include:

- Add the .PHONY, .PARALLEL, and .WAIT directives
- Added the -B and -m commandline flags
- misc. man page cleanups
- numerous job-related enhancements
- removed unused header file (bit.h)
- add util.c for functions not found in other envs.
- and a few coordinated whitespace changes

Special thanks to Christos Zoulas <christos@netbsd.org>
for help in the merge. A 'diff -ur' between Net and
FreeBSD now only contains sccsid-related diffs. :)

Obtained from: NetBSD, christos@netbsd.org, and me


# 11997 01-Nov-1995 adam

Fix the :S modifier to substitute in each word of the variable, according
to the description in the manpage. g flag means "replace every occurence
in each word", and its absence means "replace first occurence in each word".
Previously, absence of the g flag was implemented to mean "replace first
occurence found in all words, and then stop replacing", which was incorrect.


# 9254 18-Jun-1995 ache

NetBSD fixes: declare more prototypes, move .OPTIONAL in alphabet
order, prevent suffix rule, if direct or children dependances exists,
forget to free v->name in var.c
My fixes: fix famous ^\t\n bug, correct free order in str_end
Reviewed by: bde
Obtained from: NetBSD, me


# 8874 30-May-1995 rgrimes

Remove trailing whitespace.


# 5814 23-Jan-1995 jkh

Bring in a number of changes from NetBSD's make, fixing quite a few
problems in the process:

1. Quoting should work properly now. In particular, Chet's reported bash
make problem has gone away.
2. A lot of memory that just wasn't being free'd after use is now freed.
This should cause make to take up a LOT less memory when dealing with
archive targets.
3. Give proper credit to Adam de Boor in a number of files.
Obtained from: NetBSD (and Adam de Boor)


# 1591 27-May-1994 rgrimes

This commit was generated by cvs2svn to compensate for changes in r1590,
which included commits to RCS files with non-trunk default branches.


# 1590 27-May-1994 rgrimes

BSD 4.4 Lite Usr.bin Sources