Commit Graph

155 Commits

Author SHA1 Message Date
sjg 9772f81de8 Add .unexport - the exact opposite of .export
and .unexport-env which unexport's all previously .export'd globals
as well as clearing environ[].
Allow's sys.mk near total controll.

Reviewed by: apb
2009-11-19 00:30:25 +00:00
sjg 44c6580dd0 Reviewed by: apb
Use .MAKE.LEVEL to track recursion.
The first instance of make will have .MAKE.LEVEL 0, which
can be handy for excluding rules which should not apply
in a sub-make.
gmake and freebsd's make have a similar mechanism, but each
uses a different variable to track it.  Since we cannot be
compatible with both, we allow the makefiles to cope if they want
by handling the export of .MAKE.LEVEL+1 in Var_Set().
2009-09-08 17:29:20 +00:00
sjg cd5a3748ef PR: 41998
:Ufu\:goo

should expand to fu:goo even when it appears in :M${:Ufu\:goo}
When scanning for :M do not compress \: if we know we have
to call Var_Subst.
2009-09-07 17:56:23 +00:00
sjg 39bb2e98a1 Child of vfork() must not alter the state of parent.
There is no need to touch the state of vars in child anyway.
Change 2nd arg to Var_Export1() to indicate if we are the parent or child,
and only set flags in the parent.
2009-06-16 05:44:06 +00:00
christos a5e73ebace adjust patch to current. 2009-02-18 21:06:47 +00:00
christos ca9294c412 CID 5044: Protect against NULL deref. 2009-02-18 20:08:32 +00:00
dsl 530cac2556 Allow for () in the argument to .ifdef et al.
Save/restore current values of global data across expression evaluation
to give ${foo:? ...} a change of working inside another .if.
2009-01-28 21:38:12 +00:00
dsl 0cbb4ab551 Change 'ClientData' to 'void *' so that relevant parameters can
be made 'const void *'.
2009-01-23 21:26:30 +00:00
lukem ab93b4bc61 fix -Wsign-compare issues 2009-01-18 01:31:12 +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 74a68f7259 Debug print improvements. 2009-01-16 21:14:30 +00:00
dsl aee1343f51 In the :M code, 'pattern' is always malloced memory - so unconditionally
free.
2008-12-29 10:18:38 +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 e4be9d4f2c Treat '\\' as a possible terminator for a loop control variable.
(Typically an escaped \: of a nested modifier.)
2008-12-23 21:56:38 +00:00
dsl d003f8f69b Don't allow $) $} $: or $$ as variable expansions, they confuse other
parts of make that try to scan through variable expansions.
  (given the make syntax that is all rather doomed anyway!)
Move the check for $\0 to a place where it will be detected - otherwise
  the parser will run off the input buffer!
2008-12-21 10:44:10 +00:00
dsl e06fc1c61f A lot of code assumes that the pointer returned by Buf_GetAll() is malloced.
Replace Buf_Discard() with Buf_Empty() since the former might leave the
'outPtr != buffer' and the only caller wanted all the data discared.
Remove 'outPtr' now that it always equals 'buffer'.
The assumption about Buf_GetAll()is now guaranteed by design.
2008-12-20 18:08:24 +00:00
dsl 03a9360df5 Do not allow Var_Set() or Var_Append() to set the empty variable (which will
now forever remain undefined).
Rework/simplify code to avoid UNCONST().
2008-12-20 17:14:04 +00:00
dsl b7b48965cc Change some "^I *^I" to "^I^I" and align the comment block about
variable modifiers.
2008-12-20 16:03:59 +00:00
christos 9faa233ea6 add a little more debugging. 2008-12-19 21:33:10 +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 40e0ab7a8f Do not let the variable name "" be set from the command line (-D "")
or from ::= modifiers (${::=foo}).
2008-12-13 14:26:10 +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
joerg f45c989c53 Micro-optimise VarQuote by exploiting that meta characters are normally
rare and skipping over normal characters with strcspn is therefore
faster. Further simplify logic by always setting newline and precompute
the size of the string.

