1
0
mirror of https://github.com/openbsd/src.git synced 2025-01-03 06:45:37 -08:00
Commit Graph

50 Commits

Author SHA1 Message Date
millert
7e30afce04 Quiet compiler warnings when built with WARNINGS=Yes
Most are from functions that take no args but used the old
K&R style foo() instead of foo(void).  From espie@
2024-06-18 02:11:03 +00:00
espie
c9fc29cfc6 GC old code that was originally implemented to facilitate adoption by
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@
2023-09-04 11:35:11 +00:00
tb
e33a93b366 Fix :S with anchors and replacement
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
2020-08-30 12:16:04 +00:00
bluhm
cde1cf7166 Also check for NUL termination at the first character of tstr in
the error path of VarModifiers_Apply().  This prevents a sporadic
crash in make's regress target t41.
OK espie@
2017-07-10 07:10:29 +00:00
espie
3782e4f0b5 add support for variables in the lhs of SYSV modifiers.
lack of support noted by naddy@
source, xenocara, and ports still build without a hitch.

okay naddy@
2017-02-24 23:38:47 +00:00
espie
e4dd574c63 off-by-one, leading to segfaults. Trivial fix.
reported by jasper@
2017-01-25 14:17:45 +00:00
tb
cc313b3ad7 Avoid two printf("%s", NULL) with 'make -d v'.
improvements & ok espie, earlier version ok deraadt
2016-10-02 17:42:31 +00:00
daniel
be11ae5cb3 unifdef MAKE_BOOTSTRAP now that Makefile.boot is gone.
ok espie@
2015-11-15 06:19:22 +00:00
deraadt
cfff592fdc Do not cast result of malloc/calloc/realloc* if stdlib.h is in scope
ok krw millert
2015-08-20 22:32:41 +00:00
espie
6eef43d013 a wee little bit more cleanup (more const and remove noise from CDIAGFLAGS...
-pedantic kind of requires -std=c99 here to avoid LL warnings)
okay miod@, millert@
2015-01-23 22:35:57 +00:00
espie
7f5855dc00 remove a bunch of dangerous casts (useless casts from void * to something
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.
2015-01-23 13:18:40 +00:00
espie
7172227b79 plug a small memory leak, fairly infrequent. 2014-09-21 13:43:25 +00:00
espie
77c73da267 a bit more reallocarray (and kill ecalloc, which isn't used)
okay chl@
2014-05-18 08:08:50 +00:00
espie
e2ff9f51c4 adjust to ohash being in libutil now, and to the interface changes.
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.
2014-05-12 19:11:19 +00:00
espie
75d77f2cf6 effectively use emult_realloc, okay guenther@ 2014-04-22 08:26:31 +00:00
espie
56afcde6d4 wrappers for is*/to* that make damn sure their arguments are
cast to unsigned chars.

okay deraadt@
2013-11-22 15:47:35 +00:00
deraadt
eac6c57475 Do not use a char as index, unless first making it unsigned.
(signed char, ya know)
ok espie
2013-11-12 17:44:03 +00:00
espie
be710f6fb8 numerous error message fixes:
- 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@
2012-10-18 17:54:43 +00:00
espie
6cba5522ed fix infinite loops on regexps that match the empty word, which is
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@
2012-10-12 13:20:11 +00:00
espie
a6b963c872 major overhaul of the way make handle jobs, inspired by dpb:
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.
2012-09-21 07:55:20 +00:00
espie
5694c93bb5 recommit, now that release is done (handle sysv if bsd is incorrect, may
make more extensive plans later)
2011-08-16 14:18:25 +00:00
espie
72a705e521 deemed unsafe by theo, will wait after 5.0 2011-07-30 21:02:13 +00:00
espie
ac8de1ed9b systemV trumps our modifiers.
fixes a case encountered by jeremy@
full fix not prudent at this time.
okay millert@, otto@
2011-07-29 13:39:00 +00:00
espie
bb4544df9a Correct $OpenBSD$ stuff 2010-07-19 19:46:43 +00:00
espie
dba68890dc two small changes:
- 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} ...
2010-07-19 19:30:37 +00:00
deraadt
76411979b4 fix some lint FALLTHROUGH 2007-11-03 15:42:10 +00:00
espie
2ef67a9294 zap more spaces at end of line 2007-09-17 09:44:20 +00:00
espie
cbd06537ff kill extra spaces at end of line 2007-09-17 09:28:36 +00:00
espie
036838cec6 reindent varmodifiers.c, no binary change 2007-09-16 12:02:38 +00:00
espie
e790ff591e remove warnings 2007-09-16 12:01:11 +00:00
espie
1ef8d39280 remove dead code: #define RECHECK is always on 2007-09-16 09:46:14 +00:00
espie
5a5ca93eff everywhere except in Var_Parse, we always add/append variables to the
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@
2007-07-30 09:51:53 +00:00
espie
0f4e4af8fe simplify computations in the var module: instead of advancing a char *
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@
2007-07-24 18:58:48 +00:00
espie
25a3fea32d move the code that grabs a value in Var_Parse in its own function,
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@
2007-07-24 18:56:15 +00:00
espie
34b15a7f11 change Var_ParseSkip API to increment the position instead of returning a
length, simplifies code.

(warns a bit, symptom of some further issues to fix).

okay millert@
2007-07-24 18:52:47 +00:00
espie
68636f61ac big clean-up patch:
- 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.
2007-07-20 12:32:45 +00:00
espie
d62a8bbed3 fixes 4286.
back & forth between fgs and me.
2005-07-15 20:43:23 +00:00
espie
ad2b054beb ISO function declarations, trim a few comments, rename a few variables to
more explicit/more consistent names.

okay otto@
2004-04-07 13:11:35 +00:00
fgsch
75a7162821 - check if result is valid before using it.
- correctly set *freePtr, not freePtr.
input and ok espie@.
2003-10-07 18:33:08 +00:00
millert
f75387cb26 Remove the advertising clause in the UCB license which Berkeley
rescinded 22 July 1999.  Proofed by myself and Theo.
2003-06-03 02:56:05 +00:00
espie
890e38f604 Repair regular expression substitution.
Even though the code can share some common parts, there is an important
difference I had missed.
2001-09-07 12:19:46 +00:00
espie
f7923656a1 Mostly clean-up:
- 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).
2001-05-23 12:34:39 +00:00
espie
7940ed9080 some complex situations need those functions to be reentrant, hence no
static VarPatterns...

Old make could use dynamic variables because everything was jumbled
into one single function.
2001-05-07 22:59:33 +00:00
espie
04ed836e6d Synch with my current work.
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...
2001-05-03 13:40:59 +00:00
espie
be10dfac63 Clean-up, systematic use of UNUSED, white space... 2000-09-14 13:36:46 +00:00
espie
032093b68a Two new functions:
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.
2000-09-14 13:35:38 +00:00
espie
20684aa70f Oops. 2000-07-24 21:57:28 +00:00
espie
da83345cb8 FALLTHRU -> FALLTHROUGH, requested by miod@ and style(9) 2000-07-17 23:54:26 +00:00
espie
66a2e33a32 - let VarModifiers_Apply accept NULL string gracefully,
- 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).
2000-07-17 23:26:50 +00:00
espie
6b5ae4824d Major unobfuscation: split var modifiers handling to a separate file.
This does finally make var handling somewhat readable.
2000-07-17 23:09:06 +00:00