summaryrefslogtreecommitdiff
path: root/msg.c
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2010-11-18 23:00:31 +0200
committerArnold D. Robbins <arnold@skeeve.com>2010-11-18 23:00:31 +0200
commit6f3612539c425da2bc1d34db621696e6a273b01c (patch)
tree9623b3ac2c54a93e5eed3be2b1dda7f4e4bf0e47 /msg.c
parent4e3701015635401df2fc4da58abaab7645f4ebd3 (diff)
downloadgawk-6f3612539c425da2bc1d34db621696e6a273b01c.tar.gz
Bring latest byte code gawk into git. Hurray!
Diffstat (limited to 'msg.c')
-rw-r--r--msg.c99
1 files changed, 31 insertions, 68 deletions
diff --git a/msg.c b/msg.c
index f8bb9654..a75396f5 100644
--- a/msg.c
+++ b/msg.c
@@ -1,9 +1,10 @@
/*
- * msg.c - routines for error messages
+ * msg.c - routines for error messages.
*/
/*
- * Copyright (C) 1986, 1988, 1989, 1991-2001, 2003 the Free Software Foundation, Inc.
+ * Copyright (C) 1986, 1988, 1989, 1991-2001, 2003, 2010
+ * the Free Software Foundation, Inc.
*
* This file is part of GAWK, the GNU implementation of the
* AWK Programming Language.
@@ -25,12 +26,15 @@
#include "awk.h"
+extern FILE *output_fp;
int sourceline = 0;
char *source = NULL;
-
static const char *srcfile = NULL;
static int srcline;
+jmp_buf fatal_tag;
+int fatal_tag_valid = FALSE;
+
/* err --- print an error message with source line and file and record */
/* VARARGS2 */
@@ -38,9 +42,13 @@ void
err(const char *s, const char *emsg, va_list argp)
{
char *file;
+ const char *me;
- (void) fflush(stdout);
- (void) fprintf(stderr, "%s: ", myname);
+ (void) fflush(output_fp);
+ me = myname;
+ if (STREQN(me, "dgawk", 5))
+ me = &myname[1];
+ (void) fprintf(stderr, "%s: ", me);
#ifdef GAWKDEBUG
if (srcfile != NULL) {
fprintf(stderr, "%s:%d:", srcfile, srcline);
@@ -70,29 +78,11 @@ err(const char *s, const char *emsg, va_list argp)
/* msg --- take a varargs error message and print it */
-/*
- * Function identifier purposely indented to avoid mangling
- * by ansi2knr. Sigh.
- */
-
void
-#ifdef CAN_USE_STDARG_H
- msg(const char *mesg, ...)
-#else
-/*VARARGS0*/
- msg(va_alist)
- va_dcl
-#endif
+msg(const char *mesg, ...)
{
va_list args;
-#ifdef CAN_USE_STDARG_H
va_start(args, mesg);
-#else
- char *mesg;
-
- va_start(args);
- mesg = va_arg(args, char *);
-#endif
err("", mesg, args);
va_end(args);
}
@@ -100,45 +90,19 @@ void
/* warning --- print a warning message */
void
-#ifdef CAN_USE_STDARG_H
- warning(const char *mesg, ...)
-#else
-/*VARARGS0*/
- warning(va_alist)
- va_dcl
-#endif
+warning(const char *mesg, ...)
{
va_list args;
-#ifdef CAN_USE_STDARG_H
va_start(args, mesg);
-#else
- char *mesg;
-
- va_start(args);
- mesg = va_arg(args, char *);
-#endif
err(_("warning: "), mesg, args);
va_end(args);
}
void
-#ifdef CAN_USE_STDARG_H
- error(const char *mesg, ...)
-#else
-/*VARARGS0*/
- error(va_alist)
- va_dcl
-#endif
+error(const char *mesg, ...)
{
va_list args;
-#ifdef CAN_USE_STDARG_H
va_start(args, mesg);
-#else
- char *mesg;
-
- va_start(args);
- mesg = va_arg(args, char *);
-#endif
err(_("error: "), mesg, args);
va_end(args);
}
@@ -155,30 +119,29 @@ set_loc(const char *file, int line)
file = srcfile; line = srcline;
}
-/* fatal --- print an error message and die */
+/* r_fatal --- print a fatal error message */
void
-#ifdef CAN_USE_STDARG_H
- r_fatal(const char *mesg, ...)
-#else
-/*VARARGS0*/
- r_fatal(va_alist)
- va_dcl
-#endif
+r_fatal(const char *mesg, ...)
{
va_list args;
-#ifdef CAN_USE_STDARG_H
va_start(args, mesg);
-#else
- char *mesg;
-
- va_start(args);
- mesg = va_arg(args, char *);
-#endif
err(_("fatal: "), mesg, args);
va_end(args);
#ifdef GAWKDEBUG
abort();
#endif
- exit(EXIT_FATAL);
+ gawk_exit(EXIT_FATAL);
+}
+
+/* gawk_exit --- longjmp out if necessary */
+
+void
+gawk_exit(int status)
+{
+ if (fatal_tag_valid) {
+ exit_val = status;
+ longjmp(fatal_tag, 1);
+ }
+ exit(status);
}