Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/bin/expr On memory allocation failure, return 3 as per POSIX...



details:   https://anonhg.NetBSD.org/src/rev/eebe16d5ceba
branches:  trunk
changeset: 480502:eebe16d5ceba
user:      mjl <mjl%NetBSD.org@localhost>
date:      Fri Jan 14 07:14:41 2000 +0000

description:
On memory allocation failure, return 3 as per POSIX. (from OpenBSD)

diffstat:

 bin/expr/expr.1 |  4 +++-
 bin/expr/expr.c |  8 ++++----
 2 files changed, 7 insertions(+), 5 deletions(-)

diffs (54 lines):

diff -r 9336117ccde1 -r eebe16d5ceba bin/expr/expr.1
--- a/bin/expr/expr.1   Fri Jan 14 06:53:48 2000 +0000
+++ b/bin/expr/expr.1   Fri Jan 14 07:14:41 2000 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: expr.1,v 1.10 1997/10/20 08:51:56 enami Exp $
+.\"    $NetBSD: expr.1,v 1.11 2000/01/14 07:14:41 mjl Exp $
 .\"
 .\" Written by J.T. Conklin <jtc%netbsd.org@localhost>.
 .\" Public domain.
@@ -97,6 +97,8 @@
 the expression is an empty string or 0.
 .It 2
 the expression is invalid.
+.It >2
+an error occurred (such as memory allocation failure).
 .El
 .Sh STANDARDS
 The
diff -r 9336117ccde1 -r eebe16d5ceba bin/expr/expr.c
--- a/bin/expr/expr.c   Fri Jan 14 06:53:48 2000 +0000
+++ b/bin/expr/expr.c   Fri Jan 14 07:14:41 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: expr.c,v 1.11 1999/11/09 15:06:31 drochner Exp $       */
+/*     $NetBSD: expr.c,v 1.12 2000/01/14 07:14:41 mjl Exp $    */
 
 /*
  * Written by J.T. Conklin <jtc%netbsd.org@localhost>.
@@ -62,7 +62,7 @@
 
        vp = (struct val *) malloc(sizeof(*vp));
        if (vp == NULL) {
-               err(2, NULL);
+               err(3, NULL);
        }
        vp->type = integer;
        vp->u.i = i;
@@ -78,7 +78,7 @@
 
        vp = (struct val *) malloc(sizeof(*vp));
        if (vp == NULL || ((vp->u.s = strdup(s)) == NULL)) {
-               err(2, NULL);
+               err(3, NULL);
        }
        vp->type = string;
        return vp;
@@ -172,7 +172,7 @@
 
        tmp = malloc(25);
        if (tmp == NULL) {
-               err(2, NULL);
+               err(3, NULL);
        }
        (void)snprintf(tmp, 25, "%d", vp->u.i);
        vp->type = string;



Home | Main Index | Thread Index | Old Index