Commit Graph

171 Commits

Author SHA1 Message Date
Andriy Gapon
09606b760a make: report :M or :N pattern in debug mode
MFC after:	12 days
2012-10-06 19:19:32 +00:00
Dimitry Andric
30a845609c 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
2012-08-05 15:55:36 +00:00
David E. O'Brien
b3dc6c07e2 Add "-V '${VAR}'" variable expansion from Portable Berkeley Make.
Submitted by:	Simon Gerraty <sjg@juniper.net>
2012-05-31 00:36:56 +00:00
David E. O'Brien
d81f04d7fa 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>
2012-05-30 22:23:08 +00:00
Ulrich Spörlein
487ac9ac21 Spelling fixes for usr.bin/ 2011-12-30 11:02:40 +00:00
Xin LI
512be259a7 Remove unnecessary includes.
Reviewed by:	rodrigc
2009-12-11 23:20:02 +00:00
David E. O'Brien
fa600cb9ba 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.
2009-01-06 16:24:22 +00:00
David E. O'Brien
eee3404481 + 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.
2009-01-03 10:14:01 +00:00
David E. O'Brien
2cae2b7d30 VarAdd() already does the debug printing, so Var_Set() only needs to do it
in the case the var already exists.
2006-07-17 21:05:27 +00:00
Max Khon
99d3c2c46c Update comment about var modifiers (add 'N' and 'O' descriptions). 2006-04-08 07:02:39 +00:00
Max Khon
66b07418fa Add :u var modifier (remove adjacent duplicate words like uniq(1).
Reviewed by:	harti
Obtained from:	NetBSD (mostly)
2006-04-08 06:59:54 +00:00
Max Khon
7d81571413 - 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
2005-11-30 20:38:03 +00:00
Hartmut Brandt
527505d8cb The caller of Var_Value() should not change the variable value. Make
this clear by constifying the return value.

Obtained from:	DragonFlyBSD
2005-05-24 16:05:51 +00:00
Hartmut Brandt
19446efc06 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
2005-05-24 15:58:35 +00:00
Hartmut Brandt
87c7b797f0 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
2005-05-18 14:50:35 +00:00
Hartmut Brandt
1185781977 Replace a lot of Var_Set(..., VAR_GLOBAL) by Var_SetGlobal().
Submitted by:	Max Okumoto <okumoto@ucsd.edu> (7.237)
2005-05-12 14:47:22 +00:00
Hartmut Brandt
7594df85cf Move variable printing from main.c to var.c
Submitted by:	Max Okumoto <okumoto@ucsd.edu> (7.233)
2005-05-12 14:31:42 +00:00
Hartmut Brandt
0ec9b6feef Move some global variables to the correct files.
Submitted by:	Max Okumoto <okumoto@ucsd.edu> (7.232)
2005-05-12 11:58:39 +00:00
Hartmut Brandt
a139b7bac1 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>
2005-05-10 14:10:44 +00:00
Hartmut Brandt
c26295ddea 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>
2005-05-10 13:18:58 +00:00
Hartmut Brandt
671adc85da 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>
2005-05-10 12:02:15 +00:00
Hartmut Brandt
3b5ff5e82d Clean up comments. No code changes.
Patch:		7.195
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-05-10 11:55:46 +00:00
Hartmut Brandt
74369e814b 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>
2005-05-10 11:53:20 +00:00
Hartmut Brandt
70d7035e1f Move some debugging code from targ.c to var.c where it actually belongs.
Patch:		7.192
Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-05-10 08:14:26 +00:00
Hartmut Brandt
103823e628 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>
2005-05-10 08:06:13 +00:00
Hartmut Brandt
02c3270da1 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>
2005-05-09 14:06:04 +00:00
Hartmut Brandt
352a63dee8 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>
2005-05-06 18:30:06 +00:00
Hartmut Brandt
beed8bb5f6 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>
2005-04-13 11:40:44 +00:00
Hartmut Brandt
f43eb6f83b 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>
2005-03-30 15:14:22 +00:00
Hartmut Brandt
e4a90d00b4 Remove the last two instances of Lst_Find() calls. 2005-03-22 12:38:55 +00:00
Hartmut Brandt
144b68a7ef Use VarParse() inside var.c instead of Var_Parse().
Patch:		7.163

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-22 08:20:08 +00:00
Hartmut Brandt
6fd71d7a66 Unify callers to Var_Parse() with regard to variable names.
Patch:		7.162

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-22 08:18:15 +00:00
Hartmut Brandt
a4c193bbe2 Make some callers of VarFind using the same code structure.
Patch:		7.161

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-22 08:16:09 +00:00
Hartmut Brandt
29b59e2865 De-lispify some if()-expressions by removing extra parantheses.
Patch:		7.160
Requested by:	harti

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-22 08:12:16 +00:00
Hartmut Brandt
b6c44471ba 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>
2005-03-22 08:09:43 +00:00
Hartmut Brandt
ce873d22d5 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>
2005-03-22 08:06:34 +00:00
Hartmut Brandt
6edf648505 Merge struct VarREPattern into struct VarPattern. This will help sorting
out common code.

Patch:		7.156

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-22 08:03:42 +00:00
Hartmut Brandt
5af70720f4 Delete an extra empty line.
Patch:		7.153

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-22 07:57:18 +00:00
Hartmut Brandt
4896df6314 Simplify buffer access by using Buf_Data() and Buf_Peel() where
appropriate.

Patch:		7.147-7.151

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-22 07:50:40 +00:00
Hartmut Brandt
cffe7fcdef 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>
2005-03-22 07:38:46 +00:00
Hartmut Brandt
1610cab61d 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>
2005-03-21 12:40:27 +00:00
Hartmut Brandt
090051a931 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>
2005-03-21 12:32:41 +00:00
Hartmut Brandt
f244a9fb0a Split out SysV variable substitution into its own function.
Patch:		7.139

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-21 12:27:53 +00:00
Hartmut Brandt
a33399ac68 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>
2005-03-21 12:19:23 +00:00
Hartmut Brandt
6cb006aff1 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>
2005-03-21 12:17:44 +00:00
Hartmut Brandt
61cc000336 Cleanup the VAR_JUNK handling.
Patch:		7.136

Submitted by:	Max Okumoto <okumoto@ucsd.edu>
2005-03-21 12:15:06 +00:00
Hartmut Brandt
8f712e5034 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>
2005-03-21 12:07:14 +00:00
Hartmut Brandt
b072d12283 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>
2005-03-21 11:54:46 +00:00
Hartmut Brandt
0906b0904f 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>
2005-03-21 11:43:02 +00:00
Hartmut Brandt
73c5a04dfa 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>
2005-03-21 07:40:33 +00:00