Index: /trunk/archive/pslib/src/Utils/error.c
===================================================================
--- /trunk/archive/pslib/src/Utils/error.c	(revision 385)
+++ /trunk/archive/pslib/src/Utils/error.c	(revision 386)
@@ -146,4 +146,23 @@
 		       ...)		// arguments for format
 {
+    va_list ap;
+    /*
+     * Print header?
+     */
+    if (fmt != NULL) {
+	va_start(ap, fmt);
+    }
+
+    psVErrorStackPrint(fd, fmt, ap);
+
+    if (fmt != NULL) {
+	va_end(ap);
+    }
+}
+
+void psVErrorStackPrint(FILE *fd,	// write to this file descriptor
+			const char *fmt,// format for any header information; may be NULL
+			va_list ap)	// arguments for format
+{
     static int first = 1;
     
@@ -171,8 +190,8 @@
      */
     if (fmt != NULL) {
-	va_list ap;
-	va_start(ap, fmt);
-	vprintf(fmt, ap);
-	va_end(ap);
+	vfprintf(fd, fmt, ap);
+	if (strchr(fmt, '\n') == NULL) {
+	    fprintf(fd, "\n");
+	}
     }
     /*
@@ -187,7 +206,8 @@
     
     for (int i = 0; i < nerror; i++) {
+	int code = stack[i]->error.code;
 	fprintf(fd, "%*s%-*s %-30s %s\n",
 		i, "", 30 - i, stack[i]->error.name,
-		errorStringList[stack[i]->error.code], stack[i]->error.msg);
-    }
-}
+		(code < PS_ERR_BASE ? strerror(code) : errorStringList[code]), stack[i]->error.msg);
+    }
+}
