Commit Graph

36 Commits

Author SHA1 Message Date
Baptiste Daroussin
c57596e1ae m4: import from OpenBSD
By deraadt@

mkstemp() returns -1 on failure

Obtained from:	OpenBSD
2019-09-09 15:37:40 +00:00
Baptiste Daroussin
db531a5d18 m4: import from OpenBSD
patch by espie@

replace sloppy parsing of numeric values with strtonum (incr, decr, divert)

still use integers, so use the natural bounds for these.

POSIX says m4 should error when these use non numeric values, and now they
do.

okay millert@

Obtained from:	OpenBSD
2019-09-09 15:35:34 +00:00
Baptiste Daroussin
e0f4e0415e m4: import patch from OpenBSD
by espie@
ifelse is special, fix argv parsing to avoid segfault

problem noticed by Matthew Green (netbsd), slightly different fix
so that argc counting makes more sense.

we might want to warn on wrong number of parameters later, but this is
somewhat inconsistent depending on the builtin right now.

okay millert@

Obtained from:	OpenBSD
2019-09-09 15:28:22 +00:00
Baptiste Daroussin
c560b67c5c Import from OpenBSD: -E flag
Add -E flag (make warnings fatal), following the behavior of GNU m4 1.4.9+

Help and direction millert@ espie@ anton@ deraadt@

ok espie@

Obtained from:	OpenBSD
2019-09-09 15:18:04 +00:00
Pedro F. Giffuni
8a16b7a18f General further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2017-11-20 19:49:47 +00:00
Pedro F. Giffuni
af7ca7c85d usr.bin: minor spelling fixes on comments.
No functional change.
2016-05-01 16:13:05 +00:00
Baptiste Daroussin
46ef9581dd Synchronize m4(1) with OpenBSD 2015-11-21 11:05:38 +00:00
Baptiste Daroussin
88497f0c68 Sync with OpenBSD
This brings:
- check for integer overflows in custom allocs
- fix potential integer overflows in memory allocation
- annotate regexp error messages with source string
- better error handling in mkstemp/unlink/fdopen logic
2014-07-27 22:54:13 +00:00
Jung-uk Kim
8ce3644c91 Reduce diff with upstream. 2013-05-03 23:29:38 +00:00
Baptiste Daroussin
fb3f3d7caf Improve m4 compatibility with GNU m4 extension ** (exponent)
Submitted by:	Marc Espie (espie@OpenBSD.org)
Approved by:	des@ (mentor)
2012-04-15 13:25:51 +00:00
Bjoern A. Zeeb
2cce1b69c4 Unbreak the build after r228697 adding the { } block to make clear which
if the else belongs to.
2011-12-19 08:50:17 +00:00
Baptiste Daroussin
4fff7a14ae Reimplement support for the ** (exponent) gnu extension, make it available thought the -g (mimic gnu) option
Reviewed by:	cognet
Approved by:	cognet
Discussed with:	espie@OpenBSD.org (upstream)
2011-12-18 22:04:55 +00:00
Baptiste Daroussin
a841e1ebe6 Synchronize with laster version of m4 from OpenBSD and NetBSD
This bring better compatibility with gnum4

Reviewed by:	cognet
Approved by:	cognet
Obtained from:	OpenBSD, NetBSD
2011-11-28 13:32:39 +00:00
Joel Dahl
da52b4caaf Remove the advertising clause from UCB copyrighted files in usr.bin. This
is in accordance with the information provided at
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change

Also add $FreeBSD$ to a few files to keep svn happy.

Discussed with:	imp, rwatson
2010-12-11 08:32:16 +00:00
Tim J. Robbins
f03b27517b Store a pointer to "null" in struct ndblock's defn member instead of a
duplicate allocated on the heap; the address defn points to is significant,
and is checked against the address of "null" in certain conditionals.

PR:		59883
MFC after:	1 week
2004-08-16 14:18:22 +00:00
Tim J. Robbins
aef4bb33e5 Flush streams before calling system() so that the output appears in the
right place in the output stream when redirected to a file (when full
buffering is enabled). Noticed by schweikh on freebsd-standards.
2003-05-01 02:36:27 +00:00
Juli Mallett
2c4acd2f49 Kill extraneous whitespace. 2002-07-15 02:15:12 +00:00
Juli Mallett
90432ef88d Revert vendor identifiers, and #if 0 what is #if 0/#else for OpenBSD.
Add __FBSDID() properly.

