Commit Graph

82 Commits

Author SHA1 Message Date
jmc 89996408fa Fixes from PR#23210 to eliminate use of asprintf which makes cross building
on non-NetBSD hosts work again
2003-10-23 15:58:29 +00:00
sjg d388dcd1a3 Implement :[] modifier to allow picking a range of words out of a variable.
Also :tW and a W flag to :C and :S to allow treating value as a single word.
Add unit tests for the above, and fix some corner cases.
Based on patches supplied by Alan Barrett <apb@cequrux.com>
2003-09-27 21:29:37 +00:00
agc 89aaa1bb64 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22365, verified by myself.
2003-08-07 11:13:06 +00:00
scw bc25d2ab5f Const poisoning. 2003-07-31 13:48:11 +00:00
sjg 82cba16bce A couple of other places where delim should be set 2003-07-29 09:06:29 +00:00
sjg b806b12f2d First bug picked up by the unit tests - delim wasn't always initialized.
Avoid putting '\' in test case script lines since shell's like that on
SunOS insist on interpreting them.
2003-07-29 08:44:41 +00:00
sjg db7ca3c993 Fix parsing bug for :ts - patch from Alan Barrett <apb@cequrux.com>
Also add simple unit-test jig (regress/usr.bin/make will use it too)
but having it local here makes inclusion in bmake simpler.
2003-07-28 22:52:10 +00:00
sjg 59b1f67a11 Fix merge problem with ts modifier and const correctness.
Need to pass nstr to VarModify.
2003-07-23 18:06:46 +00:00
sjg f1cf540a8d Add a :ts[c] modifier to allow controlling the separator used between
words in a variable expansion.  If 'c' is omitted no separator is used.
2003-07-14 20:39:20 +00:00
christos 6a7d20bb25 Pass WARNS=3 2003-07-14 18:19:11 +00:00
christos 11dc6dfd26 PR/19781: Thomas Klausner: make error message not helpful on unclosed ${var:foo 2003-05-22 18:20:10 +00:00
thorpej c5007c219b Add a -X option, which prevents make(1) from putting variables
set on the command line into the environment individually.  This
can be useful on systems which have a tight limit on the size
of the argument space.
2003-03-14 05:19:43 +00:00
wiz 86ebbc3a0e Remove !__STDC__ stuff, de-__P(), ANSIfy, and de-register. 2002-06-15 18:24:55 +00:00
christos a7ffc9ca78 don't print extra newlines on errors. 2002-03-21 01:24:43 +00:00
pk 086b942780 Add `tu' and `tl' variable expansion modifiers, which transform the
value to uppercase and lowercase, respectively. From Kevin Neal from FreeBSD.
2002-02-06 16:26:12 +00:00
reinoud a233fbd53e Fix major bug in make(1) ... due to shadowing of the dotLast path used for
the .DOTLAST primitive by a boolean variable with the same name, this whole
mechanism was broken ... it doesn't save much stat calls but it was wrong.

Thanks to Jason Thorpe for the other shadow-variable fixing patches he
made.
2002-01-27 01:50:54 +00:00
lukem a269984793 - partially fix ${foo:?true:false} so that at least it now parses ok and
the true result works. for some reason the false result doesn't, even
  though make -dv shows it being set as the result. (blah!)
- add braces in comments to fix vi showmatch
2001-12-25 14:50:36 +00:00
sjg e28cc22621 Add 4th arg (flags) to Var_Set so that VarLoopExpand can tell it not
to export interator variables when using context VAR_CMD.

Reviewed: christos
2001-06-12 23:36:17 +00:00
sjg fc0df160d8 Simplify the exporting of VAR_CMD's via MAKEFLAGS.
We now just list the names of such variables in .MAKEOVERRIDES.
When we come to export MAKEFLAGS we quote the value of each exported variable
using :Q, using: ${.MAKEOVERRIDES:O:u:@v@$v=${$v:Q}@}
The :O:u suppresses duplicate names.
Also modifed Parse_DoVar to re-export MAKEFLAGS whenever .MAKEOVERRIDES
is assigned to so .MAKEOVERRIDES+= PATH will export PATH=${PATH:Q}
to the environment, while .MAKEOVERRIDES= will disable export of VAR_CMD's.
2001-06-10 02:31:00 +00:00
sjg d7c22ce2d7 Do a better job of duplicate suppression in .MAKEOVERRIDES.
From Var_Set: We actually want the equivalent of
.MAKEOVERRIDES:= ${.MAKEOVERRIDES:Nname=*} name='val'
clearing the previous value for name is important, since
doing simple duplicate suppression does not handle:
$ make FOO=goo
which then runs a sub-make with FOO=boo
the commands from that sub-make should see just FOO=boo.
2001-06-09 05:57:31 +00:00
sjg 44372a7be4 Modify handling of command line variable assignments and their exporting
via MAKEFLAGS.  Instead of appending them directly to .MAKEFLAGS, put
them in .MAKEOVERRIDES (and ensure they are quoted).  This is now done
in Var_Set when it exports VAR_CMD's.
Use ExportMAKEFLAGS() to export MAKEFLAGS, using the combined content
of .MAKEFLAGS and .MAKEOVERRIDES (with duplicate supression).
If .MAKEFLAGS is assigned to in a Makefile, ExportMAKEFLAGS is called again.
This allows a line like:
.MAKEOVERRIDES=
to effectively stop the exporting of the command line vars in MAKEFLAGS.
2001-06-09 05:22:47 +00:00
explorer 4b9b13c33f Perform variable expansion on sysv rhs patterns. That is, expand ${O} in: ${SRCS:.c=.${O}} 2001-06-05 06:00:39 +00:00
sjg 9cfd89292b A number of semi-related changes.
1. make -dx turns on DEBUG_SHELL which causes sh -x to be used where
   possible.
2. PrintOnError() is now called when make is stopping due to an error.
   This routine reports the curdir and the value of any variables listed
   in MAKE_PRINT_VAR_ON_ERROR.
3. Variables set via command line, are propagated to child-makes via
   MAKEFLAGS.  This behaviour appears to be necessary for POSIX (according
   to the GNU folk anyway).
4. Do not reset MAKEFILE when reading ".depend" as this rather eliminates the
   usefulness of ${MAKEFILE}.
5. Added ${.newline} as a simple means of being able to include \n in the
   result of a :@ loop expansion.
6. Set ${MAKE_VERSION} if defined.  Need to come up with a useful value.

Reviewed: christos
2001-06-01 20:33:37 +00:00
sjg 843e9049af Modifier :P avoid segfault if gn is found but path is NULL. 2001-05-12 06:48:49 +00:00
itojun 6924e04336 redo of previous: do not destroy v->val if str points to v->val.
XXX GC of v->val
2001-03-10 00:41:48 +00:00
itojun 4679105873 correct case with VAR_KEEP. if clause checked VAR_KEEP backwards,
and made str a dangling pointer.
2001-03-09 12:49:05 +00:00
christos 89d34c0b70 fixed comment U -> u 2000-09-05 21:08:35 +00:00
christos 73e15c3ea3 :u modifier a'la uniq(1) [from der Mouse] 2000-09-05 17:57:52 +00:00
christos a9e7fd9028 don't attempt to free varNoError too. 2000-08-13 22:47:01 +00:00
sjg 70fc6bfcaf no need for v->name-- on JUNK vars anymore 2000-06-10 05:54:29 +00:00
mycroft b0d51d4783 For VAR_JUNK variables, defer freeing of the name string until the bottom of
Var_Parse(), as it may be used (strdup()ed) by some modifiers.
2000-06-10 04:51:00 +00:00
sjg 5d93c6ecfd Don't free v until after the last use. 2000-06-10 04:17:58 +00:00
mycroft 6bf47769cb Do some evil with VAR_KEEP to make it happier. This seems... wrong. 2000-06-06 09:00:49 +00:00
mycroft 39bf056eb6 Allow further patterns after a :D or :U, as in ODE make. (Copied some code
from VarGetPattern.  It should become more flexible instead.)
2000-06-06 08:44:57 +00:00
mycroft 123757193a Roll back my for-expansion changes. Doing this right is just too hard to be
worth it.
2000-06-06 04:56:52 +00:00
sjg 2293fdd17b Make ::= work again with the VAR_FOR context changes. 2000-06-01 09:39:02 +00:00
mycroft ea218bb6e9 Create a `for' context, and substitute iteration variable from it using the
normal Var_Parse() path.  This allows :R, etc. to work on iteration variables.
2000-06-01 04:16:39 +00:00
sjg cd8908a299 Rats! ${FOO:=bar} is a common usage of the SysV = modifier.
To avoid that, we now do ::[+?!]*= but the SysV = modifier can
conflict with any new modifier.  At there are currently no Makefiles
in our tree that use ${FOO::=bar}
2000-06-01 02:29:21 +00:00
sjg 339f702f71 Implemented a set of assignment modifiers. These solve obscure
problems such as using modifiers on .for loop iterators derived from
local variables (eg .TARGET).
Unless the variable already exists in a global context, these assignments are
local to the current context (this is usually what is wanted).
2000-05-30 02:32:21 +00:00
sjg 489a59f8c6 Expand variables that appear in a [No]Match pattern. Allows
[ x${DONE:M${.TARGET}} != x ] || blah
2000-05-14 15:14:41 +00:00
sjg edfc5b4270 Expand variables in variable name passed to Var_Set and Var_Append.
This allows ${FOO}.bar=fubar etc to work.
This does not impact any Makefiles in the current tree but allows
some cool magic (which I need elsewhere).
2000-05-11 07:43:42 +00:00
sjg 0051977fda Pass ctxt along to VarLoopExpand so that local variables such as .TARGET
can be expanded.
2000-05-11 03:32:56 +00:00
sjg 5fe132c5cb Added the :U :D :L :P :! and :@ modifiers as used by ODE make.
These allow some very useful magic in the makefiles.
The comment in var.c describing their behaviour is mostly lifted
from ODE make, but the implementation of the modifiers themselves
is quite different (much simpler) due to divergence of our code base.
2000-04-29 12:18:52 +00:00
christos 94c2d86134 Don't type && when you mean || (pointed out by David Holland) 2000-04-17 14:59:02 +00:00
christos 13a6d6acf1 PR/9898: David Holland: small glitch in var substitution for single letter
variables.
2000-04-16 23:35:16 +00:00
sommerfeld bcb141e5d0 Reuse the Hash_Entry `name' field to store the variable name when we
can (i.e., everything except environment variables, which aren't
stored in hash tables).

While we're here, inline the body of VarDelete into Var_Delete since
it's the only caller and it's just simpler that way when v->name can
share storage with the hash entry and may not need to be freed
separately.

Speeds up the infamous libc build benchhmark maybe 1% on PIII, 4% on
alpha pc164

Suggested by Perry Metzger.
1999-09-15 22:51:05 +00:00
mycroft d2ec8b0e26 Replace the linear variable list in the GNode with a hash table. Gives a
small (~10% on my machine) speedup building libc.
Changes by: perry (+ bug fix and minor change by me)
Reviewed by: mycroft sommerfeld
1999-09-15 02:56:34 +00:00
christos ab01074993 Add :O var modifier, that sorts the words in a variable. 1999-09-12 00:17:50 +00:00
christos eee5bfa70d Revert previous change. I am a bonehead. 1999-06-06 21:16:23 +00:00
christos 9081585e9b remove accidentally left debugging code 1999-06-06 20:41:04 +00:00