The NetBSD Project

CVS log for src/usr.bin/make/var.c

[BACK] Up to [cvs.NetBSD.org] / src / usr.bin / make

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.953 / (download) - annotate - [select for diffs], Sun Oct 17 18:40:14 2021 UTC (6 days, 21 hours ago) by rillig
Branch: MAIN
CVS Tags: HEAD
Changes since 1.952: +7 -7 lines
Diff to previous 1.952 (colored)

make: fix order of parameters in function comments

No functional change.

Revision 1.952 / (download) - annotate - [select for diffs], Thu Sep 23 22:54:09 2021 UTC (4 weeks, 2 days ago) by rillig
Branch: MAIN
Changes since 1.951: +4 -2 lines
Diff to previous 1.951 (colored)

make: fix memory leak in error case of the ':?' modifier

Revision 1.951 / (download) - annotate - [select for diffs], Tue Sep 21 23:06:18 2021 UTC (4 weeks, 4 days ago) by rillig
Branch: MAIN
Changes since 1.950: +4 -4 lines
Diff to previous 1.950 (colored)

make: reduce relocations, thereby reducing .text size

No functional change.

Revision 1.950 / (download) - annotate - [select for diffs], Sat Sep 11 09:16:14 2021 UTC (6 weeks, 1 day ago) by rillig
Branch: MAIN
Changes since 1.949: +16 -12 lines
Diff to previous 1.949 (colored)

make: eliminate a few common subexpressions

This commit contains only changes that don't increase the code size on
x86_64.  Replacing the remaining instance of ModChain_ShouldEval would
either increase the code size or make the code harder to understand.

No functional change.

Revision 1.949 / (download) - annotate - [select for diffs], Mon Sep 6 19:38:30 2021 UTC (6 weeks, 5 days ago) by rillig
Branch: MAIN
Changes since 1.948: +3 -3 lines
Diff to previous 1.948 (colored)

make: fix typos in comments

Revision 1.948 / (download) - annotate - [select for diffs], Wed Aug 25 22:14:38 2021 UTC (8 weeks, 3 days ago) by rillig
Branch: MAIN
Changes since 1.947: +7 -5 lines
Diff to previous 1.947 (colored)

make: fix lint warnings on ilp32 platforms

The warnings in arch.c were about conversions from int to long.

The warnings in var.c were about conversions from long long to
ptrdiff_t.

No functional change.

