Commit Graph

166 Commits

Author SHA1 Message Date
tsutsui 56683e6b6e Explicitly #include <time.h> for time(3) and strftime(3).
Fixes warnings on some non NetBSD hosts.
2011-05-21 07:30:42 +00:00
sjg 521f3749c8 If a "long" modifier name does not match, goto default case
so SysV modifier can be tried.
2011-04-11 14:49:09 +00:00
sjg b446ef338f Add :localtime and :gmtime which use value as format string for strftime. 2011-04-11 01:44:15 +00:00
joerg 53d81ae021 Add the :hash modifier to compute a 32bit hash of an variable.
This uses MurmurHash3 to get a reasonable collission-free hash with
small code. The result is endian neutral.
2011-04-07 01:40:01 +00:00
sjg 8892f885fd Add unit tests to check that exists(some/dir/) works
Also fix handling of sysV substitutions when lhs and variable are empty.

Also that modifiers do not cause errors during conditional tests
when undefined variables should otherwise be ok.
Ie. .if defined(nosuch) && ${nosuch:Mx} != ""
2011-03-06 00:02:14 +00:00
christos 24e17e276b From Aleksey Cheusov: Fix unexpected behavior with:
all: test1 test2
test1:
	@echo ${foo::=foo-text}
test2:
	@echo $(foo::=foo-text)
Saying:
nbmake: Unclosed substitution for foo (} missing)
for test 2
2010-12-02 16:46:22 +00:00
christos 8d8e09f9aa add commented out a possible addition that provides $^ like gmake, but
I am not sure if we should add it, since we already have $> for it.
2010-12-02 16:36:55 +00:00
sjg fbb620d711 Add .export-env which tells make to export a variable to the environment
but not to track it - as is done for .export
This allows the variable to be updated without affecting what was put
into the environment.
Older versions of make will simply treat this as .export
2010-06-06 01:13:12 +00:00
sjg 862d4ff05d If we do .export (all) and have any variables that involve :sh
we will hit an error (var is recursive) while trying to evaluate that.
Fix, and add a unit test for this.
2010-04-21 04:25:27 +00:00
sjg b7f72d44a7 Behavior of realpath() appears to vary.
To ensure consistent results, use stat(2) as a final check for success.
2010-04-20 17:48:16 +00:00
sjg 290b1f00e6 Add :tA to attempt to resolve to absoute path using realpath(). 2010-04-15 03:48:39 +00:00
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