Requested by:	bde, mike
2002-05-03 14:48:21 +00:00
Juli Mallett
bd2bfb5846 Merge local changes again, against ANSIfied m4(1). 2002-05-01 21:37:29 +00:00
Juli Mallett
ccc5b4e6f4 Crank WARNS.
Cast sizeof() to (int), as it's being compared against an int, not a size_t.
If i is changed to a size_t, it means the logic must be slightly changed later
in the flow, where --i is checked to be >= 0.  I am not sure I want to make a
logic change to account for clearing up a warning, when an aesthetic one will
keep from modifying the logic.

Other harmless casts, that I think I've made in the right directions.

Make gpbc() an inline function, rather than an obfuscated macro, make its
scratch space local, rather than global.  The previous macro used a dirty
hack (logical AND in place of a conditional) which would lead GCC to throw
a fit (rightly so) as the logical check, as well as the incrementation of
a variable, were not used for anything.

const'ify a few places where gcc3 yells. xstrdup() some global consts in
places where we xstrdup() when not using consts, but tried to assign them
to non-consts before.

Don't use execv(2) if we don't have the kind of arguments it wants.

Reviewed by:    asmodai obrien tjr
Submitted by:   tjr (a gcc3 build log)
2002-04-20 01:49:10 +00:00
Juli Mallett
acc9d40838 Bring OpenBSD m4(1) off of the OPENBSD vendor branch, and add the -s option,
$FreeBSD$ identifiers, and fix initialisation to stderr to happen in a function
as stderr is not the same in CURRENT as in OpenBSD.

Reviewed by:	obrien
2002-04-19 17:26:21 +00:00
Juli Mallett
b1ea3d46b7 This adds support for -s to the m4(1) utility, which causes #line directives
to be emitted as per the C preprocessor.  It updates the manual page in
regards to standards accordingly.

PR:		standards/36075
Submitted by:	tjr
Reviewed by:	mike
MFC after:	1 week
2002-04-17 17:26:32 +00:00
David E. O'Brien
de9b3b9034 Remove the local basename in favor of the libc version.
Remove xmalloc and xstrdup and do the error checking at the place of use.
2001-07-24 14:09:47 +00:00
Gregory Neil Shapiro
1d3ebaf302 Make sure the len() builtin always returns an answer. Previously,
len(`') didn't return an answer.  Now it returns 0.

PR:		bin/12942
MFC after:	5 days
2001-05-29 03:32:38 +00:00
Gregory Neil Shapiro
4ba4d3873a String operations could silently truncate long strings, leaving the output
corrupted.  Mark's patch fixes this be removing the MAXTOK limitation on
substring operations and allowing the putback buffer size to be the limiting
factor.  If the putback buffer size if reached, m4 gives an error instead of
silently truncating the string.

PR:		bin/26619
Submitted by:	Mark Peek <mark-ml@whistle.com>
MFC after:	5 days
2001-05-18 18:35:34 +00:00
Kris Kennaway
50d793ebb0 Fix format string warnings.
Submitted by:	nra
Obtained from:	NetBSD
2000-11-27 04:26:39 +00:00
Peter Wemm
c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Steve Price
bbfd144724 Make the builtin unix macro work as it should (well like Solaris's,
GNU's, and OSF1's).
1998-09-07 22:09:13 +00:00
Jonathan Lemon
ef2cea8123 divnum is no longer silently restricted to the range 0..9. (cf: 4098)
changequote(,) is now a synonym for changequote().	 	(cf: 803)

buffer size for translit() enlarged to handle a full string

PR:		803, 4098
1997-08-18 21:01:45 +00:00
Philippe Charnier
9510535891 Use err(3) instead of local redefinition. Remove progname. 1997-07-23 06:50:06 +00:00
Joerg Wunsch
232eaee62a Make the $@ macro behave as described in the man page.
This patch has been submitted by Andreas Burmester (i think) on the
German Usenet long ago.  Andreas told me that our m4 has quite more
subtle bugs, so we might consider using NGU m4 instead.
1997-04-13 17:51:32 +00:00
Rodney W. Grimes
7799f52a32 Remove trailing whitespace. 1995-05-30 06:41:30 +00:00
Andrey A. Chernov
cac6992aca 1) kill temp diver upon exit
2) add logical ops, fix ! precedence, implement unary +, fix exp
Obtained from: NetBSD
1995-04-16 23:31:35 +00:00
Andrey A. Chernov
3ee80812fd Fix syscmd() output out of sync
Submitted by: smp@clem.systemsix.com
1995-03-11 16:57:54 +00:00
Andrey A. Chernov
7c5eeb390e Make m4 more 8bit clean.
Don't use is*(EOF)
This fix core dump when LANG setted to 8bit wide charset
and ENABLE_STARTUP_LOCALE
1994-12-18 23:58:25 +00:00
Rodney W. Grimes
9b50d90275 BSD 4.4 Lite Usr.bin Sources 1994-05-27 12:33:43 +00:00