Commit graph

41 commits

Author SHA1 Message Date
Warner Losh 1d386b48a5 Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:42 -06:00
Dag-Erling Smørgrav 6c9ed64c94 m4: Add -G option which reverses -g.
This matches GNU m4's -G / --traditional option, and although BSD m4 in non-GNU mode is not exactly identical to GNU mode in traditional mode, it's close enough.

Sponsored by:	Klara, Inc.
Reviewed by:	kevans, imp
Differential Revision:	https://reviews.freebsd.org/D40697
2023-06-21 20:59:03 +00:00
Dag-Erling Smørgrav 47b32f8f93 m4: Support long options.
The option names are identical to those of the equivalent options in GNU m4, except of course for --gnu which does not exist in GNU m4.

While here, make the argument to -d / --debug optional, with the same default behavior as in GNU m4, and document it properly.

Sponsored by:	Klara, Inc.
Reviewed by:	kevans, imp
Differential Revision:	https://reviews.freebsd.org/D40694
2023-06-21 20:59:03 +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
Baptiste Daroussin 46ef9581dd Synchronize m4(1) with OpenBSD 2015-11-21 11:05:38 +00:00
Baptiste Daroussin 31129d4f23 Synchronize with OpenBSD
Obtained from:	OpenBSD
2015-05-18 22:40:12 +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
Ed Schouten eccad22277 More -Wmissing-variable-declarations fixes.
In addition to adding missing `static' keywords:
- bin/dd: Pull in `extern.h' to guarantee consistency with source file.
- libexec/rpc.rusersd: Move shared globals into an extern.h.
- libexec/talkd: Move `debug' and `hostname' into extern.h.
- usr.bin/cksum: Put counters in extern.h, as they are used by ckdist/mtree.
- usr.bin/m4: Move `end_result' into extern.h.
- usr.sbin/services_mkdb: Move shared globals into an extern.h.
2012-10-20 10:33:15 +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
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
Ed Schouten df6dd6933d Mark global functions and/or variables in m4(1) static where possible.
This allows compilers and static analyzers to more thorough analysis.
2011-11-06 18:49:48 +00:00
Ed Schouten 1e2070ab5b Fix build of m4 with WARNS=6.
Change the parser; rename `exp' to `exponent' not to collide with exp(3).
2011-10-16 08:09:17 +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 338b72d96e Respect locale settings from the environment. 2004-07-12 02:48:40 +00:00
Juli Mallett c624d24df3 Die on -D=foo, when parsing options - we can't let someone define (nil).
MFC after:	3 days
2002-09-04 01:12:39 +00:00
Juli Mallett 2c4acd2f49 Kill extraneous whitespace. 2002-07-15 02:15:12 +00:00
Juli Mallett 010b4b09f1 Add a default case to the getopt(3) switch, remove a blank line nearby. 2002-07-14 02:34:37 +00:00
Juli Mallett d1fea89cae Functions declared as <type> <identifier>(<nil>) should be declared as
<type> <identifier>(<void-type>) in ANSI C.
2002-07-14 02:03:23 +00:00
Juli Mallett 7b6f658ced Remove prototype for main(). 2002-07-14 02:00:45 +00:00
Juli Mallett d40d348ceb Cast sp to uintptr_t when doing a compare of it to STACKMAX which is a size_t.
This messes up some indentation in mdef.h for some macros.
2002-06-20 11:14:54 +00:00
Tim J. Robbins 456fc9e56f If a file operand cannot be processed, go on to process any remaining files
but exit non-zero.
2002-05-26 06:15:15 +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 8f12fc049c Remove redundant declarations of getopt(3) externals (since <unistd.h> does
take care of them), and add __FreeBSD__ to the defined() checks for the
_PATH_DIVNAME.
2002-05-02 05:25:23 +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 164c01f05b Clean up temporary file(s) and directory when m4 exits without falling
through main() (e.g., signals or calls to errx()).

PR:		conf/25715
2001-04-16 18:36:35 +00:00
John Hay b88a90fd4c The secure temporary directory is always created, so always remove it. 2001-02-28 19:21:44 +00:00
Kris Kennaway 4f377e65c4 Create temporary files in a secure directory, instead of using multiple
filenames based on a single invocation of mktemp() in /tmp, which is
easily predictable after the first one.

Audited by:     markm
2000-11-22 11:09:30 +00:00
Warner Losh 62f882d620 getopt and friends are declared in <unistd.h>
getopt returns -1 not EOF.
2000-09-04 06:09:54 +00:00
Peter Wemm c3aac50f28 $Id$ -> $FreeBSD$ 1999-08-28 01:08:13 +00:00
Philippe Charnier 9510535891 Use err(3) instead of local redefinition. Remove progname. 1997-07-23 06:50:06 +00:00
Warner Losh 1c8af87873 compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.
1997-03-29 04:34:07 +00:00
Rodney W. Grimes 7799f52a32 Remove trailing whitespace. 1995-05-30 06:41:30 +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