Commit Graph

51 Commits

Author SHA1 Message Date
rillig
12b3007c76 make(1): refactor Str_Match
- use shorter variable names to avoid line breaks
- eliminate c2 variable
- change return type to Boolean
2020-07-03 07:40:13 +00:00
rillig
76ed5386c9 make(1): clean up Str_Match
- removed unnecessary parentheses
- uniform test for end of string
2020-07-03 06:30:02 +00:00
rillig
001c9f20c0 make(1): clean up documentation of Str_Match 2020-07-03 06:25:23 +00:00
rillig
a230e16d2d make(1): fix performance problem in specially crafted :M modifier
This fix was previously suspected to make the vax build fail.  The next
build succeeded though, and it started 2 hours before this fix was
reverted.
2020-06-15 14:46:28 +00:00
rillig
014f40b954 usr.bin/make: revert performance improvement
That change might be the cause of a build failure for vax.
http://releng.netbsd.org/builds/HEAD/202006131940Z/ builds fine.
http://releng.netbsd.org/builds/HEAD/202006141020Z/ doesn't.

The build fails with:
/home/source/ab/HEAD/src/external/gpl3/gcc/dist/gcc/machmode.h:524:28:
error: 'mode_size_inline' was not declared in this scope
2020-06-14 23:13:21 +00:00
rillig
09fc09f3fb usr.bin/make: make Str_Match faster for repeated asterisks
Conceptually related to https://en.wikipedia.org/wiki/ReDoS.
2020-06-13 21:16:27 +00:00
rillig
e8c43cef44 usr.bin/make: remove redundant parentheses around return 2020-06-13 07:48:59 +00:00
rillig
6bcabb95b0 usr.bin/make: consistently use ++ for incrementing pointers 2020-06-13 07:36:07 +00:00
rillig
2548dc6c57 usr.bin/make: fix typo in comment 2020-06-13 07:30:02 +00:00
christos
3e820cb068 Behave like gmake: empty string does not match % pattern 2020-05-06 02:30:10 +00:00
rillig
8176f52bc9 usr.bin/make: refactor brk_string
The variables are renamed to reflect to which memory region each pointer
belongs.

The variable "curlen" was always zero.

The type of "ch" has changed to char, and its scope is now limited to
its actual use.

Comparisons of pointers are now consistently written as p != NULL
instead of !p, like character comparisons are written as ch != '\0'.

The "store_words_buf" is updated when the function returns, not before.
2020-05-03 12:10:28 +00:00
christos
3b58d8437a - 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
2020-04-25 18:20:57 +00:00
rillig
f5741db816 Fix out-of-bounds read in Str_Match. 2019-12-01 23:53:49 +00:00
sjg
63284db849 Str_Match: fix closure tests for [^] and add unit-test. 2017-04-21 22:15:44 +00:00
sjg
624bde60ca Str_Match: allow [^a-z] to behave as expected. 2017-04-11 17:30:13 +00:00
gson
4efe3992f9 Fully avoid the nonstandard types u_char, u_int, and u_long, which
were only used inconsistently in a few places anyway.
2016-04-06 09:57:00 +00:00
sjg
e84a63caab Reduce the calls to realloc from brk_string by basing initial argmax guess
on length of input.

Reviewed by: christos
2014-02-12 01:35:56 +00:00
dholland
62244ded10 Note in comment that Str_Match() does not detect or report invalid
patterns. This is not critical, since for the moment both possible
cases (unclosed [], and \ at the end of the string) are handled more
or less sanely.
2012-03-03 23:16:47 +00:00
sno
6adead3ca0 replace c++ style comment by a c-style one 2009-02-25 21:17:21 +00:00
dsl
462d090d0f Change 'Buffer' so that it is the actual struct, not a pointer to it.
Saves having to malloc/free a fixed size structure.
Buf_Init() now takes ptr to Buffer to initialiase.
Change Buf_Destroy() to return ptr to string when not freed.
Remove large number of casts to (Byte) and (Byte *) - 'Byte' is 'char' here.
Buf_AddByte[s] guarantees that the data is 0 termininated, so never add '\0'.
Keep 'count' not 'left' and 'inPtr', code is simplier with only one update.
Fix fallou, no functional change.
2009-01-17 13:29:37 +00:00
christos
6caebc4e79 PR/32154: Roland Illig: brk_string fails to report errors in unquoted strings. 2008-12-19 22:04:36 +00:00
christos
0bf1037e4e PR/34138: Roland Illig: In the non-expand case, fix brk_string not to eat
quotes.
2008-12-19 21:34:14 +00:00
joerg
bd681a4d7e Don't use emalloc and friends directly, but call them consistently
bmake_malloc and friends. Implement them via macros for the native case
and provide fallback implementations otherwise. Avoid polluting the
namespace by not defining enomem globally. Don't bother to provide
strdup and strndup, they were only used for the estrdup and estrndup
comapt code.

