/* GNU m4 -- A simple macro processor
- Copyright (C) 1989-1994, 2004-2011 Free Software Foundation, Inc.
+ Copyright (C) 1989-1994, 2004-2014, 2016-2017, 2020-2021 Free
+ Software Foundation, Inc.
This file is part of GNU M4.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
+ along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "m4.h"
#include <signal.h>
#include "c-stack.h"
+#include "configmake.h"
#include "ignore-value.h"
#include "progname.h"
+#include "propername.h"
#include "version-etc.h"
#ifdef DEBUG_STKOVF
# include "assert.h"
#endif
-#define AUTHORS "Rene' Seindal"
+/* TRANSLATORS: This is a non-ASCII name: The first name is (with
+ Unicode escapes) "Ren\u00e9" or (with HTML entities) "René". */
+#define AUTHORS proper_name_utf8 ("Rene' Seindal", "Ren\xC3\xA9 Seindal")
-static void usage (int) M4_GNUC_NORETURN;
+static _Noreturn void usage (int);
/* Enable sync output for /lib/cpp (-s). */
int sync_output = 0;
current_line, format, args);
if (fatal_warnings && ! retcode)
retcode = EXIT_FAILURE;
+ va_end (args);
+}
+
+void
+m4_failure (int errnum, const char *format, ...)
+{
+ va_list args;
+ va_start (args, format);
+ verror_at_line (EXIT_FAILURE, errnum, current_line ? current_file : NULL,
+ current_line, format, args);
+ assume (false);
}
/*-------------------------------.
verror_at_line (status, errnum, line ? file : NULL, line, format, args);
if (fatal_warnings && ! retcode)
retcode = EXIT_FAILURE;
+ va_end (args);
+}
+
+void
+m4_failure_at_line (int errnum, const char *file, int line,
+ const char *format, ...)
+{
+ va_list args;
+ va_start (args, format);
+ verror_at_line (EXIT_FAILURE, errnum, line ? file : NULL,
+ line, format, args);
+ assume (false);
}
#ifndef SIGBUS
usage (int status)
{
if (status != EXIT_SUCCESS)
- xfprintf (stderr, "Try `%s --help' for more information.\n", program_name);
+ {
+ xfprintf (stderr, _("Try `%s --help' for more information."),
+ program_name);
+ fputs ("\n", stderr);
+ }
else
{
- xprintf ("Usage: %s [OPTION]... [FILE]...\n", program_name);
- fputs ("\
+ xprintf (_("Usage: %s [OPTION]... [FILE]...\n"), program_name);
+ fputs (_("\
Process macros in FILEs. If no FILE or if FILE is `-', standard input\n\
is read.\n\
-", stdout);
- fputs ("\
-\n\
+"), stdout);
+ puts ("");
+ fputs (_("\
Mandatory or optional arguments to long options are mandatory or optional\n\
for short options too.\n\
-\n\
+"), stdout);
+ puts ("");
+ fputs (_("\
Operation modes:\n\
--help display this help and exit\n\
--version output version information and exit\n\
-", stdout);
- xprintf ("\
+"), stdout);
+ fputs (_("\
-E, --fatal-warnings once: warnings become errors, twice: stop\n\
execution at first error\n\
-i, --interactive unbuffer output, ignore interrupts\n\
-P, --prefix-builtins force a `m4_' prefix to all builtins\n\
-Q, --quiet, --silent suppress some warnings for builtins\n\
+"), stdout);
+ xprintf (_("\
--warn-macro-sequence[=REGEXP]\n\
warn if macro definition matches REGEXP,\n\
default %s\n\
-", DEFAULT_MACRO_SEQUENCE);
+"), DEFAULT_MACRO_SEQUENCE);
#ifdef ENABLE_CHANGEWORD
- fputs ("\
+ fputs (_("\
-W, --word-regexp=REGEXP use REGEXP for macro name syntax\n\
-", stdout);
+"), stdout);
#endif
- fputs ("\
-\n\
+ puts ("");
+ fputs (_("\
Preprocessor features:\n\
-D, --define=NAME[=VALUE] define NAME as having VALUE, or empty\n\
-I, --include=DIRECTORY append DIRECTORY to include path\n\
-s, --synclines generate `#line NUM \"FILE\"' lines\n\
-U, --undefine=NAME undefine NAME\n\
-", stdout);
+"), stdout);
puts ("");
xprintf (_("\
Limits control:\n\
-L, --nesting-limit=NUMBER change nesting limit, 0 for unlimited [%d]\n\
"), nesting_limit);
puts ("");
- fputs ("\
+ fputs (_("\
Frozen state files:\n\
-F, --freeze-state=FILE produce a frozen state on FILE at end\n\
-R, --reload-state=FILE reload a frozen state from FILE at start\n\
-", stdout);
- fputs ("\
-\n\
+"), stdout);
+ puts ("");
+ fputs (_("\
Debugging:\n\
-d, --debug[=FLAGS] set debug level (no FLAGS implies `aeq')\n\
--debugfile[=FILE] redirect debug and trace output to FILE\n\
(default stderr, discard if empty string)\n\
-l, --arglength=NUM restrict macro tracing size\n\
-t, --trace=NAME trace NAME when it is defined\n\
-", stdout);
- fputs ("\
-\n\
+"), stdout);
+ puts ("");
+ fputs (_("\
FLAGS is any of:\n\
a show actual arguments\n\
c show before collect, after collect and after call\n\
e show expansion\n\
f say current input file name\n\
i show changes in input files\n\
+"), stdout);
+ fputs (_("\
l say current input line number\n\
p show results of path searches\n\
q quote values as necessary, with a or e flag\n\
t trace for all macro calls, not only traceon'ed\n\
x add a unique macro call id, useful with c flag\n\
V shorthand for all of the above flags\n\
-", stdout);
- fputs ("\
-\n\
+"), stdout);
+ puts ("");
+ fputs (_("\
If defined, the environment variable `M4PATH' is a colon-separated list\n\
of directories included after any specified by `-I'.\n\
-", stdout);
- fputs ("\
-\n\
+"), stdout);
+ puts ("");
+ fputs (_("\
Exit status is 0 for success, 1 for failure, 63 for frozen file version\n\
mismatch, or whatever value was passed to the m4exit macro.\n\
-", stdout);
+"), stdout);
emit_bug_reporting_address ();
}
exit (status);
{"trace", required_argument, NULL, 't'},
{"traditional", no_argument, NULL, 'G'},
{"undefine", required_argument, NULL, 'U'},
+#ifdef ENABLE_CHANGEWORD
{"word-regexp", required_argument, NULL, 'W'},
+#endif
{"debugfile", optional_argument, NULL, DEBUGFILE_OPTION},
{"diversions", required_argument, NULL, DIVERSIONS_OPTION},
set_program_name (argv[0]);
retcode = EXIT_SUCCESS;
+ setlocale (LC_ALL, "");
+ bindtextdomain (PACKAGE, LOCALEDIR);
+ textdomain (PACKAGE);
atexit (close_stdin);
include_init ();
case 'e':
error (0, 0, _("warning: `m4 -e' is deprecated, use `-i' instead"));
- /* fall through */
+ FALLTHROUGH;
case 'i':
interactive = true;
break;
/* Do the basic initializations. */
if (debugfile && !debug_set_output (debugfile))
- M4ERROR ((warning_status, errno, "cannot set debug file `%s'", debugfile));
+ M4ERROR ((warning_status, errno, _("cannot set debug file `%s'"),
+ debugfile));
input_init ();
output_init ();
case DEBUGFILE_OPTION:
if (!debug_set_output (defines->arg))
- M4ERROR ((warning_status, errno, "cannot set debug file `%s'",
+ M4ERROR ((warning_status, errno, _("cannot set debug file `%s'"),
debugfile ? debugfile : _("stderr")));
break;