Revision 1.947 / (download) - annotate - [select for diffs], Sat Aug 14 13:11:33 2021 UTC (2 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.946: +2 -4 lines
Diff to previous 1.946 (colored)

make: remove workaround for initialization bug in lint

The bug has been fixed in init.c 1.208 from 2021-08-14.

Revision 1.946 / (download) - annotate - [select for diffs], Sun Aug 8 12:00:30 2021 UTC (2 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.945: +3 -3 lines
Diff to previous 1.945 (colored)

make: remove redundant initialization in ApplyModifier_Order

No functional change.

Revision 1.945 / (download) - annotate - [select for diffs], Sat Jul 31 09:30:17 2021 UTC (2 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.944: +4 -2 lines
Diff to previous 1.944 (colored)

make: fix lint warnings

The string functions from str.h are declared as 'static __unused' when
compiled with GCC, but lint explicitly undefines __GCC__ during
preprocessing.  Therefore, make those functions inline, to prevent
warnings that they are unused.

The macro UNCONST is used in a few places, and (again) since lint
undefines __GCC__, that macro expanded to a simple type cast, which lint
warned about.  To prevent this warning, implement UNCONST as a function
that works everywhere and hides the type cast.

In filemon_open, the code for closing F->in was obviously unreachable.

No functional change.

Revision 1.944 / (download) - annotate - [select for diffs], Sat Jul 31 00:17:04 2021 UTC (2 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.943: +12 -22 lines
Diff to previous 1.943 (colored)

make: clean up ApplyModifier_Order

No functional change.

Revision 1.943 / (download) - annotate - [select for diffs], Fri Jul 30 23:35:38 2021 UTC (2 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.942: +8 -4 lines
Diff to previous 1.942 (colored)

make: reword comment for ApplyModifier_Order

Revision 1.942 / (download) - annotate - [select for diffs], Fri Jul 30 23:28:04 2021 UTC (2 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.941: +39 -27 lines
Diff to previous 1.941 (colored)

make: handle parse errors in ':O' uniformly

Previously, the error handling for the variable modifier ':O' differed
depending on the exact variant and in some cases led to misleading
or missing diagnostics.

Revision 1.941 / (download) - annotate - [select for diffs], Fri Jul 30 22:19:51 2021 UTC (2 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.940: +4 -8 lines
Diff to previous 1.940 (colored)

make: merge duplicate code for sorting strings and numbers

No functional change.

Revision 1.940 / (download) - annotate - [select for diffs], Fri Jul 30 22:16:09 2021 UTC (2 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.939: +4 -4 lines
Diff to previous 1.939 (colored)

make: fix typo in manual page, add more tests for the new ':On'

Revision 1.939 / (download) - annotate - [select for diffs], Fri Jul 30 19:55:22 2021 UTC (2 months, 3 weeks ago) by sjg
Branch: MAIN
Changes since 1.938: +70 -4 lines
Diff to previous 1.938 (colored)

Add :On for numeric sort

Reviewed by: christos rillig

Revision 1.938 / (download) - annotate - [select for diffs], Mon Jun 21 18:25:20 2021 UTC (4 months ago) by rillig
Branch: MAIN
Changes since 1.937: +6 -7 lines
Diff to previous 1.937 (colored)

make: use more practical data type in RegexReplace

While size_t is most appropriate for array indexes, make needs to be
compatible with C90, which does not support the %zu printf conversion.
To avoid type casts, use a simple unsigned int here, which is more than
enough for storing a single decimal digit.

No functional change.

Revision 1.937 / (download) - annotate - [select for diffs], Mon Jun 21 18:12:49 2021 UTC (4 months ago) by rillig
Branch: MAIN
Changes since 1.936: +50 -43 lines
Diff to previous 1.936 (colored)

make: extract RegexReplace from ModifyWord_SubstRegex

No functional change.

Revision 1.936 / (download) - annotate - [select for diffs], Mon Jun 21 17:52:33 2021 UTC (4 months ago) by rillig
Branch: MAIN
Changes since 1.935: +7 -8 lines
Diff to previous 1.935 (colored)

make: move all labels in ModifyWord_SubstRegex to the same level

No functional change.

Revision 1.935 / (download) - annotate - [select for diffs], Mon Jun 21 17:21:37 2021 UTC (4 months ago) by rillig
Branch: MAIN
Changes since 1.934: +59 -63 lines
Diff to previous 1.934 (colored)

make: reduce indentation in ModifyWord_SubstRegex for ':C'

No functional change.

Revision 1.934 / (download) - annotate - [select for diffs], Mon Jun 21 08:40:44 2021 UTC (4 months ago) by rillig
Branch: MAIN
Changes since 1.933: +8 -9 lines
Diff to previous 1.933 (colored)

make: fix documentation for ParseModifierPart

Revision 1.933 / (download) - annotate - [select for diffs], Mon Jun 21 04:24:17 2021 UTC (4 months ago) by sjg
Branch: MAIN
Changes since 1.932: +7 -5 lines
Diff to previous 1.932 (colored)

Do not report unmatched regex subexpressions

It is not always an error for a subexpression to have not matched,
since the regex library can/does not convey how many matches are
expected, only report an error if opts.strict (-dL)

Reviewed by: christos

Revision 1.930.2.1 / (download) - annotate - [select for diffs], Mon May 31 22:15:25 2021 UTC (4 months, 3 weeks ago) by cjep
Branch: cjep_staticlib_x
Changes since 1.930: +25 -22 lines
Diff to previous 1.930 (colored) next main 1.931 (colored)

sync with head

Revision 1.932 / (download) - annotate - [select for diffs], Sun May 30 20:41:34 2021 UTC (4 months, 3 weeks ago) by rillig
Branch: MAIN
CVS Tags: cjep_sun2x-base1, cjep_sun2x-base, cjep_sun2x, cjep_staticlib_x-base1
Changes since 1.931: +13 -8 lines
Diff to previous 1.931 (colored)

make: uncompress code in ApplyModifier_Unique

The algorithm is easier to understand when each line of code only
focuses on a single topic.

No change to the resulting binary, except for line numbers in assertion
messages.

Revision 1.931 / (download) - annotate - [select for diffs], Sun May 30 20:31:03 2021 UTC (4 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.930: +20 -22 lines
Diff to previous 1.930 (colored)

make: inline VarUniq into ApplyModifier_Unique

No functional change.

Revision 1.930 / (download) - annotate - [select for diffs], Mon Apr 19 22:22:27 2021 UTC (6 months ago) by rillig
Branch: MAIN
CVS Tags: cjep_staticlib_x-base
Branch point for: cjep_staticlib_x
Changes since 1.929: +3 -3 lines
Diff to previous 1.929 (colored)

make: use straight quotes for error 'Bad conditional expression'

This diagnostic was supposed to be an error, see ApplyModifier_IfElse.

When such an error occurs while the makefiles are read, make stops with
an error, as can be expected.  But when such an error occurs later,
after all makefiles have been read, the message is printed but make does
not stop.

In lint mode (-dL), make stops in such a case.  I didn't dare to make
this the default behavior, out of fear of breaking existing build
infrastructure, not only in NetBSD or pkgsrc, but also FreeBSD and other
operating systems that use the bmake distribution, generated from the
same source code.

Revision 1.929 / (download) - annotate - [select for diffs], Wed Apr 14 16:59:34 2021 UTC (6 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.928: +9 -9 lines
Diff to previous 1.928 (colored)

make: reduce memory allocations in the modifiers ':D' and ':U'

Revision 1.928 / (download) - annotate - [select for diffs], Wed Apr 14 16:12:26 2021 UTC (6 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.927: +13 -13 lines
Diff to previous 1.927 (colored)

make: rename members of ModifyWord_LoopArgs

No functional change.

Revision 1.927 / (download) - annotate - [select for diffs], Wed Apr 14 15:41:08 2021 UTC (6 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.926: +13 -17 lines
Diff to previous 1.926 (colored)

make: clean up pattern flags for the modifiers ':S' and ':C'

No special handling is necessary for C90 since none of the struct
members is a const_member.

The prefix 'Var' is not necessary since this type does not apply to a
variable but only to a modifier.

No functional change.

Revision 1.926 / (download) - annotate - [select for diffs], Mon Apr 12 18:53:51 2021 UTC (6 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.925: +7 -7 lines
Diff to previous 1.925 (colored)

make: spell SysV in mixed case

No functional change.

Revision 1.925 / (download) - annotate - [select for diffs], Mon Apr 12 18:48:00 2021 UTC (6 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.924: +57 -110 lines
Diff to previous 1.924 (colored)

make: reduce memory allocation and strlen calls in modifier ':from=to'

Previously, SysVMatch was quite verbose and felt like hand-optimized
assembler code, which made it difficult to discover the underlying idea
of the code.

All this code was replaced with two simple calls to Substring_HasPrefix
and Substring_HasSuffix.  Now that the operands of that modifier are no
longer passed as C strings, there is no need to collect all information
in a single scan through the word and the pattern.

It was not necessary to call Var_Subst unconditionally.  Calling it only
when the string contains a '$' saves another memory allocation and two
string copies (because of the Buf_DoneDataCompact).

No functional change.

Revision 1.924 / (download) - annotate - [select for diffs], Mon Apr 12 13:28:35 2021 UTC (6 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.923: +26 -20 lines
Diff to previous 1.923 (colored)

make: in the ':Q' modifier, only allocate memory if necessary

Revision 1.923 / (download) - annotate - [select for diffs], Sun Apr 11 22:53:45 2021 UTC (6 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.922: +4 -4 lines
Diff to previous 1.922 (colored)

make: improve performance for LazyBuf

The previous O(n^2) time complexity for parsing a long string with many
variable expressions was not meant to last for long.  I had hoped to fix
it within a few minutes, but that will take more time.

For now, make LazyBuf simpler by using a traditional C string for the
expected part instead of a Substring.  This avoids a strlen call per
Var_Parse.

No functional change, only performance.

Revision 1.922 / (download) - annotate - [select for diffs], Sun Apr 11 21:29:57 2021 UTC (6 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.921: +7 -7 lines
Diff to previous 1.921 (colored)

make: remove redundant parameter from ParseVarnameLong

No functional change.

Revision 1.921 / (download) - annotate - [select for diffs], Sun Apr 11 20:38:43 2021 UTC (6 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.920: +129 -96 lines
Diff to previous 1.920 (colored)

make: migrate ParseModifierPart to use Substring

This will reduce memory allocation for modifier parts without the escape
characters '$' or '\'.

No functional change.

Revision 1.920 / (download) - annotate - [select for diffs], Sun Apr 11 19:05:06 2021 UTC (6 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.919: +6 -8 lines
Diff to previous 1.919 (colored)

make: avoid unnecessary calls to strlen when evaluating modifiers

No functional change.

Revision 1.919 / (download) - annotate - [select for diffs], Sun Apr 11 18:44:57 2021 UTC (6 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.918: +82 -58 lines
Diff to previous 1.918 (colored)

make: migrate ModifyWord functions to use Substring

This benefits the modifiers ':T' and ':H' since these scan the word from
the end.  The SysV modifier '.c=.o' does not benefit yet, this will be
done in a follow-up commit.

Currently ModifyWords calls strlen for each single word, which degrades
performance.  This will be cleaned up in a follow-up commit as well.

No functional change.

Revision 1.918 / (download) - annotate - [select for diffs], Sun Apr 11 17:48:01 2021 UTC (6 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.917: +48 -38 lines
Diff to previous 1.917 (colored)

make: migrate handling of the modifier ':S,from,to,' to Substring

Right now this does not gain any performance, it only makes the code in
ModifyWord_Subst a little simpler since it only uses
Buf_AddBytesBetween, not a mixture with Buf_AddBytes.

When the word passed to the ModifyWord functions is converted to
Substring as well, the call to strlen will become redundant.

No functional change.

Revision 1.917 / (download) - annotate - [select for diffs], Sun Apr 11 13:35:56 2021 UTC (6 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.916: +13 -13 lines
Diff to previous 1.916 (colored)

make: clean up remaining references to VarEvalFlags

VarEvalFlags has been replaced with VarEvalMode.  There were some
comments and tests that still referred to the old names.

No functional change.

Revision 1.916 / (download) - annotate - [select for diffs], Sun Apr 11 12:46:54 2021 UTC (6 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.915: +87 -103 lines
Diff to previous 1.915 (colored)

make: avoid allocating memory for simple variable names

The main change is in ParseVarname, where a Buffer is replaced with the
newly introduced LazyBuf.  LazyBuf is inspired by
https://golang.org/src/path/path.go.

In CanonicalVarname, the pre-comparison of the first letter of the
variable name is no longer necessary.  GCC 9 optimizes a fixed-length
memcmp so well that the code can finally be written to target human
readers, leaving the optimization to the compiler.

Revision 1.915 / (download) - annotate - [select for diffs], Sat Apr 10 22:40:34 2021 UTC (6 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.914: +4 -3 lines
Diff to previous 1.914 (colored)

make: fix out-of-bounds read in Var_Parse_FastLane (since 30 minutes)

This bug made the test varmod-edge.mk fail sometimes with varying error
messages, as can be expected for an out-of-bounds read.

Revision 1.914 / (download) - annotate - [select for diffs], Sat Apr 10 22:35:02 2021 UTC (6 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.913: +8 -7 lines
Diff to previous 1.913 (colored)

make: reword debug log message for empty variable name

The function names did not match anymore, after one of the many
refactorings in the last few months.

Revision 1.913 / (download) - annotate - [select for diffs], Sat Apr 10 22:09:53 2021 UTC (6 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.912: +38 -2 lines
Diff to previous 1.912 (colored)

make: reduce debug logging and memory allocation for ${:U...}

Expressions of the form ${:U...} are often generated by .for loops.
Since these expressions are not generated knowingly by the make user, do
not fill the debug log with them since that would interrupt the normal
reading flow of the -dv log for nested expressions.

Revision 1.912 / (download) - annotate - [select for diffs], Tue Apr 6 01:38:39 2021 UTC (6 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.911: +11 -2 lines
Diff to previous 1.911 (colored)

make: reduce verbosity of the -dv debug logging for standard cases

The verbosity was already removed from LogBeforeApply, now it is
consistent between LogBeforeApply and LogAfterApply.

Revision 1.911 / (download) - annotate - [select for diffs], Mon Apr 5 13:35:41 2021 UTC (6 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.910: +7 -7 lines
Diff to previous 1.910 (colored)

make: in debug log, add space between scope and variable name

Without this space, the debug log looked more like line noise, even
though the only punctuation was a single innocent ':'.  From a make
user's perspective, the variable name is a word of its own and should
not be visually glued to its namespace.

Revision 1.910 / (download) - annotate - [select for diffs], Mon Apr 5 13:27:30 2021 UTC (6 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.909: +12 -4 lines
Diff to previous 1.909 (colored)

make: omit unnecessary details from -dv debug log

When an expression is based on a defined variable, it does not matter
whether the evaluation mode is "eval" or "eval-defined", therefore omit
these details to reduce confusion.

Revision 1.909 / (download) - annotate - [select for diffs], Mon Apr 5 13:14:54 2021 UTC (6 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.908: +16 -7 lines
Diff to previous 1.908 (colored)

make: be more verbose in -dv debug logging

The previous log output was too brief to be understandable.  Give more
hints by describing each part of the expression when evaluating a
modifier.  Distinguish between parse-only mode and eval mode since in
parse-only mode most of the details are irrelevant.

Revision 1.908 / (download) - annotate - [select for diffs], Mon Apr 5 12:51:35 2021 UTC (6 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.907: +5 -5 lines
Diff to previous 1.907 (colored)

make: clean up debug logging for ':M' and ':N'

Using square brackets as quotes was confusing since patterns can contain
square brackets themselves.

The debug logging for VarMatch was a bit too detailed.  Having the
"before" and "after" states is enough for all practically relevant
cases.

Revision 1.907 / (download) - annotate - [select for diffs], Sun Apr 4 13:35:25 2021 UTC (6 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.906: +5 -11 lines
Diff to previous 1.906 (colored)

make: disallow '$' in the variable name of the modifier ':@'

If this restriction should break any existing makefile, the author of
that makefile was probably heading for the IOMCC.

Revision 1.906 / (download) - annotate - [select for diffs], Sun Apr 4 11:56:43 2021 UTC (6 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.905: +112 -95 lines
Diff to previous 1.905 (colored)

make: convert VarEvalFlags back into an enum, but not a bit-set

As was apparent in VarEvalFlags_ToString, a bit-set was not the best
data type since most of the flags were not freely combinable.  The two
flags that could be combined were keepDollar and keepUndef, but even
these have distinguished names in the debug log.

The downside of struct bit-fields is that they need extra helper
functions in C90 (see nonints.h).  Exchange these for a few helper
functions in var.c, to keep the code outside var.c simple.

No functional change.

Revision 1.905 / (download) - annotate - [select for diffs], Sun Apr 4 11:47:54 2021 UTC (6 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.904: +44 -24 lines
Diff to previous 1.904 (colored)

make: extract decision for evaluating an expression

No functional change.

Revision 1.904 / (download) - annotate - [select for diffs], Sat Apr 3 23:24:06 2021 UTC (6 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.903: +23 -22 lines
Diff to previous 1.903 (colored)

make: move VarEvalFlags_ToString down to the other functions

No functional change.

Revision 1.903 / (download) - annotate - [select for diffs], Sat Apr 3 23:19:08 2021 UTC (6 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.902: +6 -11 lines
Diff to previous 1.902 (colored)

make: condense definition of VarPatternFlags

No functional change.

Revision 1.902 / (download) - annotate - [select for diffs], Sat Apr 3 23:15:52 2021 UTC (6 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.901: +74 -76 lines
Diff to previous 1.901 (colored)

make: inline VarFlags into Var

No functional change.

Revision 1.901 / (download) - annotate - [select for diffs], Sat Apr 3 23:08:30 2021 UTC (6 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.900: +44 -42 lines
Diff to previous 1.900 (colored)

make: replace enum bit-set with struct bit-fields

This makes the code easier to read, especially when setting one of the
flags to false.

No functional change.

Revision 1.900 / (download) - annotate - [select for diffs], Sat Apr 3 22:06:23 2021 UTC (6 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.899: +6 -13 lines
Diff to previous 1.899 (colored)

make: remove unused Expr.varFlags

No functional change.

Revision 1.899 / (download) - annotate - [select for diffs], Sat Apr 3 22:02:59 2021 UTC (6 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.898: +4 -8 lines
Diff to previous 1.898 (colored)

make: remove VarFlags from debug logging

Before the introduction of ExprDefined, VarFlags contained whether the
expression was defined or not, which was useful to know since the final
value of the expression depends on this information.  The other VarFlags
do not influence the evaluation, so there is no point logging them.

Revision 1.898 / (download) - annotate - [select for diffs], Sat Apr 3 21:55:27 2021 UTC (6 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.897: +38 -35 lines
Diff to previous 1.897 (colored)

make: simplify access to the name of an expression during evaluation

During the evaluation, the flags of the variable don't change, except
for VFL_IN_USE, but in such a case make exits immediately anyway.

Logging the variable flags does not provide any useful information, so
it will be removed soon.  Logging the variable flags made sense when the
definedness of the expression was still encoded in the variable flags,
instead of in the separate ExprDefined.

No functional change.

Revision 1.897 / (download) - annotate - [select for diffs], Sat Apr 3 14:39:02 2021 UTC (6 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.896: +74 -28 lines
Diff to previous 1.896 (colored)

make: backport to C90

In the past few months I had accidentally used C99 features in the make
code.  According to tools/README, tools that are used in the build
system should restrict themselves to C90.

This allows make to build with GCC's options "-pedantic
-Wno-system-headers -Dinline= -Wno-error=cast-qual".

I didn't notice anyone actively complaining though, I just wanted to see
how much work this backporting would be.  The identifier __func__ is
still used, as in other tools.

No functional change.

Revision 1.896 / (download) - annotate - [select for diffs], Sat Apr 3 14:31:44 2021 UTC (6 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.895: +35 -35 lines
Diff to previous 1.895 (colored)

make: rename function parameters to match boolean constants

No functional change.

Revision 1.895 / (download) - annotate - [select for diffs], Sat Apr 3 11:08:40 2021 UTC (6 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.894: +173 -173 lines
Diff to previous 1.894 (colored)

make: use C99 bool type instead of defining its own

No functional change.

Revision 1.894 / (download) - annotate - [select for diffs], Tue Mar 30 14:58:17 2021 UTC (6 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.893: +2 -7 lines
Diff to previous 1.893 (colored)

make: remove workaround for bug in lint

The bug has been fixed in lint.

No functional change.

Revision 1.893 / (download) - annotate - [select for diffs], Sun Mar 21 23:03:33 2021 UTC (7 months ago) by rillig
Branch: MAIN
Changes since 1.892: +4 -4 lines
Diff to previous 1.892 (colored)

make: fix typos in documentation of ModChain

Revision 1.892 / (download) - annotate - [select for diffs], Tue Mar 16 16:21:27 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.891: +14 -9 lines
Diff to previous 1.891 (colored)

make: fix documentation for ModChain

The outer ModChain can be interrupted by an inner ModChain, but it
continues to exist.

No functional change.

Revision 1.891 / (download) - annotate - [select for diffs], Mon Mar 15 20:00:50 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.890: +207 -207 lines
Diff to previous 1.890 (colored)

make: rename ApplyModifiersState to ModChain

The new name accurately describes the structural element that holds such
properties as the separator character and whether the expression value
is considered a single word.  The old name ApplyModifiersState was too
long and was meant as a placeholder anyway, when I introduced it in
var.c 1.236 from 2020-07-03.

Revision 1.890 / (download) - annotate - [select for diffs], Mon Mar 15 19:15:04 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.889: +13 -10 lines
Diff to previous 1.889 (colored)

make: improve documentation of ApplyModifiersState

No functional change.

Revision 1.889 / (download) - annotate - [select for diffs], Mon Mar 15 19:02:57 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.888: +10 -2 lines
Diff to previous 1.888 (colored)

make: document an example for a 'chain of modifiers'

No functional change.

Revision 1.888 / (download) - annotate - [select for diffs], Mon Mar 15 18:56:37 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.887: +5 -6 lines
Diff to previous 1.887 (colored)

make: fix double varname expansion in the variable modifier '::='

This is an edge case that doesn't occur in practice since pretty much
nobody dares to use variable names that contain an actual '$' in their
name.  This is not about the fairly common VAR.${param} (as written in
the makefile), but instead about the variable whose name is literally
'VAR.${param}'.

The test demonstrates that after the fix, the variable name is taken
exactly as-is for the simple assignment modifier '::='.  There are no
such tests for the modifiers '::+=', '::!=' and '::?=', but that's ok.
The code in ApplyModifier_Assign would look assymetrical and suspicious
enough if one of these modifiers would expand its variable name and the
others wouldn't.

Revision 1.887 / (download) - annotate - [select for diffs], Mon Mar 15 16:51:14 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.886: +6 -7 lines
Diff to previous 1.886 (colored)

make: clean up documentation of ApplyModifiersState

No functional change.

Revision 1.886 / (download) - annotate - [select for diffs], Mon Mar 15 15:39:13 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.885: +21 -36 lines
Diff to previous 1.885 (colored)

make: change debug log for variable evaluation flags to lowercase

This makes them easier distinguishable from variable names since the
latter are usually uppercase.

No functional change outside debug mode.

Revision 1.885 / (download) - annotate - [select for diffs], Mon Mar 15 12:15:03 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.884: +84 -56 lines
Diff to previous 1.884 (colored)

make: replace enum bit-field with struct bit-field for VarEvalFlags

This makes the code easier to read, especially in var.c.  It also makes
debugging sessions easier since some debuggers don't show enum
bit-fields symbolically as soon as more than one bit is set.

The code outside var.c is basically unchanged, except that instead of
passing the individual flags, there are 4 predefined evaluation modes.
These suffice for all practical use cases.  Only in the implementation
deep inside var.c, the value of the flags keepDollar and keepUndef
differs.

There is no way of passing the struct to EnumFlags_ToString, which means
the ToString function has to be spelled out explicitly.  This allows for
fine-tuning the representation in the debug log, to reduce the amount of
uppercae letters.

No functional change.

Revision 1.884 / (download) - annotate - [select for diffs], Mon Mar 15 11:41:07 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.883: +7 -7 lines
Diff to previous 1.883 (colored)

make: rename VARE_NONE to VARE_PARSE_ONLY

The name 'NONE' described the bit pattern, which was not useful to
understand its meaning.  Omitting VARE_WANTRES only parses the
expression, without evaluating any part of it.

No functional change, not even in debug mode since Enum_FlagsToString
always returns "none" for all-bits-unset.

Revision 1.883 / (download) - annotate - [select for diffs], Sun Mar 14 20:23:29 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.882: +3 -9 lines
Diff to previous 1.882 (colored)

make: fix documentation of VarFreeEnv

No functional change.

Revision 1.882 / (download) - annotate - [select for diffs], Sun Mar 14 20:18:33 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.881: +28 -26 lines
Diff to previous 1.881 (colored)

make: skip variable lookup for '::=' modifiers in parse-only mode

This is just to keep the code consistent among the various variable
modifiers.  The performance gain is negligible.

The actual assignment to the variable had already been skipped
previously.

No functional change.

Revision 1.881 / (download) - annotate - [select for diffs], Sun Mar 14 20:12:16 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.880: +11 -13 lines
Diff to previous 1.880 (colored)

make: separate parsing and evaluating for modifier '::='

No functional change.

Revision 1.880 / (download) - annotate - [select for diffs], Sun Mar 14 20:09:26 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.879: +2 -11 lines
Diff to previous 1.879 (colored)

make: in parse-only mode, do not update the expression value in ':sh'

No functional change outside debug mode.  The other variable modifiers
behave in the same way.

Revision 1.879 / (download) - annotate - [select for diffs], Sun Mar 14 20:03:56 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.878: +5 -2 lines
Diff to previous 1.878 (colored)

make: do not evaluate the ':O' modifiers in parse-only mode

No functional change in practical usage.  Theoretically this change can
be observed by looking at the generated random numbers for the ':Ox'
modifier, but the quality or exact sequence of these random numbers is
not guaranteed anyway.

Revision 1.878 / (download) - annotate - [select for diffs], Sun Mar 14 20:00:48 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.877: +16 -19 lines
Diff to previous 1.877 (colored)

make: separate parsing and evaluating in the ':O' modifiers

No functional change.

Revision 1.877 / (download) - annotate - [select for diffs], Sun Mar 14 19:29:37 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.876: +5 -2 lines
Diff to previous 1.876 (colored)

make: do not evaluate modifier ':[...]' in parse-only mode

In parse-only mode, variable expressions in the argument to that
modifier are not resolved.  This led to the error message about the 'Bad
modifier' in var-eval-short.mk.

Revision 1.876 / (download) - annotate - [select for diffs], Sun Mar 14 19:25:05 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.875: +9 -6 lines
Diff to previous 1.875 (colored)

make: do not evaluate modifiers ':M' and ':N' in parse-only mode

No functional change outside debug mode (-dv for ModifyWord_Match).

Revision 1.875 / (download) - annotate - [select for diffs], Sun Mar 14 19:21:28 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.874: +6 -3 lines
Diff to previous 1.874 (colored)

make: do not return unevaluated 'else' part from the ':?' modifier

No functional change outside debug mode.

Revision 1.874 / (download) - annotate - [select for diffs], Sun Mar 14 18:30:24 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.873: +8 -6 lines
Diff to previous 1.873 (colored)

make: do not evaluate ':gmtime' and ':localtime' in parse-only mode

No functional change.

Revision 1.873 / (download) - annotate - [select for diffs], Sun Mar 14 18:23:44 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.872: +28 -8 lines
Diff to previous 1.872 (colored)

make: don't evaluate several simple modifiers in parse-only mode

This affects the modifiers ':E', ':H', ':P', ':Q', ':R', ':T', ':hash',
':q', ':range', ':tl', ':ts', ':tu', and ':u'.  All these modifiers are
side-effect free.

Skipping the evaluation for these modifiers is purely for code
consistency and performance.

No functional change.

Revision 1.872 / (download) - annotate - [select for diffs], Sun Mar 14 18:10:57 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.871: +6 -4 lines
Diff to previous 1.871 (colored)

make: skip strdup when parsing an irrelevant ':L' modifier

No functional change.

Revision 1.871 / (download) - annotate - [select for diffs], Sun Mar 14 18:08:25 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.870: +4 -3 lines
Diff to previous 1.870 (colored)

make: skip memcpy when parsing but not evaluating ':D' and ':U'

No functional change, just a tiny bit of performance improvement,
probably not even measurable.  Having the code nevertheless serves as a
copy-and-paste template for implementing other modifiers that might
perform more costly tasks.

Revision 1.870 / (download) - annotate - [select for diffs], Sun Mar 14 18:02:44 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.869: +7 -2 lines
Diff to previous 1.869 (colored)

make: only evaluate the ':@' modifier if the result is actually used

The test 'var-eval-short' had produced the output 'unexpected' before,
on stderr.  It had been generated by '${:Uword:@${FAIL}@expr@}' by
combining the following obscure "features" of make:

1.  the ':@' modifier loops over the words of the variable.  This
    modifier is not really obscure, it still takes some time to get used
    to it.

2.  the ':@' modifier allows a '$' sign in the variable name, which is
    useless in practice.

3.  the ':@' modifier creates a temporary loop variable in the global
    namespace.  Luckily there are only few collisions with other
    variable names since their naming conventions differ.

4.  after looping over the words of the expression, the temporary global
    loop variable is deleted, and at that point the '$' is expanded,
    being interpreted as the start of a variable expression.

5.  The ':@' modifier deleted the global variable even when it was
    called in parse-only mode (without VARE_WANTRES).

When the modifier ':@' was initially added to make in var.c 1.40 from
2000-04-29, Var_Delete didn't expand the variable name.  That feature
was added in var.c 1.174 from 2013-05-18, probably without thinking of
this very edge-casey combination of features.

This commit fixes item 5 from the above list.  The other obscurities
remain for now.

Revision 1.869 / (download) - annotate - [select for diffs], Sun Mar 14 17:38:24 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.868: +6 -5 lines
Diff to previous 1.868 (colored)

make: eliminate common subexpression in ApplyModifier_Remember

No functional change.

Revision 1.868 / (download) - annotate - [select for diffs], Sun Mar 14 17:34:50 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.867: +10 -12 lines
Diff to previous 1.867 (colored)

make: merge duplicate code in ApplyModifier_Remember

This way, parsing and evaluating the modifier is only written once in
the code.  The downside is that the variable name is allocated even if
VARE_WANTRES is not set, but since this modifier is so obscure and
seldom used this doesn't matter in practice.

Revision 1.867 / (download) - annotate - [select for diffs], Sun Mar 14 17:27:27 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.866: +3 -9 lines
Diff to previous 1.866 (colored)

make: do not expand the variable name in the ':_' modifier

This edge case had been so obscure that even discovering this takes
quite some time and requires reading the source code of make.

The manual page doesn't document whether the variable name is expanded
or not, it doesn't even give an example.  When this obscure modifier was
initially added in var.c 1.210 from 2017-01-30, Var_Set always expanded
the variable name once, and there was no way around it.  Therefore this
expansion has probably been unintentional.

Revision 1.866 / (download) - annotate - [select for diffs], Sun Mar 14 16:43:30 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.865: +16 -10 lines
Diff to previous 1.865 (colored)

make: only evaluate the ':_' modifier if the expression is needed

See var-eval-short.mk:46 for the test demonstrating this change.
Previously, the expression ${:Uword:_=VAR} was evaluated including all
its side effects even though it was in an irrelevant branch of the
condition.

Revision 1.865 / (download) - annotate - [select for diffs], Sun Mar 14 16:03:04 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.864: +5 -2 lines
Diff to previous 1.864 (colored)

make: return failure in TryParseIntBase0 for empty string

No functional change since the only caller of TryParseIntBase0 already
handles all possible parse errors.  Without this check, the code just
looked wrong though.

Revision 1.864 / (download) - annotate - [select for diffs], Sun Mar 14 15:43:31 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.863: +40 -19 lines
Diff to previous 1.863 (colored)

make: separate parsing from evaluating for several modifiers

This aligns the implementation of these modifiers with the requirements
in the long comment starting with 'The ApplyModifier functions'.

No functional change.

Revision 1.863 / (download) - annotate - [select for diffs], Sun Mar 14 15:24:37 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.862: +22 -22 lines
Diff to previous 1.862 (colored)

make: reduce indentation in ApplyModifier_SunShell

No functional change.

Revision 1.862 / (download) - annotate - [select for diffs], Sun Mar 14 15:22:21 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.861: +9 -8 lines
Diff to previous 1.861 (colored)

make: separate parsing and evaluating for modifier ':u'

No functional change.

Revision 1.861 / (download) - annotate - [select for diffs], Sun Mar 14 15:19:15 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.860: +9 -8 lines
Diff to previous 1.860 (colored)

make: separate parsing and evaluating for modifiers ':Q' and ':q'

No functional change.

Revision 1.860 / (download) - annotate - [select for diffs], Sun Mar 14 15:15:28 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.859: +19 -22 lines
Diff to previous 1.859 (colored)

make: extract duplicate code for parsing ':S' and ':C'

No functional change.

Revision 1.859 / (download) - annotate - [select for diffs], Sun Mar 14 15:06:19 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.858: +44 -42 lines
Diff to previous 1.858 (colored)

make: extract duplicate code for detecting a modifier's end

No functional change.

Revision 1.858 / (download) - annotate - [select for diffs], Sun Mar 14 15:04:13 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.857: +12 -2 lines
Diff to previous 1.857 (colored)

make: document how error handling should be done correctly

Right now, when a variable expression cannot be parsed, the result of
calling Var_Subst is a string containing garbage, and no error is
reported.  In addition, there are some silent errors that are not
reported at all.  This combination makes it difficult to change the
error handling without introducing subtle breakage in some edge cases.

An example for garbage output is in varmod-subst-regex.mk, in target
mod-regex-compile-error.

No functional change.

Revision 1.857 / (download) - annotate - [select for diffs], Sun Mar 14 11:15:37 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.856: +34 -33 lines
Diff to previous 1.856 (colored)

make: sort modifiers in ApplyModifier alphabetically

No functional change.

Revision 1.856 / (download) - annotate - [select for diffs], Sun Mar 14 10:57:12 2021 UTC (7 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.855: +8 -2 lines
Diff to previous 1.855 (colored)

make: fix wrong expression evaluation in -dL mode

The modifier ':C' now only compiles the regular expression if the result
of the expression is actually needed.

Several other modifiers have the same bug of evaluating the expression
in cases where this is not needed.  It just doesn't show up because they
don't have any noticeable side effects, other than wasting CPU time.
This affects irrelevant conditions as well.

Revision 1.855 / (download) - annotate - [select for diffs], Tue Feb 23 16:29:52 2021 UTC (7 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.854: +9 -12 lines
Diff to previous 1.854 (colored)

make: reduce indentation in Var_Parse

The extra condition had been necessary before FStr made memory
management simpler.

The Coverity annotation got out-of-date when the parameter was converted
to FStr since that type is not allocated on the heap, only its inner
members are.

No functional change.

Revision 1.854 / (download) - annotate - [select for diffs], Tue Feb 23 16:14:11 2021 UTC (7 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.853: +7 -10 lines
Diff to previous 1.853 (colored)

make: restructure code in ParseVarname to target human readers

Breaking the loop once for depth == 0 and once for depth == 1 was
unnecessarily confusing, as was the nested 'if'.  Start counting with 0
since there is no reason to start at 1.

Evaluating the common subexpression '*p == endc' is left as an exercise
to the compiler.

No functional change.

Revision 1.853 / (download) - annotate - [select for diffs], Tue Feb 23 16:07:14 2021 UTC (7 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.852: +3 -3 lines
Diff to previous 1.852 (colored)

make: improve error message for bad modifier in variable expression

The improvement is especially noteable for variable expressions based on
the empty variable, see moderrs.exp:103.

Revision 1.852 / (download) - annotate - [select for diffs], Tue Feb 23 15:56:29 2021 UTC (7 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.851: +8 -7 lines
Diff to previous 1.851 (colored)

make: improve error message for unclosed modifier

Replace "variable specification" with the more modern "variable
expression", reduce the number of parentheses, output more than a single
character for modifiers, make it obvious that in expressions such as
${:Serror}, the "" means a variable name.

Revision 1.851 / (download) - annotate - [select for diffs], Tue Feb 23 15:19:41 2021 UTC (7 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.850: +4 -3 lines
Diff to previous 1.850 (colored)

make: improve error message for unknown modifier

Back in 1995, the modifiers were all single-character, and it made sense
to print only the first character.  Nowadays, with ':S', ':@var@...@',
'::=' and several others, a little more context is useful to see where
the exact error is.  The actual modifier is still guessed, and the guess
may be wrong as soon as backslashes get involved, but it is still better
than before.

Revision 1.850 / (download) - annotate - [select for diffs], Tue Feb 23 15:07:58 2021 UTC (7 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.849: +5 -5 lines
Diff to previous 1.849 (colored)

make: remove redundant parameter of ApplySingleModifier

Revision 1.849 / (download) - annotate - [select for diffs], Tue Feb 23 15:03:56 2021 UTC (7 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.848: +11 -6 lines
Diff to previous 1.848 (colored)

make: explain non-obvious code around indirect variable modifiers

No functional change.

Revision 1.848 / (download) - annotate - [select for diffs], Tue Feb 23 14:27:27 2021 UTC (7 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.847: +11 -3 lines
Diff to previous 1.847 (colored)

make: comment on possible inconsistency in handling modifier ':sh'

Revision 1.847 / (download) - annotate - [select for diffs], Tue Feb 23 14:21:45 2021 UTC (7 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.846: +7 -2 lines
Diff to previous 1.846 (colored)

make: note inconsistent parsing behavior in modifier ':_='

Revision 1.846 / (download) - annotate - [select for diffs], Tue Feb 23 00:27:47 2021 UTC (8 months ago) by rillig
Branch: MAIN
Changes since 1.845: +3 -3 lines
Diff to previous 1.845 (colored)

make: quote ':S' in error message about missing delimiter

Revision 1.845 / (download) - annotate - [select for diffs], Tue Feb 23 00:25:06 2021 UTC (8 months ago) by rillig
Branch: MAIN
Changes since 1.844: +24 -9 lines
Diff to previous 1.844 (colored)

make: extract ParseModifier_Match into separate function

No functional change.

Revision 1.844 / (download) - annotate - [select for diffs], Tue Feb 23 00:15:22 2021 UTC (8 months ago) by rillig
Branch: MAIN
Changes since 1.843: +4 -3 lines
Diff to previous 1.843 (colored)

make: add context information to error message about ':range' modifier

Revision 1.843 / (download) - annotate - [select for diffs], Tue Feb 23 00:11:07 2021 UTC (8 months ago) by rillig
Branch: MAIN
Changes since 1.842: +8 -8 lines
Diff to previous 1.842 (colored)

make: fix local variable name for parsing arguments

The variable name 'arg' was misleading since after a successful
TryParseTime, it would no longer point to the argument of the variable
modifier, but to the _end_ of the argument.  To reduce confusion, use p
instead, like everywhere else.  This name is less specific, which is
still better than a wrong name.

Revision 1.842 / (download) - annotate - [select for diffs], Tue Feb 23 00:04:48 2021 UTC (8 months ago) by rillig
Branch: MAIN
Changes since 1.841: +3 -3 lines
Diff to previous 1.841 (colored)

make: add quotes around variable name in an error message

Revision 1.841 / (download) - annotate - [select for diffs], Mon Feb 22 23:46:03 2021 UTC (8 months ago) by rillig
Branch: MAIN
Changes since 1.840: +3 -4 lines
Diff to previous 1.840 (colored)

make: reorder code in ModifyWords

No functional change.

Revision 1.840 / (download) - annotate - [select for diffs], Mon Feb 22 23:42:29 2021 UTC (8 months ago) by rillig
Branch: MAIN
Changes since 1.839: +6 -6 lines
Diff to previous 1.839 (colored)

make: use more common parameter order for VarSelectWords

No functional change.

Revision 1.839 / (download) - annotate - [select for diffs], Mon Feb 22 23:39:24 2021 UTC (8 months ago) by rillig
Branch: MAIN
Changes since 1.838: +5 -5 lines
Diff to previous 1.838 (colored)

make: make ModifyWord_Subst a little easier to understand

Addition is easier than subtraction, and the expression 'word + wordLen'
obviously means 'the end of the word', which was not as easy to spot
before.

No functional change.

Revision 1.838 / (download) - annotate - [select for diffs], Mon Feb 22 23:21:33 2021 UTC (8 months ago) by rillig
Branch: MAIN
Changes since 1.837: +15 -16 lines
Diff to previous 1.837 (colored)

make: remove freestanding freeIt variables

These variables all belong to a string variable.  Connect them using
FStr, which reduces the number of variables to keep track of.

No functional change.

Revision 1.837 / (download) - annotate - [select for diffs], Mon Feb 22 22:55:43 2021 UTC (8 months ago) by rillig
Branch: MAIN
Changes since 1.836: +21 -24 lines
Diff to previous 1.836 (colored)

make: remove boolean parameter and return type from VarFreeEnv

There was only a single case where this parameter was false.  Inline
that case.  That was the only case that needed the return value, so
remove that as well.

Revision 1.836 / (download) - annotate - [select for diffs], Mon Feb 22 22:34:04 2021 UTC (8 months ago) by rillig
Branch: MAIN
Changes since 1.835: +5 -2 lines
Diff to previous 1.835 (colored)

make: add a few open questions to Var_SetWithFlags

Revision 1.835 / (download) - annotate - [select for diffs], Mon Feb 22 22:26:50 2021 UTC (8 months ago) by rillig
Branch: MAIN
Changes since 1.834: +4 -5 lines
Diff to previous 1.834 (colored)

make: do not expand variable name from the command line twice in a row

When

1.  there is a global variable containing a dollar in its expanded name
    (very unlikely since there are lots of undocumented edge cases that
    make variable names containing dollar signs fragile), and

2.  after that (unlikely since that requires .MAKEFLAGS instead of a
    normal command line)

3.  there is a command line variable of the same name (again very
    unlikely since that variable name would contain a dollar sign as
    well in the expanded form),

the global variable would not be undefined as promised by the comments
since its name was expanded once more than intended.

Because of the two 'very unlikely' above, this edge case hopefully does
not affect any practical use cases.

Note that this is not about VAR.${param} (which has a dollar sign in its
unexpanded form), but about the case where param itself would expand to
a dollar sign, such as after param=$$.

Revision 1.834 / (download) - annotate - [select for diffs], Mon Feb 22 21:43:57 2021 UTC (8 months ago) by rillig
Branch: MAIN
Changes since 1.833: +30 -21 lines
Diff to previous 1.833 (colored)

make: extract ExistsInCmdline from Var_SetWithFlags

No functional change.

Revision 1.833 / (download) - annotate - [select for diffs], Mon Feb 22 21:30:33 2021 UTC (8 months ago) by rillig
Branch: MAIN
Changes since 1.832: +8 -8 lines
Diff to previous 1.832 (colored)

make: save a hash map lookup when defining a cmdline variable

This is a preparation to extract the code for exporting a cmdline
variable.  That code differs in several details from the other code in
ExportVar.

No functional change.

Revision 1.832 / (download) - annotate - [select for diffs], Mon Feb 22 21:14:15 2021 UTC (8 months ago) by rillig
Branch: MAIN
Changes since 1.831: +12 -2 lines
Diff to previous 1.831 (colored)

make: document interaction between cmdline and global variables

Make prevents global variables from being or becoming visible when a
command line variable of the same name is already defined.

There is a double safety net here.  Even if the call to Var_DeleteExpand
were removed, there would be no noticeable effect, other than one less
line in the debug log.

No functional change.

Revision 1.831 / (download) - annotate - [select for diffs], Tue Feb 16 19:46:15 2021 UTC (8 months ago) by rillig
Branch: MAIN
Changes since 1.830: +10 -12 lines
Diff to previous 1.830 (colored)

make: clean up VarAdd, Var_Delete, Var_ReexportVars

No functional change.

Revision 1.830 / (download) - annotate - [select for diffs], Tue Feb 16 17:41:23 2021 UTC (8 months ago) by rillig
Branch: MAIN
Changes since 1.829: +50 -57 lines
Diff to previous 1.829 (colored)

make: clean up and update comments in var.c

During the refactorings of the last months, several comments have become
outdated, some are now redundant since the code is as clear as the
comment, and some code benefits from a bit of explanation.

Revision 1.829 / (download) - annotate - [select for diffs], Tue Feb 16 16:33:40 2021 UTC (8 months ago) by rillig
Branch: MAIN
Changes since 1.828: +8 -8 lines
Diff to previous 1.828 (colored)

make: use bit-shift expressions for VarFlags constants

These are easier to read than hex constants.

There was no need to skip bits 2 and 3 (there were no constants for 0x04
and 0x08).  Close this gap, to avoid confusing future readers.  Keep the
relative order of the flags since that affects the debug output of -dv.

No functional change.

Revision 1.828 / (download) - annotate - [select for diffs], Tue Feb 16 16:28:41 2021 UTC (8 months ago) by rillig
Branch: MAIN
Changes since 1.827: +38 -38 lines
Diff to previous 1.827 (colored)

make: rename constants for VarFlags

The old prefix was "VAR_" and this prefix is used for several other
constants as well, which made it ambiguous.

Revision 1.827 / (download) - annotate - [select for diffs], Tue Feb 16 16:14:27 2021 UTC (8 months ago) by rillig
Branch: MAIN
Changes since 1.826: +4 -3 lines
Diff to previous 1.826 (colored)

make: sync comment about duplicated code with reality

There are only very few places in var.c that contain really duplicate
code anymore.

There is still lots of _almost_ duplicate, for example the code for
parsing variable modifiers.  It differs subtly in behavior:

*   The modifiers ':M' and ':N' use '$$' to escape a '$' sign, while
    almost all other modifiers use '\$' for this purpose.

*   The modifiers ':M', ':N', ':S', ':@' and several others parse
    balanced parentheses and braces, allowing '(' to '}' to match.
    The modifiers ':D' and ':U' only treat the end character special but
    not the other 3 of '(){}'.

*   When parsing the modifier ':S' but not evaluating it, the code for
    nested variable expressions is parsed differently from when it is in
    evaluation mode (VARE_WANTRES).  This applies to an outer ':S'
    modifier and an inner ':D' or ':M' modifier.

Since these inconsistencies affect the behavior in edge cases and some
users of make might depend on it, they cannot be fixed by
behavior-preserving refactorings.

Revision 1.826 / (download) - annotate - [select for diffs], Mon Feb 15 18:23:32 2021 UTC (8 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.825: +5 -5 lines
Diff to previous 1.825 (colored)

make: rename ExprDefined constants for debug logging

Revision 1.825 / (download) - annotate - [select for diffs], Mon Feb 15 18:21:13 2021 UTC (8 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.824: +27 -27 lines
Diff to previous 1.824 (colored)

make: rename ExprStatus to ExprDefined

The type describes the definedness of an expression, not a general
status, therefore the new name is more precise.

The constants are renamed as well since their prefix 'VES' does not
match the type name anymore, it was correct 3 days ago when the type was
still named VarExprStatus.  The name VES_NONE was misleading since
'none' does not describe its actual effect.  That name came from the
time when the status was a bit set, and 'none' simply meant 'none of the
bits are set'.

The names used in debug logging will be renamed in a follow-up commit,
to demonstrate that the changes in this commit indeed have no functional
change, especially not the change from '!=' to '==' in line 4304.

No functional change.

Revision 1.824 / (download) - annotate - [select for diffs], Mon Feb 15 17:59:08 2021 UTC (8 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.823: +4 -4 lines
Diff to previous 1.823 (colored)

make: update comments for Expr, amending the previous commit

Revision 1.823 / (download) - annotate - [select for diffs], Mon Feb 15 17:44:09 2021 UTC (8 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.822: +200 -164 lines
Diff to previous 1.822 (colored)

make: split parameters for evaluating variable expressions

The details of how variable expressions are evaluated is controlled by
several parameters: startc and endc differ for $(VAR) and ${VAR}, the
value of the expression can be interpreted as a single big word, and
when joining several words (such as with ':M' or ':S'), there may be a
custom word separator (defined with ':ts*').

The scope of half of these parameters is the whole variable expression,
the other half of the parameters are reset after each chain of indirect
modifiers.  To make this distinction obvious in the code, extract Expr
from ApplyModifiersState.  Previously, these details were hidden in how
parameters are passed and restored among ApplyModifiersIndirect and
ApplyModifiers.

The changes in the individual ApplyModifier functions are numerous but
straight-forward.  They mostly replace 'st' with 'expr'.

The changes in ApplyModifiers and ApplyModifiersIndirect are more
subtle.  The value of the expression is no longer passed around but is
stored in a fixed location, in Expr, which makes it easier to reason
about memory management.

The code in ApplyModifiers after 'cleanup' looks quite different but
preserves the existing behavior.  Expr_SetValueRefer is nothing else
than the combination of FStr_Done followed by FStr_InitRefer.  Storing
exprStatus back at the end was responsible for passing the definedness
of the expression after applying the indirect modifiers back to the
outer ApplyModifiersState.  The same effect is now achieved by having
Expr.status with a wider scope.

No functional change.

Revision 1.822 / (download) - annotate - [select for diffs], Mon Feb 15 06:46:01 2021 UTC (8 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.821: +12 -16 lines
Diff to previous 1.821 (colored)

make: clean up code and comments around ModifyWord

In ModifyWords, there is no "passed string" anymore since that function
now directly operates on the expression value.

While here, improve the documentation of ModifyWordsCallback and rename
it to ModifyWordProc, focusing on its purpose instead of where it is
used.

Revision 1.821 / (download) - annotate - [select for diffs], Sun Feb 14 22:48:17 2021 UTC (8 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.820: +122 -140 lines
Diff to previous 1.820 (colored)

make: clean up memory management in evaluation of expressions

The condition "st->newValue.str != val" in ApplySingleModifier made the
memory management look more complicated than it really was.  Freeing an
object based on another object's value is harder to understand than
necessary.

To fix this, the "current value" of the expression is now stored in
ApplyModifiersState, and it gets updated in-place by the ApplyModifier
functions.  This reduces the number of parameters for the ApplyModifier
functions.

Accessing the current value of the expression is now more verbose than
before (st->value.str instead of the simple val).  To compensate for
this verbosity, ApplyModifiersIndirect is now much easier to understand
since there is no extra "current value" floating around.

There is still room for improvement.  In ApplyModifiers, passing an FStr
in and returning another (or possibly the same) makes it difficult to
understand memory management.  Adding a separate Expr type that outlives
the ApplyModifiersState will make this easier, in a follow-up commit.

Revision 1.820 / (download) - annotate - [select for diffs], Sun Feb 14 21:54:42 2021 UTC (8 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.819: +55 -65 lines
Diff to previous 1.819 (colored)

make: reduce redundant code around ModifyWords

The result of ModifyWords had been passed to Expr_SetValueOwn in all
cases.  The last argument to ModifyWords had always been st->sep.

Revision 1.819 / (download) - annotate - [select for diffs], Sun Feb 14 20:22:30 2021 UTC (8 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.818: +4 -3 lines
Diff to previous 1.818 (colored)

make: print error about failed shell command before overwriting variable

Memory management of the value of variable expressions is currently more
complicated than necessary.  It is the responsibility of ApplyModifiers,
even though conceptually the value belongs to an expression, so it
should rather be in Expr.  Right now, this is an alias for
ApplyModifiersState, but that will change soon.

When that is done, there will no longer be a "current value" and a "new
value", only a single "value" of an expression.  At that point, before
Expr_SetValueOwn will overwrite the old value with the output of the
shell command, the error message needs to refer to the latter.

Revision 1.818 / (download) - annotate - [select for diffs], Sun Feb 14 18:59:36 2021 UTC (8 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.817: +4 -11 lines
Diff to previous 1.817 (colored)

make: clean up ValidShortVarname

The switch statement was hard to read, especially the "break" that
needed a comment since it was effectively a "continue".

Revision 1.817 / (download) - annotate - [select for diffs], Sun Feb 14 18:55:51 2021 UTC (8 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.816: +8 -14 lines
Diff to previous 1.816 (colored)

make: clean up ParseVarnameShort

Single-character short variable expressions such as $V neither have a
starting character nor an ending character.  The only interesting
character forms the complete variable name.

No functional change.

Revision 1.816 / (download) - annotate - [select for diffs], Sun Feb 14 18:21:31 2021 UTC (8 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.815: +16 -16 lines
Diff to previous 1.815 (colored)

make: rename VarExprStatus to ExprStatus

It is only used in var.c so there is no need to use a prefix.

Revision 1.815 / (download) - annotate - [select for diffs], Sun Feb 14 17:27:25 2021 UTC (8 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.814: +133 -169 lines
Diff to previous 1.814 (colored)

make: revert part of previous commit

That code was not ready yet.

Revision 1.814 / (download) - annotate - [select for diffs], Sun Feb 14 17:24:47 2021 UTC (8 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.813: +171 -135 lines
Diff to previous 1.813 (colored)

make: update line numbers in expected test output

The documentation from the previous commit added a few lines.

Revision 1.813 / (download) - annotate - [select for diffs], Sun Feb 14 13:53:28 2021 UTC (8 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.812: +68 -56 lines
Diff to previous 1.812 (colored)

make: add functions for assigning the value of an expression

The plan is to have only the "current value" of the expression as a
member, not the "new value".  To do this consistently and get the memory
management right, there must be a single place (or two) where the value
of the expression is updated.

No functional change.

Revision 1.812 / (download) - annotate - [select for diffs], Sun Feb 14 13:46:01 2021 UTC (8 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.811: +12 -10 lines
Diff to previous 1.811 (colored)

make: rename ApplyModifiersState_Define to Expr_Define

The type name ApplyModifiersState was only intended as a working draft,
its name is too long and its scope a little too narrow.

Applying the modifiers is the main part of evaluating a variable
expression, and the scope of that type will be extended to parsing the
name of the expression as well.  This will hopefully reduce the number
of parameters, which is currently at 14.

No functional change.

Revision 1.811 / (download) - annotate - [select for diffs], Sun Feb 14 12:35:27 2021 UTC (8 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.810: +12 -20 lines
Diff to previous 1.810 (colored)

make: condense the code for parsing :S and :C modifiers

No functional change.

Revision 1.810 / (download) - annotate - [select for diffs], Sun Feb 14 12:24:53 2021 UTC (8 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.809: +13 -17 lines
Diff to previous 1.809 (colored)

make: rearrange some comments to make them easier to spot

Revision 1.809 / (download) - annotate - [select for diffs], Sun Feb 14 12:16:13 2021 UTC (8 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.808: +8 -8 lines
Diff to previous 1.808 (colored)

make: document purpose of stepping back in the parser

In ApplyModifier_Assign there was no need to compute the delimiter from
st->startc since that has already be done at that point.

Revision 1.808 / (download) - annotate - [select for diffs], Sat Feb 6 21:40:14 2021 UTC (8 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.807: +12 -11 lines
Diff to previous 1.807 (colored)

make: sync comment for ApplyModifier_Assign with reality

In compat mode, empty shell commands are handled correctly since at
least 1993.

In jobs mode, empty shell commands are handled correctly since at least
job.c 1.93 from 2005-06-16.

The only place where empty shell commands led to problems was in
Cmd_Exec, but that has nothing to do with the example from the comment.
See var-op-shell.mk for more details.

Revision 1.807 / (download) - annotate - [select for diffs], Fri Feb 5 05:42:39 2021 UTC (8 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.806: +29 -18 lines
Diff to previous 1.806 (colored)

make: improve documentation about variable scopes

In an experiment, I tried to separate the concepts of a GNode and a
variable scope.  The global variables SCOPE_GLOBAL, SCOPE_INTERNAL and
SCOPE_CMDLINE are implemented as GNode even though they only need the
members 'name' and 'vars'.  All their other members are unused.
Therefore it seemed natural to extract this part of the GNode into a
separate type called Scope.

The resulting code was harder to read though since it had split the
namespace of the functions into several parts that were not obviously
related: The Var_ functions, the Scope_ functions, and the short-cut
Global_ functions.  Because of this, I threw away the experiment.

All that is left are a few updated comments.

Revision 1.806 / (download) - annotate - [select for diffs], Fri Feb 5 05:19:57 2021 UTC (8 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.805: +9 -8 lines
Diff to previous 1.805 (colored)

make: rename remaining ctx to scope

One less small inconsistency.  Everywhere else, that variable had been
named ctxt, not ctx.

Revision 1.805 / (download) - annotate - [select for diffs], Fri Feb 5 05:15:12 2021 UTC (8 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.804: +34 -34 lines
Diff to previous 1.804 (colored)

make: in the Var_ functions, move the scope to the front

This change provides for a more natural reading order in the code.
Placing the scope first makes it immediately clear in which context the
remaining parameters are interpreted.

No functional change.

Revision 1.804 / (download) - annotate - [select for diffs], Fri Feb 5 04:41:17 2021 UTC (8 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.803: +10 -4 lines
Diff to previous 1.803 (colored)

make: add shortcut Global_Delete for deleting a global variable

Revision 1.803 / (download) - annotate - [select for diffs], Thu Feb 4 21:50:39 2021 UTC (8 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.802: +4 -4 lines
Diff to previous 1.802 (colored)

make: rename Var_ValueDirect to GNode_ValueDirect

Revision 1.802 / (download) - annotate - [select for diffs], Thu Feb 4 21:42:46 2021 UTC (8 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.801: +156 -157 lines
Diff to previous 1.801 (colored)

make: rename context and ctxt to scope

This continues the previous commit, in which VAR_GLOBAL, VAR_INTERNAL
and VAR_CMDLINE were renamed.

Renaming the variable 'ctxt' was trivial since that word is used nowhere
else.  In the comments though, each occurrence of the word 'context' had
to be checked individually since the word 'context' was not only used
for referring to a variable scope.  It is also used to distinguish
different situations where characters are escaped in a certain way
('parsing context') and in a few other expressions.

Revision 1.801 / (download) - annotate - [select for diffs], Thu Feb 4 21:33:14 2021 UTC (8 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.800: +48 -48 lines
Diff to previous 1.800 (colored)

make: rename some VAR constants to SCOPE

The word "context" does not fit perfectly to the variables that are
associate with a GNode, as the context is usually something from the
outside and the variables are more like properties inherent to the
GNode.

The term "global context" fits even less.  Since the thing where
variables are looked up is commonly named a scope, use that term
instead.

This commit only renames the global variables VAR_GLOBAL, VAR_INTERNAL
and VAR_CMDLINE, plus a few very closely related comments.  These are:

	GNode.vars (because of line breaks)
	GNode_Free (dito)
	varname-make_print_var_on_error.mk
	varname-make_print_var_on_error-jobs.mk

The debug message in Var_Stats is left as-is since there is no unit test
for it yet.

The other renamings (variable names "context", "ctxt", as well as
further comments) will be done in a follow-up commit.

Revision 1.800 / (download) - annotate - [select for diffs], Thu Feb 4 19:43:00 2021 UTC (8 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.799: +9 -15 lines
Diff to previous 1.799 (colored)

make: merge SetVar into Var_SetWithFlags

No functional change.

Revision 1.799 / (download) - annotate - [select for diffs], Thu Feb 4 19:15:13 2021 UTC (8 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.798: +13 -5 lines
Diff to previous 1.798 (colored)

make: rename Var_SetWithFlags to Var_SetExpandWithFlags

Add back Var_SetWithFlags for the one call that doesn't need to expand
the name.

Now one of the flags is encoded in the function name while the others
are encoded in VarSetFlags.  This is inconsistent.  Maybe there is a
better way to model the different variants of setting a variable.

Revision 1.798 / (download) - annotate - [select for diffs], Thu Feb 4 19:00:45 2021 UTC (8 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.797: +18 -8 lines
Diff to previous 1.797 (colored)

make: rename Var_Set to Var_SetExpand

After doing the textual renaming across all files, I added a new
function Var_Set that does not expand the variable name.  I then undid
the renaming for all calls where the variable name cannot ever contain a
dollar sign.  I omitted the word "Expand" from the textual references in
the unit tests and in the debug logging messages since the focus is
usually on the "Set" part, not on the "Expand".

No functional change.

Revision 1.797 / (download) - annotate - [select for diffs], Wed Feb 3 15:08:17 2021 UTC (8 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.796: +11 -9 lines
Diff to previous 1.796 (colored)

make: rename Var_Delete to Var_DeleteExpand, Var_DeleteVar to Var_Delete

The function names now follow the naming scheme from the other functions
that handle variables.

There are several calls that remain syntactically unchanged but that
omit the call to strchr('$') now.  Since all these calls use constant
variable names, there is no functional change.

Revision 1.796 / (download) - annotate - [select for diffs], Wed Feb 3 14:33:09 2021 UTC (8 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.795: +20 -11 lines
Diff to previous 1.795 (colored)

make: split Var_Exists into plain Var_Exists and Var_ExistsExpand

Most previous calls to Var_Exists use constant variable names.  Only the
two calls in parse.c need to expand the variable name.

It may be a good idea to expand the variable name once in VarAssign_Eval
instead of repeating the expansion in each of its special cases.

No functional change.

Revision 1.795 / (download) - annotate - [select for diffs], Wed Feb 3 13:53:12 2021 UTC (8 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.794: +6 -6 lines
Diff to previous 1.794 (colored)

make: replace Global_AppendExpand with Global_Append

All callers with a variable name that is guaranteed to not contain a
dollar sign have been converted to call Global_Append instead of the
previous Global_AppendExpand.  After that, Global_AppendExpand was
unused, therefore it was effectively just renamed.

Revision 1.794 / (download) - annotate - [select for diffs], Wed Feb 3 13:44:39 2021 UTC (8 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.793: +52 -35 lines
Diff to previous 1.793 (colored)

make: split Var_Append into Var_Append and Var_AppendExpand

The plain Var_Append now does not expand the variable name anymore.  It
is used in situations where the variable name is known to not contain a
dollar sign.

This is a preparation for adding Global_Append, corresponding to
Global_AppendExpand.

Revision 1.793 / (download) - annotate - [select for diffs], Wed Feb 3 08:40:47 2021 UTC (8 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.792: +10 -10 lines
Diff to previous 1.792 (colored)

make: fix double expansion when appending to a new variable

Revision 1.792 / (download) - annotate - [select for diffs], Wed Feb 3 08:08:18 2021 UTC (8 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.791: +14 -3 lines
Diff to previous 1.791 (colored)

make: replace Global_SetExpand with Global_Set for constant names

Revision 1.791 / (download) - annotate - [select for diffs], Wed Feb 3 08:00:36 2021 UTC (8 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.790: +17 -5 lines
Diff to previous 1.790 (colored)

make: use shortcut functions Global_SetExpand and Global_AppendExpand

There are many places where global variables are set or appended to.  To
reduce clutter and code size, encode the VAR_GLOBAL in the function
name.

The word Expand in the function names says that the variable name is
expanded.  In most of the cases, this is not necessary, but there are no
corresponding functions Global_Set or Global_Append yet.

Encoding the information whether the name is expanded or not in the
function name will make inconsistencies obvious in future manual code
reviews. Letting the compiler check this by using different types for
unexpanded and expanded variable names is probably not worth the effort.
There are still a few bugs to be fixed, such as in SetVar, which expands
the variable name twice in a row.

Revision 1.790 / (download) - annotate - [select for diffs], Tue Feb 2 21:26:51 2021 UTC (8 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.789: +3 -4 lines
Diff to previous 1.789 (colored)

make: remove unused INTERNAL flag

It had been used for cached_realpaths, until this variable had its type
changed from GNode to HashTable in main.c 1.469 from 2020-11-14.

Revision 1.789 / (download) - annotate - [select for diffs], Tue Feb 2 16:18:16 2021 UTC (8 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.788: +35 -34 lines
Diff to previous 1.788 (colored)

make: replace VarExprFlags with VarExprStatus

The combination of !VEF_UNDEF && VEF_DEF was not possible, which made it
rather strange to model this state as a bit set.

The only functional change is the renamed constants in the debug output.

Using ENUM_VALUE_RTTI_2 felt like overengineering since it's harder to
understand than a simple array of names.

Revision 1.788 / (download) - annotate - [select for diffs], Tue Feb 2 15:41:14 2021 UTC (8 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.787: +23 -23 lines
Diff to previous 1.787 (colored)

make: replace enum bit-set with bit-field

No functional change.

The generated code from GCC 5.5 is very similar.  On x86_64, memory
access is no longer in 32-bit units but in 8-bit units since only the
first few bits are actually used.  The bit patterns are the same as
before, so if there is any difference in performance, GCC should have
chosen the more efficient variant all along.

In a previous experiment, the code size increased a lot, surprisingly.

Revision 1.787 / (download) - annotate - [select for diffs], Mon Feb 1 19:46:58 2021 UTC (8 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.786: +3 -3 lines
Diff to previous 1.786 (colored)

make: replace pre-increment with post-increment or simple addition

The rest of the code already prefers post-increment if there is no
actual difference.

Revision 1.786 / (download) - annotate - [select for diffs], Sat Jan 30 21:25:10 2021 UTC (8 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.785: +5 -5 lines
Diff to previous 1.785 (colored)

make(1): inline Buf_Len

Revision 1.785 / (download) - annotate - [select for diffs], Sat Jan 30 21:03:32 2021 UTC (8 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.784: +8 -10 lines
Diff to previous 1.784 (colored)

make(1): inline Buf_GetAll

Revision 1.784 / (download) - annotate - [select for diffs], Sat Jan 30 20:53:29 2021 UTC (8 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.783: +23 -20 lines
Diff to previous 1.783 (colored)

make(1): split Buf_Destroy into Buf_Done and Buf_DoneData

In all cases except one, the boolean argument to Buf_Destroy was
constant.  Removing that argument by splitting the function into two
separate functions makes the intention clearer on the call site.  It
also removes the possibility for using the return value of Buf_Done,
which would have made no sense.

The function Buf_Done now pairs with Buf_Init, just as in HashTable and
Lst.

Even though Buf_Done is essentially a no-op, it is kept as a function,
both for symmetry with Buf_Init and for clearing the Buffer members
after use (this will be done only in CLEANUP mode, in a follow-up
commit).

Revision 1.783 / (download) - annotate - [select for diffs], Sat Jan 30 15:48:42 2021 UTC (8 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.782: +9 -18 lines
Diff to previous 1.782 (colored)

make(1): reduce boilerplate for printing bit sets in debug mode

No functional change.

Revision 1.782 / (download) - annotate - [select for diffs], Sat Jan 16 20:49:31 2021 UTC (9 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.781: +7 -2 lines
Diff to previous 1.781 (colored)

make(1): fix a few inconsistencies for lint's strict bool mode

Revision 1.781 / (download) - annotate - [select for diffs], Sun Jan 10 23:59:53 2021 UTC (9 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.780: +4 -4 lines
Diff to previous 1.780 (colored)

make(1): make a few more bool expressions more precise

The previous version of lint(1) from a few hours ago didn't catch all
occurrences.  And even the current one doesn't catch everything.
Function arguments and return types still need some work.  The "return
quietly" from shouldDieQuietly still implicitly converts from int to
_Bool.

No functional change.

Revision 1.780 / (download) - annotate - [select for diffs], Sun Jan 10 21:20:47 2021 UTC (9 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.779: +4 -4 lines
Diff to previous 1.779 (colored)

make(1): consistently use boolean expressions in conditions

Most of the make code already followed the style of explicitly writing
(ptr != NULL) instead of the shorter (ptr) in conditions.

The remaining 50 instances have been found by an experimental,
unpublished check in lint(1) that treats bool expressions as
incompatible to any other scalar type, just as in Java, C#, Pascal and
several other languages.

The only unsafe operation on Boolean that is left over is (flags &
FLAG), for an enum implementing a bit set.  If Boolean is an ordinary
integer type (the default), some high bits may get lost.  But if Boolean
is the same as _Bool (by compiling with -DUSE_C99_BOOLEAN), C99 6.3.1.2
defines that a conversion from any scalar to the type _Bool acts as a
comparison to 0, which cannot lose any bits.

Revision 1.779 / (download) - annotate - [select for diffs], Sat Jan 9 16:06:09 2021 UTC (9 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.778: +10 -4 lines
Diff to previous 1.778 (colored)

make(1): fix lint warnings

Revision 1.778 / (download) - annotate - [select for diffs], Wed Dec 30 10:03:16 2020 UTC (9 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.777: +114 -58 lines
Diff to previous 1.777 (colored)

make(1): format multi-line comments

Revision 1.777 / (download) - annotate - [select for diffs], Tue Dec 29 03:21:09 2020 UTC (9 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.776: +37 -128 lines
Diff to previous 1.776 (colored)

make(1): clean up code in extracted ExportVar functions

Revision 1.776 / (download) - annotate - [select for diffs], Tue Dec 29 03:05:15 2020 UTC (9 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.775: +140 -27 lines
Diff to previous 1.775 (colored)

make(1): split ExportVar into separate functions

Revision 1.775 / (download) - annotate - [select for diffs], Tue Dec 29 01:48:46 2020 UTC (9 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.774: +10 -10 lines
Diff to previous 1.774 (colored)

make(1): rename local variables in Var_ReexportVars

Revision 1.774 / (download) - annotate - [select for diffs], Mon Dec 28 00:46:24 2020 UTC (9 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.773: +6 -5 lines
Diff to previous 1.773 (colored)

make(1): replace global preserveUndefined with VARE_KEEP_UNDEF

Controlling the expansion of variable expressions using a global
variable and a VARE flag was inconsistent.

Converting the global variable into a flag had to prerequisites:

1.  The unintended duplicate variable assignment had to be fixed, as
done in parse.c 1.520 from 2020-12-27.  Without this fix, it would have
been necessary to add more flags to Var_Exists and Var_SetWithFlags, and
this would have become too complex.

2.  There had to be a unit test demonstrating that VARE_KEEP_DOLLAR only
applies to the top-level expression and is not passed to the
subexpressions, while VARE_KEEP_UNDEF applies to all subexpressions as
well.  This test is in var-op-expand.mk 1.10 from 2020-12-28, at least
for the ':@word@' modifier.  In ParseModifierPartSubst, VARE_KEEP_UNDEF
is not passed down either, in the same way.

Revision 1.773 / (download) - annotate - [select for diffs], Sun Dec 27 16:31:58 2020 UTC (9 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.772: +3 -4 lines
Diff to previous 1.772 (colored)

make(1): remove dead code from ApplyModifiersIndirect

At that point, the expression can never be varUndefined.  At the
beginning of ParseVarnameLong, the expression is initialized to a simple
empty string, and that string is only ever converted to varUndefined at
the very end of Var_Parse.

Revision 1.772 / (download) - annotate - [select for diffs], Sun Dec 27 14:41:25 2020 UTC (9 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.771: +2 -12 lines
Diff to previous 1.771 (colored)

make(1): remove outdated comment about string comparisons

Back in 1993, the variables in a context were stored in a linked list.
Searching such a list indeed required literally thousands of calls to
strcmp.  In make.h 1.22 from 1999-09-15, the linked list was replaced
with a hash table, requiring much fewer string comparisons.  Since then,
the rationale doesn't apply anymore.

Revision 1.771 / (download) - annotate - [select for diffs], Sun Dec 27 14:02:12 2020 UTC (9 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.770: +4 -6 lines
Diff to previous 1.770 (colored)

make(1): remove unnecessary VPR_ERR_SILENT

Revision 1.770 / (download) - annotate - [select for diffs], Sun Dec 27 13:15:43 2020 UTC (9 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.769: +9 -8 lines
Diff to previous 1.769 (colored)

make(1): do not inspect output variables in ParseVarnameShort

Revision 1.769 / (download) - annotate - [select for diffs], Sun Dec 27 13:12:34 2020 UTC (9 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.768: +10 -5 lines
Diff to previous 1.768 (colored)

make(1): move error handling code out of UndefinedShortVarValue

Revision 1.768 / (download) - annotate - [select for diffs], Sun Dec 27 11:03:00 2020 UTC (9 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.767: +39 -29 lines
Diff to previous 1.767 (colored)

make(1): split Var_Subst into easily understandable functions

Extracting the character-level details makes the essence of Var_Subst
visible in the code, which is to iterate over the given text, handling a
few types of tokens.

Revision 1.767 / (download) - annotate - [select for diffs], Sun Dec 27 10:53:23 2020 UTC (9 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.766: +24 -12 lines
Diff to previous 1.766 (colored)

make(1): clean up VarParseResult constants

The many constants were invented because at that time I didn't quite
understand the actual outcomes of Var_Parse that need to be
distinguished.  There are only a few:

(1) Errors, whether they are parse errors, or evaluation errors or
    undefined variables.  The old constants VPR_PARSE_MSG and
    VPR_UNDEF_MSG are merged into VPR_ERR.

(2) Undefined expressions in a situation in which they are allowed.
    Previously the documentation for VPR_UNDEF_SILENT talked about
    undefined expressions in situations where they were not allowed.
    That case is fully covered by VPR_ERR instead.

(3) Errors that are silently ignored.  These are probably bugs.

(4) Everything went fine, the expression has a defined value.

Revision 1.766 / (download) - annotate - [select for diffs], Sun Dec 27 10:09:53 2020 UTC (9 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.765: +3 -3 lines
Diff to previous 1.765 (colored)

make(1): remove unnecessary VPR_UNKNOWN for error handling

There is no sensible way for a caller of Var_Parse to deal with an error
state of "maybe successful, maybe not", therefore remove the constant
for it.

Revision 1.765 / (download) - annotate - [select for diffs], Sun Dec 27 05:06:17 2020 UTC (9 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.764: +20 -15 lines
Diff to previous 1.764 (colored)

make(1): align names of VarExportMode with the directives

Revision 1.764 / (download) - annotate - [select for diffs], Wed Dec 23 13:50:54 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.763: +8 -8 lines
Diff to previous 1.763 (colored)

make(1): rename CmdOpts.lint to strict

When running lint(1) on the code, it defines the preprocessor macro
"lint" to 1, which generated a syntax error in the declaration "Boolean
lint", as that became "Boolean 1".

Revision 1.763 / (download) - annotate - [select for diffs], Wed Dec 23 13:11:27 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.762: +3 -2 lines
Diff to previous 1.762 (colored)

make(1): fix memory leak in Var_Undef (since 2020-12-22)

Revision 1.762 / (download) - annotate - [select for diffs], Tue Dec 22 20:10:21 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.761: +29 -27 lines
Diff to previous 1.761 (colored)

make(1): allow .undef to undefine multiple variables at once

Since make doesn't support variable names containing spaces, this edge
case is not enough reason to stop this feature.  Having multiple
variable names as arguments nicely aligns with other directives such as
.for and .export.

Revision 1.761 / (download) - annotate - [select for diffs], Mon Dec 21 21:04:18 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.760: +6 -6 lines
Diff to previous 1.760 (colored)

make(1): remove excess newline from parse errors (since 2020-11-01)

For the modifiers :gmtime and :localtime, the excess newline had been
added in var.c 1.631 from 2020-10-31 21:40:20.

For the modifiers :range and :ts, the excess newline had been added in
var.c 1.635 from 2020-11-01 14:36:25.

Revision 1.760 / (download) - annotate - [select for diffs], Mon Dec 21 02:38:57 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.759: +47 -44 lines
Diff to previous 1.759 (colored)

make(1): remove redundant parameters from ParseModifierPart

Revision 1.759 / (download) - annotate - [select for diffs], Mon Dec 21 00:30:13 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.758: +6 -6 lines
Diff to previous 1.758 (colored)

make(1): save a few memory allocations in variable expressions

Revision 1.758 / (download) - annotate - [select for diffs], Mon Dec 21 00:20:58 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.757: +66 -65 lines
Diff to previous 1.757 (colored)

make(1): switch memory handling from MFStr to FStr

This makes all intermediate strings constant.  For this simple
search-and-replace refactoring, all intermediate locations where the
"current value of the expression" was stored had to be of the type
MFStr.

Using FStr instead of MFStr allows to save a few memory allocations,
which will be done in the follow-up commits.

Revision 1.757 / (download) - annotate - [select for diffs], Mon Dec 21 00:11:29 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.756: +29 -48 lines
Diff to previous 1.756 (colored)

make(1): clean up memory management for expanding variable expressions

Previously, memory management had been split among several variables.
The general idea was very simple though.  The current value of the
expression needs to be kept in memory, and each modifier either keeps
that value or replaces it with its own newly allocated result, or
var_Error or varUndefined.

Using MFStr, it does not matter anymore that var_Error and varUndefined
are statically allocated since these are assigned using MFStr_InitRefer.

The complexity of the implementation is now closer to the actual
complexity.  Most probably the code can be simplified even more.

Revision 1.756 / (download) - annotate - [select for diffs], Sun Dec 20 23:27:37 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.755: +61 -55 lines
Diff to previous 1.755 (colored)

make(1): use FStr for ApplyModifiersState.newVal

Memory management is still complicated in this area.  To clean this up,
the previous value of the expression needs to be converted to an MFStr
first, and later to an FStr.

Revision 1.755 / (download) - annotate - [select for diffs], Sun Dec 20 19:51:37 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.754: +2 -3 lines
Diff to previous 1.754 (colored)

make(1): remove redundant assignment in ApplyModifier_SysV

Revision 1.754 / (download) - annotate - [select for diffs], Sun Dec 20 19:47:34 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.753: +3 -3 lines
Diff to previous 1.753 (colored)

make(1): error out on unknown variable modifiers at parse time

Before, make printed an "error message" that did not include the word
error and thus was not easily identified as such.  This "error message"
also did not influence the exit status in the default mode but only in
-dL mode.  The error message also didn't include any line number
information and was thus rude.

Revision 1.753 / (download) - annotate - [select for diffs], Sun Dec 20 19:10:53 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.752: +2 -8 lines
Diff to previous 1.752 (colored)

make(1): remove wrong error message for indirect modifier in lint mode

Revision 1.752 / (download) - annotate - [select for diffs], Sun Dec 20 19:02:28 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.751: +24 -14 lines
Diff to previous 1.751 (colored)

make(1): document that indirect modifiers fall back to SysV modifiers

Revision 1.751 / (download) - annotate - [select for diffs], Sun Dec 20 18:23:24 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.750: +5 -5 lines
Diff to previous 1.750 (colored)

make(1): remove redundant const declarations for parameters

Revision 1.750 / (download) - annotate - [select for diffs], Sun Dec 20 18:13:50 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.749: +77 -57 lines
Diff to previous 1.749 (colored)

make(1): extract ApplySingleModifier from ApplyModifiers

Revision 1.749 / (download) - annotate - [select for diffs], Sun Dec 20 17:22:10 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.748: +99 -102 lines
Diff to previous 1.748 (colored)

make(1): turn ApplyModifiersState.val into a local variable

This reduces the scope and makes it more obvious at which places this
variable can be changed and how the memory management is done.

Revision 1.748 / (download) - annotate - [select for diffs], Sun Dec 20 15:31:29 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.747: +11 -13 lines
Diff to previous 1.747 (colored)

make(1): use FStr for memory management in Var_SetWithFlags

Revision 1.747 / (download) - annotate - [select for diffs], Sun Dec 20 15:26:40 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.746: +43 -34 lines
Diff to previous 1.746 (colored)

make(1): extract SetVar from Var_SetWithFlags

SetVar contains the part that is not concerned about memory management
and expansion of the variable name.

Revision 1.746 / (download) - annotate - [select for diffs], Sun Dec 20 15:04:29 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.745: +10 -7 lines
Diff to previous 1.745 (colored)

make(1): fix memory leak in Var_Delete (since yesterday)

The memory leak had been introduced in var.c 1.736 from 2020-12-19
20:47:24.

Revision 1.745 / (download) - annotate - [select for diffs], Sun Dec 20 14:32:13 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.744: +8 -9 lines
Diff to previous 1.744 (colored)

make(1): change return type of Var_Value to FStr

Revision 1.744 / (download) - annotate - [select for diffs], Sun Dec 20 13:50:10 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.743: +7 -8 lines
Diff to previous 1.743 (colored)

make(1): use FStr in VarNew

Revision 1.743 / (download) - annotate - [select for diffs], Sun Dec 20 13:38:43 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.742: +53 -72 lines
Diff to previous 1.742 (colored)

make(1): return FStr from Var_Parse

This reduces the number of variable declarations at the call sites.

Revision 1.742 / (download) - annotate - [select for diffs], Sun Dec 20 12:53:34 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.741: +2 -27 lines
Diff to previous 1.741 (colored)

make(1): export FStr and MFStr

These types are a replacement for the pattern "var + var_freeIt" that
enforces these two variables to be updated together.

Revision 1.741 / (download) - annotate - [select for diffs], Sun Dec 20 11:38:51 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.740: +4 -3 lines
Diff to previous 1.740 (colored)

make(1): document memory handling in ApplyModifiers

Revision 1.740 / (download) - annotate - [select for diffs], Sun Dec 20 10:59:21 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.739: +16 -15 lines
Diff to previous 1.739 (colored)

make(1): replace freeIt with FStr in EvalUndefined

Previously, the parameter out_freeIt was not guaranteed to be
initialized in every case, at least when looking only at EvalUndefined.
This contradicted the variable name.

Replace the two parameters with a single FStr to ensure that these
variables are always initialized together.

Revision 1.739 / (download) - annotate - [select for diffs], Sun Dec 20 00:57:29 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.738: +15 -11 lines
Diff to previous 1.738 (colored)

make(1): replace FStr_Assign with separate initialization functions

In GetVarnamesToUnexport, there is no need to free the local FStr since
the only place where it is assigned an allocated string is at the very
end.

Having separate functions for the two main use cases of a possibly
allocated string makes the calling code simpler.  This is a preparatory
commit for making the memory allocation in ApplyModifiers easier to
understand.

Revision 1.738 / (download) - annotate - [select for diffs], Sun Dec 20 00:47:21 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.737: +32 -12 lines
Diff to previous 1.737 (colored)

make(1): extract string functions from ApplyModifier_To

Revision 1.737 / (download) - annotate - [select for diffs], Sat Dec 19 22:10:17 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.736: +25 -4 lines
Diff to previous 1.736 (colored)

make(1): error out if .undef has not exactly 1 argument

Revision 1.736 / (download) - annotate - [select for diffs], Sat Dec 19 20:47:24 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.735: +30 -18 lines
Diff to previous 1.735 (colored)

make(1): extract Var_DeleteVar from Var_Delete

Revision 1.735 / (download) - annotate - [select for diffs], Sat Dec 19 20:16:36 2020 UTC (10 months ago) by rillig
Branch: MAIN
Changes since 1.734: +16 -2 lines
Diff to previous 1.734 (colored)

make(1): extract Var_Undef from ParseDirective

Revision 1.734 / (download) - annotate - [select for diffs], Sun Dec 13 21:27:45 2020 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.733: +8 -7 lines
Diff to previous 1.733 (colored)

make(1): replace %zu with %u in printf calls

This is needed to compile bmake with GCC 2.8.1 on SunOS 5.9.

To support ancient systems like this, the whole code of usr.bin/make is
supposed to use only ISO C90 features, except for filemon, which is not
used on these systems.

Revision 1.733 / (download) - annotate - [select for diffs], Sun Dec 13 20:14:48 2020 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.732: +3 -5 lines
Diff to previous 1.732 (colored)

make(1): add str_basename to reduce duplicate code

The function basename from POSIX has a few unfortunate properties, it is
allowed to return a pointer to static memory.  This is too unreliable,
therefore this trivial own implementation.

Revision 1.732 / (download) - annotate - [select for diffs], Sun Dec 13 02:15:49 2020 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.731: +10 -20 lines
Diff to previous 1.731 (colored)

make(1): remove dead code from GetVarnamesToUnexport

Now that the parsing of the directives is unified and strict, there is
no need anymore for the dispatched functions to check for unknown
directives.  These functions don't even get the information to decide
that since this decision is already done.

Revision 1.731 / (download) - annotate - [select for diffs], Sun Dec 13 01:41:12 2020 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.730: +7 -34 lines
Diff to previous 1.730 (colored)

make(1): clean up Var_Export

Revision 1.730 / (download) - annotate - [select for diffs], Sun Dec 13 01:33:17 2020 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.729: +26 -31 lines
Diff to previous 1.729 (colored)

make(1): replace bitset VarExportFlags with enum VarExportMode

The previous flags were not combined at all.

Revision 1.729 / (download) - annotate - [select for diffs], Sat Dec 12 21:20:30 2020 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.728: +13 -7 lines
Diff to previous 1.728 (colored)

make(1): eliminate boolean argument of Var_Export

Revision 1.728 / (download) - annotate - [select for diffs], Sat Dec 12 20:00:51 2020 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.727: +14 -7 lines
Diff to previous 1.727 (colored)

make(1): extract ExportVarsExpand from Var_Export

Revision 1.727 / (download) - annotate - [select for diffs], Sat Dec 12 19:39:34 2020 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.726: +18 -17 lines
Diff to previous 1.726 (colored)

make(1): fix undefined behavior when exporting ${:U }

Revision 1.726 / (download) - annotate - [select for diffs], Sat Dec 12 19:31:17 2020 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.725: +28 -22 lines
Diff to previous 1.725 (colored)

make(1): extract ExportVars from Var_Export

Revision 1.725 / (download) - annotate - [select for diffs], Sat Dec 12 18:53:53 2020 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.724: +5 -4 lines
Diff to previous 1.724 (colored)

make(1): rename Var_ExportVars to Var_ReexportVars

Revision 1.724 / (download) - annotate - [select for diffs], Sat Dec 12 18:11:42 2020 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.723: +7 -3 lines
Diff to previous 1.723 (colored)

make(1): error out on misspelled .export directives

Revision 1.723 / (download) - annotate - [select for diffs], Sat Dec 12 18:00:18 2020 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.722: +19 -9 lines
Diff to previous 1.722 (colored)

make(1): error out on misspelled .unexport-env

Revision 1.722 / (download) - annotate - [select for diffs], Sat Dec 12 00:53:23 2020 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.721: +4 -5 lines
Diff to previous 1.721 (colored)

make(1): inline local variable in ApplyModifiersIndirect

Revision 1.721 / (download) - annotate - [select for diffs], Sat Dec 12 00:42:35 2020 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.720: +15 -15 lines
Diff to previous 1.720 (colored)

make(1): in ApplyModifiersIndirect, rename local variable

In other places, the parsing position is abbreviated as pp as well.

Revision 1.720 / (download) - annotate - [select for diffs], Sat Dec 12 00:33:25 2020 UTC (10 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.719: +16 -19 lines
Diff to previous 1.719 (colored)

make(1): remove const from function parameters

These have been left-overs from refactoring, when these pieces were
extracted to separate functions.

Revision 1.719 / (download) - annotate - [select for diffs], Mon Dec 7 01:50:19 2020 UTC (10 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.718: +8 -8 lines
Diff to previous 1.718 (colored)

make(1): rename Var_Export1 to ExportVar

Since Var_Export1 is neither exported by the module nor does it belong
to the Var type, the previous function name was misleading.  The 1 in
the function name was not as expressive as possible.  The new name
aligns nicely with UnexportVar, which is a very young name as well.

Revision 1.718 / (download) - annotate - [select for diffs], Sun Dec 6 18:13:17 2020 UTC (10 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.717: +16 -25 lines
Diff to previous 1.717 (colored)

make(1): remove comment decoration

Revision 1.717 / (download) - annotate - [select for diffs], Sun Dec 6 17:41:52 2020 UTC (10 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.716: +9 -6 lines
Diff to previous 1.716 (colored)

make(1): move CleanEnv to UnexportVars

It clearly didn't belong in the GetVarnamesToUnexport part of the code.

Revision 1.716 / (download) - annotate - [select for diffs], Sun Dec 6 17:35:51 2020 UTC (10 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.715: +19 -17 lines
Diff to previous 1.715 (colored)

make(1): extract UnexportVars from Var_UnExport

Revision 1.715 / (download) - annotate - [select for diffs], Sun Dec 6 17:27:10 2020 UTC (10 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.714: +6 -8 lines
Diff to previous 1.714 (colored)

make(1): clean up GetVarnamesToUnexport

Revision 1.714 / (download) - annotate - [select for diffs], Sun Dec 6 17:22:44 2020 UTC (10 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.713: +40 -24 lines
Diff to previous 1.713 (colored)

make(1): extract GetVarnamesToUnexport from Var_UnExport

Revision 1.713 / (download) - annotate - [select for diffs], Sun Dec 6 16:24:30 2020 UTC (10 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.712: +20 -13 lines
Diff to previous 1.712 (colored)

make(1): replace pointer comparisons with enum

Keeping track of what it means if varname.str == str is not as
expressive as declaring what exactly to unexport.

Revision 1.712 / (download) - annotate - [select for diffs], Sun Dec 6 15:40:46 2020 UTC (10 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.711: +23 -16 lines
Diff to previous 1.711 (colored)

make(1): use FStr in Var_UnExport

Revision 1.711 / (download) - annotate - [select for diffs], Sun Dec 6 14:50:09 2020 UTC (10 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.710: +47 -36 lines
Diff to previous 1.710 (colored)

make(1): add FStr to var.c to make memory handling simpler

The pattern of having a variable and a corresponding freeIt variable
appears over and over again in make, so cast it into a struct.

Revision 1.710 / (download) - annotate - [select for diffs], Sun Dec 6 14:20:20 2020 UTC (10 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.709: +76 -74 lines
Diff to previous 1.709 (colored)

make(1): move type definitions in var.c to the top

Revision 1.709 / (download) - annotate - [select for diffs], Sun Dec 6 13:51:06 2020 UTC (10 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.708: +17 -12 lines
Diff to previous 1.708 (colored)

make(1): extract FreeEnvVar from Var_Parse

Revision 1.708 / (download) - annotate - [select for diffs], Sun Dec 6 10:49:02 2020 UTC (10 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.707: +24 -30 lines
Diff to previous 1.707 (colored)

make(1): inline macros for debug logging

No changes to the resulting binary, except for the line numbers in
assertions.

Revision 1.707 / (download) - annotate - [select for diffs], Sat Dec 5 18:38:02 2020 UTC (10 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.706: +11 -8 lines
Diff to previous 1.706 (colored)

make(1): define constants for enum zero-values

Revision 1.706 / (download) - annotate - [select for diffs], Sat Dec 5 18:15:40 2020 UTC (10 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.705: +2 -3 lines
Diff to previous 1.705 (colored)

make(1): remove redundant assignments

Revision 1.705 / (download) - annotate - [select for diffs], Sat Dec 5 15:31:18 2020 UTC (10 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.704: +36 -36 lines
Diff to previous 1.704 (colored)

make(1): extract ShuffleStrings from ApplyModifier_Order

Revision 1.704 / (download) - annotate - [select for diffs], Sat Dec 5 14:55:17 2020 UTC (10 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.703: +288 -275 lines
Diff to previous 1.703 (colored)

make(1): indent remaining code of var.c with tabs instead of spaces

Revision 1.703 / (download) - annotate - [select for diffs], Sat Dec 5 14:28:09 2020 UTC (10 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.702: +2354 -2245 lines
Diff to previous 1.702 (colored)

make(1): indent large parts of var.c with tabs instead of spaces

The few remaining functions need to be cleaned up before being indented
further, to reduce the overall indentation.

Revision 1.702 / (download) - annotate - [select for diffs], Sat Dec 5 13:01:33 2020 UTC (10 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.701: +3 -3 lines
Diff to previous 1.701 (colored)

make(1): improve explanation of tests for the SysV modifier

Revision 1.701 / (download) - annotate - [select for diffs], Fri Dec 4 22:47:57 2020 UTC (10 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.700: +29 -23 lines
Diff to previous 1.700 (colored)

make(1): extract UnexportEnv from Var_UnExport

Revision 1.700 / (download) - annotate - [select for diffs], Fri Dec 4 22:35:40 2020 UTC (10 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.699: +31 -31 lines
Diff to previous 1.699 (colored)

make(1): extract UnexportVar from Var_UnExport

Revision 1.699 / (download) - annotate - [select for diffs], Sat Nov 28 16:36:19 2020 UTC (10 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.698: +3 -3 lines
Diff to previous 1.698 (colored)

make(1): improve type of local variable in Var_Export1

Revision 1.698 / (download) - annotate - [select for diffs], Sat Nov 28 10:09:28 2020 UTC (10 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.697: +4 -4 lines
Diff to previous 1.697 (colored)

make(1): rename local variable in ModifyWord_Root

The name 'dot' conflicted with the global variable from dir.c when make
was compiled in all-in-one mode.

Revision 1.697 / (download) - annotate - [select for diffs], Sat Nov 28 10:07:26 2020 UTC (10 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.696: +5 -5 lines
Diff to previous 1.696 (colored)

make(1): rename local variable in ModifyWord_Suffix

It conflicted with 'dot' from dir.c.

Revision 1.696 / (download) - annotate - [select for diffs], Tue Nov 24 21:42:28 2020 UTC (10 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.695: +8 -8 lines
Diff to previous 1.695 (colored)

make(1): rename local variable in ApplyModifier_Assign

Revision 1.695 / (download) - annotate - [select for diffs], Mon Nov 23 23:41:11 2020 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.694: +6 -6 lines
Diff to previous 1.694 (colored)

make(1): use comparisons in boolean expressions

The generated code stays exactly the same.

Revision 1.694 / (download) - annotate - [select for diffs], Mon Nov 23 20:52:59 2020 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.693: +5 -6 lines
Diff to previous 1.693 (colored)

make(1): use properly typed comparisons in boolean contexts

Revision 1.693 / (download) - annotate - [select for diffs], Sat Nov 21 18:41:57 2020 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.692: +11 -11 lines
Diff to previous 1.692 (colored)

make(1): rename GNode.context to vars

Especially in the variables module, the expression 'ctxt->context' looked
redundant.  Having a GNode as a context sounds ok, but a context of a
context just doesn't make sense.

Revision 1.692 / (download) - annotate - [select for diffs], Sat Nov 21 15:32:52 2020 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.691: +13 -8 lines
Diff to previous 1.691 (colored)

make(1): clean up freeing of environment variables in Var_Parse

The previous code with the extra boolean variable was a brain-twister
since the responsibility of freeing the memory was distributed over 3
different functions.

Revision 1.691 / (download) - annotate - [select for diffs], Sat Nov 21 15:28:44 2020 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.690: +5 -5 lines
Diff to previous 1.690 (colored)

make(1): clean up parameter order in EvalUndefined

Revision 1.690 / (download) - annotate - [select for diffs], Sat Nov 21 15:02:52 2020 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.689: +9 -9 lines
Diff to previous 1.689 (colored)

make(1): rename local variable in Var_Subst

Revision 1.689 / (download) - annotate - [select for diffs], Tue Nov 17 20:11:02 2020 UTC (11 months ago) by rillig
Branch: MAIN
Changes since 1.688: +4 -5 lines
Diff to previous 1.688 (colored)

make(1): fix error message of failed :!cmd! modifier (since 2000-04-29)

Revision 1.688 / (download) - annotate - [select for diffs], Mon Nov 16 21:39:22 2020 UTC (11 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.687: +5 -5 lines
Diff to previous 1.687 (colored)

make(1): rename Targ_NewGN to GNode_New

This function is a classical constructor function, and if it weren't for
CLEANUP mode, it would have no dependencies on anything else besides the
memory allocator.  Therefore it doesn't really matter which module
defines this function, and there is no need for the "Targ" to be part of
the function name.

Revision 1.687 / (download) - annotate - [select for diffs], Sun Nov 15 18:33:41 2020 UTC (11 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.686: +37 -10 lines
Diff to previous 1.686 (colored)

make(1): add remarks to var.c and the test varmod-match

Revision 1.686 / (download) - annotate - [select for diffs], Sun Nov 15 18:32:29 2020 UTC (11 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.685: +29 -27 lines
Diff to previous 1.685 (colored)

make(1): rename ApplyModifiersState.v to var

Revision 1.685 / (download) - annotate - [select for diffs], Sat Nov 14 21:29:44 2020 UTC (11 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.684: +5 -6 lines
Diff to previous 1.684 (colored)

make(1): replace a few HashTable_CreateEntry with HashTable_Set

Instead of HashTable_CreateEntry and HashEntry_Set, several places just
need the HashEntry for storing a value in it.  This makes the calling
code simpler to understand.

These parts of the code are already hard enough to understand since they
are about memory management and aliasing.  Having a too detailed API for
the HashTable only distracts from these topics.

Revision 1.684 / (download) - annotate - [select for diffs], Tue Nov 10 00:32:12 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.683: +4 -4 lines
Diff to previous 1.683 (colored)

make(1): use consistent definition for MAKE_INLINE

Revision 1.683 / (download) - annotate - [select for diffs], Sun Nov 8 23:38:02 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.682: +9 -9 lines
Diff to previous 1.682 (colored)

make(1): move lint option away from the debug flags

The lint option affects much more than a typical debug flag.  Not only
does it produce additional diagnostics, it also changes the control flow
and fixes the traditional error handling in a few places.

No functional change.

Revision 1.682 / (download) - annotate - [select for diffs], Sun Nov 8 19:53:11 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.681: +3 -8 lines
Diff to previous 1.681 (colored)

make(1): clean up code related to VarEvalFlags

Mention VARE_WANTRES before VARE_UNDEFERR since the latter depends on
the former.

In ApplyModifier_Assign, VARE_KEEP_DOLLAR doesn't have to be removed
from eflags since ParseModifierPart does this already.

In EvalUndefined, testing for VARE_WANTRES is redundant if VARE_UNDEFERR
is already set.

Revision 1.681 / (download) - annotate - [select for diffs], Sun Nov 8 19:24:19 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.680: +12 -14 lines
Diff to previous 1.680 (colored)

make(1): clean up VarEvalFlags in the calls to Var_Parse and Var_Subst

There are only 3 flags, and some combinations don't even make sense.

VARE_UNDEFERR only makes sense if combined with VARE_WANTRES.  If the
latter is not set, the variable expressions are only parsed, without
asking whether they are defined or not.  Therefore, VARE_UNDEFERR cannot
have any effect in that case.

VARE_KEEP_DOLLAR is actively ignored by ParseModifierPart.  In cases
where VARE_WANTRES is not set, this means that VARE_NONE can be passed,
which is easier to grasp than any bitset operations.  This also gets rid
of a few type casts from enum to unsigned int that were necessary to
pass WARNS=6.

Revision 1.680 / (download) - annotate - [select for diffs], Sun Nov 8 18:27:14 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.679: +5 -5 lines
Diff to previous 1.679 (colored)

make(1): rename local variable in VarSubstNested

Revision 1.679 / (download) - annotate - [select for diffs], Sun Nov 8 18:16:55 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.678: +7 -5 lines
Diff to previous 1.678 (colored)

make(1): reorder branches in Var_Subst

This way, '$$' is handled first, followed by '$', followed by everything
else.  This is easier to follow than first '$$' then not '$' and finally
'$'.

Revision 1.678 / (download) - annotate - [select for diffs], Sun Nov 8 18:13:01 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.677: +53 -42 lines
Diff to previous 1.677 (colored)

make(1): extract VarSubstNested from Var_Subst

Each of these functions now fits on a moderately large screen.

Revision 1.677 / (download) - annotate - [select for diffs], Sun Nov 8 16:58:33 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.676: +8 -9 lines
Diff to previous 1.676 (colored)

make(1): rename VARE_ASSIGN to VARE_KEEP_DOLLAR

The other flags in VarEvalFlags already describe their effects, not the
place where they are used.  It's more important to know the effect.

Only a single unit test had to be adjusted.  This probably means that
there are too few tests where the special effects of VARE_KEEP_DOLLAR
come into play.  It could also mean that the effects are so simple and
obvious that they don't need any debug log, but that's not the case.

Revision 1.676 / (download) - annotate - [select for diffs], Sun Nov 8 15:07:37 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.675: +4 -4 lines
Diff to previous 1.675 (colored)

make(1): use strict typing in conditions of the form !var

Revision 1.675 / (download) - annotate - [select for diffs], Sat Nov 7 22:28:24 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.674: +5 -4 lines
Diff to previous 1.674 (colored)

make(1): fix type mismatch between int and VarExportFlags

Revision 1.674 / (download) - annotate - [select for diffs], Sat Nov 7 21:31:07 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.673: +6 -6 lines
Diff to previous 1.673 (colored)

make(1): fix type mismatch between int and VarSetFlags

Revision 1.673 / (download) - annotate - [select for diffs], Sat Nov 7 14:11:58 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.672: +12 -12 lines
Diff to previous 1.672 (colored)

make(1): make API of Buf_Init simpler

In most cases, the caller doesn't want to specify the exact number of
preallocated bytes.

Revision 1.672 / (download) - annotate - [select for diffs], Sat Nov 7 10:16:19 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.671: +11 -11 lines
Diff to previous 1.671 (colored)

make(1): clean up code stylistically

* Replace character literal 0 with '\0'.
* Replace pointer literal 0 with NULL.
* Remove redundant parentheses.
* Parentheses in multi-line conditions are not redundant at the
  beginning of a line.
* Replace a few !ptr with ptr == NULL.
* Replace a few ptr with ptr != NULL.
* Replace (expr & mask) == 0 with !(expr & mask).
* Remove redundant braces for blocks in cases where the generated code
  stays the same.  (Assertions further down in the code would get
  different line numbers.)
* Rename parameters in CondParser_String to reflect the data flow.
* Replace #ifdef notdef with #if 0.

The generated code stays exactly the same, at least with GCC 5.5.0 on
NetBSD 8.0 amd64 using the default configuration.

Revision 1.671 / (download) - annotate - [select for diffs], Sat Nov 7 00:06:13 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.670: +6 -6 lines
Diff to previous 1.670 (colored)

make(1): rename Var_Set_with_flags to Var_SetWithFlags

Now that the function is exported from the var module, it should stick
to the naming conventions for public functions.

Revision 1.670 / (download) - annotate - [select for diffs], Sat Nov 7 00:02:54 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.669: +4 -4 lines
Diff to previous 1.669 (colored)

make(1): rename VarSet_Flags to VarSetFlags

Most other types don't have an underscore as well.

Revision 1.669 / (download) - annotate - [select for diffs], Fri Nov 6 23:11:11 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.668: +3 -3 lines
Diff to previous 1.668 (colored)

make(1): rename getBoolean and s2Boolean

Revision 1.668 / (download) - annotate - [select for diffs], Fri Nov 6 00:29:50 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.667: +21 -27 lines
Diff to previous 1.667 (colored)

make(1): rename local variable in Var_Parse

Revision 1.667 / (download) - annotate - [select for diffs], Fri Nov 6 00:05:18 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.666: +12 -21 lines
Diff to previous 1.666 (colored)

make(1): format source code of a few functions in var.c

Revision 1.666 / (download) - annotate - [select for diffs], Thu Nov 5 23:52:08 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.665: +37 -42 lines
Diff to previous 1.665 (colored)

make(1): update and clean up documentation of Var_Parse

Revision 1.665 / (download) - annotate - [select for diffs], Thu Nov 5 23:24:47 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.664: +11 -11 lines
Diff to previous 1.664 (colored)

make(1): fix parameter name in ApplyModifiersIndirect and ApplyModifiers

The variable must be properly initialized before these functions are
called.

Revision 1.664 / (download) - annotate - [select for diffs], Thu Nov 5 21:16:20 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.663: +14 -13 lines
Diff to previous 1.663 (colored)

make(1): clean up ParseVarnameLong

A parameter named pp is usually used as the parsing position, which is
updated upon successful return.  Not so in ParseVarnameLong, where it
was updated in the unsuccessful branch only.

To avoid confusion, rename it to out_FALSE_pp, which is a longer name
but expresses more clearly what actually happens.

Revision 1.663 / (download) - annotate - [select for diffs], Thu Nov 5 20:50:13 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.662: +42 -32 lines
Diff to previous 1.662 (colored)

make(1): extract EvalUndefined from ParseVarnameLong

Revision 1.662 / (download) - annotate - [select for diffs], Thu Nov 5 18:43:55 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.661: +35 -24 lines
Diff to previous 1.661 (colored)

make(1): extract FindLocalLegacyVar from Var_Parse

Revision 1.661 / (download) - annotate - [select for diffs], Thu Nov 5 18:26:59 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.660: +3 -3 lines
Diff to previous 1.660 (colored)

make(1): replace '(' and ')' with neutral '\0' in Var_Parse

The only possible values for extramodifiers are "H:" and "T:", therefore
parsing is independent of startc and endc.  Use '\0' instead of '(' and
')' to remove any possible confusion about how '{' and '}' would be
handled.

Revision 1.660 / (download) - annotate - [select for diffs], Thu Nov 5 18:20:23 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.659: +8 -11 lines
Diff to previous 1.659 (colored)

make(1): clean up documentation for Var_Subst

Revision 1.659 / (download) - annotate - [select for diffs], Thu Nov 5 17:27:16 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.658: +8 -8 lines
Diff to previous 1.658 (colored)

make(1): remove redundant parentheses from sizeof operator

The parentheses are only needed if the argument is a type, not an
expression.

Revision 1.658 / (download) - annotate - [select for diffs], Thu Nov 5 15:04:51 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.657: +2 -5 lines
Diff to previous 1.657 (colored)

make(1): remove wrong comment from Var_Subst

The error handling in variable expressions is inconsistent.  Some errors
are detected, most aren't.  In particular, the error message for
undefined variables is _not_ issued on undefined variables but instead
on parse errors.

Revision 1.657 / (download) - annotate - [select for diffs], Wed Nov 4 04:49:32 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.656: +8 -3 lines
Diff to previous 1.656 (colored)

make(1): negate discardUndefined to preserveUndefined

Revision 1.656 / (download) - annotate - [select for diffs], Wed Nov 4 04:24:57 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.655: +4 -2 lines
Diff to previous 1.655 (colored)

make(1): add test for undefined variables in command line arguments

The variable discardUndefined has an implicit negation in its name,
which makes it hard to understand.  Plus, most of the time it is true.
It's better to have a flag that is false most of the time and has a
positive name.

On the first attempt of inverting that variable, I stumbled upon
MainParseArgs, which initially leaves discardUndefined == FALSE, and
after handling the dashed options, sets it to TRUE.  This would make a
difference when more command line arguments would be added later via the
.MAKEFLAGS special target.

Upon further inspection, the only place where discardUndefined is used
is in VarAssign_EvalSubst in parse.c, and that place is not reachable
from any of the dashed options.  Therefore, discardUndefined could
already be set at the very beginning of MainParseArgs or even when
initializing the global variable itself, without any observable
difference.

Not even the ::= variable modifier could do anything about this since it
is not reachable from the dashed command line options as well, and in
addition, it expands its right-hand side in any case, always discarding
undefined variables.  Oh, these little inconsistencies everywhere.

Revision 1.655 / (download) - annotate - [select for diffs], Wed Nov 4 03:37:51 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.654: +3 -9 lines
Diff to previous 1.654 (colored)

make(1): rename oldVars to discardUndefined

While here, moved all the documentation about this variable into a
single place.

Revision 1.654 / (download) - annotate - [select for diffs], Wed Nov 4 02:53:18 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.653: +4 -5 lines
Diff to previous 1.653 (colored)

make(1): remove redundant condition from ApplyModifiersIndirect

Whenever varUndefined is returned from another function, that is only
done if eflags does not contain VARE_UNDEFERR.  Therefore, testing for
that flag is unnecessary.

Revision 1.653 / (download) - annotate - [select for diffs], Wed Nov 4 02:26:21 2020 UTC (11 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.652: +6 -13 lines
Diff to previous 1.652 (colored)

make(1): replace emptyString with allocated empty string

Special-casing this variable only made the code more complicated.
Furthermore, it is not related to error handling in any way and
therefore distracted the reader from this topic.

Revision 1.652 / (download) - annotate - [select for diffs], Mon Nov 2 21:34:40 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.651: +10 -8 lines
Diff to previous 1.651 (colored)

make(1): fix error handling on parse errors in variable expressions

This change doesn't change any of the unit tests since the error
handling code is not yet complete, see the many "handle errors" in the
code.  Nevertheless, the "out_FALSE_res = VPR_PARSE_MSG" was wrong since
the error message was only printed in lint mode, not in default mode.

Revision 1.651 / (download) - annotate - [select for diffs], Mon Nov 2 21:24:23 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.650: +8 -7 lines
Diff to previous 1.650 (colored)

make(1): improve local variable name in ParseVarname

Revision 1.650 / (download) - annotate - [select for diffs], Mon Nov 2 21:15:00 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.649: +5 -2 lines
Diff to previous 1.649 (colored)

make(1): document that skipping a modifier on parse errors is risky

Revision 1.649 / (download) - annotate - [select for diffs], Mon Nov 2 20:48:36 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.648: +9 -2 lines
Diff to previous 1.648 (colored)

make(1): error out on unclosed expressions after the colon

Revision 1.648 / (download) - annotate - [select for diffs], Mon Nov 2 19:07:09 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.647: +4 -4 lines
Diff to previous 1.647 (colored)

make(1): remove word "Ptr" from variable names

Whether or not a variable is a pointer is obvious from the context.
Since the introduction of function prototypes in C90, this information
is checked by the compiler and no longer needs to be encoded in the
variable names.

Revision 1.647 / (download) - annotate - [select for diffs], Mon Nov 2 18:15:12 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.646: +3 -3 lines
Diff to previous 1.646 (colored)

make(1): fix wording of a comment in var.c

The "why again" could be easily misunderstood, it was ambiguous.

Revision 1.646 / (download) - annotate - [select for diffs], Mon Nov 2 17:55:26 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.645: +3 -2 lines
Diff to previous 1.645 (colored)

make(1): add a comment where to fix the STOP/STORE test from varmod.mk

Revision 1.645 / (download) - annotate - [select for diffs], Mon Nov 2 17:00:33 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.644: +11 -10 lines
Diff to previous 1.644 (colored)

make(1): format code in ApplyModifiersIndirect and ApplyModifiers

Revision 1.644 / (download) - annotate - [select for diffs], Mon Nov 2 16:55:18 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.643: +6 -10 lines
Diff to previous 1.643 (colored)

make(1): merge variables p and nested_p in ApplyModifiersIndirect

When the code was still in ApplyModifiers, the variable nested_p was
necessary to distinguish the parsing position in the nested modifier
from the parsing position of the main expression.

Revision 1.643 / (download) - annotate - [select for diffs], Mon Nov 2 16:48:49 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.642: +12 -12 lines
Diff to previous 1.642 (colored)

make(1): rename rval to mods in ApplyModifiersIndirect

Revision 1.642 / (download) - annotate - [select for diffs], Mon Nov 2 16:38:47 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.641: +8 -9 lines
Diff to previous 1.641 (colored)

make(1): inline and rename variables in ApplyModifiersIndirect

Revision 1.641 / (download) - annotate - [select for diffs], Sun Nov 1 23:17:40 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.640: +85 -59 lines
Diff to previous 1.640 (colored)

make(1): extract ApplyModifiersIndirect from ApplyModifiers

Revision 1.640 / (download) - annotate - [select for diffs], Sun Nov 1 22:48:41 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.639: +14 -16 lines
Diff to previous 1.639 (colored)

make(1): rename local variable in ApplyModifiers

Revision 1.639 / (download) - annotate - [select for diffs], Sun Nov 1 22:12:54 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.638: +19 -18 lines
Diff to previous 1.638 (colored)

make(1): rename local variables in ApplyModifier_SysV

Revision 1.638 / (download) - annotate - [select for diffs], Sun Nov 1 21:28:42 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.637: +8 -6 lines
Diff to previous 1.637 (colored)

make(1): reduce number of nested parentheses in ApplyModifier_Assign

Revision 1.637 / (download) - annotate - [select for diffs], Sun Nov 1 18:48:13 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.636: +4 -3 lines
Diff to previous 1.636 (colored)

make(1): revert unintended change from previous commit

Revision 1.636 / (download) - annotate - [select for diffs], Sun Nov 1 18:45:49 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.635: +3 -4 lines
Diff to previous 1.635 (colored)

make(1): fix indentation of source code

Revision 1.635 / (download) - annotate - [select for diffs], Sun Nov 1 14:36:25 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.634: +86 -21 lines
Diff to previous 1.634 (colored)

make(1): treat malformed :range, :ts and :[...] as errors

Before, integer overflow in the :[1..2] modifier had not been detected,
and the actual behavior varied between ILP64 and LP64I32 machines.

Before, the :ts modifier accepted character literals like \012345 and
\x1F600, which don't fit in a single character and were thus truncated.

Before, the :range modifier issued an "Unknown modifier" error message
for :range=x, which was not quite correct.  The error message in this
case is now "Invalid number".

Revision 1.634 / (download) - annotate - [select for diffs], Sun Nov 1 13:55:31 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.633: +3 -3 lines
Diff to previous 1.633 (colored)

make(1): add tests for the variable modifiers :[words] and :range

Revision 1.633 / (download) - annotate - [select for diffs], Sun Nov 1 12:34:45 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.632: +7 -6 lines
Diff to previous 1.632 (colored)

make(1): clean up comments in ApplyModifier_Words

Revision 1.632 / (download) - annotate - [select for diffs], Sat Oct 31 23:23:22 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.631: +7 -7 lines
Diff to previous 1.631 (colored)

make(1): rename parameter of Var_Value

Revision 1.631 / (download) - annotate - [select for diffs], Sat Oct 31 21:40:20 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.630: +33 -8 lines
Diff to previous 1.630 (colored)

make(1): make parsing of the :gmtime and :localtime modifiers stricter

These variable modifiers accept an optional timestamp in seconds, to
select which date to print.  This feature is only used very rarely.  The
NetBSD build doesn't use it at all, and the FreeBSD build mainly uses
the plain modifiers :gmtime and :localtime, but not their optional
argument :gmtime=1500000000.

Therefore, this change is not going to affect many builds.  Those that
are indeed affected had been wrong all the time anyway.

At parse time, these errors stop the build, as intended.  After that,
when the actual shell commands of the targets are expanded and run,
these errors don't stop anything, the build just continues as if nothing
had happened.  This is a general problem with Var_Parse, see the many
"handle errors" markers in the code.  Another problem is that on parse
errors, parsing continues and spits out spurious strings of the form
"mtime" and "ocaltime".  This as well is a general problem with error
handling in make.

ok sjg

Revision 1.630 / (download) - annotate - [select for diffs], Sat Oct 31 18:41:07 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.629: +13 -13 lines
Diff to previous 1.629 (colored)

make(1): format #include directives consistently

Revision 1.629 / (download) - annotate - [select for diffs], Sat Oct 31 18:17:08 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.628: +3 -3 lines
Diff to previous 1.628 (colored)

make(1): rename ismeta to is_shell_metachar

The old name was too broad.

Revision 1.628 / (download) - annotate - [select for diffs], Sat Oct 31 18:14:59 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.627: +3 -6 lines
Diff to previous 1.627 (colored)

make(1): remove debug logging for the :Q variable modifier

The same information is already logged in LogAfterApply.

Revision 1.627 / (download) - annotate - [select for diffs], Sat Oct 31 18:05:16 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.626: +6 -6 lines
Diff to previous 1.626 (colored)

make(1): fix local variable names in ParseModifierPart

Revision 1.626 / (download) - annotate - [select for diffs], Sat Oct 31 15:23:52 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.625: +17 -26 lines
Diff to previous 1.625 (colored)

make(1): rewrite VarIsDynamic to VarnameIsDynamic

The condition for the context is the same for both short and long names,
therefore move that condition to the only caller.

Clean up the comment and move its parts to the appropriate places.  The
"with the dollar sign escaped" part had been wrong already in 1993, and
it didn't get better over time.

Revision 1.625 / (download) - annotate - [select for diffs], Sat Oct 31 14:55:33 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.624: +17 -20 lines
Diff to previous 1.624 (colored)

make(1): rename local variable freePtr in Var_Parse

Revision 1.624 / (download) - annotate - [select for diffs], Sat Oct 31 14:47:32 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.623: +28 -25 lines
Diff to previous 1.623 (colored)

make(1): use consistent parameter order in varname parsing functions

Revision 1.623 / (download) - annotate - [select for diffs], Sat Oct 31 14:40:34 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.622: +148 -101 lines
Diff to previous 1.622 (colored)

make(1): extract ParseVarnameLong from Var_Parse

Revision 1.622 / (download) - annotate - [select for diffs], Sat Oct 31 14:12:01 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.621: +52 -32 lines
Diff to previous 1.621 (colored)

make(1): extract ParseVarnameShort from Var_Parse

With its more than 200 lines, the latter has too much code to be read
easily.

Revision 1.621 / (download) - annotate - [select for diffs], Sat Oct 31 12:59:28 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.620: +3 -3 lines
Diff to previous 1.620 (colored)

make(1): fix type of ParseModifierPart parameter delim

Revision 1.620 / (download) - annotate - [select for diffs], Sat Oct 31 12:57:39 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.619: +21 -13 lines
Diff to previous 1.619 (colored)

make(1): extract IsEscapedModifierPart from ParseModifierPart

Revision 1.619 / (download) - annotate - [select for diffs], Sat Oct 31 12:45:42 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.618: +24 -28 lines
Diff to previous 1.618 (colored)

make(1): clean up ModifyWords

Reorder the parameters to match the documentation comment, and the
remaining parameters in chronological order.  Remove the unused
parameter ctxt.  The callbacks that need it pass it in their
modifyWordArgs instead.

Revision 1.618 / (download) - annotate - [select for diffs], Sat Oct 31 12:34:03 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.617: +4 -4 lines
Diff to previous 1.617 (colored)

make(1): add test for combining the :@ and :? variable modifiers

Revision 1.617 / (download) - annotate - [select for diffs], Sat Oct 31 12:22:43 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.616: +3 -3 lines
Diff to previous 1.616 (colored)

make(1): remove redundant condition for regmatch_t.rm_eo being -1

If rm_so is -1, rm_eo is guaranteed to be -1 as well.

Revision 1.616 / (download) - annotate - [select for diffs], Sat Oct 31 11:54:33 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.615: +11 -2 lines
Diff to previous 1.615 (colored)

make(1): do not look up local variables like .TARGET anywhere else

Nobody defines a global variable named .TARGET since that would have
many unpredictable effects, applying to all targets at once.

Nobody defines an environment variable named .TARGET since that's
against the naming conventions for environment variables and would have
the same effect.

Because of this, there is no point looking up the variables that are
local to a GNode anywhere else.  This means they cannot come from the
environment and thus their value doesn't need to be freed after use,
which makes the code simpler.

The newly added accessor functions in make.h refer to external
functions, but since that header is not used anywhere outside of
usr.bin/make, it doesn't matter.  Between 2020-08-25 and 2020-10-30,
that header had been referenced by usr.bin/xinstall.

Revision 1.615 / (download) - annotate - [select for diffs], Sat Oct 31 11:34:30 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.614: +5 -9 lines
Diff to previous 1.614 (colored)

make(1): reduce the scope where recursive expressions are detected

Only the call to Var_Subst needs to be protected since the other
functions have nothing to do with expanding variables.

Revision 1.614 / (download) - annotate - [select for diffs], Sat Oct 31 09:57:47 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.613: +4 -4 lines
Diff to previous 1.613 (colored)

make(1): fix indentation in source code

Revision 1.613 / (download) - annotate - [select for diffs], Sat Oct 31 09:27:19 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.612: +3 -3 lines
Diff to previous 1.612 (colored)

make(1): remove redundant null check from s2Boolean

Revision 1.612 / (download) - annotate - [select for diffs], Sat Oct 31 09:03:36 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.611: +2 -7 lines
Diff to previous 1.611 (colored)

make(1): remove redundant code branch in SysVMatch

The general code path of parsing :from=to achieves the same effect.

Revision 1.611 / (download) - annotate - [select for diffs], Sat Oct 31 08:40:54 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.610: +9 -15 lines
Diff to previous 1.610 (colored)

make(1): merge duplicate code in ModifyWord_Subst

Revision 1.610 / (download) - annotate - [select for diffs], Fri Oct 30 22:55:34 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.609: +14 -18 lines
Diff to previous 1.609 (colored)

make(1): rename Str_SYSVMatch and its parameters

Revision 1.609 / (download) - annotate - [select for diffs], Fri Oct 30 22:49:07 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.608: +12 -9 lines
Diff to previous 1.608 (colored)

make(1): improve variable name in Var_Value, document callback

Revision 1.608 / (download) - annotate - [select for diffs], Fri Oct 30 22:43:39 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.607: +7 -10 lines
Diff to previous 1.607 (colored)

make(1): remove unsatisfiable conditions in Var_Set_with_flags

Revision 1.607 / (download) - annotate - [select for diffs], Fri Oct 30 22:30:42 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.606: +13 -8 lines
Diff to previous 1.606 (colored)

make(1): document where the variable name is expanded

Revision 1.606 / (download) - annotate - [select for diffs], Fri Oct 30 20:30:44 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.605: +3 -3 lines
Diff to previous 1.605 (colored)

make(1): change char * to void * in Var_Value

The only purpose of the parameter freeIt is to free the memory
associated with the return value.  To do this, no pointer arithmetic is
needed.  Therefore, change to a void pointer, to catch accidental use of
that pointer.

Revision 1.605 / (download) - annotate - [select for diffs], Fri Oct 30 17:10:48 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.604: +22 -30 lines
Diff to previous 1.604 (colored)

make(1): clean up comments and local variables in var.c

Revision 1.604 / (download) - annotate - [select for diffs], Fri Oct 30 16:54:38 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.603: +6 -6 lines
Diff to previous 1.603 (colored)

make(1): fix documentation for VARP_SUB_ONE

The pattern is only replaced a single time, not everywhere in the first
matching word.

Revision 1.603 / (download) - annotate - [select for diffs], Fri Oct 30 16:48:58 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.602: +6 -8 lines
Diff to previous 1.602 (colored)

make(1): make iterating over HashTable simpler

Revision 1.602 / (download) - annotate - [select for diffs], Fri Oct 30 16:45:37 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.601: +5 -5 lines
Diff to previous 1.601 (colored)

make(1): rename VAR_EXPORTED_YES to VAR_EXPORTED_SOME

The "yes" sounded too much like "all".

Revision 1.601 / (download) - annotate - [select for diffs], Fri Oct 30 16:16:16 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.600: +11 -3 lines
Diff to previous 1.600 (colored)

make(1): document VAR_READONLY, now that it is really read-only

Revision 1.600 / (download) - annotate - [select for diffs], Fri Oct 30 16:09:56 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.599: +4 -2 lines
Diff to previous 1.599 (colored)

make(1): prevent appending to read-only variables

Revision 1.599 / (download) - annotate - [select for diffs], Fri Oct 30 15:39:17 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.598: +15 -15 lines
Diff to previous 1.598 (colored)

make(1): fix indentation in source code

Revision 1.598 / (download) - annotate - [select for diffs], Fri Oct 30 15:28:38 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.597: +22 -15 lines
Diff to previous 1.597 (colored)

make(1): extract MayExport from Var_Export1

Revision 1.597 / (download) - annotate - [select for diffs], Fri Oct 30 07:47:11 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.596: +8 -6 lines
Diff to previous 1.596 (colored)

make(1): remove redundant evaluations in VarFind

Revision 1.596 / (download) - annotate - [select for diffs], Fri Oct 30 07:37:30 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.595: +13 -21 lines
Diff to previous 1.595 (colored)

make(1): replace VarFindFlags with a simple Boolean

Either all flags had been given or none.  Except in Var_Append, but
since the ctxt was VAR_GLOBAL anyway, adding FIND_GLOBAL there did not
make a difference.

Revision 1.595 / (download) - annotate - [select for diffs], Fri Oct 30 07:30:29 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.594: +10 -12 lines
Diff to previous 1.594 (colored)

make(1): rename FIND_CMD to FIND_CMDLINE, to match VAR_CMDLINE

While here, use a consistent order for the enum constants.  This is both
the declaration order and at the same time the usual lookup order,
unless the -e option is given.

Revision 1.594 / (download) - annotate - [select for diffs], Fri Oct 30 07:19:30 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.593: +26 -26 lines
Diff to previous 1.593 (colored)

make(1): rename VAR_CMD to VAR_CMDLINE

Since make has to do with both the command line and child commands, the
former name was confusing.

Revision 1.593 / (download) - annotate - [select for diffs], Fri Oct 30 06:59:12 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.592: +7 -6 lines
Diff to previous 1.592 (colored)

make(1): rename SAVE_DOLLARS to follow the naming conventions

Revision 1.592 / (download) - annotate - [select for diffs], Fri Oct 30 06:44:57 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.591: +33 -25 lines
Diff to previous 1.591 (colored)

make(1): clean up and update module comment in var.c

Revision 1.591 / (download) - annotate - [select for diffs], Tue Oct 27 07:16:27 2020 UTC (11 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.590: +3 -3 lines
Diff to previous 1.590 (colored)

make(1): initialize all CmdOpts fiels

Revision 1.590 / (download) - annotate - [select for diffs], Mon Oct 26 21:34:10 2020 UTC (11 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.589: +5 -5 lines
Diff to previous 1.589 (colored)

make(1): group the command line options and arguments

By having a single struct that holds all command line options and
arguments, it is easy to see in the code when such a command line
argument is modified.  It also cleans up the namespace since the command
line options don't follow a common naming style.  Having them in a
struct also means that there is a single place for putting the
documentation, not two as before.

The struct also suggests to extract the initialization code out of main,
which is still too large, having more than 400 lines of code and
covering far too many topics.

Revision 1.589 / (download) - annotate - [select for diffs], Sun Oct 25 21:51:49 2020 UTC (11 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.588: +3 -3 lines
Diff to previous 1.588 (colored)

make(1): add GNode_Path to access the path of a GNode

Revision 1.588 / (download) - annotate - [select for diffs], Sun Oct 25 19:19:07 2020 UTC (11 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.587: +13 -13 lines
Diff to previous 1.587 (colored)

make(1): rename hash functions to identify the type name

This makes it easier to spot mismatches between the function name and
its first parameter, although the compiler should already catch most of
them.  Except for void pointers.

Revision 1.587 / (download) - annotate - [select for diffs], Sun Oct 25 19:11:30 2020 UTC (11 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.586: +14 -8 lines
Diff to previous 1.586 (colored)

make(1): reduce duplicate code in VarFind

Revision 1.586 / (download) - annotate - [select for diffs], Sun Oct 25 17:01:05 2020 UTC (11 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.585: +10 -8 lines
Diff to previous 1.585 (colored)

make(1): reduce amount of string hashing

In pkgsrc, running "bmake show-all" in pkgtools/pkglint called the hash
function 249130 times before, and only 115502 times after.

Still, a single call to Var_Set hashes the same string 3 times.

Revision 1.585 / (download) - annotate - [select for diffs], Sun Oct 25 13:06:12 2020 UTC (11 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.584: +11 -9 lines
Diff to previous 1.584 (colored)

make(1): replace PtrVector with Vector, which can contain any type

Revision 1.584 / (download) - annotate - [select for diffs], Sun Oct 25 12:08:53 2020 UTC (11 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.583: +6 -6 lines
Diff to previous 1.583 (colored)

make(1): rename type Vector to PtrVector

This allows the name Vector to be used for a more generic vector type,
which will be added soon.

Revision 1.583 / (download) - annotate - [select for diffs], Sat Oct 24 20:51:49 2020 UTC (11 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.582: +10 -9 lines
Diff to previous 1.582 (colored)

make(1): remove macros MIN and MAX

These macros typically evaluate one of their arguments twice.  Until
2020-08-31, they had not parenthesized their arguments properly.  They
are only used in a few places, therefore it doesn't hurt much to have
them expanded.

Revision 1.582 / (download) - annotate - [select for diffs], Fri Oct 23 13:38:17 2020 UTC (12 months ago) by rillig
Branch: MAIN
Changes since 1.581: +7 -7 lines
Diff to previous 1.581 (colored)

make(1): move comment in Var_Set_with_flags

Until 2000-05-11, that comment was just above a VarFind call.  20 years
later, it is back again where it belongs.

Revision 1.581 / (download) - annotate - [select for diffs], Thu Oct 22 05:50:02 2020 UTC (12 months ago) by rillig
Branch: MAIN
Changes since 1.580: +3 -3 lines
Diff to previous 1.580 (colored)

make(1): remove redundant type casts

This mainly affects the void pointers in callback functions for lists.
These had been necessary once when the parameter type was still
ClientData instead of void pointer.

Revision 1.580 / (download) - annotate - [select for diffs], Thu Oct 22 05:35:21 2020 UTC (12 months ago) by rillig
Branch: MAIN
Changes since 1.579: +40 -36 lines
Diff to previous 1.579 (colored)

make(1): extract CanonicalVarname from VarFind

Revision 1.579 / (download) - annotate - [select for diffs], Tue Oct 20 23:15:23 2020 UTC (12 months ago) by rillig
Branch: MAIN
Changes since 1.578: +6 -2 lines
Diff to previous 1.578 (colored)

make(1): document parameter to Var_Parse

Revision 1.578 / (download) - annotate - [select for diffs], Sun Oct 18 17:19:54 2020 UTC (12 months ago) by rillig
Branch: MAIN
Changes since 1.577: +8 -8 lines
Diff to previous 1.577 (colored)

make(1): add tags to enum types

This allows IDEs to offer better type information than "anonymous enum".

Revision 1.577 / (download) - annotate - [select for diffs], Sun Oct 18 12:47:43 2020 UTC (12 months ago) by rillig
Branch: MAIN
Changes since 1.576: +5 -5 lines
Diff to previous 1.576 (colored)

make(1): rename HashEntry.name to key

Revision 1.576 / (download) - annotate - [select for diffs], Sun Oct 18 12:36:43 2020 UTC (12 months ago) by rillig
Branch: MAIN
Changes since 1.575: +8 -8 lines
Diff to previous 1.575 (colored)

make(1): remove underscore from Hash_Table and Hash_Entry

For consistency with the other type names, such as GNodeListNode.

Revision 1.575 / (download) - annotate - [select for diffs], Sun Oct 18 10:44:25 2020 UTC (12 months ago) by rillig
Branch: MAIN
Changes since 1.574: +15 -15 lines
Diff to previous 1.574 (colored)

make(1): make API for iterating over hash tables simpler

Revision 1.574 / (download) - annotate - [select for diffs], Sun Oct 18 08:58:29 2020 UTC (12 months ago) by rillig
Branch: MAIN
Changes since 1.573: +6 -6 lines
Diff to previous 1.573 (colored)

make(1): rename Stack to Vector

Both Var_Dump and GetActuallyIncludingFile access more than only the top
item of the stack, therefore it is more honest to rename the data type.

Revision 1.573 / (download) - annotate - [select for diffs], Sun Oct 18 08:47:54 2020 UTC (12 months ago) by rillig
Branch: MAIN
Changes since 1.572: +23 -13 lines
Diff to previous 1.572 (colored)

make(1): sort variables in debug output

This way it's easier to see whether an expected variable is missing, or
to compare the values of related variables, since they usually share a
common prefix.  Any sorting criterion is better than the hash code.

Sorting the variables by name changed the order of the output in
varname.mk.  That test didn't test anything meaningful, it was just a
playground to understand and demonstrate the current implementation of
how the variables are stored, therefore it has been removed.

Revision 1.572 / (download) - annotate - [select for diffs], Sat Oct 17 21:32:30 2020 UTC (12 months ago) by rillig
Branch: MAIN
Changes since 1.571: +4 -4 lines
Diff to previous 1.571 (colored)

make(1): normalize initialization and cleanup of the modules

Revision 1.571 / (download) - annotate - [select for diffs], Sat Oct 17 17:47:14 2020 UTC (12 months ago) by rillig
Branch: MAIN
Changes since 1.570: +15 -15 lines
Diff to previous 1.570 (colored)

make(1): fix indentation

Revision 1.570 / (download) - annotate - [select for diffs], Tue Oct 6 08:13:27 2020 UTC (12 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.569: +40 -30 lines
Diff to previous 1.569 (colored)

make(1): rework memory allocation for the name of variables

There's more to know about variable names than fits in a one-liner.
While here, enforce that the name is not modified by splitting it into
the established (var + var_freeIt) pattern.

Since the name is not modified and not freed in the middle of evaluating
an expression, there is no need to make a backup copy of it.  That code
had been necessary more than 12 years ago, but not anymore since the
code got a lot cleaner since then.

Revision 1.569 / (download) - annotate - [select for diffs], Tue Oct 6 07:52:47 2020 UTC (12 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.568: +19 -31 lines
Diff to previous 1.568 (colored)

make(1): remove duplicate code for creating variables

Revision 1.568 / (download) - annotate - [select for diffs], Mon Oct 5 19:39:30 2020 UTC (12 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.567: +3 -3 lines
Diff to previous 1.567 (colored)

make(1): fix compilation with GCC 10 and -Wimplicit-fallthrough=4

Revision 1.567 / (download) - annotate - [select for diffs], Mon Oct 5 19:27:47 2020 UTC (12 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.566: +53 -27 lines
Diff to previous 1.566 (colored)

make(1): revert previous commit

It had accidentally reverted all the work from the past few days.

Revision 1.566 / (download) - annotate - [select for diffs], Mon Oct 5 19:24:29 2020 UTC (12 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.565: +27 -53 lines
Diff to previous 1.565 (colored)

make(1): fix double-free bug in -DCLEANUP mode (since 2020-10-02)

The bug had been introduced with dir.c 1.155 on 2020-10-02 22:20:25.  In
that commit, openDirectories was replaced with a combination of a list
with a hash table, for more efficient lookup by name.

Upon cleanup, OpenDirs_Done is called, which in turn called
Dir_ClearPath.  Dir_ClearPath takes full ownership of the given list and
empties it.  This was no problem before since afterwards the list was
empty and calling Lst_Free just frees the remaining list pointer.

With OpenDirs, this list was combined with a hash table, and the hash
table contains the list nodes, assuming that the OpenDirs functions have
full ownership of both the list and the hash table.  This assumption was
generally correct, except for the one moment during cleanup where full
ownership of the list was passed to Dir_ClearPath, while the hash table
still contained pointers to the (now freed) list nodes.  This by itself
was not a problem since the hash table would be freed afterwards.  But
as part of Dir_ClearPath, OpenDirs_Remove was called, which looked up
the freed directory by name and now found the freed list node, trying to
free it again.  Boom.

Fixed by replacing the call to Dir_ClearPath with code that only frees
the directories, without giving up control over the list.

Revision 1.565 / (download) - annotate - [select for diffs], Sun Oct 4 10:35:25 2020 UTC (12 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.564: +3 -7 lines
Diff to previous 1.564 (colored)

make(1): only use the VARE_ASSIGN flag if necessary

When checking the right-hand side of a variable assignment for syntax
errors, it does not matter  whether a '$$' is expanded to '$' or kept as
'$$'.

Revision 1.564 / (download) - annotate - [select for diffs], Sat Oct 3 21:19:54 2020 UTC (12 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.563: +3 -4 lines
Diff to previous 1.563 (colored)

make(1): use consistent pattern for parsing whitespace

The pp and cpp in the function names stand for "parsing position" and
"const parsing position".

Revision 1.563 / (download) - annotate - [select for diffs], Sat Oct 3 14:41:20 2020 UTC (12 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.562: +6 -3 lines
Diff to previous 1.562 (colored)

make(1): inline Str_FindSubstring in ModifyWord_Subst

Revision 1.562 / (download) - annotate - [select for diffs], Sat Oct 3 12:51:49 2020 UTC (12 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.561: +13 -6 lines
Diff to previous 1.561 (colored)

make(1): extract ApplyModifier_Literal into separate function

Revision 1.561 / (download) - annotate - [select for diffs], Sat Oct 3 12:46:52 2020 UTC (12 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.560: +14 -8 lines
Diff to previous 1.560 (colored)

make(1): extract ApplyModifier_Unique into separate function

Revision 1.560 / (download) - annotate - [select for diffs], Sat Oct 3 12:30:17 2020 UTC (12 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.559: +17 -4 lines
Diff to previous 1.559 (colored)

make(1): in lint mode, reject modifiers without delimiter

The expression ${VAR:LPL} must now be written as ${VAR:L:P:L}.  The
manual page has never documented that some modifiers don't need to be
delimited by ':' and others need to.  That would have been unnecessarily
confusing anyway.

Revision 1.559 / (download) - annotate - [select for diffs], Sat Oct 3 10:42:08 2020 UTC (12 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.558: +4 -4 lines
Diff to previous 1.558 (colored)

make(1): ignore -env and -literal in assignments to .MAKE.EXPORTED

Previously, assigning the string "-env" to the variable .MAKE.EXPORTED
had the same effect as the .export-env directive.  This was only due to
a sloppy implementation, not by design.

For the string "-literal" and the directive .export-literal, the
situation was even worse since the actually executed code was a wild
mixture between .export and .export-literal that in the end exported the
expanded form of the variable.  Therefore there was no practical use
case of this implementation flaw.

Revision 1.558 / (download) - annotate - [select for diffs], Sat Oct 3 10:31:05 2020 UTC (12 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.557: +4 -2 lines
Diff to previous 1.557 (colored)

make(1): do not export variable names starting with '-'

By convention, names of environment variables consist of uppercase
letters and underscores.  Most of them start with an uppercase letter.
In a few cases, the names also contain lowercase letters, such as in
http_proxy.

Variable names starting with a hyphen are confusing and might be
mistaken as command line options.  Therefore don't export these.

This also affects a few edge cases that don't occur in practice, such as
setting .MAKE.EXPORTED=-env or .MAKE.EXPORTED=-literal.  These had not
worked as expected anyway.

Revision 1.557 / (download) - annotate - [select for diffs], Sat Oct 3 10:13:39 2020 UTC (12 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.556: +5 -5 lines
Diff to previous 1.556 (colored)

make(1): clean up confusing code in Var_Export

The generated code stays exactly the same.

Revision 1.556 / (download) - annotate - [select for diffs], Fri Oct 2 17:42:33 2020 UTC (12 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.555: +22 -14 lines
Diff to previous 1.555 (colored)

make(1): in ApplyModifier_To, update pp in each branch

Before, the parsing position was updated once at the beginning, which
didn't make sense.  Updating it in each branch allows to decide for its
appropriate value in each branch individually.

Revision 1.555 / (download) - annotate - [select for diffs], Wed Sep 30 06:46:43 2020 UTC (12 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.554: +15 -8 lines
Diff to previous 1.554 (colored)

make(1): extract ApplyModifier_Quote into separate function

Revision 1.554 / (download) - annotate - [select for diffs], Wed Sep 30 05:58:22 2020 UTC (12 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.553: +3 -3 lines
Diff to previous 1.553 (colored)

make(1): fix bug in evaluation of indirect variable modifiers

Since 2020-09-22, when indirect variable modifiers were applied to a
variable expression based on an undefined variable, these modifiers did
not change the state of a variable expression from undefined to defined.
The modifiers that do this are :D, :U, :L, :P.  Minimal example:

	${VARNAME:${:UL}}

The :L modifier from the inner expression sets the value of the outer
expression to its variable name, in this case "VARNAME".  The outer
expression was not marked as being defined though, which resulted in a
"Malformed conditional" error.

In the commit from 2020-09-22, vardebug.exp had changed a lot, and I had
not inspected the change closely.  The important detail was in lines 56
and 60, where VAR_JUNK|VAR_KEEP changed into VEF_UNDEF, thereby losing
the VEF_DEF bit.

Revision 1.553 / (download) - annotate - [select for diffs], Tue Sep 29 19:20:08 2020 UTC (12 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.552: +4 -4 lines
Diff to previous 1.552 (colored)

make(1): rename ShortVarValue to UndefinedShortVarValue

Revision 1.552 / (download) - annotate - [select for diffs], Tue Sep 29 18:44:30 2020 UTC (12 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.551: +2 -4 lines
Diff to previous 1.551 (colored)

make(1): remove unused assignments to local variables

These only became obvious once ApplyModifier had been extracted, which
shrank the source code of ApplyModifiers by about 100 lines.

Even GCC 5 had seen that they are redundant and had not generated any
code for them.

Revision 1.551 / (download) - annotate - [select for diffs], Tue Sep 29 18:31:39 2020 UTC (12 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.550: +82 -101 lines
Diff to previous 1.550 (colored)

make(1): extract ApplyModifier from ApplyModifiers

This allows a return, instead of a variable assignment followed by a
break, saving a few lines of source code.

The size of the resulting binary shrinks as well, even though the code
is essentially the same as before.

Revision 1.550 / (download) - annotate - [select for diffs], Mon Sep 28 22:23:35 2020 UTC (12 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.549: +21 -23 lines
Diff to previous 1.549 (colored)

make(1): make debug logging simpler

This avoids referring to the debug_file variable in many places where
this implementation detail is not necessary.

Revision 1.549 / (download) - annotate - [select for diffs], Mon Sep 28 21:11:05 2020 UTC (12 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.548: +50 -40 lines
Diff to previous 1.548 (colored)

make(1): extract logging from ApplyModifiers into separate functions

These two logging blocks are massive enough to disturb the reading flow
of the remaining code.

Even without these two blocks, ApplyModifiers is still 250 lines long,
which is quite much.

Revision 1.548 / (download) - annotate - [select for diffs], Mon Sep 28 21:01:53 2020 UTC (12 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.547: +24 -14 lines
Diff to previous 1.547 (colored)

make(1): move variable modifier :sh into separate function

Revision 1.547 / (download) - annotate - [select for diffs], Mon Sep 28 20:55:20 2020 UTC (12 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.546: +55 -55 lines
Diff to previous 1.546 (colored)

make(1): make debug logging in var.c compatible to C90

The ... ellipsis for macros is only available since C99.

Revision 1.546 / (download) - annotate - [select for diffs], Sun Sep 27 21:35:16 2020 UTC (12 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.545: +32 -32 lines
Diff to previous 1.545 (colored)

make(1): normalize whitespace in source code

There is no more space tab.  Either only tabs or only spaces or tabs
followed by spaces, but not spaces followed by tabs.

Revision 1.545 / (download) - annotate - [select for diffs], Sun Sep 27 16:52:22 2020 UTC (12 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.544: +5 -5 lines
Diff to previous 1.544 (colored)

make(1): rename Buf_Size to Buf_Len

The new name better matches the field name Buffer.len as well as the
variables around the calls to this function.

Revision 1.544 / (download) - annotate - [select for diffs], Sun Sep 27 16:10:07 2020 UTC (12 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.543: +4 -5 lines
Diff to previous 1.543 (colored)

make(1): replace direct access to Buffer fields with inline function

This way, renaming the fields of the buffer is restricted to only buf.h
and buf.c.

Revision 1.543 / (download) - annotate - [select for diffs], Sat Sep 26 16:00:12 2020 UTC (12 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.542: +3 -3 lines
Diff to previous 1.542 (colored)

make(1): clean up API for finding and creating GNodes

The previous API had complicated rules for the cases in which the single
function returned NULL or what it did.  The flags for that function were
confusing since passing TARG_NOHASH would create a new node even though
TARG_CREATE was not included in that bit mask.

Splitting the function into 3 separate functions avoids this confusion.
It also reveals several places where the complicated API led to
unreachable code.  Such code has been removed.

Revision 1.542 / (download) - annotate - [select for diffs], Sat Sep 26 14:48:31 2020 UTC (12 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.541: +12 -18 lines
Diff to previous 1.541 (colored)

make(1): add Hash_FindValue, for direct access to hash table data

Revision 1.541 / (download) - annotate - [select for diffs], Fri Sep 25 15:54:51 2020 UTC (12 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.540: +22 -21 lines
Diff to previous 1.540 (colored)

make(1): add tags to some of the unnamed structs

The tags prevent the structs from accidentally becoming compatible
types.

While here, remove a few typedefs for structs that are single-purpose,
since there is no point in abstracting from the actual representation of
these types.

Revision 1.540 / (download) - annotate - [select for diffs], Fri Sep 25 14:10:09 2020 UTC (12 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.539: +3 -3 lines
Diff to previous 1.539 (colored)

make(1): fix type of local variable in ParseModifierPart

Thanks, Clang-Tidy.

Revision 1.539 / (download) - annotate - [select for diffs], Fri Sep 25 14:07:12 2020 UTC (12 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.538: +3 -3 lines
Diff to previous 1.538 (colored)

make(1): fix type of local variable in ApplyModifiers

Thanks, Clang-Tidy.

Revision 1.538 / (download) - annotate - [select for diffs], Fri Sep 25 06:06:15 2020 UTC (12 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.537: +6 -2 lines
Diff to previous 1.537 (colored)

make(1): document expansion of undefined variables in Var_Subst

From reading the code alone, it is not obvious what effects this
innocent-looking code has.

Revision 1.537 / (download) - annotate - [select for diffs], Fri Sep 25 05:04:51 2020 UTC (12 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.536: +18 -17 lines
Diff to previous 1.536 (colored)

make(1): rename local variables in Var_Subst

The variable name "str" did not make it clear enough that the pointer is
constantly moving, to parse the given string.  The name "p" expresses
this more clearly.

Revision 1.536 / (download) - annotate - [select for diffs], Wed Sep 23 07:50:58 2020 UTC (13 months ago) by rillig
Branch: MAIN
Changes since 1.535: +37 -37 lines
Diff to previous 1.535 (colored)

make(1): fix unexpected behavior in ::= variable modifier

Previously, the ::= modifier had returned an error value, which caused
the variable expression to be preserved.  This behavior was not useful
in this case; it had only been intended to be used for undefined
variables.

To fix it, distinguish between parse errors, undefined variables and
regular empty strings.

Revision 1.535 / (download) - annotate - [select for diffs], Wed Sep 23 04:27:39 2020 UTC (13 months ago) by rillig
Branch: MAIN
Changes since 1.534: +13 -23 lines
Diff to previous 1.534 (colored)

make(1): inline local variable delim

Now that ParseModifierPart generates the error message itself, there is
no need to keep this variable around since it is read a single time.

Revision 1.534 / (download) - annotate - [select for diffs], Tue Sep 22 20:23:57 2020 UTC (13 months ago) by rillig
Branch: MAIN
Changes since 1.533: +3 -7 lines
Diff to previous 1.533 (colored)

make(1): condense code in Var_Subst

Revision 1.533 / (download) - annotate - [select for diffs], Tue Sep 22 20:19:46 2020 UTC (13 months ago) by rillig
Branch: MAIN
Changes since 1.532: +45 -22 lines
Diff to previous 1.532 (colored)

make(1): prepare Var_Subst for proper error handling

Returning a VarParseResult instead of a string makes it possible to let
the error bubble up, until it reaches the main expression.

Revision 1.532 / (download) - annotate - [select for diffs], Tue Sep 22 19:08:47 2020 UTC (13 months ago) by rillig
Branch: MAIN
Changes since 1.531: +2 -8 lines
Diff to previous 1.531 (colored)

make(1): remove obsolete fix for PR bin/29985

Revision 1.531 / (download) - annotate - [select for diffs], Tue Sep 22 18:07:58 2020 UTC (13 months ago) by rillig
Branch: MAIN
Changes since 1.530: +52 -43 lines
Diff to previous 1.530 (colored)

make(1): prepare error handling in nested variable expressions

Having ParseModifierPart return VarParseResult allows to report the
errors from nested variable expressions.

Revision 1.530 / (download) - annotate - [select for diffs], Tue Sep 22 17:51:06 2020 UTC (13 months ago) by rillig
Branch: MAIN
Changes since 1.529: +17 -48 lines
Diff to previous 1.529 (colored)

make(1): handle errors about missing delimiter in a single place

Revision 1.529 / (download) - annotate - [select for diffs], Tue Sep 22 17:42:57 2020 UTC (13 months ago) by rillig
Branch: MAIN
Changes since 1.528: +153 -152 lines
Diff to previous 1.528 (colored)

make(1): move ParseModifierPart further down in the code

This way, it can access the ApplyModifierState, which will be used in a
follow-up commit to reduce the code duplication around the error
handling for missing delimiters.

Revision 1.528 / (download) - annotate - [select for diffs], Tue Sep 22 06:23:33 2020 UTC (13 months ago) by rillig
Branch: MAIN
Changes since 1.527: +11 -14 lines
Diff to previous 1.527 (colored)

make(1): remove remaining references to VAR_JUNK and VAR_KEEP

Revision 1.527 / (download) - annotate - [select for diffs], Tue Sep 22 06:13:38 2020 UTC (13 months ago) by rillig
Branch: MAIN
Changes since 1.526: +57 -35 lines
Diff to previous 1.526 (colored)

make(1): move VAR_JUNK and VAR_KEEP away from VarFlags

These two flags have nothing to do with a variable.  They are only used
while evaluating a variable expression.

While here, rename the flags and make their documentation more precise.

Revision 1.526 / (download) - annotate - [select for diffs], Tue Sep 22 06:06:18 2020 UTC (13 months ago) by rillig
Branch: MAIN
Changes since 1.525: +12 -12 lines
Diff to previous 1.525 (colored)

make(1): rename VarParseErrors to VarParseResult

The name VPE_OK was confusing since it was not an error at all.

Revision 1.525 / (download) - annotate - [select for diffs], Tue Sep 22 05:55:49 2020 UTC (13 months ago) by rillig
Branch: MAIN
Changes since 1.524: +15 -12 lines
Diff to previous 1.524 (colored)

make(1): extract common code from the ApplyModifier functions

Revision 1.524 / (download) - annotate - [select for diffs], Tue Sep 22 04:05:41 2020 UTC (13 months ago) by rillig
Branch: MAIN
Changes since 1.523: +3 -3 lines
Diff to previous 1.523 (colored)

make(1): use fine-grained type names for lists and their nodes

This is only intended to help the human reader.  There is no additional
type safety yet.

Revision 1.523 / (download) - annotate - [select for diffs], Mon Sep 21 05:28:26 2020 UTC (13 months ago) by rillig
Branch: MAIN
Changes since 1.522: +4 -4 lines
Diff to previous 1.522 (colored)

make(1): clean up VarParseErrors, for proper error handling

Having a pure bitset was wrong.

Instead, there are several alternatives (parse error, eval error, undef
error), and each of them can either have an error message printed (good)
or not (bad).  In addition, there are VPE_OK for successful expression
evaluation and VPE_UNKNOWN (only used during migration to the correct
error handling scheme).

Revision 1.522 / (download) - annotate - [select for diffs], Mon Sep 14 21:55:53 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.521: +5 -3 lines
Diff to previous 1.521 (colored)

make(1): fix wrong error for undefined variables in lint mode

Revision 1.521 / (download) - annotate - [select for diffs], Mon Sep 14 20:43:44 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.520: +7 -12 lines
Diff to previous 1.520 (colored)

make(1): inline character constants in var.c

This removes a level of indirection, and the macro names were quite
similar in appearance as well.  The macros may have been used by people
whose editors don't recognize C string and character literals when
navigating to the corresponding brace or parenthesis.  These editors had
already been confused before this commit since there are also string
literals with unbalanced parentheses, and there are far fewer
compensating comments such as /*{*/ or /*)*/ in the code.  In fact, the
only such comment that is left over was in for.c.

This way, there is now a single consistent way of writing these
character literals, which is without macros or comments, since that is
the simplest form.

Revision 1.520 / (download) - annotate - [select for diffs], Mon Sep 14 07:04:56 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.519: +6 -3 lines
Diff to previous 1.519 (colored)

make(1): don't require nested variables to be defined in conditions

This code only applies to lint mode (-dL) for now.  After a test phase
and a thorough check for possible side effects, it will be activated in
normal mode, too.  Having this code in lint mode is required to run
src/build.sh, which relies a lot on using variables with undefined
nested variables in conditions.

In the default mode, any errors about nested undefined variables are not
printed since in Var_Subst, oldVars is true.  Therefore, it is not urgent
to properly handle these nested variables correctly there.

Revision 1.519 / (download) - annotate - [select for diffs], Sun Sep 13 21:03:14 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.518: +7 -5 lines
Diff to previous 1.518 (colored)

make(1): in Var_Parse, replace bmake_strldup with bmake_strsedup

Revision 1.518 / (download) - annotate - [select for diffs], Sun Sep 13 20:21:24 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.517: +19 -5 lines
Diff to previous 1.517 (colored)

make(1): in lint mode, report undefined variables in conditions

Revision 1.517 / (download) - annotate - [select for diffs], Sun Sep 13 19:46:23 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.516: +7 -5 lines
Diff to previous 1.516 (colored)

make(1): suppress wrong "Malformed conditional" for undefined variables

This only has an effect in lint mode right now.

Revision 1.516 / (download) - annotate - [select for diffs], Sun Sep 13 19:28:46 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.515: +6 -4 lines
Diff to previous 1.515 (colored)

make(1): in lint mode, improve error handling for undefined variables

It's a first step for improving the error message that make prints.

Revision 1.515 / (download) - annotate - [select for diffs], Sun Sep 13 19:16:22 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.514: +3 -5 lines
Diff to previous 1.514 (colored)

make(1): make documentation of VarParseErrors more precise

Revision 1.514 / (download) - annotate - [select for diffs], Sun Sep 13 18:27:39 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.513: +37 -19 lines
Diff to previous 1.513 (colored)

make(1): prepare Var_Parse for proper error handling and reporting

Right now, Var_Parse swallows many errors during parsing and evaluation.
Ideally, these errors should propagate from the deeply nested
expressions where they occur up to the top-level expressions.  When such
an error occurs, the depending expressions should not be evaluated any
further.  They may still be parsed, but side effects should be
minimized.

The goal is to prevent incomplete expressions like the "xy}" in
moderrs.exp:106 from being evaluated and eventually passed to the shell
for execution.  This expression is a left-over from a parse error in the
mod-t-parse target in moderrs.mk:154.

This commit is a first step in analyzing and verifying the current state
of affairs. The modelling in VarParseErrors already looks complicated
but is expected to closely match reality.

Revision 1.513 / (download) - annotate - [select for diffs], Sun Sep 13 16:47:24 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.512: +4 -6 lines
Diff to previous 1.512 (colored)

make(1): shorten debug output of ApplyModifiers

Having the words "eflags" and "vflags" in the debug output was too
repetitive.  That they are flags is made obvious by the '|' separator,
and the flags have clearly distinguishable names (VARE_* vs. VAR_*),
which lowers the chance for confusion.

Revision 1.512 / (download) - annotate - [select for diffs], Sun Sep 13 15:15:51 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.511: +4 -14 lines
Diff to previous 1.511 (colored)

make(1): clean up RCSID blocks

These blocks mostly consisted of redundant structure, following the same
#ifndef pattern over and over, with only minimal variation.

It's easier to maintain if the common structure is only written once and
encapsulated in a macro.

To avoid "defined but unused" warnings from GCC in the case where
MAKE_NATIVE is not defined, I had to add volatile.  Adding
MAKE_ATTR_UNUSED alone would not preserve the rcsid variable in the
resulting binary.

Revision 1.511 / (download) - annotate - [select for diffs], Sun Sep 13 13:50:27 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.510: +4 -4 lines
Diff to previous 1.510 (colored)

make(1): clean up API for evaluating conditions

There was no need to make struct If publicly visible.

There was no need to have parameters in the public API that were passed
the same constants all the time.

The former function names had not been distinctive.

Revision 1.510 / (download) - annotate - [select for diffs], Sun Sep 13 09:35:09 2020 UTC (13 months, 1 week ago) by martin
Branch: MAIN
Changes since 1.509: +4 -6 lines
Diff to previous 1.509 (colored)

Initialize endc unconditionally, gcc complains and it is not obvious
whether this is a false positive.

Revision 1.509 / (download) - annotate - [select for diffs], Sun Sep 13 08:17:14 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.508: +5 -5 lines
Diff to previous 1.508 (colored)

make(1): rename ApplyModifier_Exclam

The names of all other ApplyModifier functions already describe the
effect instead of the spelling.

Revision 1.508 / (download) - annotate - [select for diffs], Sun Sep 13 08:11:40 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.507: +13 -5 lines
Diff to previous 1.507 (colored)

make(1): inline call to strchr in ValidShortVarname

It's a pity that neither GCC 5 nor GCC 10 nor Clang 9 inline this code
themselves, even though it would be easy to do.

Clang 9 at least replaces strchr with memchr, but that is still too
complicated for a simple "is this character one of these" question.

For a repeated "if (varname != ...)" instead of the switch, GCC 10
generates really boring and inefficient code, even though it is easy to
see that the order of the comparisons doesn't matter.

Revision 1.507 / (download) - annotate - [select for diffs], Sun Sep 13 07:42:20 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.506: +26 -6 lines
Diff to previous 1.506 (colored)

make(1): in lint mode, complain about erroneous $$

Since 2008-12-21, make has silently ignored strange variable names in
constructs like '$$', '$}', '$' followed by nothing.  Ignoring these
bugs in makefiles instead of reporting them is not a good idea.

To improve the situation, make complains about these errors now, but
only in lint mode (-dL).  This preserves existing behavior while still
allowing to validate existing makefiles that they don't depend on this
bug.

If the test phase goes well, these error messages may be enabled
unconditionally.

https://mail-index.netbsd.org/pkgsrc-users/2020/09/12/msg032229.html

Revision 1.506 / (download) - annotate - [select for diffs], Sun Sep 13 05:55:39 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.505: +11 -11 lines
Diff to previous 1.505 (colored)

make(1): improve implementation comment in Var_Parse

Revision 1.505 / (download) - annotate - [select for diffs], Sat Sep 12 22:12:17 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.504: +4 -4 lines
Diff to previous 1.504 (colored)

make(1): fix return type of ApplyModifier_Localtime

Revision 1.504 / (download) - annotate - [select for diffs], Sat Sep 12 20:03:37 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.503: +22 -20 lines
Diff to previous 1.503 (colored)

make(1): move buffer from Var_Parse to ParseVarname

There's no reason to keep the buffer in memory after the variable name
has been parsed.

Revision 1.503 / (download) - annotate - [select for diffs], Sat Sep 12 19:41:20 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.502: +6 -6 lines
Diff to previous 1.502 (colored)

make(1): reword variable invocation to variable expression

Variables are a passive thing.  They cannot be invoked, they can only be
evaluated.

Revision 1.502 / (download) - annotate - [select for diffs], Sat Sep 12 19:33:02 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.501: +31 -25 lines
Diff to previous 1.501 (colored)

make(1): extract ShortVarValue from Var_Parse

Revision 1.501 / (download) - annotate - [select for diffs], Sat Sep 12 19:24:59 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.500: +38 -29 lines
Diff to previous 1.500 (colored)

make(1): extract ParseVarname from Var_Parse

This was an easy part since it affects only a few variables.  250 lines
for a single function is still quite a lot, so further refactorings will
follow.

Revision 1.500 / (download) - annotate - [select for diffs], Sat Sep 12 19:15:20 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.499: +7 -7 lines
Diff to previous 1.499 (colored)

make(1): rename local variable in Var_Subst

Revision 1.499 / (download) - annotate - [select for diffs], Sat Sep 12 19:13:43 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.498: +9 -11 lines
Diff to previous 1.498 (colored)

make(1): remove double negation in Var_Parse

Revision 1.498 / (download) - annotate - [select for diffs], Sat Sep 12 18:45:24 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.497: +11 -19 lines
Diff to previous 1.497 (colored)

make(1): clean up Var_Parse

Revision 1.497 / (download) - annotate - [select for diffs], Sat Sep 12 18:39:37 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.496: +26 -26 lines
Diff to previous 1.496 (colored)

make(1): rename local variables in Var_Parse

The main property of the former "str" is not being a string but pointing
at the start of the expression to be parsed.

The main property of the former "tstr" is not being a string but being
the moving pointer, the current parsing position.  No idea what the "t"
in "tstr" stood for.

Revision 1.496 / (download) - annotate - [select for diffs], Sat Sep 12 18:19:50 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.495: +24 -41 lines
Diff to previous 1.495 (colored)

make(1): rename Var_ParsePP back to Var_Parse

The migration to the "parsing position" pointer has been done.

Revision 1.495 / (download) - annotate - [select for diffs], Sat Sep 12 18:04:45 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.494: +4 -4 lines
Diff to previous 1.494 (colored)

make(1): migrate CondParser_String to Var_ParsePP

Revision 1.494 / (download) - annotate - [select for diffs], Sat Sep 12 14:41:00 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.493: +10 -10 lines
Diff to previous 1.493 (colored)

make(1): fix inconsistent code indentation

Revision 1.493 / (download) - annotate - [select for diffs], Fri Sep 11 17:32:36 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.492: +11 -12 lines
Diff to previous 1.492 (colored)

make(1): add wrappers around ctype.h functions

This avoids casting the argument to unsigned char, and to cast the
result of toupper/tolower back to char.

Revision 1.492 / (download) - annotate - [select for diffs], Fri Sep 11 04:32:39 2020 UTC (13 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.491: +4 -4 lines
Diff to previous 1.491 (colored)

make(1): replace *a->b with a->b[0]

This allows the code to be read strictly from left to right.  In most
places this style was already used.

Revision 1.491 / (download) - annotate - [select for diffs], Tue Sep 8 05:26:21 2020 UTC (13 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.490: +14 -3 lines
Diff to previous 1.490 (colored)

make(1): fix off-by-one error in SuffExpandChildren

In suff.c r1.144 from yesterday, in the line "cp += nested_p - cp", I
accidentally removed the "- 1".  Since these "- 1" lines lead to slow
execution, each branch now increments the pointer separately by the
actually needed amount.

Fixing this bug posed way more new questions than it answered, and it
revealed an inconsistency in the parser about how characters are to be
escaped, and missing details in the documentation of Var_Parse, as well
as a parse error that unexpectedly doesn't stop make from continuing.

Revision 1.490 / (download) - annotate - [select for diffs], Mon Sep 7 07:10:56 2020 UTC (13 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.489: +15 -16 lines
Diff to previous 1.489 (colored)

make(1): migrate to Var_ParsePP in Var_Parse and Var_Subst

Revision 1.489 / (download) - annotate - [select for diffs], Mon Sep 7 07:04:30 2020 UTC (13 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.488: +9 -8 lines
Diff to previous 1.488 (colored)

make(1): migrate ApplyModifiers to Var_ParsePP

Revision 1.488 / (download) - annotate - [select for diffs], Mon Sep 7 06:20:07 2020 UTC (13 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.487: +3 -4 lines
Diff to previous 1.487 (colored)

make(1): remove redundant includes

Revision 1.487 / (download) - annotate - [select for diffs], Fri Sep 4 20:28:15 2020 UTC (13 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.486: +20 -13 lines
Diff to previous 1.486 (colored)

make(1): add more explanation for undefined variable expressions

Revision 1.486 / (download) - annotate - [select for diffs], Thu Sep 3 18:53:46 2020 UTC (13 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.485: +8 -10 lines
Diff to previous 1.485 (colored)

make(1): migrate ApplyModifier_Defined to Var_ParsePP

Revision 1.485 / (download) - annotate - [select for diffs], Thu Sep 3 18:19:15 2020 UTC (13 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.484: +20 -10 lines
Diff to previous 1.484 (colored)

make(1): migrate Var_Parse API to parsing position

The ApplyModifier functions already use this pattern.  For simplicity
and consistency Var_Parse should do the same.  This saves a parameter to
be passed.

The migration takes place step by step, just like for the Lst functions
a few days ago.

Revision 1.484 / (download) - annotate - [select for diffs], Wed Sep 2 06:25:48 2020 UTC (13 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.483: +10 -15 lines
Diff to previous 1.483 (colored)

make(1): fix documentation of Var_Subst

The "var" parameter does not exist anymore.

Revision 1.483 / (download) - annotate - [select for diffs], Wed Sep 2 06:19:11 2020 UTC (13 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.482: +18 -44 lines
Diff to previous 1.482 (colored)

make(1): clean up comments in var.c, make VarQuote const-correct

Revision 1.482 / (download) - annotate - [select for diffs], Mon Aug 31 19:09:19 2020 UTC (13 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.481: +5 -6 lines
Diff to previous 1.481 (colored)

make(1): inline a local variable in VarUniq

Just to eliminate any remote possibility of aliasing and thereby
forgetting to update all involved variables.

Revision 1.481 / (download) - annotate - [select for diffs], Mon Aug 31 19:05:53 2020 UTC (13 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.480: +7 -6 lines
Diff to previous 1.480 (colored)

make(1): add more examples to the documentation of ParseModifierPart

Revision 1.480 / (download) - annotate - [select for diffs], Mon Aug 31 17:41:38 2020 UTC (13 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.479: +6 -7 lines
Diff to previous 1.479 (colored)

make(1): fix the :u modifier, which was broken for almost a day

Big thanks go to sjg, who discovered the bug and did the main work to
track it down.

In the unit tests for the :u modifier from the previous commit, I had
forgotten to actually add the :u modifier at the end.  I added it now
and also added a few other tests.  It's better to have a few more tests
than too few.

Revision 1.479 / (download) - annotate - [select for diffs], Sun Aug 30 19:56:02 2020 UTC (13 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.478: +63 -88 lines
Diff to previous 1.478 (colored)

make(1): replace brk_string with Str_Words

The API is much simpler, and there is less detail that is exposed by
default and fewer punctuation to type on the caller's side.  To see that
there is some memory to be freed, one would have to look into the
struct.  Having part of the return value as the actual return value and
the rest in output parameters was unnecessarily asymmetrical.

Revision 1.478 / (download) - annotate - [select for diffs], Sat Aug 29 13:38:48 2020 UTC (13 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.477: +5 -7 lines
Diff to previous 1.477 (colored)

make(1): trust that Var_Parse never returns NULL

That function is quite long, but all its return paths lead either to the
expanded variable expression, or to var_Error or varNoError.

Revision 1.477 / (download) - annotate - [select for diffs], Sat Aug 29 13:16:54 2020 UTC (13 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.476: +9 -12 lines
Diff to previous 1.476 (colored)

make(1): trust that Var_Subst never returns NULL

It really never does, and it doesn't even report errors.  It just
returns the content of the buffer, up to the first parse error.

Revision 1.476 / (download) - annotate - [select for diffs], Sat Aug 29 12:48:17 2020 UTC (13 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.475: +6 -3 lines
Diff to previous 1.475 (colored)

make(1): add comments for ModifyWord_Subst

Without any comments, the code is unnecessarily hard to follow.

Revision 1.475 / (download) - annotate - [select for diffs], Sat Aug 29 12:27:10 2020 UTC (13 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.474: +19 -10 lines
Diff to previous 1.474 (colored)

make(1): split ApplyModifier_To into paragraphs

Revision 1.474 / (download) - annotate - [select for diffs], Sat Aug 29 11:24:54 2020 UTC (13 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.473: +4 -8 lines
Diff to previous 1.473 (colored)

make(1): add bmake_strsedup for duplicating a substring

Revision 1.473 / (download) - annotate - [select for diffs], Sat Aug 29 07:52:55 2020 UTC (13 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.472: +9 -3 lines
Diff to previous 1.472 (colored)

make(1): allow for strict type checking for Boolean

Having Boolean aliased to int creates ambiguities since int is widely
used.  Allow to occasionally compile make with -DUSE_DOUBLE_BOOLEAN to
check that the type definitions still agree.

Revision 1.472 / (download) - annotate - [select for diffs], Tue Aug 25 21:16:53 2020 UTC (13 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.471: +4 -4 lines
Diff to previous 1.471 (colored)

make(1): fix error message for ::!= modifier with shell error

It's just too easy to confuse st->val and val.

Revision 1.471 / (download) - annotate - [select for diffs], Tue Aug 25 16:27:24 2020 UTC (13 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.470: +8 -16 lines
Diff to previous 1.470 (colored)

make(1): distinguish enum flags and values in debugging mode

When printing an enum value in debugging mode, distinguish between
bitsets containing flags and ordinary enums that just contain different
values.

Make the macros in enum.h more uniform.  Provide a simple scheme for
defining the run-time type information of enums whose number of values
is a number with more than 2 bits set in the binary representation.
This case was not obvious before, and it was pure luck that the current
interesting enum types only had 3, 10 or 32 different values.

The type with the 32 different values actually only has 31 significant
bits since the enum constant OP_OPMASK is only used when querying the
enum, not for defining or describing the possible values.  For this
reason, it was unavoidable to refactor the rtti macros, to support even
this case.

Revision 1.470 / (download) - annotate - [select for diffs], Mon Aug 24 20:15:51 2020 UTC (14 months ago) by rillig
Branch: MAIN
Changes since 1.469: +13 -13 lines
Diff to previous 1.469 (colored)

make(1): in debug mode, print GNode details in symbols

A string like OP_DEPENDS|OP_OPTIONAL|OP_PRECIOUS is much easier to read
and understand than the bit pattern 00000089.

The implementation in enum.h looks really bloated and ugly, but using
this API is as simple and natural as possible.  That's the trade-off.

In enum.h, I thought about choosing the numbers in the macros such that
it is always possible to combine two of them in order to reach an
arbitrary number, because of the "part1, part2" in the ENUM__SPEC macro.
The powers of 2 are not these numbers, as 7 cannot be expressed as the
sum of two of them.  Neither are the fibonacci numbers since 12 cannot
be expressed as the sum of 2 fibonacci numbers.  I tried to find a
general pattern to generate these minimal 2-sum numbers, but failed.

Revision 1.469 / (download) - annotate - [select for diffs], Sun Aug 23 22:49:45 2020 UTC (14 months ago) by rillig
Branch: MAIN
Changes since 1.468: +3 -5 lines
Diff to previous 1.468 (colored)

make(1): remove redundant range restriction

re.re_nsub is at least 0, and (at least 0) + 1 cannot be 0.

Revision 1.468 / (download) - annotate - [select for diffs], Sun Aug 23 22:13:38 2020 UTC (14 months ago) by rillig
Branch: MAIN
Changes since 1.467: +45 -39 lines
Diff to previous 1.467 (colored)

make(1): restructure code of the :ts modifier

Now there is one paragraph per case, as opposed to the highly condensed
code from before.

In the cases of :ts\n and :ts\t, the variables for number parsing are no
longer in the code path, which makes the code easier to understand for
humans.  Not sure what the compilers made out of it.

The assignment "base = 0" has gone since it was redundant.  An integer
that starts with 0 is always interpreted as octal by strtol, no matter
if the base is 8 or 0.

Revision 1.467 / (download) - annotate - [select for diffs], Sun Aug 23 21:40:30 2020 UTC (14 months ago) by rillig
Branch: MAIN
Changes since 1.466: +66 -32 lines
Diff to previous 1.466 (colored)

make(1): extend the documentation on the ApplyModifier functions

Revision 1.466 / (download) - annotate - [select for diffs], Sun Aug 23 20:57:02 2020 UTC (14 months ago) by rillig
Branch: MAIN
Changes since 1.465: +21 -22 lines
Diff to previous 1.465 (colored)

make(1): split code for parsing the :U modifier into digestible parts

The comment about "unescaped $'s that aren't before the delimiter" was
wrong, as the code didn't contain the "aren't before the delimiter"
part.  By splitting the code into paragraphs, the larger structure
becomes easily visible.  Having a few short comments in the right place
is more helpful than a big block of text.

Revision 1.465 / (download) - annotate - [select for diffs], Sun Aug 23 18:26:35 2020 UTC (14 months ago) by rillig
Branch: MAIN
Changes since 1.464: +42 -42 lines
Diff to previous 1.464 (colored)

make(1): make brk_string return size_t for the number of words

Revision 1.464 / (download) - annotate - [select for diffs], Sun Aug 23 10:27:22 2020 UTC (14 months ago) by rillig
Branch: MAIN
Changes since 1.463: +8 -11 lines
Diff to previous 1.463 (colored)

make(1): save a variable lookup when adding a read-only variable

Revision 1.463 / (download) - annotate - [select for diffs], Sun Aug 23 09:28:52 2020 UTC (14 months ago) by rillig
Branch: MAIN
Changes since 1.462: +12 -11 lines
Diff to previous 1.462 (colored)

make(1): fix assertion failure in debug output for read-only variables

Revision 1.462 / (download) - annotate - [select for diffs], Sun Aug 23 08:32:57 2020 UTC (14 months ago) by rillig
Branch: MAIN
Changes since 1.461: +5 -5 lines
Diff to previous 1.461 (colored)

make(1): improve variable name in ApplyModifiers

The bare q was too unspecific.

Revision 1.461 / (download) - annotate - [select for diffs], Sun Aug 23 08:31:07 2020 UTC (14 months ago) by rillig
Branch: MAIN
Changes since 1.460: +11 -8 lines
Diff to previous 1.460 (colored)

make(1): use local variable in ApplyModifier_Path

Without this variable, it might seem as if st->newVal could become NULL
in some code paths.

Revision 1.460 / (download) - annotate - [select for diffs], Sun Aug 23 08:29:18 2020 UTC (14 months ago) by rillig
Branch: MAIN
Changes since 1.459: +12 -6 lines
Diff to previous 1.459 (colored)

make(1): add assertions for non-nullness of strings

Verified by manually inspecting all call sites.

Revision 1.459 / (download) - annotate - [select for diffs], Sat Aug 22 21:42:38 2020 UTC (14 months ago) by rillig
Branch: MAIN
Changes since 1.458: +3 -7 lines
Diff to previous 1.458 (colored)

make(1): clean up headers

Remove redundant headers that are already included by "make.h".
Make <assert.h> available to all compilation units that use "make.h".

Revision 1.458 / (download) - annotate - [select for diffs], Sat Aug 22 20:31:50 2020 UTC (14 months ago) by rillig
Branch: MAIN
Changes since 1.457: +12 -12 lines
Diff to previous 1.457 (colored)

make(1): prevent assignment to the variable with the empty name

Revision 1.457 / (download) - annotate - [select for diffs], Sat Aug 22 19:30:58 2020 UTC (14 months ago) by sjg
Branch: MAIN
Changes since 1.456: +23 -10 lines
Diff to previous 1.456 (colored)

Add .SHELL as read-only variable

The .SHELL variable represents the shellPath used to run
scripts.

Reviewed by: rillig, christos

Revision 1.456 / (download) - annotate - [select for diffs], Sat Aug 22 17:34:25 2020 UTC (14 months ago) by rillig
Branch: MAIN
Changes since 1.455: +5 -5 lines
Diff to previous 1.455 (colored)

make(1): fix indentation

Revision 1.455 / (download) - annotate - [select for diffs], Sat Aug 22 17:32:55 2020 UTC (14 months ago) by rillig
Branch: MAIN
Changes since 1.454: +11 -15 lines
Diff to previous 1.454 (colored)

make(1): fix documentation of Var_Parse

Revision 1.454 / (download) - annotate - [select for diffs], Thu Aug 20 07:15:52 2020 UTC (14 months ago) by rillig
Branch: MAIN
Changes since 1.453: +11 -12 lines
Diff to previous 1.453 (colored)

make(1): make a few comments more precise

Revision 1.453 / (download) - annotate - [select for diffs], Thu Aug 20 07:09:06 2020 UTC (14 months ago) by rillig
Branch: MAIN
Changes since 1.452: +9 -9 lines
Diff to previous 1.452 (colored)

make(1): use more descriptive variable name in ModifyWords

Revision 1.452 / (download) - annotate - [select for diffs], Thu Aug 20 07:01:39 2020 UTC (14 months ago) by rillig
Branch: MAIN
Changes since 1.451: +16 -13 lines
Diff to previous 1.451 (colored)

make(1): remove VARP_SUB_MATCHED

This flag didn't really belong to the other flags.  The other flags are
set during parsing and are then left as-is by ModifyWord_Subst and
ModifyWord_SubstRegex.

It's clearer to use a separate variable for storing whether there was a
match already.

Revision 1.451 / (download) - annotate - [select for diffs], Thu Aug 20 06:48:18 2020 UTC (14 months ago) by rillig
Branch: MAIN
Changes since 1.450: +4 -5 lines
Diff to previous 1.450 (colored)

make(1): consistently access args->pflags in ModifyWord_Subst

It was confusing that some accesses were via pflags and some via
args->pflags.

Revision 1.450 / (download) - annotate - [select for diffs], Thu Aug 20 06:35:14 2020 UTC (14 months ago) by rillig
Branch: MAIN
Changes since 1.449: +7 -7 lines
Diff to previous 1.449 (colored)

make(1): remove unreached code from bmake_strndup

The "at most" branch was never taken since all call sites in var.c only
ever need a substring, and the target buffer is not limited.  Therefore
rename the function and make it simpler.

It's ok that bmake_strldup is defined as estrndup in case of USE_EMALLOC
since that function's implementation is compatible to the "copy
exactly", it just contains some extra null checks that will never match
since the variable values cannot (well, or should not) contain null
bytes.  Theoretically they can, but the behavior then depends on the
exact implementation and is unreliable, therefore nobody does this.
After all, Makefiles are used for text processing, not for binary data.

Revision 1.449 / (download) - annotate - [select for diffs], Thu Aug 13 04:12:13 2020 UTC (14 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.448: +7 -7 lines
Diff to previous 1.448 (colored)

make(1): remove type alias Byte = char

This alias was only actually used in very few places, and changing it to
unsigned char or any other type would not be possible without generating
lots of compile-time errors.  Therefore there was no abstraction, only
unnecessary complexity.

Revision 1.448 / (download) - annotate - [select for diffs], Wed Aug 12 19:14:38 2020 UTC (14 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.447: +45 -43 lines
Diff to previous 1.447 (colored)

make(1): prepare var.c for WARNS=6

I'm unhappy with the (unsigned) casts for the enum constants, but there
is no way around that since the base type of enums is int by definition,
and there is no way in C90 to explicitly specify the base type of an
enum type.

The (size_t) casts on the pointer differences are another pain point,
but for these as well, C90 does not have a ready-made solution.  A
possible workaround would be an inline function ptr_diff that returns
size_t instead of ptrdiff_t, but that would make the code look even more
bloated than with the casts.

The remaining casts to (char), (int) and (time_t) look so suspicious
that it's easy enough to stumble upon them, as soon as someone finds the
time to fix these properly by adding a function ParseInt or
ParseSeconds.

Revision 1.447 / (download) - annotate - [select for diffs], Wed Aug 12 18:53:59 2020 UTC (14 months, 1 week ago) by rillig
Branch: MAIN
Changes since 1.446: +10 -7 lines
Diff to previous 1.446 (colored)

make(1): replace redundant NULL tests with assertions

Revision 1.446 / (download) - annotate - [select for diffs], Mon Aug 10 20:07:14 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.445: +15 -20 lines
Diff to previous 1.445 (colored)

make(1): replace snprintf with concat3

This makes the code more predictable for long strings, since the main
action is never skipped.

The code also becomes simpler since there is no %s anymore, and the 3
arguments just appear in the same order as in the result.

Revision 1.445 / (download) - annotate - [select for diffs], Sun Aug 9 15:07:13 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.444: +22 -24 lines
Diff to previous 1.444 (colored)

make(1): clean up code for subexpressions in the :C modifier

An ampersand in the replacement string can never produce an
out-of-bounds error or an undefined-subexpression error.  This makes the
error message simpler since it only needs to cover the case of a single
digit.

Revision 1.444 / (download) - annotate - [select for diffs], Sun Aug 9 14:30:35 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.443: +8 -8 lines
Diff to previous 1.443 (colored)

make(1): use char literals, improve documentation

Revision 1.443 / (download) - annotate - [select for diffs], Sun Aug 9 14:02:15 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.442: +9 -15 lines
Diff to previous 1.442 (colored)

make(1): revert C99 initializer in ApplyModifiers

The code of usr.bin/make is supposed to be C90-compatible.  That's why
it neither uses line-end comments nor declaration-after-statement nor a
few other features.

The fields that were copied "by name" did not get any additional
comments, only the ones with literal values did, since it's hard to see
what these mean.

This style of initializer has the additional benefit that a missing or
extraneous initializer-item would lead to a compile-time error, rather
than going undetected.

Revision 1.442 / (download) - annotate - [select for diffs], Sun Aug 9 13:16:10 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.441: +6 -5 lines
Diff to previous 1.441 (colored)

make(1): mark inconsistent word separators for variable modifiers

Revision 1.441 / (download) - annotate - [select for diffs], Sun Aug 9 13:05:04 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.440: +8 -4 lines
Diff to previous 1.440 (colored)

make(1): improve type signature of Var_Export

Revision 1.440 / (download) - annotate - [select for diffs], Sun Aug 9 11:04:05 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.439: +27 -19 lines
Diff to previous 1.439 (colored)

make(1): extend the documentation for variable flags

Revision 1.439 / (download) - annotate - [select for diffs], Sun Aug 9 09:44:14 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.438: +4 -4 lines
Diff to previous 1.438 (colored)

make(1): clean up indentation, includes, add documentation

Revision 1.438 / (download) - annotate - [select for diffs], Sun Aug 9 09:40:48 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.437: +6 -4 lines
Diff to previous 1.437 (colored)

make(1): document a hard-to-understand pointer calculation

Revision 1.437 / (download) - annotate - [select for diffs], Sun Aug 9 07:09:57 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.436: +7 -7 lines
Diff to previous 1.436 (colored)

make(1): restrict the type of startc and endc to char

Revision 1.436 / (download) - annotate - [select for diffs], Sun Aug 9 07:03:06 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.435: +8 -8 lines
Diff to previous 1.435 (colored)

make(1): use fixed-size arrays for Enum_ToString

Declaring the ToStringSize as "static const size_t" made it an ordinary
integer expression.  To avoid variable length arrays, the commonly
accepted way is to declare the length as an enum constant, as that is
considered an integer constant expression, which in turn makes the
declaration a fixed-size array.

Revision 1.435 / (download) - annotate - [select for diffs], Sun Aug 9 02:53:21 2020 UTC (14 months, 2 weeks ago) by christos
Branch: MAIN
Changes since 1.434: +21 -11 lines
Diff to previous 1.434 (colored)

Fix build; gcc does not like VLA's, so hard code the boundary
Use c99 initializers

Revision 1.434 / (download) - annotate - [select for diffs], Sat Aug 8 19:13:39 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.433: +22 -31 lines
Diff to previous 1.433 (colored)

make(1): merge duplicate code for the :H :T :R :E modifiers

By setting modifyWord first, the rest of the code becomes exactly the
same and is merged by the compiler.

Revision 1.433 / (download) - annotate - [select for diffs], Sat Aug 8 18:54:04 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.432: +29 -29 lines
Diff to previous 1.432 (colored)

make(1): remove trailing Z from buffer functions

This Z had been useful during the migration from int to size_t.  This
migration is finished, at least for the Buffer type, so the Z is no
longer necessary.

Revision 1.432 / (download) - annotate - [select for diffs], Sat Aug 8 18:50:11 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.431: +8 -3 lines
Diff to previous 1.431 (colored)

make(1): add debug logging for Var_Parse

This will hopefully help with tracking down why the "Undefined variable"
error message is not triggered.

There is some other non-obvious behavior nearby.  In Parse_DoVar, the !=
assignment operator evaluates the variable using VARE_UNDEFERR, but
there is not even a warning for the following line:

!= echo err ${UNDEFINED} 1>&2

Revision 1.431 / (download) - annotate - [select for diffs], Sat Aug 8 14:28:46 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.430: +7 -5 lines
Diff to previous 1.430 (colored)

make(1): extend debug logging to error values

The error marker var_Error is just an empty string.  In the debug log
this empty string was not distinguishable from an otherwise empty
string.

Having this distinction helps in understanding the exact data flow.

Revision 1.430 / (download) - annotate - [select for diffs], Sat Aug 8 13:50:23 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.429: +48 -5 lines
Diff to previous 1.429 (colored)

make(1): add more detailed debug logging for variable modifiers

Before a modifier is applied to a variable, it is not yet parsed,
therefore it is only possible to log a rough estimate of the modifier.
But after applying it, the parsing position has advanced, and the full
modifier can be logged.

In addition, to fully understand how the modifiers work, it's not enough
to just know the variable names and values, there are also some flags
that influence how the modifiers behave.  The most influential is
VARE_WANTRES.

Thanks to sjg for the extensive review and valuable feedback on the
first drafts.

Revision 1.429 / (download) - annotate - [select for diffs], Sat Aug 8 13:31:24 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.428: +8 -9 lines
Diff to previous 1.428 (colored)

make(1): improve documentation of Var_Parse and reorder conditions

Revision 1.428 / (download) - annotate - [select for diffs], Sat Aug 8 13:27:42 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.427: +5 -5 lines
Diff to previous 1.427 (colored)

make(1): improve error message in case of unfinished modifiers

The previous error message "Unclosed substitution" was wrong for several
reasons.

It is not about "unclosed", but about "unfinished" since in the
:@var@...@ modifier the missing '@' does not really close anything.

The word "substitution" may have originated in a time where :S and
:from=to were the only modifiers, and these were indeed substitutions,
but several other modifiers aren't.

The :S and :C modifiers allow an arbitrary delimiter, therefore it is
helpful to enclose the delimiter in quotes, just in case someone chooses
')' or '{' or even ' ' as delimiter.

Revision 1.427 / (download) - annotate - [select for diffs], Sat Aug 8 13:17:39 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.426: +11 -11 lines
Diff to previous 1.426 (colored)

make(1): align the code in Var_Append with Var_Set

The code has the same effect in both functions, therefore it should also
look the same.

Revision 1.426 / (download) - annotate - [select for diffs], Sat Aug 8 13:13:34 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.425: +8 -8 lines
Diff to previous 1.425 (colored)

make(1): consistently use postfix-increment

Revision 1.425 / (download) - annotate - [select for diffs], Sat Aug 8 13:05:24 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.424: +9 -9 lines
Diff to previous 1.424 (colored)

make(1): clean up VarStrftime

The parameter names were confusing and had outdated types.

Revision 1.424 / (download) - annotate - [select for diffs], Sat Aug 8 13:03:13 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.423: +4 -4 lines
Diff to previous 1.423 (colored)

make(1): add test for unknown sub-modifier of the :S modifier

Revision 1.423 / (download) - annotate - [select for diffs], Sat Aug 8 13:00:07 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.422: +32 -26 lines
Diff to previous 1.422 (colored)

make(1): clean up Var_UnExport

Mark the parameter as constant since it is not modified.

Remove tests for '\n' since these can never succeed.

newenv can never be NULL since neither of bmake_malloc or bmake_realloc
returns NULL.

Improve variable names: vlist was too unexpressive.

Add debug logging since unexporting variables is an uncommon operation
that directly affects the observable environment of the child processes.

Fix CRLF line endings in a few unit tests.

Revision 1.422 / (download) - annotate - [select for diffs], Sat Aug 8 12:43:06 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.421: +9 -24 lines
Diff to previous 1.421 (colored)

make(1): clean up Var_Export

The string from the .export directive can never be NULL.

The test for local single-char variables is already done in Var_Export1.

Revision 1.421 / (download) - annotate - [select for diffs], Sat Aug 8 12:39:48 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.420: +14 -13 lines
Diff to previous 1.420 (colored)

make(1): change return type of Var_Export1 to Boolean

Revision 1.420 / (download) - annotate - [select for diffs], Sat Aug 8 12:37:37 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.419: +6 -6 lines
Diff to previous 1.419 (colored)

make(1): fix yoda-style comparisons in var.c

Revision 1.419 / (download) - annotate - [select for diffs], Sat Aug 8 12:35:15 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.418: +4 -69 lines
Diff to previous 1.418 (colored)

make(1): condense comment for ApplyModifiers

This comment only repeats what is written in the manual page.
Furthermore, it didn't get updated consistently.  The missing modifiers
were :_, :gmtime, :localtime, :hash, :Q, :range, :Or.

Revision 1.418 / (download) - annotate - [select for diffs], Sat Aug 8 12:32:26 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.417: +4 -5 lines
Diff to previous 1.417 (colored)

make(1): fix debug output for indirect modifiers

The trailing part after the modifier was confusing at best.  It does
make sense to log the string from p to p+rlen, but not from p+len to
p+len+len.

Consistently use double quotes for strings.

Revision 1.417 / (download) - annotate - [select for diffs], Fri Aug 7 20:35:03 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.416: +43 -40 lines
Diff to previous 1.416 (colored)

make(1): format the code in var.c a little more consistently

Revision 1.416 / (download) - annotate - [select for diffs], Thu Aug 6 17:51:21 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.415: +16 -16 lines
Diff to previous 1.415 (colored)

make(1): use consistent name for result of Cmd_Exec

Revision 1.415 / (download) - annotate - [select for diffs], Thu Aug 6 17:48:41 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.414: +9 -16 lines
Diff to previous 1.414 (colored)

make(1): reduce code size in :D and :U modifier

This affects both the source code size and the binary code size, at
least on x86_64.

Revision 1.414 / (download) - annotate - [select for diffs], Thu Aug 6 17:32:40 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.413: +20 -17 lines
Diff to previous 1.413 (colored)

make(1): clean up code for variable handling

The VarFlags type doesn't need an underscore.  The underscore is
typically only used for exported functions.

Document the memory allocation details for Var.name.

Use consistent names for Hash_Entry variables.  Quite possibly one of
them was a Lst_Node in ancient times, but that's not a reason to keep
this variable name forever.

Revision 1.413 / (download) - annotate - [select for diffs], Mon Aug 3 21:44:43 2020 UTC (14 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.412: +4 -4 lines
Diff to previous 1.412 (colored)

make(1): fix wrong assertion in ApplyModifiers

The assertion was supposed to validate startc and endc individually.

For unknown reasons (once again), this reduces the code size by 49 bytes
on x86_64.

Revision 1.412 / (download) - annotate - [select for diffs], Mon Aug 3 20:26:09 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.411: +221 -125 lines
Diff to previous 1.411 (colored)

make(1): no declaration-after-statement anymore

NetBSD make is intended to be maximally portable, therefore it uses only
C89.  This was not declared in the Makefile before.

There are still a few places in parse.c and metachar.c that use
end-of-line comments.  These will be fixed in a follow-up commit.

Revision 1.411 / (download) - annotate - [select for diffs], Mon Aug 3 16:45:23 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.410: +36 -65 lines
Diff to previous 1.410 (colored)

make(1): use VAR_DEBUG macro instead of if statements

This removes some clutter from the code and reduces the indentation.

Revision 1.410 / (download) - annotate - [select for diffs], Mon Aug 3 15:43:32 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.409: +10 -3 lines
Diff to previous 1.409 (colored)

make(1): in lint mode, disallow dynamic variable names in :@ modifier

This is an extremely obscure feature that hopefully nobody ever
considered using.

Revision 1.409 / (download) - annotate - [select for diffs], Mon Aug 3 15:08:00 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.408: +182 -146 lines
Diff to previous 1.408 (colored)

make(1): replace st->next with a simple string iterator

This is the same style that OpenBSD's make has been using for 20 years
now.  Having one less field in ApplyModifiersState reduces complexity in
that place.

The individual modifiers currently don't handle parse errors
consistently.  Some update pp while others leave it as-is.  This
behavior may be aligned in a follow-up commit.

Revision 1.408 / (download) - annotate - [select for diffs], Mon Aug 3 14:42:50 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.407: +10 -10 lines
Diff to previous 1.407 (colored)

make(1): don't use st->next as a local variable

Revision 1.407 / (download) - annotate - [select for diffs], Sun Aug 2 20:13:05 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.406: +4 -4 lines
Diff to previous 1.406 (colored)

make(1): remove duplicate code in :ts modifier

The pointer xp had already been there with the correct value, and
there's no point in not using it.  This reduces the code size on x86_64
by 48 bytes, which is more than I had expected.

Revision 1.406 / (download) - annotate - [select for diffs], Sun Aug 2 19:59:17 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.405: +9 -9 lines
Diff to previous 1.405 (colored)

make(1): clean up NULL pointer comparisons, use separate variable

st->newVal is not meant to be a general-purpose storage.

Eliminate the unnecessary initialization of freeIt since Var_Parse
initializes it in every case.

Revision 1.405 / (download) - annotate - [select for diffs], Sun Aug 2 19:49:17 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.404: +9 -9 lines
Diff to previous 1.404 (colored)

make(1): make :hash modifier more efficient

It's not necessary to allocate a 256-byte buffer just to store 9 bytes
in it, and to null-terminate it after writing every single byte to it.

Revision 1.404 / (download) - annotate - [select for diffs], Sun Aug 2 19:11:57 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.403: +17 -17 lines
Diff to previous 1.403 (colored)

make(1): move qsort helper functions closer to ApplyModifier_Order

Revision 1.403 / (download) - annotate - [select for diffs], Sun Aug 2 19:08:54 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.402: +24 -31 lines
Diff to previous 1.402 (colored)

make(1): merge duplicate code in the :O and :u modifiers

Revision 1.402 / (download) - annotate - [select for diffs], Sun Aug 2 18:57:55 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.401: +50 -73 lines
Diff to previous 1.401 (colored)

make(1): inline VarOrder into ApplyModifier_Order

Removing the extra mapping layer "otype" makes the code both faster and
smaller.

Revision 1.401 / (download) - annotate - [select for diffs], Sun Aug 2 18:23:00 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.400: +79 -95 lines
Diff to previous 1.400 (colored)

make(1): reduce scope of variables

This groups the variables by topic and only introduces them when they
are actually needed.  The compiler doesn't care, but during a debugging
session this means fewer uninitialized variables.

In VarUniq, the variable i has been split into two.  All others remain
exactly as before, just with a smaller scope.

Revision 1.400 / (download) - annotate - [select for diffs], Sun Aug 2 17:10:54 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.399: +35 -100 lines
Diff to previous 1.399 (colored)

make(1): clean up comments in var.c

Some of the effects listed in "Side Effects" were really "Main Effects"
and have been moved to the main description.

VarAdd: There's no "front" in a hash table.

VarHash: A const char * is not a "String to modify".

Var_Subst: Even in r1.1 of var.c, there was no "variable structure to
store in" anywhere nearby.

Revision 1.399 / (download) - annotate - [select for diffs], Sun Aug 2 16:06:49 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.398: +18 -18 lines
Diff to previous 1.398 (colored)

make(1): remove visual clutter from VarFind

Having fewer { else } around makes the return statements easier to find.

Revision 1.398 / (download) - annotate - [select for diffs], Sun Aug 2 15:26:49 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.397: +3 -4 lines
Diff to previous 1.397 (colored)

make(1): remove unnecessary assignment in Var_Parse

In a variable expression without braces or parentheses, it is not
possible to have modifiers.  Therefore the assigned endc could not have
been used anywhere.

Revision 1.397 / (download) - annotate - [select for diffs], Sun Aug 2 12:43:40 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.396: +10 -15 lines
Diff to previous 1.396 (colored)

make(1): eliminate another unnecessary UNCONST in Var_Delete

Revision 1.396 / (download) - annotate - [select for diffs], Sun Aug 2 10:49:53 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.395: +14 -5 lines
Diff to previous 1.395 (colored)

make(1): document almost duplicate code

ParseModifierPart and Var_Parse are very similar, but there might be
subtle differences.  Until these differences are documented in the form
of unit tests, merging these code pieces is too dangerous.

Revision 1.395 / (download) - annotate - [select for diffs], Sun Aug 2 10:47:09 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.394: +4 -6 lines
Diff to previous 1.394 (colored)

make(1): eliminate local variable in ParseModifierPart

The evaluation flags passed to the nested variables consist of 3 flags.
Therefore, (eflags & VARE_UNDEFERR) | (eflags & VARE_WANTRES) is
equivalent to (eflags & ~VARE_ASSIGN).

The variable name errnum was misleading anyway, just like the other
errnum from a few commits ago that had been renamed to errfmt.

Revision 1.394 / (download) - annotate - [select for diffs], Sun Aug 2 10:01:50 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.393: +12 -9 lines
Diff to previous 1.393 (colored)

make(1): don't needlessly chain p-- and p++ in ParseModifierPart

At least GCC 5 didn't optimize this, although I wouldn't have been
surprised if it did.

Revision 1.393 / (download) - annotate - [select for diffs], Sun Aug 2 09:54:44 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.392: +14 -14 lines
Diff to previous 1.392 (colored)

make(1): reduce the number of moving variables in ParseModifierPart

Having only the p walk through the string is easier to understand than
assigning between p and cp2 (with its unexpressive name).

Revision 1.392 / (download) - annotate - [select for diffs], Sun Aug 2 09:43:22 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.391: +25 -25 lines
Diff to previous 1.391 (colored)

make(1): use shorter local variable names

The c in cp was redundant since the context makes it obvious that this
is a character pointer. In a tight loop where lots of characters are
compared, every letter counts.

Revision 1.391 / (download) - annotate - [select for diffs], Sun Aug 2 09:36:54 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.390: +53 -51 lines
Diff to previous 1.390 (colored)

make(1): reduce indentation in ParseModifierPart

Revision 1.390 / (download) - annotate - [select for diffs], Sun Aug 2 09:06:32 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.389: +19 -20 lines
Diff to previous 1.389 (colored)

make(1): restructure documentation of ParseModifierPart

Before, the long documentation looked too frightening, and it was not
immediately clear which parts of it had to be read and which could be
skipped.

Revision 1.389 / (download) - annotate - [select for diffs], Sun Aug 2 08:49:43 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.388: +8 -8 lines
Diff to previous 1.388 (colored)

make(1): update implementation documentation

Revision 1.388 / (download) - annotate - [select for diffs], Sat Aug 1 21:40:49 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.387: +39 -39 lines
Diff to previous 1.387 (colored)

make(1): switch Buffer size from int to size_t

This change helps to make the various integer types compatible and is a
preparational step for setting WARNS=6 in the Makefile.

The documentation of buf.c has been cleaned up and condensed since it
was mostly redundant, and some statements were even slightly wrong.

All code changes are covered by the existing unit tests, except for the
few lines in for.c around for_var_len.  These changes have been reviewed
thoroughly and manually, like all the others in this commit.

Those buffer functions that deal with sizes have been renamed by
appending a Z, to make sure that no function call was accidentally
forgotten.  They will be renamed back in a follow-up commit.

As usual, the scope of a few affected variables has been reduced, and
some variables had to be split since they had been incorrectly merged
before.

The order of the arguments to Buf_AddBytes has changed from (mem_len,
mem) to (mem, mem_len), in order to make it consistent with the
functions from the C standard library, such as snprintf.

Revision 1.387 / (download) - annotate - [select for diffs], Sat Aug 1 19:19:05 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.386: +6 -6 lines
Diff to previous 1.386 (colored)

make(1): start nesting level in ApplyModifier_Match at 0

There is no need to start at 1, and starting at 0 generates smaller code
on x86_64.  Reordering the --nest and the following break would increase
the code size though, for unknown reasons.

Revision 1.386 / (download) - annotate - [select for diffs], Sat Aug 1 18:36:49 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.385: +24 -46 lines
Diff to previous 1.385 (colored)

make(1): inline and untangle the code for the :range modifier

There's no need to keep the result from brk_string in memory until the
buffer has been filled with the range.  The only thing necessary from
brk_string is the number of words.

Revision 1.385 / (download) - annotate - [select for diffs], Sat Aug 1 18:14:08 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.384: +4 -4 lines
Diff to previous 1.384 (colored)

make(1): fix error message when regcomp fails

If regcomp fails, it's not the regex substitution that is erroneous, but
the regex compilation.

Revision 1.384 / (download) - annotate - [select for diffs], Sat Aug 1 18:02:37 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.383: +6 -6 lines
Diff to previous 1.383 (colored)

make(1): use enum for return values of Cond_Eval and friends

Revision 1.383 / (download) - annotate - [select for diffs], Sat Aug 1 17:29:00 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.382: +9 -9 lines
Diff to previous 1.382 (colored)

make(1): fix documentation, use safer fallback value

The variable res is overwritten in every case, but better be safe than
sorry.  In case of programming errors it's better to issue an error
message than to continue.

Revision 1.382 / (download) - annotate - [select for diffs], Sat Aug 1 16:27:03 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.381: +4 -6 lines
Diff to previous 1.381 (colored)

make(1): make ModifyWords simpler

There is no need to test whether an actual word has been added.  The
rule is simply "add a space before every word, except for the very
first".

Revision 1.381 / (download) - annotate - [select for diffs], Sat Aug 1 15:03:43 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.380: +9 -10 lines
Diff to previous 1.380 (colored)

make(1): inline literal dollar characters

This reduces the code size when compiling with GCC 5.  Apparently GCC
wasn't sure enough that str[0] and str[1] stay the same around the call
to Buf_AddByte.

Revision 1.380 / (download) - annotate - [select for diffs], Sat Aug 1 14:47:49 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.379: +6 -6 lines
Diff to previous 1.379 (colored)

make(1): use consistent indentation in source code

Tabs for multiples of 8, then spaces.

The usage string has been kept as-is since the spaces there are
indentional and do influence the output.

Revision 1.379 / (download) - annotate - [select for diffs], Sat Aug 1 13:51:40 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.378: +26 -38 lines
Diff to previous 1.378 (colored)

make(1): inline function in SysV modifier processing

Revision 1.378 / (download) - annotate - [select for diffs], Sat Aug 1 13:35:13 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.377: +13 -14 lines
Diff to previous 1.377 (colored)

make(1): reduce the number of string comparisons in ${VAR:%.c=%.o}

There is only a single position in the word where the tail ".c" can
match, since it is implicitly anchored at the end.  Therefore there's no
need to do several string comparisons.

Revision 1.377 / (download) - annotate - [select for diffs], Sat Aug 1 13:16:29 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.376: +44 -47 lines
Diff to previous 1.376 (colored)

make(1): make variable names in SysV modifier more expressive

When matching a word against a substitution having a lhs and a rhs,
including a possible wildcard, there are just too many string variables
around to know what a simple "len" means and where it belongs.

Revision 1.376 / (download) - annotate - [select for diffs], Sat Aug 1 12:04:46 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.375: +10 -11 lines
Diff to previous 1.375 (colored)

make(1): more descriptive variable names in Str_SYSVSubst

Revision 1.375 / (download) - annotate - [select for diffs], Sat Aug 1 09:25:36 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.374: +4 -4 lines
Diff to previous 1.374 (colored)

make(1): let Var_Value return a const char *

The return value must not be modified anyway, so let the compiler check
this for free.

Revision 1.374 / (download) - annotate - [select for diffs], Sat Aug 1 08:42:33 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.373: +4 -4 lines
Diff to previous 1.373 (colored)

make(1): fix documentation of Var_Value

Revision 1.373 / (download) - annotate - [select for diffs], Sat Aug 1 07:29:04 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.372: +8 -9 lines
Diff to previous 1.372 (colored)

make(1): use better variable names in Var_Exists

Calling strchr just to initialize a variable to NULL is not as
straight-forward as possible.

The unspecific variable name cp made it unnecessarily difficult to
understand its purpose.

Revision 1.372 / (download) - annotate - [select for diffs], Sat Aug 1 07:14:04 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.371: +5 -7 lines
Diff to previous 1.371 (colored)

make(1): make condition in Var_Export1 simpler to read

Revision 1.371 / (download) - annotate - [select for diffs], Sat Aug 1 07:10:37 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.370: +9 -9 lines
Diff to previous 1.370 (colored)

make(1): use consistent pattern for testing flags

Revision 1.370 / (download) - annotate - [select for diffs], Sat Aug 1 07:03:50 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.369: +10 -10 lines
Diff to previous 1.369 (colored)

make(1): clearly mark a variable in Var_Set_with_flags for freeing

No functional change.

Revision 1.369 / (download) - annotate - [select for diffs], Sat Aug 1 06:35:00 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.368: +12 -18 lines
Diff to previous 1.368 (colored)

make(1): remove unnecessary snprintf from Var_ExportVars

String literals can be concatenated at compile time.

Furthermore, MAKE_EXPORTED can now contain percent characters without
invoking undefined behavior.  Not that anyone would ever want to do this.

Revision 1.368 / (download) - annotate - [select for diffs], Fri Jul 31 14:59:53 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.367: +8 -8 lines
Diff to previous 1.367 (colored)

make(1): mark unmodified part of ApplyModifiersState as constant

Revision 1.367 / (download) - annotate - [select for diffs], Fri Jul 31 14:54:03 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.366: +16 -19 lines
Diff to previous 1.366 (colored)

make(1): reduce number of parameters to ApplyModifiers

This saves a call to strlen and some arithmetic operations.

Revision 1.366 / (download) - annotate - [select for diffs], Fri Jul 31 14:26:22 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.365: +8 -11 lines
Diff to previous 1.365 (colored)

make(1): clean up Var_Parse

If *freePtr is not NULL, it only makes sense to free that pointer and not
a semmingly unrelated variable.

Revision 1.365 / (download) - annotate - [select for diffs], Fri Jul 31 14:11:21 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.364: +8 -8 lines
Diff to previous 1.364 (colored)

make(1): remove some redundant parentheses

Revision 1.364 / (download) - annotate - [select for diffs], Fri Jul 31 14:07:21 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.363: +13 -9 lines
Diff to previous 1.363 (colored)

make(1): omit unnecessary memory writes in :tu and :tl modifiers

Revision 1.363 / (download) - annotate - [select for diffs], Fri Jul 31 13:56:19 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.362: +6 -4 lines
Diff to previous 1.362 (colored)

make(1): fix undefined behavior when parsing incomplete :t modifier

mod[2] must only ever be accessed if mod[1] != '\0'.

Revision 1.362 / (download) - annotate - [select for diffs], Fri Jul 31 13:43:44 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.361: +7 -11 lines
Diff to previous 1.361 (colored)

make(1): reduce scope of local variables in ApplyModifier_Subst

Revision 1.361 / (download) - annotate - [select for diffs], Fri Jul 31 13:39:15 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.360: +6 -7 lines
Diff to previous 1.360 (colored)

make(1): reduce scope of local variables in ApplyModifier_Regex

Revision 1.360 / (download) - annotate - [select for diffs], Fri Jul 31 13:30:09 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.359: +8 -3 lines
Diff to previous 1.359 (colored)

make(1): fix undefined behavior when parsing malformed :C modifier

Same as in the :S modifier.

Revision 1.359 / (download) - annotate - [select for diffs], Fri Jul 31 07:29:21 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.358: +8 -3 lines
Diff to previous 1.358 (colored)

make(1): fix undefined behavior in malformed :S modifier

The unit tests failed on Ubuntu, and by looking closely at the code, it
was trivial to see the out-of-bounds memory read.

Other modifiers may have the same problem and will be inspected later.

Revision 1.358 / (download) - annotate - [select for diffs], Wed Jul 29 21:35:35 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.357: +10 -19 lines
Diff to previous 1.357 (colored)

make(1): remove unnecessary assignments to st->next

No change in the size of the resulting binary.  Apparently GCC already
knew these assignments were redundant.

Revision 1.357 / (download) - annotate - [select for diffs], Wed Jul 29 21:23:26 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.356: +19 -11 lines
Diff to previous 1.356 (colored)

make(1): document parameters to ApplyModifiers

Revision 1.356 / (download) - annotate - [select for diffs], Wed Jul 29 20:57:31 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.355: +154 -161 lines
Diff to previous 1.355 (colored)

make(1): use specialized return type for ApplyModifier functions

This makes it immediately obvious what happens after a modifier has been
applied, instead of having to translate single-character mnemonics or
booleans to their actual intention.

This also reduces the size of the binary since there are fewer jumps.

Revision 1.355 / (download) - annotate - [select for diffs], Wed Jul 29 20:33:38 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.354: +8 -5 lines
Diff to previous 1.354 (colored)

make(1): fix segfault when evaluating ${::=value}

The bug had been in the handling of the SysV modifier for many years, but
it had not been triggered since the "parsing position for the next
modifier" had been initialized to a non-NULL pointer.

In var.v r1.350, this pointer had been initialized to NULL instead since
every ApplyModifier function must set it in every case where it returns
anything except "default_case".

There might have been a slight chance of tricking make to output a wrong
error message, but nothing worse.

Revision 1.354 / (download) - annotate - [select for diffs], Wed Jul 29 19:48:33 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.353: +4 -4 lines
Diff to previous 1.353 (colored)

make(1): add enough tests to cover the ApplyModifier functions

Only a few return statements are still missing from the code coverage.

In ApplyModifier_Assign, the test for an empty variable name is skipped
for now since it segfaults.

In ApplyModifier_SysV after the second ParseModifierPart, the branch for
the missing delimiter is not reached since this case is already checked
for in the first part of the function. To trigger this branch, a
specially crafted, unrealistic string needs to be created, and that's too
complicated for the moment.

Revision 1.353 / (download) - annotate - [select for diffs], Tue Jul 28 17:18:40 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.352: +5 -3 lines
Diff to previous 1.352 (colored)

make(1): issue a parse error on unclosed variables

These errors had not been detected before by make.
In pkgsrc, this task as been done by pkglint since 2019-04-07.

Revision 1.352 / (download) - annotate - [select for diffs], Tue Jul 28 16:42:22 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.351: +18 -73 lines
Diff to previous 1.351 (colored)

make(1): remove dead code from Var_Subst

The first parameter from Var_Subst had been a literal NULL in all cases.
These have been fixed using this command:

sed -i 's|Var_Subst(NULL, |Var_Subst(|' *.c

The one remaining case was not found because the "NULL," was followed by
a line break instead of a space.

The removed code probably wouldn't have worked as expected anyway.
Expanding a single variable to a literal string would have led to
unexpected behavior for cases like ${VAR:M${pattern}}, in case pattern
would contain an unescaped ':' itself.

Revision 1.351 / (download) - annotate - [select for diffs], Tue Jul 28 00:01:13 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.350: +9 -42 lines
Diff to previous 1.350 (colored)

make(1): remove redundant ApplyModifiersState.termc

Revision 1.350 / (download) - annotate - [select for diffs], Mon Jul 27 23:56:15 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.349: +15 -9 lines
Diff to previous 1.349 (colored)

make(1): document and reorder ApplyModifiersState

Revision 1.349 / (download) - annotate - [select for diffs], Mon Jul 27 23:37:37 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.348: +82 -82 lines
Diff to previous 1.348 (colored)

make(1): rename ApplyModifiersState.nstr and newStr

The old names were too easy to confuse.  In Var_Parse, nstr is indeed
used for the "new string", but that was misleading in ApplyModifiers,
especially since there was another variable called newStr.

The new variable names focus on the purpose of the variables, not on
their data types.

Revision 1.348 / (download) - annotate - [select for diffs], Mon Jul 27 23:24:55 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.347: +118 -117 lines
Diff to previous 1.347 (colored)

make(1): rename ApplyModifiersState.cp to next

The name "next" is more descriptive than a mere "cp".  It's easy to look
up the type of the variable, but not so easy to guess the purpose of the
variable, therefore the new name concentrates on the purpose.

Revision 1.347 / (download) - annotate - [select for diffs], Mon Jul 27 23:04:18 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.346: +13 -14 lines
Diff to previous 1.346 (colored)

make(1): in ApplyModifier_Match, use short local variable name

Revision 1.346 / (download) - annotate - [select for diffs], Mon Jul 27 22:59:49 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.345: +16 -14 lines
Diff to previous 1.345 (colored)

make(1): in ModifyWord_Match, use different variables

Using the same registers or memory locations for different variables is
the job of the register allocator, not the programmer.  For humans, that
practice is rather confusing.

Revision 1.345 / (download) - annotate - [select for diffs], Mon Jul 27 22:50:01 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.344: +6 -11 lines
Diff to previous 1.344 (colored)

make(1): replace comment in ApplyModifier_Match with code

Revision 1.344 / (download) - annotate - [select for diffs], Mon Jul 27 22:30:00 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.343: +12 -14 lines
Diff to previous 1.343 (colored)

make(1): remove unused lengthPtr and freePtr from ApplyModifiersState

Revision 1.343 / (download) - annotate - [select for diffs], Mon Jul 27 22:24:03 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.342: +7 -9 lines
Diff to previous 1.342 (colored)

make(1): remove unnecessary field from ApplyModifiersState

Revision 1.342 / (download) - annotate - [select for diffs], Mon Jul 27 22:21:29 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.341: +3 -4 lines
Diff to previous 1.341 (colored)

make(1): remove unnecessary variable assignment

It is not the job of an ApplyModifier function to directly manipulate the
final result of the ApplyModifiers function.  In fact, the resulting
pointer was overwritten unconditionally, in such an obvious way that the
compiler could have detected this.  GCC 5 didn't though, which reduces
the code size a bit.

Revision 1.341 / (download) - annotate - [select for diffs], Mon Jul 27 22:02:26 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.340: +9 -9 lines
Diff to previous 1.340 (colored)

make(1): move modifier character out of ApplyModifiersState

It is only used in the outer part of the loop to apply the modifiers.

Revision 1.340 / (download) - annotate - [select for diffs], Mon Jul 27 21:54:25 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.339: +46 -37 lines
Diff to previous 1.339 (colored)

make(1): replace macros with functions

Having the hidden parameter st->endc in the macro made it unnecessarily
difficult to understand the code.

Revision 1.339 / (download) - annotate - [select for diffs], Mon Jul 27 21:08:41 2020 UTC (14 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.338: +15 -15 lines
Diff to previous 1.338 (colored)

make(1): use shorter variable name for parsing :D and :U

Revision 1.338 / (download) - annotate - [select for diffs], Mon Jul 27 19:59:59 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.337: +6 -7 lines
Diff to previous 1.337 (colored)

make(1): remove unnecessary argument validation

Revision 1.337 / (download) - annotate - [select for diffs], Mon Jul 27 17:41:09 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.336: +13 -13 lines
Diff to previous 1.336 (colored)

make(1): document API of Var_Value

Revision 1.336 / (download) - annotate - [select for diffs], Sun Jul 26 23:03:54 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.335: +4 -4 lines
Diff to previous 1.335 (colored)

make(1): make test for dynamic variable name more specific

Since all the string literals have either 7 or 8 characters, there is no
need to call strcmp for shorter or longer variable names.

Revision 1.335 / (download) - annotate - [select for diffs], Sun Jul 26 22:43:16 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.334: +43 -36 lines
Diff to previous 1.334 (colored)

make(1): extract code for dynamic variable names out of Var_Parse

Revision 1.334 / (download) - annotate - [select for diffs], Sun Jul 26 22:19:11 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.333: +13 -8 lines
Diff to previous 1.333 (colored)

make(1): fix off-by-one error in Var_Parse for dynamic variables

Revision 1.333 / (download) - annotate - [select for diffs], Sun Jul 26 21:31:11 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.332: +21 -21 lines
Diff to previous 1.332 (colored)

make(1): rename VarEvalFlags variables to eflags

This way, they cannot be confused with other flags, and any mismatch of
mixing eflags with constants other than VARE_* is immediately apparent.

Revision 1.332 / (download) - annotate - [select for diffs], Sun Jul 26 21:19:42 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.331: +14 -14 lines
Diff to previous 1.331 (colored)

make(1): rename local variable in Var_Parse

Revision 1.331 / (download) - annotate - [select for diffs], Sun Jul 26 20:21:31 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.330: +13 -13 lines
Diff to previous 1.330 (colored)

make(1): make return value of Var_Parse constant

This return value is not supposed to be modified since it can be a string
literal.  The modifiable part is returned via freePtr, but only for
freeing, not for actually modifying anything.

Revision 1.330 / (download) - annotate - [select for diffs], Sun Jul 26 19:55:24 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.329: +14 -15 lines
Diff to previous 1.329 (colored)

make(1): revert making Var_Parse return a const string

The dependencies between the C files and nonints.h are not declared
properly, which resulted in a successful partial build, but a full "make
clean && make" failed.

Revision 1.329 / (download) - annotate - [select for diffs], Sun Jul 26 19:44:04 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.328: +18 -17 lines
Diff to previous 1.328 (colored)

make(1): mark result of Var_Parse as const

Var_Parse can return either a string literal or an allocated string.  The
former must not be modified by the caller.  If the string is allocated,
it is returned in freePtr as well, but only for freeing it after use.

Revision 1.328 / (download) - annotate - [select for diffs], Sun Jul 26 19:36:24 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.327: +14 -13 lines
Diff to previous 1.327 (colored)

make(1): reduce scope and rename local variable in Var_Parse

Revision 1.327 / (download) - annotate - [select for diffs], Sun Jul 26 19:16:17 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.326: +8 -10 lines
Diff to previous 1.326 (colored)

make(1): eliminate another local variable in Var_Parse

Revision 1.326 / (download) - annotate - [select for diffs], Sun Jul 26 19:13:42 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.325: +5 -8 lines
Diff to previous 1.325 (colored)

make(1): split local variable into two in Var_Parse

Revision 1.325 / (download) - annotate - [select for diffs], Sun Jul 26 19:11:06 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.324: +25 -24 lines
Diff to previous 1.324 (colored)

make(1): split local variable into two

Reusing a const char * parameter to store a char * and later free that
string was not a good idea. It made the pretty long code of Var_Parse
more difficult to understand.

Revision 1.324 / (download) - annotate - [select for diffs], Sun Jul 26 18:47:02 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.323: +45 -44 lines
Diff to previous 1.323 (colored)

make(1): reorder arguments of ParseModifierPart

First the input parameters, then additional data, then special arguments.

Revision 1.323 / (download) - annotate - [select for diffs], Sun Jul 26 18:11:12 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.322: +7 -8 lines
Diff to previous 1.322 (colored)

make(1): merge VARE_NOSUBST into VARE_WANTRES

The flag VARE_NOSUBST is only a few days old. It had grown out of the
VARP_NOSUBST and VAR_NOSUBST flags, not knowing at that time that it
meant the exact opposite of VARE_WANTRES.

Revision 1.322 / (download) - annotate - [select for diffs], Sun Jul 26 17:44:54 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.321: +4 -4 lines
Diff to previous 1.321 (colored)

make(1): remove wrong comment from VarOrder

Revision 1.321 / (download) - annotate - [select for diffs], Sun Jul 26 17:23:00 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.320: +6 -6 lines
Diff to previous 1.320 (colored)

make(1): reorder code in ParseModifierPart to be more readable

Revision 1.320 / (download) - annotate - [select for diffs], Sun Jul 26 17:21:28 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.319: +15 -15 lines
Diff to previous 1.319 (colored)

make(1): in ParseModifierPart, only update length on success

Revision 1.319 / (download) - annotate - [select for diffs], Sun Jul 26 17:10:56 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.318: +4 -19 lines
Diff to previous 1.318 (colored)

make(1): remove wrong comment for VarUniq

VarUniq is not about sorting the words.

Revision 1.318 / (download) - annotate - [select for diffs], Sun Jul 26 17:09:23 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.317: +9 -9 lines
Diff to previous 1.317 (colored)

make(1): save a few bytes and cycles by comparing against 0

The comparison against ac - 1 could have been optimized by the compilers
as well, but both GCC 5 and Clang produce smaller code for the comparison
against 0.

Revision 1.317 / (download) - annotate - [select for diffs], Sun Jul 26 16:59:08 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.316: +14 -16 lines
Diff to previous 1.316 (colored)

make(1): remove unnecessary block scope

Revision 1.316 / (download) - annotate - [select for diffs], Sun Jul 26 15:53:01 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.315: +11 -13 lines
Diff to previous 1.315 (colored)

make(1): avoid memory allocation for oneBigWord in modifiers

Revision 1.315 / (download) - annotate - [select for diffs], Sun Jul 26 15:37:44 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.314: +9 -8 lines
Diff to previous 1.314 (colored)

make(1): help the compiler to find common subexpressions

Revision 1.314 / (download) - annotate - [select for diffs], Sun Jul 26 15:26:27 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.313: +37 -25 lines
Diff to previous 1.313 (colored)

make(1): add convenience functions for adding to a SepBuf

Revision 1.313 / (download) - annotate - [select for diffs], Sun Jul 26 15:09:10 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.312: +22 -32 lines
Diff to previous 1.312 (colored)

make(1): add Buffer functions for common tasks

Adding a string or a substring to a buffer are common tasks when handling
variables.  There is no need to spell out the strlen call or the pointer
subtraction at every call site.

Subtracting pointers results in a ptrdiff_t, which would have to be
converted to an int in each case for WARNS=6. Having this conversion in a
single place keeps the code clean.

Revision 1.312 / (download) - annotate - [select for diffs], Sun Jul 26 13:39:30 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.311: +12 -23 lines
Diff to previous 1.311 (colored)

make(1): add Buf_AddInt to make the calling code simpler

Revision 1.311 / (download) - annotate - [select for diffs], Sun Jul 26 12:27:09 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.310: +4 -5 lines
Diff to previous 1.310 (colored)

make(1): make code in the :S modifier simpler

This code path is covered by the "sequences of letters" in modmisc.mk.

Revision 1.310 / (download) - annotate - [select for diffs], Sun Jul 26 12:19:37 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.309: +4 -4 lines
Diff to previous 1.309 (colored)

make(1): fix bug in :S modifier from 2020-07-19

Revision 1.309 / (download) - annotate - [select for diffs], Sun Jul 26 10:11:04 2020 UTC (14 months, 4 weeks ago) by rillig
Branch: MAIN
Changes since 1.308: +5 -4 lines
Diff to previous 1.308 (colored)

make(1): fix missing error message about missing @ delimiter

This had been broken since 2020-07-03, during a "refactoring".

Revision 1.308 / (download) - annotate - [select for diffs], Fri Jul 24 08:24:23 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.307: +5 -7 lines
Diff to previous 1.307 (colored)

make(1): remove redundant condition

If there are multiple words from brk_string, none of them can be empty.
And if there is oneSingleWord that is empty, it doesn't hurt to add 0
bytes.

Revision 1.307 / (download) - annotate - [select for diffs], Fri Jul 24 08:22:05 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.306: +8 -8 lines
Diff to previous 1.306 (colored)

make(1): prefer direct jump over indirect variable assignment

Revision 1.306 / (download) - annotate - [select for diffs], Fri Jul 24 08:20:24 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.305: +4 -5 lines
Diff to previous 1.305 (colored)

make(1): make condition in ModifyWord_SubstRegex simpler

The generated code is still the same, at least with Clang.

Revision 1.305 / (download) - annotate - [select for diffs], Fri Jul 24 08:12:43 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.304: +11 -14 lines
Diff to previous 1.304 (colored)

make(1): reduce lifetime of regmatch_t for :C modifier

Revision 1.304 / (download) - annotate - [select for diffs], Fri Jul 24 08:06:28 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.303: +19 -18 lines
Diff to previous 1.303 (colored)

make(1): rename local variable

Revision 1.303 / (download) - annotate - [select for diffs], Fri Jul 24 08:03:27 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.302: +4 -6 lines
Diff to previous 1.302 (colored)

make(1): allocate capturing groups for :C modifier statically

Since there are at most 10 capturing groups, it's easier to allocate them
on the stack.

To avoid growing the code size on x86_64, the matches have been moved to
the end of the struct, to keep the other offsets small.

Revision 1.302 / (download) - annotate - [select for diffs], Fri Jul 24 07:59:35 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.301: +8 -9 lines
Diff to previous 1.301 (colored)

make(1): clean up Var_Export

Revision 1.301 / (download) - annotate - [select for diffs], Fri Jul 24 07:52:44 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.300: +51 -60 lines
Diff to previous 1.300 (colored)

make(1): inline Var_Parse_State into ApplyModifiersState

There was no need to have this as a separate struct.  Especially none of
the modifiers used by ModifyWords modify this state, therefore it was
not necessary to pass it by reference.  This makes the code easier to
understand since there's less modifiable state.

Revision 1.300 / (download) - annotate - [select for diffs], Fri Jul 24 07:29:18 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.299: +5 -5 lines
Diff to previous 1.299 (colored)

make(1): document ApplyModifiersState.cp

Revision 1.299 / (download) - annotate - [select for diffs], Fri Jul 24 07:24:21 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.298: +145 -152 lines
Diff to previous 1.298 (colored)

make(1): eliminate ApplyModifiersState.tstr

This field always pointed to the beginning of the current modifier.
Therefore a better name is "mod", and there is no need to store it in the
shared state.

Revision 1.298 / (download) - annotate - [select for diffs], Thu Jul 23 20:24:22 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.297: +62 -47 lines
Diff to previous 1.297 (colored)

make(1): only set missing_delim if it is actually missing

Just to make it easier to understand the code.

Revision 1.297 / (download) - annotate - [select for diffs], Thu Jul 23 19:49:39 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.296: +10 -8 lines
Diff to previous 1.296 (colored)

make(1): fix wrong warning about missing delimiter

Revision 1.296 / (download) - annotate - [select for diffs], Thu Jul 23 19:32:54 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.295: +4 -6 lines
Diff to previous 1.295 (colored)

make(1): reduce code size on x86_64

Revision 1.295 / (download) - annotate - [select for diffs], Tue Jul 21 23:47:50 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.294: +32 -40 lines
Diff to previous 1.294 (colored)

make(1): remove parameter from ModifyWordCallback

Most modifiers don't need a variable context, and those that do already
get all their parameters in a custom Args struct.

Revision 1.294 / (download) - annotate - [select for diffs], Tue Jul 21 23:22:45 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.293: +8 -14 lines
Diff to previous 1.293 (colored)

make(1): make implementation of the :C modifier simpler

Revision 1.293 / (download) - annotate - [select for diffs], Tue Jul 21 21:32:55 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.292: +8 -12 lines
Diff to previous 1.292 (colored)

make(1): only ask for newline if :Q actually needs it

This simple change reduces the binary size of var.o by 96 bytes (Clang,
x86_64). Given that the code is still the same, just in a different
order, this is a bit surprising.

Revision 1.292 / (download) - annotate - [select for diffs], Tue Jul 21 21:13:24 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.291: +52 -58 lines
Diff to previous 1.291 (colored)

make(1): clean up various things in var.c

Revision 1.291 / (download) - annotate - [select for diffs], Tue Jul 21 20:56:56 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.290: +142 -158 lines
Diff to previous 1.290 (colored)

make(1): use consistent and descriptive names for callback functions

Revision 1.290 / (download) - annotate - [select for diffs], Tue Jul 21 20:08:44 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.289: +20 -27 lines
Diff to previous 1.289 (colored)

make(1): remove unnecessary VarSelectWords_t struct

Revision 1.289 / (download) - annotate - [select for diffs], Mon Jul 20 21:33:13 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.288: +92 -92 lines
Diff to previous 1.288 (colored)

make(1): extract :ts<separator> modifier into separate function

Revision 1.288 / (download) - annotate - [select for diffs], Mon Jul 20 20:56:39 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.287: +104 -128 lines
Diff to previous 1.287 (colored)

make(1): clean up implementation of :[...] and other modifiers

Revision 1.287 / (download) - annotate - [select for diffs], Mon Jul 20 19:53:40 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.286: +11 -19 lines
Diff to previous 1.286 (colored)

make(1): fix edge cases with $ at the end of the :@ modifier

In both parts of the :@ modifier, by passing &pflags to
ParseModifierPart, a final $ was interpreted as an anchor, which only
makes sense in the :S and :C modifiers.

This edge case is neither used by src nor by pkgsrc, except for the unit
tests that have been adjusted.

Revision 1.286 / (download) - annotate - [select for diffs], Mon Jul 20 18:12:48 2020 UTC (15 months ago) by sjg
Branch: MAIN
Changes since 1.285: +10 -3 lines
Diff to previous 1.285 (colored)

Make DEBUG_HASH less of a fire-hose.

Reporting keys on every lookup is overkill unless
playing with a new HASH, so wrap in #ifdef DEBUG_HASH_LOOKUP
Also add some stats at the end so we can see
final size and max chain length - maxchain is a better
variable name than maxlen.

Revision 1.285 / (download) - annotate - [select for diffs], Mon Jul 20 16:55:10 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.284: +13 -16 lines
Diff to previous 1.284 (colored)

make(1): make conditions work without pattern flags

The "pattern flag" VARP_NOSUBST was used to prevent evaluating
irrelevant conditions.  Omitting the evaluation flag VARE_WANTRES has the
same effect.

Revision 1.284 / (download) - annotate - [select for diffs], Mon Jul 20 16:32:14 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.283: +4 -8 lines
Diff to previous 1.283 (colored)

make(1): fix obscure edge case for ${VAR:e$=x}

The characters "$=" do not occur in either src or pkgsrc, therefore this
case is unlikely to occur in practice.

Revision 1.283 / (download) - annotate - [select for diffs], Mon Jul 20 16:12:52 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.282: +25 -23 lines
Diff to previous 1.282 (colored)

make(1): move documentation for assignment modifiers

Revision 1.282 / (download) - annotate - [select for diffs], Mon Jul 20 15:48:50 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.281: +5 -4 lines
Diff to previous 1.281 (colored)

make(1): prefer memcmp over strncmp

Revision 1.281 / (download) - annotate - [select for diffs], Mon Jul 20 15:44:12 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.280: +55 -60 lines
Diff to previous 1.280 (colored)

make(1): fix type of VarPattern.lhsLen and rhsLen

String length is measured in size_t, not int.

Revision 1.280 / (download) - annotate - [select for diffs], Mon Jul 20 15:15:32 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.279: +8 -6 lines
Diff to previous 1.279 (colored)

make(1): fix undefined behavior in :S modifier

The expression word + wordLen - leftLen had resulted in an out-of-bounds
pointer before.  Luckily the heap addresses were high enough in typical
applications to prevent a wrap-around.

Revision 1.279 / (download) - annotate - [select for diffs], Mon Jul 20 15:10:35 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.278: +44 -85 lines
Diff to previous 1.278 (colored)

make(1): make implementation of the :S modifier simpler

Revision 1.278 / (download) - annotate - [select for diffs], Mon Jul 20 14:50:41 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.277: +164 -258 lines
Diff to previous 1.277 (colored)

make(1): make modifier handling simpler

Implementing a modifier such as :S or :M should not be concerned with
separating the words of the resulting string.  Ideally this should be
done in the same way by all modifiers.

Before, the :R (filename root) modifier added a separator even if the
resulting filename root was an empty string.  The chances that this
change in behavior breaks anything are epsilon.

The :@ modifier, if it appeared after a :ts modifier, did not use the
word separator from the :ts modifier (which all other modifiers do) but
always added a space.  This behavior has been preserved for now.  It's an
unnecessary inconsistency though.

In contrast to Buffer, the newly added SepBuf uses size_t for memory
sizes and also uses the conventional parameter order (mem, memsize)
instead of the unusual (memsize, mem).

Revision 1.277 / (download) - annotate - [select for diffs], Sun Jul 19 22:22:01 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.276: +9 -9 lines
Diff to previous 1.276 (colored)

make(1): remove unnecessary UNCONST

Revision 1.276 / (download) - annotate - [select for diffs], Sun Jul 19 22:04:27 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.275: +29 -32 lines
Diff to previous 1.275 (colored)

make(1): make ampersand in ${VAR:from=to&} an ordinary character

In SysV substitutions, wildcards are expressed with % instead of &.  The
& is not mentioned in the manual page, and having another wildcard for
the whole word would be such an obscure feature that not even pkgsrc uses
it.  The easiest way to discover this feature had been to read the source
code of make(1) or to use a fuzzer and accidentally stumble upon this
edge case.

Revision 1.275 / (download) - annotate - [select for diffs], Sun Jul 19 21:30:49 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.274: +16 -16 lines
Diff to previous 1.274 (colored)

make(1): don't call VarSubstitute unnecessarily

Revision 1.274 / (download) - annotate - [select for diffs], Sun Jul 19 21:14:56 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.273: +12 -15 lines
Diff to previous 1.273 (colored)

make(1): remove wrong VarPattern from ApplyModifier_Exclam

Revision 1.273 / (download) - annotate - [select for diffs], Sun Jul 19 21:10:34 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.272: +16 -20 lines
Diff to previous 1.272 (colored)

make(1): remove wrong VarPattern from ApplyModifier_Assign

Revision 1.272 / (download) - annotate - [select for diffs], Sun Jul 19 20:56:34 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.271: +80 -80 lines
Diff to previous 1.271 (colored)

make(1): flatten ApplyModifier_Assign

Revision 1.271 / (download) - annotate - [select for diffs], Sun Jul 19 19:27:08 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.270: +4 -4 lines
Diff to previous 1.270 (colored)

make(1): fix off-by-one error in :C modifier

Previously this off-by-one error had invoked undefined behavior.
Until today there was no corresponding unit test though.

Revision 1.270 / (download) - annotate - [select for diffs], Sun Jul 19 18:35:53 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.269: +4 -4 lines
Diff to previous 1.269 (colored)

make(1): fix double free introduced this morning in r1.258

Revision 1.269 / (download) - annotate - [select for diffs], Sun Jul 19 17:43:36 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.268: +17 -28 lines
Diff to previous 1.268 (colored)

make(1): remove redundant loop control variable

Revision 1.268 / (download) - annotate - [select for diffs], Sun Jul 19 17:40:30 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.267: +40 -44 lines
Diff to previous 1.267 (colored)

make(1): rename ApplyModifiersState.flags to eflags

There are just too many variables called "flags" in this file, and their
constants must not accidentally overlap.

Revision 1.267 / (download) - annotate - [select for diffs], Sun Jul 19 16:48:48 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.266: +17 -29 lines
Diff to previous 1.266 (colored)

make(1): clean up VarLoop structure

Revision 1.266 / (download) - annotate - [select for diffs], Sun Jul 19 16:22:44 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.265: +22 -36 lines
Diff to previous 1.265 (colored)

make(1): remove unused parameter from ParseModifierPart

Revision 1.265 / (download) - annotate - [select for diffs], Sun Jul 19 16:08:24 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.264: +35 -42 lines
Diff to previous 1.264 (colored)

make(1): rename VarGetPattern to ParseModifierPart

Revision 1.264 / (download) - annotate - [select for diffs], Sun Jul 19 15:51:51 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.263: +5 -7 lines
Diff to previous 1.263 (colored)

make(1): eliminate unused local variables

Revision 1.263 / (download) - annotate - [select for diffs], Sun Jul 19 15:47:10 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.262: +6 -8 lines
Diff to previous 1.262 (colored)

make(1): eliminate macro from VarGetPattern

Revision 1.262 / (download) - annotate - [select for diffs], Sun Jul 19 14:05:39 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.261: +9 -11 lines
Diff to previous 1.261 (colored)

make(1): replace ApplyModifiersState field with local variable

Revision 1.261 / (download) - annotate - [select for diffs], Sun Jul 19 13:21:56 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.260: +68 -57 lines
Diff to previous 1.260 (colored)

make(1): rename flags for :S and :C pattern matching

Renaming these flags makes it obvious that VarPattern is used in a few
places where it doesn't belong.  These will be fixed in follow-up
commits.

Revision 1.260 / (download) - annotate - [select for diffs], Sun Jul 19 12:51:06 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.259: +14 -13 lines
Diff to previous 1.259 (colored)

make(1): convert VarFind flags to typed enum

Revision 1.259 / (download) - annotate - [select for diffs], Sun Jul 19 12:26:17 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.258: +43 -43 lines
Diff to previous 1.258 (colored)

make(1): rename Varf_Flags to VarEvalFlags

In var.c there are lots of different flag types.  To make any accidental
mixture obvious, each flag group gets its own prefix.

The only flag group that is visible outside of var.c is concerned with
evaluating variables, therefore the "e", which replaces the former "f"
that probably just meant "flag".

Revision 1.258 / (download) - annotate - [select for diffs], Sun Jul 19 10:38:02 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.257: +20 -27 lines
Diff to previous 1.257 (colored)

make(1): clean up handling of :? modifier

The VarPattern type had nothing to do with parsing conditions.

Revision 1.257 / (download) - annotate - [select for diffs], Sun Jul 19 10:28:44 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.256: +49 -60 lines
Diff to previous 1.256 (colored)

make(1): clean up code in var.c

* use canonical comparison to zero in more cases
* omit unnecessary snprintf for string literal concatenation
* omit a few redundant parentheses and braces

Revision 1.256 / (download) - annotate - [select for diffs], Sun Jul 19 09:26:18 2020 UTC (15 months ago) by rillig
Branch: MAIN
Changes since 1.255: +106 -4 lines
Diff to previous 1.255 (colored)

make(1): move SysV string matching to var.c

This kind of string matching is only used in variable modifiers, and only
if this feature is enabled by SYSVVARSUB.

Revision 1.255 / (download) - annotate - [select for diffs], Sat Jul 4 17:41:04 2020 UTC (15 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.254: +8 -3 lines
Diff to previous 1.254 (colored)

make(1): expand the test for variable expansion in the :@ modifier

Revision 1.254 / (download) - annotate - [select for diffs], Sat Jul 4 17:10:33 2020 UTC (15 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.253: +9 -3 lines
Diff to previous 1.253 (colored)

make(1): add debugging output for :@ modifier

The inner working of the :@ modifier is quite tricky.  To understand what
really happens, it helps to look at each word as it is being modified.

Revision 1.253 / (download) - annotate - [select for diffs], Sat Jul 4 16:30:47 2020 UTC (15 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.252: +18 -18 lines
Diff to previous 1.252 (colored)

make(1): constify VarModify parameter

Since var.c r1.238 and r1.239, the callbacks for the :H :T :E :R modifiers
don't modify the word anymore, and the others didn't modify it at all.

Revision 1.252 / (download) - annotate - [select for diffs], Sat Jul 4 15:44:07 2020 UTC (15 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.251: +12 -9 lines
Diff to previous 1.251 (colored)

make(1): fix :hash modifier on 16-bit platforms

On platforms where int has only 16 bits the shifts would have been in
16-bit arithmetic, which would invoke undefined behavior for "ustr[3] <<
24" as well as "ustr[2] << 16" (C99, 6.5.7p3).

Revision 1.251 / (download) - annotate - [select for diffs], Sat Jul 4 10:49:09 2020 UTC (15 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.250: +6 -6 lines
Diff to previous 1.250 (colored)

make(1): remove unnecessary _t suffix from VarLoop type

Revision 1.250 / (download) - annotate - [select for diffs], Sat Jul 4 10:46:31 2020 UTC (15 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.249: +9 -37 lines
Diff to previous 1.249 (colored)

make(1): fix documentation of Var_Subst, clean up other documentation

Revision 1.249 / (download) - annotate - [select for diffs], Sat Jul 4 10:35:30 2020 UTC (15 months, 2 weeks ago) by rillig
Branch: MAIN
Changes since 1.248: +27 -41 lines
Diff to previous 1.248 (colored)

make(1): remove unnecessary forward declarations, fix indentation

Revision 1.248 / (download) - annotate - [select for diffs], Sat Jul 4 10:19:39 2020 UTC (15 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.247: +3 -30 lines
Diff to previous 1.247 (colored)

make(1): remove unnecessary forward declarations

Revision 1.247 / (download) - annotate - [select for diffs], Sat Jul 4 03:08:20 2020 UTC (15 months, 3 weeks ago) by lukem
Branch: MAIN
Changes since 1.246: +4 -4 lines
Diff to previous 1.246 (colored)

make: fix sign-compare warning

Fix -Wsign-compare warning on amd64, introduced in rev 1.239

Revision 1.246 / (download) - annotate - [select for diffs], Fri Jul 3 22:40:55 2020 UTC (15 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.245: +12 -7 lines
Diff to previous 1.245 (colored)

make(1): reduce line length in var.c

Revision 1.245 / (download) - annotate - [select for diffs], Fri Jul 3 22:34:22 2020 UTC (15 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.244: +38 -40 lines
Diff to previous 1.244 (colored)

make(1): refactor ApplyModifier_SysV to have less indentation

Revision 1.244 / (download) - annotate - [select for diffs], Fri Jul 3 22:10:42 2020 UTC (15 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.243: +74 -187 lines
Diff to previous 1.243 (colored)

make(1): clean up documentation, small refactorings for variables

- document the callback for VarModify
- clearly mark the callbacks
- shorten the documentation for some callback functions
- fix the documentation of VarSYSVMatch
- remove unnecessary null check from VarLoopExpand
- add test for applying modifiers to empty strings

Revision 1.243 / (download) - annotate - [select for diffs], Fri Jul 3 18:41:50 2020 UTC (15 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.242: +5 -5 lines
Diff to previous 1.242 (colored)

make(1): fix bug in :E modifier, introduced in r1.239 today

That case was not covered by the tests before.

Revision 1.242 / (download) - annotate - [select for diffs], Fri Jul 3 17:48:47 2020 UTC (15 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.241: +158 -173 lines
Diff to previous 1.241 (colored)

make(1): fix indentation in var.c

Fixing the indentation manually is a tedious task.  indent(1) was no help
since it has several bugs and is not flexible enough for the original
make code.

Revision 1.241 / (download) - annotate - [select for diffs], Fri Jul 3 17:03:09 2020 UTC (15 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.240: +14 -25 lines
Diff to previous 1.240 (colored)

make(1): add Hash_ForEach to avoid duplicate code

Revision 1.240 / (download) - annotate - [select for diffs], Fri Jul 3 17:00:47 2020 UTC (15 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.239: +110 -134 lines
Diff to previous 1.239 (colored)

make(1): fix indentation and alignment

Revision 1.239 / (download) - annotate - [select for diffs], Fri Jul 3 15:42:43 2020 UTC (15 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.238: +16 -68 lines
Diff to previous 1.238 (colored)

make(1): make code for the :E and :R modifiers simpler

Revision 1.238 / (download) - annotate - [select for diffs], Fri Jul 3 15:24:31 2020 UTC (15 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.237: +15 -70 lines
Diff to previous 1.237 (colored)

make(1): clean up code for the :H and :T modifiers

Revision 1.237 / (download) - annotate - [select for diffs], Fri Jul 3 14:59:17 2020 UTC (15 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.236: +4 -6 lines
Diff to previous 1.236 (colored)

make(1): add missing test for the :H and :T modifiers

Revision 1.236 / (download) - annotate - [select for diffs], Fri Jul 3 14:14:04 2020 UTC (15 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.235: +1165 -1042 lines
Diff to previous 1.235 (colored)

make(1): refactor ApplyModifiers

Previously, ApplyModifiers was 1200 lines long and pretty complicated.
Now each of the complicated modifiers has its own function, which reduces
the indentation and makes it possible to use early returns.

Revision 1.235 / (download) - annotate - [select for diffs], Fri Jul 3 08:13:23 2020 UTC (15 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.234: +5 -5 lines
Diff to previous 1.234 (colored)

make(1): remove trailing whitespace

Revision 1.234 / (download) - annotate - [select for diffs], Fri Jul 3 08:02:55 2020 UTC (15 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.233: +4 -4 lines
Diff to previous 1.233 (colored)

make(1): remove redundant parentheses around return values

Revision 1.233 / (download) - annotate - [select for diffs], Thu Jul 2 16:52:34 2020 UTC (15 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.232: +6 -6 lines
Diff to previous 1.232 (colored)

make(1): fix unnecessary evaluation of variables in :@var@ modifier

Revision 1.232 / (download) - annotate - [select for diffs], Thu Jul 2 16:46:57 2020 UTC (15 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.231: +6 -6 lines
Diff to previous 1.231 (colored)

make(1): fix unnecessary evaluation for :S :C := modifiers

Revision 1.231 / (download) - annotate - [select for diffs], Thu Jul 2 16:14:50 2020 UTC (15 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.230: +52 -103 lines
Diff to previous 1.230 (colored)

make(1): clean up code in var.c

- remove redundant parentheses in return statements
- add missing space after comma
- remove some redundant parentheses around comparisons
- use hexadecimal numbers for bit mask constants
- remove Var_GetTail and Var_GetHead, which had been unused for 19 years

Revision 1.230 / (download) - annotate - [select for diffs], Thu Jul 2 15:47:38 2020 UTC (15 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.229: +49 -42 lines
Diff to previous 1.229 (colored)

make(1): remove useless parameter from Var_Set

The enum corresponding to this int parameter is only defined in var.c,
which makes it impractical for the outside to set this parameter to
anything but 0.

On x86_64, this reduces the size of the resulting executable by 5 kB.

Revision 1.229 / (download) - annotate - [select for diffs], Thu Jul 2 15:26:21 2020 UTC (15 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.228: +24 -23 lines
Diff to previous 1.228 (colored)

make(1): use enum instead of #define for VarPattern flags

Revision 1.228 / (download) - annotate - [select for diffs], Thu Jul 2 15:14:38 2020 UTC (15 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.227: +23 -21 lines
Diff to previous 1.227 (colored)

make(1): add more type safety for enums

There are several types of flags for variables, and these cannot be
mixed.  To prevent accidental typos, these are defined in separate enum
types.  Clang warns about direct assignments between distinct types, but
not about mixing distinct types in binary expressions like A | B.  GCC
does not warn at all.

Revision 1.227 / (download) - annotate - [select for diffs], Thu Jul 2 13:04:09 2020 UTC (15 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.226: +4 -4 lines
Diff to previous 1.226 (colored)

make(1): fix unnecessary evaluation of :M and :N modifiers

Revision 1.226 / (download) - annotate - [select for diffs], Thu Jul 2 12:34:30 2020 UTC (15 months, 3 weeks ago) by rillig
Branch: MAIN
Changes since 1.225: +5 -10 lines
Diff to previous 1.225 (colored)

make(1): fix edge case for evaluating unnecessary conditions

Revision 1.225 / (download) - annotate - [select for diffs], Wed Jul 1 18:02:26 2020 UTC (15 months, 3 weeks ago) by sjg
Branch: MAIN
Changes since 1.224: +10 -5 lines
Diff to previous 1.224 (colored)

Fix parsing of nested variables during .for loop

Recent change to cond.c to avoid eval of unnecessary
terms had side effect on constructs like:

.for s in 1 2
.if defined(MAN$s) && !empty(MAN$s)
MAN+= ${MAN$s}
.endif
.endfor

resulting in MAN being flagged as recursive.

When Var_Parse encounters a variable within a variable name
we want to force it to be expanded.
But given the way get_mpt_arg calls Var_Parse we need to check
whether we actually started parsing a variable yet.

Revision 1.224 / (download) - annotate - [select for diffs], Fri Jun 5 19:20:46 2020 UTC (16 months, 2 weeks ago) by sjg
Branch: MAIN
Changes since 1.223: +14 -4 lines
Diff to previous 1.223 (colored)

make: add :Or for reverse sort

:Or is more efficient than :O:[-1..1]

Reviewed by: christos

Revision 1.223 / (download) - annotate - [select for diffs], Sat Apr 25 18:20:57 2020 UTC (17 months, 4 weeks ago) by christos
Branch: MAIN
Changes since 1.222: +7 -6 lines
Diff to previous 1.222 (colored)

- Percent on the rhs is special only if the lhs has one too.
- If the rhs does not have percent, but the lhs has, the result is the rhs
This behavior matches gmake

Revision 1.220.2.1 / (download) - annotate - [select for diffs], Mon Jun 10 22:10:21 2019 UTC (2 years, 4 months ago) by christos
Branch: phil-wifi
Changes since 1.220: +7 -4 lines
Diff to previous 1.220 (colored) next main 1.221 (colored)

Sync with HEAD

Revision 1.222 / (download) - annotate - [select for diffs], Sun Feb 3 03:19:29 2019 UTC (2 years, 8 months ago) by mrg
Branch: MAIN
CVS Tags: phil-wifi-20200421, phil-wifi-20200411, phil-wifi-20200406, phil-wifi-20191119, phil-wifi-20190609, netbsd-9-base, netbsd-9-2-RELEASE, netbsd-9-1-RELEASE, netbsd-9-0-RELEASE, netbsd-9-0-RC2, netbsd-9-0-RC1, netbsd-9, is-mlppp-base, is-mlppp
Changes since 1.221: +5 -3 lines
Diff to previous 1.221 (colored)

- add or adjust /* FALLTHROUGH */ where appropriate
- add __unreachable() after functions that can return but won't in
  this case, and thus can't be marked __dead easily

Revision 1.218.2.2 / (download) - annotate - [select for diffs], Wed Dec 26 14:02:10 2018 UTC (2 years, 9 months ago) by pgoyette
Branch: pgoyette-compat
CVS Tags: pgoyette-compat-merge-20190127
Changes since 1.218.2.1: +5 -4 lines
Diff to previous 1.218.2.1 (colored) to branchpoint 1.218 (colored) next main 1.219 (colored)

Sync with HEAD, resolve a few conflicts

Revision 1.221 / (download) - annotate - [select for diffs], Fri Dec 21 05:50:19 2018 UTC (2 years, 10 months ago) by sjg
Branch: MAIN
CVS Tags: pgoyette-compat-20190127, pgoyette-compat-20190118, pgoyette-compat-1226
Changes since 1.220: +5 -4 lines
Diff to previous 1.220 (colored)

unexport-env: avoid SEGFAULT if MAKELEVEL not in env

Revision 1.218.2.1 / (download) - annotate - [select for diffs], Mon Jun 25 07:26:11 2018 UTC (3 years, 4 months ago) by pgoyette
Branch: pgoyette-compat
Changes since 1.218: +10 -6 lines
Diff to previous 1.218 (colored)

Sync with HEAD

Revision 1.215.4.2 / (download) - annotate - [select for diffs], Sat Jun 9 15:35:38 2018 UTC (3 years, 4 months ago) by martin
Branch: netbsd-8
CVS Tags: netbsd-8-2-RELEASE, netbsd-8-1-RELEASE, netbsd-8-1-RC1, netbsd-8-0-RELEASE, netbsd-8-0-RC2
Changes since 1.215.4.1: +9 -7 lines
Diff to previous 1.215.4.1 (colored) to branchpoint 1.215 (colored) next main 1.216 (colored)

Pull up following revision(s) (requested by christos in ticket #870):

	sys/lib/libgnuefi/Makefile.inc: revision 1.5
	external/mit/xorg/xorg-pkg-ver.mk: revision 1.9
	sys/arch/i386/stand/lib/Makefile.inc: revision 1.17
	sys/compat/common/Makefile.inc: revision 1.25
	usr.bin/make/unit-tests/varquote.exp: revision 1.1, 1.2
	sys/lib/libsa/Makefile.inc: revision 1.24
	usr.bin/make/var.c: revision 1.220
	sys/arch/ia64/stand/efi/libefi/Makefile.inc: revision 1.5
	sys/arch/hppa/spmath/Makefile.inc: revision 1.10
	usr.bin/make/unit-tests/varquote.mk: revision 1.1, 1.2
	usr.bin/make/unit-tests/Makefile: revision 1.53
	sys/lib/libkern/Makefile.inc: revision 1.45
	sys/arch/acorn32/stand/lib/Makefile.inc: revision 1.4
	sys/arch/m68k/fpsp/Makefile.inc: revision 1.21
	usr.bin/make/make.1: revision 1.273
	sys/lib/libz/Makefile.inc: revision 1.17

- Introduce :q modifier for make variables and make it double escape $'s so
  that passing variables to recursive makes with :q works as expected.
- Adjust makefiles that use recursive make to use :q

Discussed on tech-toolchain@

XXX: pullup 8

Revision 1.215.4.1 / (download) - annotate - [select for diffs], Thu Jun 7 15:59:27 2018 UTC (3 years, 4 months ago) by martin
Branch: netbsd-8
Changes since 1.215: +5 -3 lines
Diff to previous 1.215 (colored)

Pull up following revision(s) (requested by christos in ticket #834):

	usr.bin/make/var.c: revision 1.219
	share/mk/bsd.obj.mk: revision 1.52
	usr.sbin/crash/Makefile: revision 1.40
	share/mk/sys.mk: revision 1.131
	share/mk/bsd.sys.mk: revision 1.276
	share/mk/bsd.sys.mk: revision 1.277

Prevent 'make obj' creating an objdir inside an objdir. This happens the
second time we call 'make obj' in /usr/src/rescue with MAKEOBJDIR set.
XXX: pullup-8
 -
Need to delete ${DESTDIR} for lint
XXX: pullup-8
 -
Fix reproducible builds
XXX: pullup-8
 -
Also substitute ${X11SRCDIR} for the random seed for reproducible builds so
that the random seed is consistent.
XXX: pullup-8
 -
Since ${MAKE} converts $$ -> $ during parsing we need to put it back to
preserve the original variable value with :Q.
XXX: pullup-8
 -
Be more selective about remapping object directories otherwise we pick
objdump and objcopy with the regex.
XXX: pullup-8

Revision 1.220 / (download) - annotate - [select for diffs], Sun May 27 01:14:51 2018 UTC (3 years, 4 months ago) by christos
Branch: MAIN
CVS Tags: phil-wifi-base, pgoyette-compat-1126, pgoyette-compat-1020, pgoyette-compat-0930, pgoyette-compat-0906, pgoyette-compat-0728, pgoyette-compat-0625
Branch point for: phil-wifi
Changes since 1.219: +9 -7 lines
Diff to previous 1.219 (colored)

- Introduce :q modifier for make variables and make it double escape $'s so
  that passing variables to recursive makes with :q works as expected.
- Revert :Q to work as before.
- Adjust makefiles that use recursive make to use :q

Discussed on tech-toolchain@
XXX: pullup 8

Revision 1.219 / (download) - annotate - [select for diffs], Thu May 24 00:27:24 2018 UTC (3 years, 5 months ago) by christos
Branch: MAIN
Changes since 1.218: +5 -3 lines
Diff to previous 1.218 (colored)

Since ${MAKE} converts $$ -> $ during parsing we need to put it back to
preserve the original variable value with :Q.
XXX: pullup-8

Revision 1.218 / (download) - annotate - [select for diffs], Sun Feb 18 00:52:42 2018 UTC (3 years, 8 months ago) by sjg
Branch: MAIN
CVS Tags: pgoyette-compat-base, pgoyette-compat-0521, pgoyette-compat-0502, pgoyette-compat-0422, pgoyette-compat-0415, pgoyette-compat-0407, pgoyette-compat-0330, pgoyette-compat-0322, pgoyette-compat-0315
Branch point for: pgoyette-compat
Changes since 1.217: +6 -5 lines
Diff to previous 1.217 (colored)

Var_Set: avoid SIGSEGV if val is NULL

A NULL val is handled gracefully (by VarAdd) when
var is not previously set, so we ought not crash
the second time.

PR: 53034

Revision 1.217 / (download) - annotate - [select for diffs], Fri Dec 8 03:36:42 2017 UTC (3 years, 10 months ago) by sjg
Branch: MAIN
Changes since 1.216: +5 -5 lines
Diff to previous 1.216 (colored)

Ensure VAR+=val on command line is handled correctly

If VAR is not previously set, call Var_Set to deal with
the special case of VAR_CMD.

If VAR is previously set, and ctxt is VAR_CMD we should do the update
even if VAR_FROM_CMD is set.

Revision 1.216 / (download) - annotate - [select for diffs], Sat Nov 18 22:34:04 2017 UTC (3 years, 11 months ago) by sjg
Branch: MAIN
Changes since 1.215: +5 -5 lines
Diff to previous 1.215 (colored)

Do not append to variable set on command line

POSIX requires that variables set on the command line
be immutable.
Var_Append needs to pass FIND_CMD and skip append
if found variable has VAR_FROM_CMD flag set.

Revision 1.208.2.2 / (download) - annotate - [select for diffs], Wed Apr 26 02:53:35 2017 UTC (4 years, 6 months ago) by pgoyette
Branch: pgoyette-localcount
Changes since 1.208.2.1: +12 -12 lines
Diff to previous 1.208.2.1 (colored) to branchpoint 1.208 (colored) next main 1.209 (colored)

Sync with HEAD

Revision 1.209.2.1 / (download) - annotate - [select for diffs], Fri Apr 21 16:54:14 2017 UTC (4 years, 6 months ago) by bouyer
Branch: bouyer-socketcan
Changes since 1.209: +97 -12 lines
Diff to previous 1.209 (colored) next main 1.210 (colored)

Sync with HEAD

Revision 1.215 / (download) - annotate - [select for diffs], Sun Apr 16 21:39:49 2017 UTC (4 years, 6 months ago) by riastradh
Branch: MAIN
CVS Tags: prg-localcount2-base3, prg-localcount2-base2, prg-localcount2-base1, prg-localcount2-base, prg-localcount2, pgoyette-localcount-20170426, perseant-stdc-iso10646-base, perseant-stdc-iso10646, netbsd-8-base, netbsd-8-0-RC1, matt-nb8-mediatek-base, matt-nb8-mediatek, bouyer-socketcan-base1
Branch point for: netbsd-8
Changes since 1.214: +4 -4 lines
Diff to previous 1.214 (colored)

Plug memory leak.

CID 978372

Revision 1.214 / (download) - annotate - [select for diffs], Sun Apr 16 19:53:58 2017 UTC (4 years, 6 months ago) by riastradh
Branch: MAIN
Changes since 1.213: +11 -11 lines
Diff to previous 1.213 (colored)

Use, don't kludge, MAKE_ATTR_UNUSED.

CID 1300234
CID 1300237
CID 1300238
CID 1300245
CID 1300255
CID 1300267
CID 1300284

Revision 1.208.2.1 / (download) - annotate - [select for diffs], Mon Mar 20 06:58:04 2017 UTC (4 years, 7 months ago) by pgoyette
Branch: pgoyette-localcount
Changes since 1.208: +113 -15 lines
Diff to previous 1.208 (colored)

Sync with HEAD

Revision 1.213 / (download) - annotate - [select for diffs], Wed Feb 1 18:39:27 2017 UTC (4 years, 8 months ago) by sjg
Branch: MAIN
CVS Tags: pgoyette-localcount-20170320
Changes since 1.212: +20 -7 lines
Diff to previous 1.212 (colored)

Since we are avoiding VAR_INTERNAL, allow the variable :_ stores to
to be specified, also allows for multiple stages of modification to
be stashed.

Revision 1.212 / (download) - annotate - [select for diffs], Wed Feb 1 18:00:14 2017 UTC (4 years, 8 months ago) by sjg
Branch: MAIN
Changes since 1.211: +6 -13 lines
Diff to previous 1.211 (colored)

Just have :_ use current ctxt, avoid need to force VAR_INTERNAL.

Revision 1.211 / (download) - annotate - [select for diffs], Tue Jan 31 07:00:59 2017 UTC (4 years, 8 months ago) by sjg
Branch: MAIN
Changes since 1.210: +12 -5 lines
Diff to previous 1.210 (colored)

Use VAR_INTERNAL when calling ApplyModifiers for VAR_{CMD,GLOBAL} only.

Revision 1.210 / (download) - annotate - [select for diffs], Mon Jan 30 02:46:20 2017 UTC (4 years, 8 months ago) by sjg
Branch: MAIN
Changes since 1.209: +75 -3 lines
Diff to previous 1.209 (colored)

Add :range and :_

:range	replaces var value with an integer sequence one per word
	in the current var value.

:_	stores the current var value in $_ so that it can be referred to
	later in the modifier series.

Reviewed by: christos

Revision 1.209 / (download) - annotate - [select for diffs], Sat Jan 14 22:58:04 2017 UTC (4 years, 9 months ago) by sjg
Branch: MAIN
CVS Tags: bouyer-socketcan-base
Branch point for: bouyer-socketcan
Changes since 1.208: +28 -15 lines
Diff to previous 1.208 (colored)

Allow providing a utc value to :{gm,local}time

Reviewed by: christos

Revision 1.208 / (download) - annotate - [select for diffs], Fri Jun 3 01:21:59 2016 UTC (5 years, 4 months ago) by sjg
Branch: MAIN
CVS Tags: pgoyette-localcount-base, pgoyette-localcount-20170107, pgoyette-localcount-20161104, pgoyette-localcount-20160806, pgoyette-localcount-20160726, localcount-20160914
Branch point for: pgoyette-localcount
Changes since 1.207: +5 -5 lines
Diff to previous 1.207 (colored)

Add cached_realpath()

realpath(3) is expensive, and meta mode at least uses it extensively.
We use cached_realpath() to save the result of successful calls to
realpath(3) in a private variable context.

This improves the worst case performance (eg examining libc with
nothing to do) by a factor of 4.

Reviewed by: christos

Revision 1.207 / (download) - annotate - [select for diffs], Fri Mar 11 15:12:39 2016 UTC (5 years, 7 months ago) by matthias
Branch: MAIN
Changes since 1.206: +5 -5 lines
Diff to previous 1.206 (colored)

$% is $(.MEMBER) and not $(.ARCHIVE), $! is $(.ARCHIVE) and not $(.MEMBER)

Revision 1.206 / (download) - annotate - [select for diffs], Mon Mar 7 20:20:35 2016 UTC (5 years, 7 months ago) by sjg
Branch: MAIN
Changes since 1.205: +15 -4 lines
Diff to previous 1.205 (colored)

For :ts numeric escapes \x* is hex, anything else is octal.

Revision 1.205 / (download) - annotate - [select for diffs], Sat Feb 20 01:19:03 2016 UTC (5 years, 8 months ago) by sjg
Branch: MAIN
Changes since 1.204: +19 -5 lines
Diff to previous 1.204 (colored)

Add a knob .MAKE.SAVE_DOLLARS to control the behavior of $$ during :=

If TRUE '$$' are not consumed (saved).
If FALSE '$$' becomes '$' just like normal expansion rules.

default is TRUE.

Reviewed by: christos

Revision 1.204 / (download) - annotate - [select for diffs], Thu Feb 18 23:33:25 2016 UTC (5 years, 8 months ago) by sjg
Branch: MAIN
Changes since 1.203: +4 -3 lines
Diff to previous 1.203 (colored)

Delete :@ loop iterator when done with it

Revision 1.203 / (download) - annotate - [select for diffs], Thu Feb 18 20:25:08 2016 UTC (5 years, 8 months ago) by sjg
Branch: MAIN
Changes since 1.202: +19 -11 lines
Diff to previous 1.202 (colored)

Add .export-literal to avoid the need for $$ dance when trying to put
unexpanded variables into environment.

Reviewed by: christos

Revision 1.202 / (download) - annotate - [select for diffs], Thu Feb 18 18:29:14 2016 UTC (5 years, 8 months ago) by christos
Branch: MAIN
Changes since 1.201: +87 -88 lines
Diff to previous 1.201 (colored)

Collapse the 3 boolean parameter to 1 flags parameter. No functional change.

Revision 1.201 / (download) - annotate - [select for diffs], Sat Jan 9 00:55:17 2016 UTC (5 years, 9 months ago) by christos
Branch: MAIN
Changes since 1.200: +35 -27 lines
Diff to previous 1.200 (colored)

Preserve $$ in := assignments..

FOO=\$$CRAP
BAR:=${FOO}

all:
	echo ${FOO}
	echo ${BAR}

Revision 1.200 / (download) - annotate - [select for diffs], Tue Dec 1 07:26:08 2015 UTC (5 years, 10 months ago) by sjg
Branch: MAIN
Changes since 1.199: +36 -32 lines
Diff to previous 1.199 (colored)

Avoid calling brk_string() and hence Var_Export1() on
empty strings.

Revision 1.199 / (download) - annotate - [select for diffs], Tue Oct 20 21:30:57 2015 UTC (6 years ago) by sjg
Branch: MAIN
Changes since 1.198: +4 -4 lines
Diff to previous 1.198 (colored)

Ensure emsg initialized

Revision 1.198 / (download) - annotate - [select for diffs], Mon Oct 12 16:48:13 2015 UTC (6 years ago) by sjg
Branch: MAIN
Changes since 1.197: +17 -12 lines
Diff to previous 1.197 (colored)

The conditional expressions used with ':?' can be expensive
eg. exists() does stat(2).
If 'wantit' is FALSE, we are going to discard everything anyway,
so skip evaluating the conditional and expanding either lhs or rhs.

Revision 1.197 / (download) - annotate - [select for diffs], Sun Oct 11 04:51:24 2015 UTC (6 years ago) by sjg
Branch: MAIN
Changes since 1.196: +90 -62 lines
Diff to previous 1.196 (colored)

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

Revision 1.196 / (download) - annotate - [select for diffs], Tue Oct 6 17:36:25 2015 UTC (6 years ago) by christos
Branch: MAIN
Changes since 1.195: +18 -35 lines
Diff to previous 1.195 (colored)

don't check for NULL before free() (Tilman Sauerbeck)

Revision 1.195 / (download) - annotate - [select for diffs], Fri Jun 19 14:25:16 2015 UTC (6 years, 4 months ago) by christos
Branch: MAIN
Changes since 1.194: +4 -4 lines
Diff to previous 1.194 (colored)

use isspace()

Revision 1.194 / (download) - annotate - [select for diffs], Fri Jun 19 08:03:35 2015 UTC (6 years, 4 months ago) by mlelstv
Branch: MAIN
Changes since 1.193: +5 -5 lines
Diff to previous 1.193 (colored)

Adjust metachar handling to previous behaviour:
- space and tab are no shell metachars, remove them from generic
  metachar function
- add space and tab as to-be-quoted characters for :Q modifier
- add = and : as characters that require command handling by the shell

Revision 1.193 / (download) - annotate - [select for diffs], Wed Jun 17 17:43:23 2015 UTC (6 years, 4 months ago) by christos
Branch: MAIN
Changes since 1.192: +13 -16 lines
Diff to previous 1.192 (colored)

Centralize the "is a meta char" test, instead of using two different arrays.

Revision 1.192 / (download) - annotate - [select for diffs], Tue May 5 21:51:09 2015 UTC (6 years, 5 months ago) by sjg
Branch: MAIN
Changes since 1.191: +4 -4 lines
Diff to previous 1.191 (colored)

When evaluating condtionals from .if we want to require
that the lhs is a variable reference, a number or a quoted string.
This helps avoid subtle bugs caused by typos.

When conditionals are being evaluated during variable expansion
we cannot be as strict becuase lhs will already have been expanded.

We therefor pass a boolean to Cond_EvalExpression to tell it how
lhs should be treated.

Add unit-tests/cond2.mk to test the above

Reviewed by: christos, joerg

Revision 1.191 / (download) - annotate - [select for diffs], Sun Sep 14 02:32:51 2014 UTC (7 years, 1 month ago) by dholland
Branch: MAIN
Changes since 1.190: +30 -35 lines
Diff to previous 1.190 (colored)

Fix handling of the silly $(@D) $(@F) etc. vars so modifiers on them
work. This is issue #1 in PR 49085 from Jarmo Jaakkola, but I've used
a different and cleaner patch this time.

Revision 1.190 / (download) - annotate - [select for diffs], Sat Sep 13 23:21:01 2014 UTC (7 years, 1 month ago) by dholland
Branch: MAIN
Changes since 1.189: +4 -4 lines
Diff to previous 1.189 (colored)

Recognize the crazy POSIXisms $(?D) and $(?F); issue 2 in PR 49085
from Jarmo Jaakkola.

Revision 1.189 / (download) - annotate - [select for diffs], Sat Sep 13 23:10:28 2014 UTC (7 years, 1 month ago) by dholland
Branch: MAIN
Changes since 1.188: +4 -4 lines
Diff to previous 1.188 (colored)

typo in comment, from the first reverted patch

Revision 1.188 / (download) - annotate - [select for diffs], Sun Sep 7 20:55:34 2014 UTC (7 years, 1 month ago) by joerg
Branch: MAIN
Changes since 1.187: +28 -32 lines
Diff to previous 1.187 (colored)

Revert all make changes except the unit tests to the state of three
weeks ago. Individual changes can be reapplied after review.

Revision 1.187 / (download) - annotate - [select for diffs], Sat Aug 23 14:50:24 2014 UTC (7 years, 2 months ago) by christos
Branch: MAIN
Changes since 1.186: +35 -31 lines
Diff to previous 1.186 (colored)

PR/49085: Jarmo Jaakkola: fix several parsing errors

Don't exit from var.c:Var_Parse() before possible modifiers are handled
on D and F modified versions of local variables.  Properly expand $(?D)
and $(?F) too.

Make line continuations in rule's commands POSIX compliant.

Fix the syntax error caused by lib(member) as the last target before
a dependency operator.

Document the line continuation change in the manual page.  Also talk
more about the POSIX style local variables and their modifiers.

Add tests covering the fixed problems into d_posix.mk.  The test is
a known failure at the moment because of PR 49086 and PR 49092.

[XXX: unconverted tests]

Revision 1.171.2.3 / (download) - annotate - [select for diffs], Wed Aug 20 00:05:00 2014 UTC (7 years, 2 months ago) by tls
Branch: tls-maxphys
Changes since 1.171.2.2: +45 -16 lines
Diff to previous 1.171.2.2 (colored) to branchpoint 1.171 (colored) next main 1.172 (colored)

Rebase to HEAD as of a few days ago.

Revision 1.184.2.1 / (download) - annotate - [select for diffs], Sun Aug 10 06:58:27 2014 UTC (7 years, 2 months ago) by tls
Branch: tls-earlyentropy
Changes since 1.184: +21 -9 lines
Diff to previous 1.184 (colored) next main 1.185 (colored)

Rebase.

Revision 1.186 / (download) - annotate - [select for diffs], Fri Jun 20 06:13:45 2014 UTC (7 years, 4 months ago) by sjg
Branch: MAIN
CVS Tags: tls-maxphys-base, tls-earlyentropy-base, netbsd-7-nhusb-base-20170116, netbsd-7-nhusb-base, netbsd-7-nhusb, netbsd-7-base, netbsd-7-2-RELEASE, netbsd-7-1-RELEASE, netbsd-7-1-RC2, netbsd-7-1-RC1, netbsd-7-1-2-RELEASE, netbsd-7-1-1-RELEASE, netbsd-7-1, netbsd-7-0-RELEASE, netbsd-7-0-RC3, netbsd-7-0-RC2, netbsd-7-0-RC1, netbsd-7-0-2-RELEASE, netbsd-7-0-1-RELEASE, netbsd-7-0, netbsd-7
Changes since 1.185: +4 -4 lines
Diff to previous 1.185 (colored)

Return varNoError rather than var_Error for ::?= etc.

Revision 1.167.2.4 / (download) - annotate - [select for diffs], Thu May 22 11:42:46 2014 UTC (7 years, 5 months ago) by yamt
Branch: yamt-pagecache
Changes since 1.167.2.3: +55 -61 lines
Diff to previous 1.167.2.3 (colored) to branchpoint 1.167 (colored) next main 1.168 (colored)

sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs.  ("Protocol error: too many arguments")

Revision 1.185 / (download) - annotate - [select for diffs], Mon May 19 22:09:58 2014 UTC (7 years, 5 months ago) by sjg
Branch: MAIN
Changes since 1.184: +20 -8 lines
Diff to previous 1.184 (colored)

Var_Parse: endc only counts when at the correct nesting depth.
This ensures we correctly detect errors like:
.if empty(VAR && !empty(FOO)

Var_Subst: if Var_Parse returns var_Error it is an error.
This ensures we detect errors like:

VAR:= ${FOO.${GOO}

Revision 1.184 / (download) - annotate - [select for diffs], Wed Sep 4 15:38:26 2013 UTC (8 years, 1 month ago) by sjg
Branch: MAIN
CVS Tags: yamt-pagecache-base9, riastradh-xf86-video-intel-2-7-1-pre-2-21-15, riastradh-drm2-base3
Branch point for: tls-earlyentropy
Changes since 1.183: +12 -3 lines
Diff to previous 1.183 (colored)

Add VAR_INTERNAL as a context for variables set by make itself,
which should not override those set by makefiles.
Currently MAKEFILE is the only variable affected.

Reviewed by: christos

Revision 1.183 / (download) - annotate - [select for diffs], Tue Jul 16 20:00:56 2013 UTC (8 years, 3 months ago) by sjg
Branch: MAIN
CVS Tags: riastradh-drm2-base2, riastradh-drm2-base1, riastradh-drm2-base, riastradh-drm2
Changes since 1.182: +11 -3 lines
Diff to previous 1.182 (colored)

When a var is set in the CMD context, it prevents the same name
being set in GLOBAL context.  We should also delete any such
variable in GLOBAL context, else make -V will show the wrong value.

Revision 1.182 / (download) - annotate - [select for diffs], Tue Jul 16 14:00:53 2013 UTC (8 years, 3 months ago) by christos
Branch: MAIN
Changes since 1.181: +13 -12 lines
Diff to previous 1.181 (colored)

More gmake compatibility:
1. add -w flag to print Entering and Leaving directory name the the beginning
   and the end of processing.
2. export MAKELEVEL=$((MAKELEVEL + 1)) only in the child environment.
3. when printing error messages, prefix them with the program name [$MAKELEVEL]
   for $MAKELEVEL > 0
4. if $MAKEFLAGS consists only of letters assume it is a set of flags (as
   allowed by posix), convert them to -f -l -a -g -s, so that they get parsed
   properly.
With those fixes gmake -> bmake -> gmake -> bmake etc. works as expected.

Revision 1.181 / (download) - annotate - [select for diffs], Mon Jul 15 20:33:11 2013 UTC (8 years, 3 months ago) by christos
Branch: MAIN
Changes since 1.180: +5 -11 lines
Diff to previous 1.180 (colored)

Make this work again like gmake. sjg: see the test program.

Revision 1.180 / (download) - annotate - [select for diffs], Sat Jul 6 18:19:17 2013 UTC (8 years, 3 months ago) by sjg
Branch: MAIN
Changes since 1.179: +11 -6 lines
Diff to previous 1.179 (colored)

If using gmake's MAKELEVEL; use it the same way

Revision 1.171.2.2 / (download) - annotate - [select for diffs], Sun Jun 23 06:29:00 2013 UTC (8 years, 4 months ago) by tls
Branch: tls-maxphys
Changes since 1.171.2.1: +30 -53 lines
Diff to previous 1.171.2.1 (colored) to branchpoint 1.171 (colored)

resync from head

Revision 1.179 / (download) - annotate - [select for diffs], Tue Jun 18 20:06:09 2013 UTC (8 years, 4 months ago) by sjg
Branch: MAIN
Changes since 1.178: +6 -6 lines
Diff to previous 1.178 (colored)

Use a #define for the variable name we put in environment to pass .MAKE.LEVEL
in case we don't want to use gmake's MAKELEVEL in a different way.

Revision 1.178 / (download) - annotate - [select for diffs], Mon Jun 10 20:24:58 2013 UTC (8 years, 4 months ago) by christos
Branch: MAIN
Changes since 1.177: +7 -13 lines
Diff to previous 1.177 (colored)

put back previous change

Revision 1.177 / (download) - annotate - [select for diffs], Mon Jun 10 19:07:09 2013 UTC (8 years, 4 months ago) by joerg
Branch: MAIN
Changes since 1.176: +10 -4 lines
Diff to previous 1.176 (colored)

Revert last, it doesn't even build.

Revision 1.176 / (download) - annotate - [select for diffs], Mon Jun 10 16:46:19 2013 UTC (8 years, 4 months ago) by christos
Branch: MAIN
Changes since 1.175: +7 -13 lines
Diff to previous 1.175 (colored)

1. Don't export .MAKE.LEVEL, because this is an illegal variable name for
   some shells; export MAKELEVEL like gmake(1) does.
2. It is absurd for the environment variable to be one greater than the
   make variable!?!?! To wit...
   printf 'all:\n\t@echo ${.MAKE.LEVEL}; printenv .MAKE.LEVEL' | make -f -

Revision 1.175 / (download) - annotate - [select for diffs], Wed May 29 00:23:31 2013 UTC (8 years, 4 months ago) by sjg
Branch: MAIN
Changes since 1.174: +4 -6 lines
Diff to previous 1.174 (colored)

Clean up some left overs

Revision 1.174 / (download) - annotate - [select for diffs], Sat May 18 13:12:45 2013 UTC (8 years, 5 months ago) by sjg
Branch: MAIN
Changes since 1.173: +15 -6 lines
Diff to previous 1.173 (colored)

Var_Delete: expand name if needed.

Revision 1.173 / (download) - annotate - [select for diffs], Sun Feb 24 19:43:37 2013 UTC (8 years, 8 months ago) by christos
Branch: MAIN
CVS Tags: dholland-make-base, agc-symver-base, agc-symver
Changes since 1.172: +13 -37 lines
Diff to previous 1.172 (colored)

While it is nice to have the same function do both the upper case and
lower case conversion, it ends up eating 4% of the total time we spend
in make calling tolower() while building libc.

Revision 1.167.2.3 / (download) - annotate - [select for diffs], Wed Jan 16 05:34:06 2013 UTC (8 years, 9 months ago) by yamt
Branch: yamt-pagecache
CVS Tags: yamt-pagecache-tag8
Changes since 1.167.2.2: +9 -7 lines
Diff to previous 1.167.2.2 (colored) to branchpoint 1.167 (colored)

sync with (a bit old) head

Revision 1.171.2.1 / (download) - annotate - [select for diffs], Tue Nov 20 03:02:58 2012 UTC (8 years, 11 months ago) by tls
Branch: tls-maxphys
Changes since 1.171: +9 -7 lines
Diff to previous 1.171 (colored)

Resync to 2012-11-19 00:00:00 UTC

Revision 1.172 / (download) - annotate - [select for diffs], Thu Nov 15 16:42:26 2012 UTC (8 years, 11 months ago) by christos
Branch: MAIN
CVS Tags: yamt-pagecache-base8, yamt-pagecache-base7
Changes since 1.171: +9 -7 lines
Diff to previous 1.171 (colored)

include the variable name in debugging printfs.

Revision 1.167.2.2 / (download) - annotate - [select for diffs], Tue Oct 30 19:00:23 2012 UTC (8 years, 11 months ago) by yamt
Branch: yamt-pagecache
Changes since 1.167.2.1: +29 -22 lines
Diff to previous 1.167.2.1 (colored) to branchpoint 1.167 (colored)

sync with head

Revision 1.171 / (download) - annotate - [select for diffs], Tue Jun 12 19:21:51 2012 UTC (9 years, 4 months ago) by joerg
Branch: MAIN
CVS Tags: yamt-pagecache-base6
Branch point for: tls-maxphys
Changes since 1.170: +18 -16 lines
Diff to previous 1.170 (colored)

Replace __dead, __unused and the various printf format attributes
with versions prefixed by MAKE_ATTR_* to avoid modifying the
implementation namespace. Make sure they are available in all places
using nonints.h to fix bootstrap on Linux.

Revision 1.170 / (download) - annotate - [select for diffs], Mon Jun 4 20:34:20 2012 UTC (9 years, 4 months ago) by sjg
Branch: MAIN
Changes since 1.169: +14 -9 lines
Diff to previous 1.169 (colored)

Var_UnExport() and setenv() can both realloc environ.
Use a common variable (savedEnv) to track that to avoid wasting memory.
Also, if providing setenv and unsetenv, do getenv too to ensure a consistent
set.

Revision 1.167.2.1 / (download) - annotate - [select for diffs], Wed May 23 10:08:26 2012 UTC (9 years, 5 months ago) by yamt
Branch: yamt-pagecache
Changes since 1.167: +6 -5 lines
Diff to previous 1.167 (colored)

sync with head.

Revision 1.169 / (download) - annotate - [select for diffs], Fri May 18 02:28:16 2012 UTC (9 years, 5 months ago) by sjg
Branch: MAIN
CVS Tags: yamt-pagecache-base5
Changes since 1.168: +5 -4 lines
Diff to previous 1.168 (colored)

Avoid nested extern declaration warnings

Revision 1.168 / (download) - annotate - [select for diffs], Tue Apr 24 20:26:58 2012 UTC (9 years, 6 months ago) by sjg
Branch: MAIN
Changes since 1.167: +4 -4 lines
Diff to previous 1.167 (colored)

Var* are generally very liberal with memory, with the expectation
that none of it persists for long.
This isn't always true - for example a long running .for loop.

Buf_DestroyCompact() is used by Var_Subst(), rather than Buf_Destroy().
If it looks like we can save BUF_COMPACT_LIMIT (128) or more bytes,
call realloc.  This can reduce memory consumption by about 20%
Setting BUF_COMPACT_LIMIT to 0 dissables this.

Revision 1.166.2.1 / (download) - annotate - [select for diffs], Thu Jun 23 14:20:44 2011 UTC (10 years, 4 months ago) by cherry
Branch: cherry-xenmp
Changes since 1.166: +19 -4 lines
Diff to previous 1.166 (colored) next main 1.167 (colored)

Catchup with rmind-uvmplock merge.

Revision 1.167 / (download) - annotate - [select for diffs], Fri Jun 3 21:10:42 2011 UTC (10 years, 4 months ago) by sjg
Branch: MAIN
CVS Tags: yamt-pagecache-base4, yamt-pagecache-base3, yamt-pagecache-base2, yamt-pagecache-base, netbsd-6-base, netbsd-6-1-RELEASE, netbsd-6-1-RC4, netbsd-6-1-RC3, netbsd-6-1-RC2, netbsd-6-1-RC1, netbsd-6-1-5-RELEASE, netbsd-6-1-4-RELEASE, netbsd-6-1-3-RELEASE, netbsd-6-1-2-RELEASE, netbsd-6-1-1-RELEASE, netbsd-6-1, netbsd-6-0-RELEASE, netbsd-6-0-RC2, netbsd-6-0-RC1, netbsd-6-0-6-RELEASE, netbsd-6-0-5-RELEASE, netbsd-6-0-4-RELEASE, netbsd-6-0-3-RELEASE, netbsd-6-0-2-RELEASE, netbsd-6-0-1-RELEASE, netbsd-6-0, netbsd-6, matt-nb6-plus-nbase, matt-nb6-plus-base, matt-nb6-plus
Branch point for: yamt-pagecache
Changes since 1.166: +19 -4 lines
Diff to previous 1.166 (colored)

ApplyModifiers: if we parse a variable in the modifier list,
do not consider it a nested modifier set, unless it is followed by
endc, a ':' or end of string.

Revision 1.166 / (download) - annotate - [select for diffs], Sat May 21 07:30:42 2011 UTC (10 years, 5 months ago) by tsutsui
Branch: MAIN
CVS Tags: cherry-xenmp-base
Branch point for: cherry-xenmp
Changes since 1.165: +4 -3 lines
Diff to previous 1.165 (colored)

Explicitly #include <time.h> for time(3) and strftime(3).
Fixes warnings on some non NetBSD hosts.

Revision 1.165 / (download) - annotate - [select for diffs], Mon Apr 11 14:49:09 2011 UTC (10 years, 6 months ago) by sjg
Branch: MAIN
Changes since 1.164: +6 -6 lines
Diff to previous 1.164 (colored)

If a "long" modifier name does not match, goto default case
so SysV modifier can be tried.

Revision 1.164 / (download) - annotate - [select for diffs], Mon Apr 11 01:44:15 2011 UTC (10 years, 6 months ago) by sjg
Branch: MAIN
Changes since 1.163: +43 -5 lines
Diff to previous 1.163 (colored)

Add :localtime and :gmtime which use value as format string for strftime.

Revision 1.163 / (download) - annotate - [select for diffs], Thu Apr 7 01:40:01 2011 UTC (10 years, 6 months ago) by joerg
Branch: MAIN
Changes since 1.162: +89 -3 lines
Diff to previous 1.162 (colored)

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.

Revision 1.162 / (download) - annotate - [select for diffs], Sun Mar 6 00:02:15 2011 UTC (10 years, 7 months ago) by sjg
Branch: MAIN
Changes since 1.161: +11 -7 lines
Diff to previous 1.161 (colored)

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} != ""

Revision 1.161 / (download) - annotate - [select for diffs], Thu Dec 2 16:46:22 2010 UTC (10 years, 10 months ago) by christos
Branch: MAIN
CVS Tags: matt-mips64-premerge-20101231, bouyer-quota2-nbase, bouyer-quota2-base, bouyer-quota2
Changes since 1.160: +4 -4 lines
Diff to previous 1.160 (colored)

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

Revision 1.160 / (download) - annotate - [select for diffs], Thu Dec 2 16:36:55 2010 UTC (10 years, 10 months ago) by christos
Branch: MAIN
Changes since 1.159: +9 -3 lines
Diff to previous 1.159 (colored)

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.

Revision 1.159 / (download) - annotate - [select for diffs], Sun Jun 6 01:13:12 2010 UTC (11 years, 4 months ago) by sjg
Branch: MAIN
Changes since 1.158: +12 -5 lines
Diff to previous 1.158 (colored)

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

Revision 1.158 / (download) - annotate - [select for diffs], Wed Apr 21 04:25:27 2010 UTC (11 years, 6 months ago) by sjg
Branch: MAIN
Changes since 1.157: +10 -3 lines
Diff to previous 1.157 (colored)

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.

Revision 1.157 / (download) - annotate - [select for diffs], Tue Apr 20 17:48:16 2010 UTC (11 years, 6 months ago) by sjg
Branch: MAIN
Changes since 1.156: +6 -4 lines
Diff to previous 1.156 (colored)

Behavior of realpath() appears to vary.
To ensure consistent results, use stat(2) as a final check for success.

Revision 1.156 / (download) - annotate - [select for diffs], Thu Apr 15 03:48:39 2010 UTC (11 years, 6 months ago) by sjg
Branch: MAIN
Changes since 1.155: +35 -4 lines
Diff to previous 1.155 (colored)

Add :tA to attempt to resolve to absoute path using realpath().

Revision 1.155 / (download) - annotate - [select for diffs], Thu Nov 19 00:30:25 2009 UTC (11 years, 11 months ago) by sjg
Branch: MAIN
CVS Tags: matt-premerge-20091211
Changes since 1.154: +107 -3 lines
Diff to previous 1.154 (colored)

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

Revision 1.154 / (download) - annotate - [select for diffs], Tue Sep 8 17:29:20 2009 UTC (12 years, 1 month ago) by sjg
Branch: MAIN
Changes since 1.153: +20 -3 lines
Diff to previous 1.153 (colored)

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().

Revision 1.153 / (download) - annotate - [select for diffs], Mon Sep 7 17:56:24 2009 UTC (12 years, 1 month ago) by sjg
Branch: MAIN
Changes since 1.152: +12 -5 lines
Diff to previous 1.152 (colored)

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.

Revision 1.152 / (download) - annotate - [select for diffs], Tue Jun 16 05:44:06 2009 UTC (12 years, 4 months ago) by sjg
Branch: MAIN
Changes since 1.151: +19 -14 lines
Diff to previous 1.151 (colored)

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.

Revision 1.149.2.1 / (download) - annotate - [select for diffs], Wed May 13 19:19:57 2009 UTC (12 years, 5 months ago) by jym
Branch: jym-xensuspend
Changes since 1.149: +5 -4 lines
Diff to previous 1.149 (colored) next main 1.150 (colored)

Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html

Revision 1.151 / (download) - annotate - [select for diffs], Wed Feb 18 21:06:47 2009 UTC (12 years, 8 months ago) by christos
Branch: MAIN
CVS Tags: jym-xensuspend-nbase, jym-xensuspend-base
Changes since 1.150: +4 -4 lines
Diff to previous 1.150 (colored)

adjust patch to current.

Revision 1.150 / (download) - annotate - [select for diffs], Wed Feb 18 20:08:32 2009 UTC (12 years, 8 months ago) by christos
Branch: MAIN
Changes since 1.149: +5 -4 lines
Diff to previous 1.149 (colored)

CID 5044: Protect against NULL deref.

Revision 1.149 / (download) - annotate - [select for diffs], Wed Jan 28 21:38:13 2009 UTC (12 years, 8 months ago) by dsl
Branch: MAIN
Branch point for: jym-xensuspend
Changes since 1.148: +4 -4 lines
Diff to previous 1.148 (colored)

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.

Revision 1.148 / (download) - annotate - [select for diffs], Fri Jan 23 21:26:30 2009 UTC (12 years, 9 months ago) by dsl
Branch: MAIN
Changes since 1.147: +32 -32 lines
Diff to previous 1.147 (colored)

Change 'ClientData' to 'void *' so that relevant parameters can
be made 'const void *'.

Revision 1.147 / (download) - annotate - [select for diffs], Sun Jan 18 01:31:12 2009 UTC (12 years, 9 months ago) by lukem
Branch: MAIN
Changes since 1.146: +5 -5 lines
Diff to previous 1.146 (colored)

fix -Wsign-compare issues

Revision 1.146 / (download) - annotate - [select for diffs], Sat Jan 17 13:29:37 2009 UTC (12 years, 9 months ago) by dsl
Branch: MAIN
Changes since 1.145: +134 -164 lines
Diff to previous 1.145 (colored)

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.

Revision 1.145 / (download) - annotate - [select for diffs], Fri Jan 16 21:14:30 2009 UTC (12 years, 9 months ago) by dsl
Branch: MAIN
Changes since 1.144: +5 -5 lines
Diff to previous 1.144 (colored)

Debug print improvements.

Revision 1.144 / (download) - annotate - [select for diffs], Mon Dec 29 10:18:38 2008 UTC (12 years, 9 months ago) by dsl
Branch: MAIN
Changes since 1.143: +6 -11 lines
Diff to previous 1.143 (colored)

In the :M code, 'pattern' is always malloced memory - so unconditionally
free.

Revision 1.143 / (download) - annotate - [select for diffs], Mon Dec 29 10:12:30 2008 UTC (12 years, 9 months ago) by dsl
Branch: MAIN
Changes since 1.142: +5 -5 lines
Diff to previous 1.142 (colored)

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.

Revision 1.142 / (download) - annotate - [select for diffs], Tue Dec 23 21:56:38 2008 UTC (12 years, 10 months ago) by dsl
Branch: MAIN
Changes since 1.141: +22 -20 lines
Diff to previous 1.141 (colored)

Treat '\\' as a possible terminator for a loop control variable.
(Typically an escaped \: of a nested modifier.)

Revision 1.141 / (download) - annotate - [select for diffs], Sun Dec 21 10:44:10 2008 UTC (12 years, 10 months ago) by dsl
Branch: MAIN
Changes since 1.140: +46 -59 lines
Diff to previous 1.140 (colored)

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!

Revision 1.140 / (download) - annotate - [select for diffs], Sat Dec 20 18:08:24 2008 UTC (12 years, 10 months ago) by dsl
Branch: MAIN
Changes since 1.139: +4 -4 lines
Diff to previous 1.139 (colored)

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.

Revision 1.139 / (download) - annotate - [select for diffs], Sat Dec 20 17:14:04 2008 UTC (12 years, 10 months ago) by dsl
Branch: MAIN
Changes since 1.138: +35 -17 lines
Diff to previous 1.138 (colored)

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().

Revision 1.138 / (download) - annotate - [select for diffs], Sat Dec 20 16:03:59 2008 UTC (12 years, 10 months ago) by dsl
Branch: MAIN
Changes since 1.137: +98 -98 lines
Diff to previous 1.137 (colored)

Change some "^I  *^I" to "^I^I" and align the comment block about
variable modifiers.

Revision 1.137 / (download) - annotate - [select for diffs], Fri Dec 19 21:33:10 2008 UTC (12 years, 10 months ago) by christos
Branch: MAIN
Changes since 1.136: +10 -3 lines
Diff to previous 1.136 (colored)

add a little more debugging.

Revision 1.136 / (download) - annotate - [select for diffs], Sat Dec 13 15:19:29 2008 UTC (12 years, 10 months ago) by dsl
Branch: MAIN
Changes since 1.135: +22 -22 lines
Diff to previous 1.135 (colored)

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 :-)

Revision 1.135 / (download) - annotate - [select for diffs], Sat Dec 13 14:26:10 2008 UTC (12 years, 10 months ago) by dsl
Branch: MAIN
Changes since 1.134: +6 -3 lines
Diff to previous 1.134 (colored)

Do not let the variable name "" be set from the command line (-D "")
or from ::= modifiers (${::=foo}).

Revision 1.134 / (download) - annotate - [select for diffs], Mon Oct 6 22:09:21 2008 UTC (13 years ago) by joerg
Branch: MAIN
CVS Tags: netbsd-5-base, netbsd-5-2-RELEASE, netbsd-5-2-RC1, netbsd-5-2-3-RELEASE, netbsd-5-2-2-RELEASE, netbsd-5-2-1-RELEASE, netbsd-5-2, netbsd-5-1-RELEASE, netbsd-5-1-RC4, netbsd-5-1-RC3, netbsd-5-1-RC2, netbsd-5-1-RC1, netbsd-5-1-5-RELEASE, netbsd-5-1-4-RELEASE, netbsd-5-1-3-RELEASE, netbsd-5-1-2-RELEASE, netbsd-5-1-1-RELEASE, netbsd-5-1, netbsd-5-0-RELEASE, netbsd-5-0-RC4, netbsd-5-0-RC3, netbsd-5-0-RC2, netbsd-5-0-RC1, netbsd-5-0-2-RELEASE, netbsd-5-0-1-RELEASE, netbsd-5-0, netbsd-5, matt-nb5-pq3-base, matt-nb5-pq3, matt-nb5-mips64-u2-k2-k4-k7-k8-k9, matt-nb5-mips64-u1-k1-k5, matt-nb5-mips64-premerge-20101231, matt-nb5-mips64-premerge-20091211, matt-nb5-mips64-k15, matt-nb5-mips64, matt-nb4-mips64-k7-u2a-k9b, matt-mips64-base2
Changes since 1.133: +23 -23 lines
Diff to previous 1.133 (colored)

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.

Revision 1.128.4.2 / (download) - annotate - [select for diffs], Thu Sep 18 04:29:16 2008 UTC (13 years, 1 month ago) by wrstuden
Branch: wrstuden-revivesa
Changes since 1.128.4.1: +17 -10 lines
Diff to previous 1.128.4.1 (colored) to branchpoint 1.128 (colored) next main 1.129 (colored)

Sync with wrstuden-revivesa-base-2.

Revision 1.133 / (download) - annotate - [select for diffs], Thu Jul 31 15:19:19 2008 UTC (13 years, 2 months ago) by joerg
Branch: MAIN
CVS Tags: wrstuden-revivesa-base-3, wrstuden-revivesa-base-2
Changes since 1.132: +16 -9 lines
Diff to previous 1.132 (colored)

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@

Revision 1.132 / (download) - annotate - [select for diffs], Thu Jul 31 14:59:39 2008 UTC (13 years, 2 months ago) by joerg
Branch: MAIN
Changes since 1.131: +4 -4 lines
Diff to previous 1.131 (colored)

Meta characters are a constant, mark it so.

Revision 1.128.4.1 / (download) - annotate - [select for diffs], Mon Jun 23 04:32:11 2008 UTC (13 years, 4 months ago) by wrstuden
Branch: wrstuden-revivesa
Changes since 1.128: +24 -4 lines
Diff to previous 1.128 (colored)

Sync w/ -current. 34 merge conflicts to follow.

Revision 1.128.2.1 / (download) - annotate - [select for diffs], Sun May 18 12:36:07 2008 UTC (13 years, 5 months ago) by yamt
Branch: yamt-pf42
Changes since 1.128: +24 -4 lines
Diff to previous 1.128 (colored) next main 1.129 (colored)

sync with head.

Revision 1.131 / (download) - annotate - [select for diffs], Thu May 15 21:05:54 2008 UTC (13 years, 5 months ago) by sjg
Branch: MAIN
CVS Tags: yamt-pf42-base4, yamt-pf42-base3, yamt-pf42-base2, wrstuden-revivesa-base-1, wrstuden-revivesa-base, hpcarm-cleanup-nbase
Changes since 1.130: +18 -9 lines
Diff to previous 1.130 (colored)

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.

Revision 1.130 / (download) - annotate - [select for diffs], Thu May 15 18:25:12 2008 UTC (13 years, 5 months ago) by sjg
Branch: MAIN
Changes since 1.129: +7 -3 lines
Diff to previous 1.129 (colored)

Disable this for now, VAR_CMD is abused for other purposes...

Revision 1.129 / (download) - annotate - [select for diffs], Wed May 14 14:27:02 2008 UTC (13 years, 5 months ago) by sjg
Branch: MAIN
Changes since 1.128: +10 -3 lines
Diff to previous 1.128 (colored)

Do not set vars in VAR_GLOBAL context, if they have been set on the
command line.
Add a suitable unit-test.

Revision 1.128 / (download) - annotate - [select for diffs], Mon Mar 31 00:12:21 2008 UTC (13 years, 6 months ago) by sjg
Branch: MAIN
CVS Tags: yamt-pf42-baseX, yamt-pf42-base
Branch point for: yamt-pf42, wrstuden-revivesa
Changes since 1.127: +11 -5 lines
Diff to previous 1.127 (colored)

If the name passed to Var_Exists contains '$' run it through Var_Subst.

Revision 1.127 / (download) - annotate - [select for diffs], Fri Feb 15 21:29:50 2008 UTC (13 years, 8 months ago) by christos
Branch: MAIN
CVS Tags: matt-armv6-nbase, keiichi-mipv6-nbase, keiichi-mipv6-base, keiichi-mipv6, hpcarm-cleanup-base
Changes since 1.126: +59 -75 lines
Diff to previous 1.126 (colored)

back all changes out until I fix it properly.

Revision 1.126 / (download) - annotate - [select for diffs], Fri Feb 15 02:50:53 2008 UTC (13 years, 8 months ago) by christos
Branch: MAIN
CVS Tags: christos-broken
Changes since 1.125: +5 -5 lines
Diff to previous 1.125 (colored)

remove error/noerror const

Revision 1.125 / (download) - annotate - [select for diffs], Fri Feb 15 02:37:51 2008 UTC (13 years, 8 months ago) by christos
Branch: MAIN
Changes since 1.124: +6 -6 lines
Diff to previous 1.124 (colored)

- symbolic names for error and no error
- more size_t

Revision 1.124 / (download) - annotate - [select for diffs], Thu Feb 14 22:11:20 2008 UTC (13 years, 8 months ago) by christos
Branch: MAIN
Changes since 1.123: +74 -58 lines
Diff to previous 1.123 (colored)

- use pid_t/size_t as appropriate instead of int.
- use %ld to print pids.
- fix a bit of lint.
- WARNS=4

Revision 1.117.4.1 / (download) - annotate - [select for diffs], Tue Nov 6 23:36:03 2007 UTC (13 years, 11 months ago) by matt
Branch: matt-armv6
CVS Tags: matt-armv6-prevmlocking
Changes since 1.117: +250 -44 lines
Diff to previous 1.117 (colored) next main 1.118 (colored)

sync with HEAD

Revision 1.123 / (download) - annotate - [select for diffs], Sat Oct 13 19:59:52 2007 UTC (14 years ago) by apb
Branch: MAIN
CVS Tags: matt-armv6-base, cube-autoconf-base, cube-autoconf
Changes since 1.122: +37 -27 lines
Diff to previous 1.122 (colored)

Don't write into const strings; not even if we intend to
reinstate the original contents later.

Revision 1.122 / (download) - annotate - [select for diffs], Sat Oct 13 16:16:41 2007 UTC (14 years ago) by apb
Branch: MAIN
Changes since 1.121: +12 -16 lines
Diff to previous 1.121 (colored)

* 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;

Revision 1.121 / (download) - annotate - [select for diffs], Sat Oct 13 14:32:18 2007 UTC (14 years ago) by apb
Branch: MAIN
Changes since 1.120: +7 -7 lines
Diff to previous 1.120 (colored)

Oops, missed a few more comments in previous.

Revision 1.120 / (download) - annotate - [select for diffs], Sat Oct 13 13:54:06 2007 UTC (14 years ago) by apb
Branch: MAIN
Changes since 1.119: +4 -4 lines
Diff to previous 1.119 (colored)

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.

Revision 1.119 / (download) - annotate - [select for diffs], Tue Oct 9 05:55:03 2007 UTC (14 years ago) by sjg
Branch: MAIN
Changes since 1.118: +12 -5 lines
Diff to previous 1.118 (colored)

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.

Revision 1.118 / (download) - annotate - [select for diffs], Fri Oct 5 15:27:46 2007 UTC (14 years ago) by sjg
Branch: MAIN
Changes since 1.117: +196 -3 lines
Diff to previous 1.117 (colored)

Add the ability to .export variables to the environment.

Revision 1.115.4.1 / (download) - annotate - [select for diffs], Mon Sep 3 07:05:33 2007 UTC (14 years, 1 month ago) by wrstuden
Branch: wrstuden-fixsa
Changes since 1.115: +8 -8 lines
Diff to previous 1.115 (colored) next main 1.116 (colored)

Sync w/ NetBSD-4-RC_1

Revision 1.117 / (download) - annotate - [select for diffs], Sat Jun 16 19:47:29 2007 UTC (14 years, 4 months ago) by dsl
Branch: MAIN
CVS Tags: matt-mips64-base, matt-mips64, hpcarm-cleanup
Branch point for: matt-armv6
Changes since 1.116: +6 -5 lines
Diff to previous 1.116 (colored)

Under DEBUG(VAR) report when the variable wasn't found.
Disposes of pr bin/15842