This addresses the presence of emalloc in system libraries on A/UX and
resulted strange issues as reported by Timothy E. Larson.
2008-10-06 22:09:21 +00:00
christos
a686e4e754 back all changes out until I fix it properly. 2008-02-15 21:29:50 +00:00
christos
2b28370627 - use pid_t/size_t as appropriate instead of int.
- use %ld to print pids.
- fix a bit of lint.
- WARNS=4
2008-02-14 22:11:20 +00:00
erh
d96de9f7f0 Correctly handle '\' at the end of a variable in the non-expanding case. 2006-12-22 20:28:31 +00:00
christos
67a75c5772 If a word is "" eat the last quote since we ate the first. 2006-08-11 19:11:00 +00:00
christos
81b135acdf From Max Okumoto:
- Remove casts to NULL.
- Remove space between cast and object.
2005-08-08 16:42:54 +00:00
christos
63fca13660 PR/29203, PR/29204: Max Okumoto: KNF changes to make [no functional changes] 2005-02-16 15:11:52 +00:00
ross
42dbdbd46a Simplify build, no functional changes.
Instead of adding MAKE_BOOTSTRAP for hosted environments, i.e., when
you want things simple, instead add MAKE_NATIVE to get those hugely
important features like __RCSID().

It's now possible to build make on some hosts with: cc *.c */*.c
2004-05-07 00:04:38 +00:00
sjg
d388dcd1a3 Implement :[] modifier to allow picking a range of words out of a variable.
Also :tW and a W flag to :C and :S to allow treating value as a single word.
Add unit tests for the above, and fix some corner cases.
Based on patches supplied by Alan Barrett <apb@cequrux.com>
2003-09-27 21:29:37 +00:00
agc
89aaa1bb64 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22365, verified by myself.
2003-08-07 11:13:06 +00:00
christos
6a7d20bb25 Pass WARNS=3 2003-07-14 18:19:11 +00:00
wiz
86ebbc3a0e Remove !__STDC__ stuff, de-__P(), ANSIfy, and de-register. 2002-06-15 18:24:55 +00:00
christos
889ce7db6e - full prototypes
- more conservative printf
- char -> unsigned char
1998-11-06 23:31:09 +00:00
christos
f46f2d693e PR/5210: Hauke Fath: make core dumps with .SHELL
Unfortunately this revealed a deeper problem with the brk_string code.
To fix it:
	- remove sharing of the buffer between brk_string invocations
	- change the semantics of brk_string so that the argument array
	  starts with 0, and return the buffer where the strings are
	  stored
1998-03-26 19:20:36 +00:00
lukem
2ba9e97765 wrap #include <sys/cdefs.h>, __RCSID(...) stuff in #ifndef MAKE_BOOTSTRAP 1997-09-28 03:30:58 +00:00
christos
254d64f064 Add WARNS=1
RCSID police
1997-07-01 21:17:00 +00:00
christos
aa49881371 - Merge in FreeBSD and Lite2 changes.
- Fix bug where a non-archive target with a .a suffix would always
  be considered to be out of date, since it does not have a TOC.
1996-11-06 17:58:58 +00:00
jtc
fea2f4c4ca Added erealloc() function that calls enomem() if the allocation fails
(this is like the existing emalloc() function).  Changed all realloc()
calls to erealloc().
1996-03-29 02:17:13 +00:00
ws
337d0ee3b1 Always ensure space for trailing NULL in argv 1995-10-30 17:36:27 +00:00
christos
b5f782e810 - $NetBSD$ rcsids
- Fixed so that .[A-Z]* targets that do not match keywords are ignored as
  Posix mandates
- Added .PHONY target keyword
1995-06-14 15:18:37 +00:00
christos
85ac32e8d2 str.c: Don't free NULL; does not work with non posix frees.
var.c: Minor memory leak plugged.
suff.c: Don't add extra sources on the null suffix if it has dependency
	lines or commands attached to it [POSIX says so]
1995-02-04 23:44:41 +00:00
jtc
ac414e10cd Christos' fix for quoting variable extraction properly. 1994-06-16 18:50:18 +00:00
jtc
26a8972fd7 Fixes from Christos Zoulas, who used purify, objectcenter and testcenter
to find memory leaks and illegal memory accesses.
1994-06-06 22:45:17 +00:00
jtc
abd412aa8d Properly parse null command line arguments in makefile rules.
Fix from Christos Zoulas.
1994-05-17 15:55:42 +00:00
jtc
aa67092685 Fixes from Christos Zoulas:
The following two patches fix a couple of problems with make(1)

1. Null Suffixes were not being copied, but they were being free'd
   This caused rules of the form:

   .c:
	${CC} ...

   to access invalid memory and potentially core dump..
   [That was always broken; I did not break that one :-)]

2. My recent fixes to parse ${VAR:%.foo=%.bar} handled the null string
   case incorrectly (${VAR:=.c} was broken).
1994-03-23 00:52:13 +00:00
cgd
3db59563ee fixes/improvements from Christos Zoulas <christos@deshaw.com>. 1994-03-05 00:34:29 +00:00
jtc
e890eb6415 Include appropriate header files to bring prototypes into scope. 1994-01-13 21:01:40 +00:00
mycroft
e9d867ef50 Add RCS identifiers. 1993-08-01 17:54:45 +00:00