OK christos@
2008-07-31 15:19:19 +00:00
joerg 2ad045d932 Meta characters are a constant, mark it so. 2008-07-31 14:59:39 +00:00
sjg f2c43a72d5 VAR_CMD context is used by conditionals and other purposes, so
actually set VAR_FROM_CMD when appropriate and only skip setting in
VAR_GLOBAL when that flag is set.
2008-05-15 21:05:54 +00:00
sjg db7f6ac403 Disable this for now, VAR_CMD is abused for other purposes... 2008-05-15 18:25:12 +00:00
sjg 20275ee931 Do not set vars in VAR_GLOBAL context, if they have been set on the
command line.
Add a suitable unit-test.
2008-05-14 14:27:02 +00:00
sjg 98deadff04 If the name passed to Var_Exists contains '$' run it through Var_Subst. 2008-03-31 00:12:21 +00:00
christos a686e4e754 back all changes out until I fix it properly. 2008-02-15 21:29:50 +00:00
christos e654b454bc remove error/noerror const 2008-02-15 02:50:53 +00:00
christos 4d9d6704c1 - symbolic names for error and no error
- more size_t
2008-02-15 02:37:51 +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
apb 7da86686ca Don't write into const strings; not even if we intend to
reinstate the original contents later.
2007-10-13 19:59:52 +00:00
apb 67bb324312 * Convert all uses of strdup() to estrdup();
* Use estrndup() in a few cases where it simplifies the code;
* Provide compatibility definitions of strndup and estrndup;
2007-10-13 16:16:41 +00:00
apb 781e1efd0c Oops, missed a few more comments in previous. 2007-10-13 14:32:18 +00:00
apb a8bf2a2f8a Correct documentation for Var_Parse's freePtr arg. It's a pointer to
the thing to be freed (or NULL if nothing to free), not to a pointer to
boolean saying whether or not to free the result.
2007-10-13 13:54:06 +00:00
sjg 3a5409e4eb Fix an off-by-one error in handing mal-formed modifiers.
The issue seems to have been present for some time, only showed up
when running unit-tests on SunOS.
Make sure we get an error message, but otherwise behave as before.
2007-10-09 05:55:03 +00:00
sjg f28827375c Add the ability to .export variables to the environment. 2007-10-05 15:27:45 +00:00
dsl 53bf780833 Under DEBUG(VAR) report when the variable wasn't found.
Disposes of pr bin/15842
2007-06-16 19:47:29 +00:00
dsl b7483eac69 Since the 'buf' code here is only used by make, we don't need two names
for the default buffer size of 256.
Also allow for the trailing 0 byte!
2007-01-01 21:29:01 +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 cdab3a7a06 More programs using efun. 2006-08-26 18:17:41 +00:00
sjg 7ab69f08a8 Indicate which modifier a result applies to, helps debug complex cases. 2006-07-28 17:08:55 +00:00
rillig a3ea8b9d59 Fixed the bug reported in PR 33866, which is that the :Q operator does not
handle newlines correctly. Ok'ed by christos.
2006-06-29 22:01:17 +00:00
christos 236f8aef2c Coverity CI D3758: Plug memory leak. 2006-05-19 17:29:01 +00:00
christos 19d4b5c5e9 Coverity CID 3757: Plug memory leak. 2006-05-19 17:27:06 +00:00
sjg 03cbcf6532 Extract the variable modifier logic to a separate function.
This cuts Var_Parse in half! and allows the modifier logic to
be used recursively - when getting modifiers via variables.

Add new unit-test, to check that certain error cases are handled
correctly.
2006-05-11 15:37:07 +00:00
christos 3d5b8ce5a8 Coverity CID 529: Call VarFreeEnv to prevent leak. 2006-04-22 19:40:40 +00:00
christos ac5c384e1b Coverity CID 534: Free junk variables on return from Var_Parse. 2006-04-22 19:32:35 +00:00