summaryrefslogtreecommitdiff
path: root/bin/sh/error.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1996-10-20 00:55:12 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1996-10-20 00:55:12 +0000
commit8414ed88be8de5352141730c176d30301d6700b4 (patch)
tree44a7f767c70131fb1d09f8a151860fee4e22ae5f /bin/sh/error.c
parent78d30b21a3fa6e2f7d7fb077246e1e015a2dafdf (diff)
Sync with NetBSD. Adds better POSIX compliance amongst others.
Diffstat (limited to 'bin/sh/error.c')
-rw-r--r--bin/sh/error.c85
1 files changed, 56 insertions, 29 deletions
diff --git a/bin/sh/error.c b/bin/sh/error.c
index 489f00f0fee..9513437ef38 100644
--- a/bin/sh/error.c
+++ b/bin/sh/error.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: error.c,v 1.2 1996/06/23 14:21:10 deraadt Exp $ */
+/* $OpenBSD: error.c,v 1.3 1996/10/20 00:54:45 millert Exp $ */
/* $NetBSD: error.c,v 1.14 1995/05/11 21:28:51 christos Exp $ */
/*-
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)error.c 8.2 (Berkeley) 5/4/95";
#else
-static char rcsid[] = "$OpenBSD: error.c,v 1.2 1996/06/23 14:21:10 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: error.c,v 1.3 1996/10/20 00:54:45 millert Exp $";
#endif
#endif /* not lint */
@@ -71,6 +71,8 @@ volatile int intpending;
char *commandname;
+static void exverror __P((int, char *, va_list));
+
/*
* Called to raise an exception. Since C doesn't include exceptions, we
* just do a longjmp to the exception handler. The type of exception is
@@ -116,20 +118,36 @@ onint() {
}
-
-void
-error2(a, b)
- char *a, *b;
- {
- error("%s: %s", a, b);
-}
-
-
/*
- * Error is called to raise the error exception. If the first argument
+ * Exverror is called to raise the error exception. If the first argument
* is not NULL then error prints an error message using printf style
* formatting. It then raises the error exception.
*/
+static void
+exverror(cond, msg, ap)
+ int cond;
+ char *msg;
+ va_list ap;
+{
+ CLEAR_PENDING_INT;
+ INTOFF;
+
+#ifdef DEBUG
+ if (msg)
+ TRACE(("exverror(%d, \"%s\") pid=%d\n", cond, msg, getpid()));
+ else
+ TRACE(("exverror(%d, NULL) pid=%d\n", cond, getpid()));
+#endif
+ if (msg) {
+ if (commandname)
+ outfmt(&errout, "%s: ", commandname);
+ doformat(&errout, msg, ap);
+ out2c('\n');
+ }
+ flushall();
+ exraise(cond);
+}
+
#if __STDC__
void
@@ -144,33 +162,42 @@ error(va_alist)
char *msg;
#endif
va_list ap;
- CLEAR_PENDING_INT;
- INTOFF;
-
#if __STDC__
va_start(ap, msg);
#else
va_start(ap);
msg = va_arg(ap, char *);
#endif
-#ifdef DEBUG
- if (msg)
- TRACE(("error(\"%s\") pid=%d\n", msg, getpid()));
- else
- TRACE(("error(NULL) pid=%d\n", getpid()));
-#endif
- if (msg) {
- if (commandname)
- outfmt(&errout, "%s: ", commandname);
- doformat(&errout, msg, ap);
- out2c('\n');
- }
+ exverror(EXERROR, msg, ap);
va_end(ap);
- flushall();
- exraise(EXERROR);
}
+#if __STDC__
+void
+exerror(int cond, char *msg, ...)
+#else
+void
+exerror(va_alist)
+ va_dcl
+#endif
+{
+#if !__STDC__
+ int cond;
+ char *msg;
+#endif
+ va_list ap;
+#if __STDC__
+ va_start(ap, msg);
+#else
+ va_start(ap);
+ cond = va_arg(ap, int);
+ msg = va_arg(ap, char *);
+#endif
+ exverror(cond, msg, ap);
+ va_end(ap);
+}
+
/*
* Table of error messages.