other BSDs, which never happened, so make things simpler for further
development.
Ditches config.h entirely since it gets reduced to 2 defines.
okay tb@
gnezdo noticed that :S/old_string/new_string/ variable modifiers such
as :S/^sth/&/ and :S/sth$/&/ with an anchor in the old_string and an &
in the new_string don't work as documented (and expected) since they
replace & with old_string including the anchors.
This is because get_spatternarg() deals with skipping the anchors in
pattern->lhs only after having replaced any '&' in the buffer that will
eventually become new_string with pattern->lhs. Fix this by moving the
logic of skipping the anchors from get_spatternarg() into
common_get_patternarg() so it is done before & is handled.
ok millert
else, in some cases by adding extra temporary variables.
IMO, it's much better practice to do
void *a;
int *p = a;
*p = 42;
rather than
void *a;
*(int *)a = 42;
okay miod@... to be revisited for some possible const additions later.
fix potential integer overflows in memory allocation (mostly for pedagogical
purposes, these are unlikely to overflow in practice)
move the rest of lst.lib stuff into its own directory.
- do ^C checking differently: don't record sent signals, but when jobs
die, recheck whether we received/have pending a INT/QUIT/TERM/HUP signal.
Then don't display our process group "normally", instead group together
everything dying by signal/shell dying by signal (just give the target
names).
- make certain we always handle signals before dying from "other conditions"
- have the parser messages look more like normal messages
- remove double error messages from some parser errors
- make sure unclosed variables ARE errors when some modifiers are present
- keep track of the base directory we're run from, so that submakes can
get shortened directories...
- make sure the whole error message including silent command fits into a
reasonable length.
okay millert@
especially bad during runtime as we trap ^C.
For instance ${A:C/-*//g}. Problem found by rpe@
Do the same as other modern tools: advance by one char and repeat, so
that there's at most one empty word match at each position.
okay millert@
instead of forking a "job" per target, and having that job further fork
separate commands, have make maintain a list of jobs, indexed by pid
of currently running commands, and handle process termination
continuation-style. This has lots of benefits:
- make is responsible for most printing, so we no longer need pipes nor
job control: make -j jobs see the tty.
- no more special-casing for jobs that don't really execute anything.
- unify code for make -jn and make -B, including signal handlers and
job waiting. So make -n, make -q, +cmd now run commands in the same
way in all cases.
- unified more accurate error-reporting, as make knows precisely which
command failed. Commands are tagged with their lines, and we display failing
commands in silent mode.
- fine-grained "expensive" command handling (recursion limiter). Do it
per-command instead of per-target.
Moreover, signal response is now simpler, as we just block the signals
in a small critical sections, test for events, and sigpause (thanks a lot
to guenther@ and millert@), so running make is now almost always paused
without any busy-waiting.
Thanks to everyone who tested and gave input.
- allow variables in SysV modifiers, as requested by matthieu@
(since recursive variables are an extension, this just extends the
extension)
- variation on :Q called :QL (quote list), which does quote every character
EXCEPT for whitespace. e.g.,
toto:
@for i in ${VAR:QL} ...
VAR_GLOBAL context, so make it the common case: rename the basic functions
to Var_Set_with_ctxt/Var_Append_with_ctxt, define Var_Set and Var_Append
as macros that specify VAR_GLOBAL, and use these.
okay miod@
and keeping track of a length, we just advance the char *, and ditch
the length. We can still get the length at the end of the top-level
functions to satisfy existing interfaces.
Much simpler code, less error-prone.
Okay millert@
get_expanded_value.
Extend the code a bit to be much more thorough in case of a recursive
expansion: shows exactly the cycle of variable names involved.
okay millert@
- rename a few functions in var.c to names that make more sense.
- introduce Var_Deletei because it makes more sense.
- rewrite .for loops to use a local LoopVar construct to avoid looking up more
stuff.
- reformat var.c to near K&R
- rewrite most comments in var.c
shown to a few people. millert@ gave me his okay since it passes through
ports correctly.
- cut up those huge include files into separate interfaces for all modules.
Put the interface documentation there, and not with the implementation.
- light-weight includes for needed concrete types (lst_t.h, timestamp_t.h).
- cut out some more logically separate parts: cmd_exec, varname, parsevar,
timestamp.
- put all error handling functions together, so that we will be able to
clean them up.
- more systematic naming: functioni to handle interval, function to handle
string.
- put the init/end code apart to minimize coupling.
- kill weird types like ReturnStatus and Boolean. Use standard bool (with a
fallback for non-iso systems)
- better interface documentation for lots of subsystems.
As a result, make compilation goes somewhat faster (5%, even considering
the largish BSD copyrights to read). The corresponding preprocessed
source goes down from 1,5M to 1M.
A few minor code changes as well: Parse_DoVar is no longer destructive.
Parse_IsVar functionality is folded into Parse_DoVar (as it knows what an
assignment is), a few more interval handling functions. Avoid calling
XXX_End when they do nothing, just #define XXX_End to nothing.
Parse_DoVar is slightly more general: it will handle compound assignments
as long as they make sense, e.g., VAR +!= cmd
will work. As a side effect, VAR++=value now triggers an error
(two + in assignment).
- this stuff doesn't occur in portable Makefiles.
- writing VAR++ = value or VAR+ +=value disambiguates it.
- this is a good thing, it uncovered a bug in bsd.port.mk.
Tested by naddy@. Okayed millert@. I'll handle the fallback if there is
any. This went through a full make build anyways, including isakmpd
(without mickey's custom binutils, as he didn't see fit to share it with me).
Numerous changes:
- generate can build several tables
- style cleanup
- statistics code
- use variable names throughout (struct Name)
- recursive variables everywhere
- faster parser (pass buffer along instead of allocating multiple copies)
- correct parser. Handles comments everywhere, and ; correctly
- more string intervals
- simplified dir.c, less recursion.
- extended for loops
- sinclude()
- finished removing extra junk from Lst_*
- handles ${@D} and friends in a simpler way
- cleaned up and modular VarModifiers handling.
- recognizes some gnu Makefile usages and errors out about them.
Additionally, some extra functionality is defined by FEATURES. The set of
functionalities is currently hardcoded to OpenBSD defaults, but this may
include support for some NetBSD extensions, like ODE modifiers.
Backed by miod@ and millert@, who finally got sick of my endless patches...
iterate_words: light-weight equivalent to brk_string,
which does not need to copy the string, and does not do \ interpretation
which are only needed for the string.
escape_dup: handles escape sequence in a systematic way.
This speeds up variable modifiers.
This also makes .for loops more consistent, as they use the same definition
of `a word' as the rest of make.
- simplify Var_Parse: use varfind, then leverage on the result
to recognize `special case' dynamic parsing.
VarModifiers_Apply need to be called on NULL strings, to be able to parse
modifiers applied to non-existent variables.
(Alternately, we could call VarModifiers_Apply on a dummy string, but
this is less efficient).