Commit Graph

53 Commits

Author SHA1 Message Date
riastradh eeadb7df8c Clarify that assignment is for effect, not truth of value.
CID 977502
2017-04-16 21:04:44 +00:00
christos 4d0b1055db Collapse the 3 boolean parameter to 1 flags parameter. No functional change. 2016-02-18 18:29:14 +00:00
christos 9487d441fb Preserve $$ in := assignments..
FOO=\$$CRAP
BAR:=${FOO}

all:
	echo ${FOO}
	echo ${BAR}
2016-01-09 00:55:17 +00:00
sjg df0424202d Add Boolean wantit to Var_Parse and Var_Subst
wantit will be FALSE when we are just consuming to discard
in which case we skip "expensive" things like Cmd_Exec.

Reviewed by: christos
2015-10-11 04:51:24 +00:00
sjg 81320ffe8e Handle "quoted strings" as items in a .for list 2012-06-03 04:29:40 +00:00
dholland 3f9d98c828 Begin cleanup of the make parser: separate out the logic for reading files
from the parsing goo. This will now use mmap for reading if it works and
fall back to read only for pipes and such. Step 1 of a cleanup program
proposed without objection on tech-toolchain.
2010-12-25 04:57:07 +00:00
dholland 607923e4ca Improve the error message that results when you have a multi-variable .for
and the substitution list doesn't divide evenly.
2010-02-06 20:37:13 +00:00
dsl 462d090d0f Change 'Buffer' so that it is the actual struct, not a pointer to it.
Saves having to malloc/free a fixed size structure.
Buf_Init() now takes ptr to Buffer to initialiase.
Change Buf_Destroy() to return ptr to string when not freed.
Remove large number of casts to (Byte) and (Byte *) - 'Byte' is 'char' here.
Buf_AddByte[s] guarantees that the data is 0 termininated, so never add '\0'.
Keep 'count' not 'left' and 'inPtr', code is simplier with only one update.
Fix fallou, no functional change.
2009-01-17 13:29:37 +00:00
dsl ac3b504aef Contrary to my previous thoughts, .for loop variable values do contain
variable references - eg ${.TARGET} since that can't be expanded earlier.
Also the variable gets re-expanded before modifiers are applied.
All this means that we do need to let :U expand variables and must not
just escape $.
2009-01-14 22:54:10 +00:00
dsl be588a30bc When substituting .for control variables (as ${:U...}) escape '$' and '\'
as well as ':' and '}' or ')'.
The parameters have just been expanded (and will be expanded again) later
so don't need expanding as part of the :U process.
Seems to fix pkgsrc breakage at line 34 of bsd.pkginstall.mk doing:
.for i in ${PKG_USERS}
_PKG_VARS.pkginstall+=  PKG_UID.${u} PKG_GECOS.${u} PKG_HOME.${u} PKG_SHELL.${u}
.endfor
when PKG_USERS = ${AVAHI_USER}:${AVAHI_GROUP}::Avahi\ user:/nonexistent
(set at line 41 of the ahavi Makefile)
I really dont think the above has the desired effect!
2009-01-13 18:30:00 +00:00
dsl 40aa52653a Instead of stashing the body of every iteration of a .for loop, pass
Parse_SetInput() the name of a function to get the loop data blocks.
This should only be a change to the program logic.
2009-01-11 15:50:06 +00:00
dsl b19182e92b When substituting .for control variables any } or ) that matches the
${ or $( must be \ escaped.
Should fix some pkgsrc issues - eg 'clean' in print/gv.
2009-01-10 16:59:02 +00:00
dsl 1fc20cc6eb Count both () and {} when looking for the end of a :M pattern.
In particular inside .if empty(...) it was only counting ().
In reality this needs further changes.
This may well fix recent pkgsrc breakage.
2008-12-29 10:12:30 +00:00
dsl 6cb006c860 Only escape ':' in the outer level of .for variable substitution.
XXX: like elsewhere this code just counts {( against })
2008-12-21 19:19:55 +00:00
dsl c2cc9b5595 Change the way .for variables are substituted.
Instead of doing a full substitution giving plain text, just replace the
variable part with something that will expand to the required text - leaving
any modifiers for the later evaluation of the input line.
This stops .for being used as an 'eval' (previously you could generate .if etc)
and also means it is still a variable expansion - which some other parts need
to work in the expected fashion.
2008-12-21 18:06:53 +00:00
dsl 899813caea Add functions for processing extendable arrays of pointers to strings.
Use for the .for variables and substution items - changing the latter from
make's all conquering lst.lib functions.
Being able to index everything makes the code simpler.
No functional changes intended.
2008-12-20 22:41:53 +00:00
dsl b1e9c7dca0 Set the .for loop control variables in reverse order to avoid faffing. 2008-12-20 17:38:37 +00:00
dsl 8a143811b9 Use NULL instead of -1 cast to the relavant type (usually via NIL).
This was a suggestion from christos - so blame him if there is a deep
reason for using -1 :-)
2008-12-13 15:19:29 +00:00
dsl f8be892cab Correct some comments. 2008-12-01 21:05:21 +00:00
christos 132080e4f9 fix off-by-one allocation. functional change intended... 2008-12-01 19:35:55 +00:00
dsl 1e7b0ea1a2 Simplify somewhat the code that parses .for lines.
Use malloc to allocate space for teh strings (instead of a buf structure)
to make it mossible to not leak the associated memory (leak not fixed!).
No functional change intended.
2008-11-30 22:37:55 +00:00
dsl 6cb9ef7eef Split For_Eval() into two functions.
For_Eval() is now only called for the first line of a .for.
For_Accum() is called for the subsequent lines.
Stops any problems with forLevel being left invalid after an error.
Use a return value of -1 from For_Eval() to mean 'skip input line' to stop
a .for line with a syntax error being reparsed by make.
2008-11-29 17:50:11 +00:00
dsl feafbbe6e5 Convert ADDWORD() to do { ... } while (0) 2008-11-22 17:34:56 +00:00
joerg bd681a4d7e Don't use emalloc and friends directly, but call them consistently
bmake_malloc and friends. Implement them via macros for the native case
and provide fallback implementations otherwise. Avoid polluting the
namespace by not defining enomem globally. Don't bother to provide
strdup and strndup, they were only used for the estrdup and estrndup
comapt code.

This addresses the presence of emalloc in system libraries on A/UX and
resulted strange issues as reported by Timothy E. Larson.
2008-10-06 22:09:21 +00:00
christos 8567cf00de PR/38756: dominik: make dumps core on invalid makefile 2008-05-26 14:29:55 +00:00
christos a686e4e754 back all changes out until I fix it properly. 2008-02-15 21:29:50 +00:00
christos 2b28370627 - use pid_t/size_t as appropriate instead of int.
- use %ld to print pids.
- fix a bit of lint.
- WARNS=4
2008-02-14 22:11:20 +00:00
dsl 3780cb6cd8 Remove 'else' after 'return', and similar whitspace changes.
Extra debug on where files are actually found.
2007-01-01 21:31:51 +00:00
dsl c822b38662 Use open/read/close instead of stdio for makefiles.
Commons up the code for reading files and buffers, and allows a further
change where we don't copy the data out of the buffer when generating 'lines.
This will speed up makefile parsing (esp .if clauses).
2006-12-16 08:59:29 +00:00
dsl 16c8499ed2 Since 'ClientData' is 'void *', nuke almost all the (ClientData) casts. 2006-10-27 21:00:18 +00:00
dsl 0195907f3d Output all debug trace output through 'debug_file' defaulting to 'stdout'.
(Almost all the debug output went there, but some went to stderr.)
Split the parsing of -d (debug flags) out into its own routine.
Allow the output filename to be changed by specifying -dF<file> to create
a log file, or -dF+<file> to append to it. <file> may be stdout or stderr.
Also change so that -d-<flags> acts on <flags> locally but doesn't copy
them to MAKEFLAGS so they aren't inherited by child makes.
I'm not 100% happy with the command line syntax for the above, so they are
currently undocumented.
2006-10-15 08:38:21 +00:00
christos abefed98a7 Add typedefs for DuplicateProc and FreeProc from Max Okumoto. 2005-08-09 21:36:42 +00:00
christos 81b135acdf From Max Okumoto:
- Remove casts to NULL.
- Remove space between cast and object.
2005-08-08 16:42:54 +00:00
christos 6240774069 More KNF cleanups from Max Okumoto 2005-08-05 00:53:18 +00:00
christos 3692d77541 Whitespace KNF cleanup from Max Okumoto 2005-07-25 22:55:58 +00:00
christos 63fca13660 PR/29203, PR/29204: Max Okumoto: KNF changes to make [no functional changes] 2005-02-16 15:11:52 +00:00
ross 42dbdbd46a Simplify build, no functional changes.
Instead of adding MAKE_BOOTSTRAP for hosted environments, i.e., when
you want things simple, instead add MAKE_NATIVE to get those hugely
important features like __RCSID().

It's now possible to build make on some hosts with: cc *.c */*.c
2004-05-07 00:04:38 +00:00
enami 222e389ef2 Print useful line number on error while executing .for directive. 2004-03-06 03:57:07 +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
christos 6a7d20bb25 Pass WARNS=3 2003-07-14 18:19:11 +00:00
wiz 86ebbc3a0e Remove !__STDC__ stuff, de-__P(), ANSIfy, and de-register. 2002-06-15 18:24:55 +00:00
christos e7dc83d9f1 PR/15888: Jarkko Teppo: Problems building on HP/UX
1. Compensate for h-pox assert brain damage where it gets confused by the
   string in: assert(!memcmp(foo, "in", 2)); I miss the h-pox broken compiler,
   I had not had to work around it for years.
2. Oh, finally h-pox has random() and utimes(). We don't need our own anymore.
2002-03-12 20:15:15 +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
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
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
simonb ae62335eb5 Buf_GetAll() takes an int *, not a size_t *.
Build failure on alpha reported by Tim Rightnour on current-users.
2000-04-18 03:46:41 +00:00
christos c407ec1982 PR/9899: David A. Holland: multi-variable .for constructs in make 2000-04-16 22:08:06 +00:00
lukem 2ba9e97765 wrap #include <sys/cdefs.h>, __RCSID(...) stuff in #ifndef MAKE_BOOTSTRAP 1997-09-28 03:30:58 +00:00
christos 254d64f064 Add WARNS=1
RCSID police
1997-07-01 21:17:00 +00:00
christos aa49881371 - Merge in FreeBSD and Lite2 changes.
- Fix bug where a non-archive target with a .a suffix would always
  be considered to be out of date, since it does not have a TOC.
1996-11-06 17:58:58 +00:00