BSD 4_4 release
[unix-history] / usr / src / old / awk / tran.c
index e25d1ba..f548fc1 100644 (file)
@@ -1,6 +1,15 @@
+/*-
+ * Copyright (c) 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This module is believed to contain source code proprietary to AT&T.
+ * Use and redistribution is subject to the Berkeley Software License
+ * Agreement and your Software Agreement with AT&T (Western Electric).
+ */
+
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)tran.c     4.3 %G%";
-#endif
+static char sccsid[] = "@(#)tran.c     4.7 (Berkeley) 5/26/93";
+#endif /* not lint */
 
 #include "stdio.h"
 #include "awk.def"
 
 #include "stdio.h"
 #include "awk.def"
@@ -136,7 +145,7 @@ awkfloat f;
                error(FATAL, "can't set $0");
        vp->tval &= ~STR;       /* mark string invalid */
        vp->tval |= NUM;        /* mark number ok */
                error(FATAL, "can't set $0");
        vp->tval &= ~STR;       /* mark string invalid */
        vp->tval |= NUM;        /* mark number ok */
-       if ((vp->tval & FLD) && vp->nval == 0)
+       if ((vp->tval & FLD) && isnull(vp->nval))
                donerec = 0;
        return(vp->fval = f);
 }
                donerec = 0;
        return(vp->fval = f);
 }
@@ -151,7 +160,7 @@ char *s;
                error(FATAL, "can't set $0");
        vp->tval &= ~NUM;
        vp->tval |= STR;
                error(FATAL, "can't set $0");
        vp->tval &= ~NUM;
        vp->tval |= STR;
-       if ((vp->tval & FLD) && vp->nval == 0)
+       if ((vp->tval & FLD) && isnull(vp->nval))
                donerec = 0;
        if (!(vp->tval&FLD))
                strfree(vp->sval);
                donerec = 0;
        if (!(vp->tval&FLD))
                strfree(vp->sval);
@@ -172,7 +181,7 @@ register cell *vp;
                /* have unlikely numeric variables, so that */
                /* $1 == $2 comparisons sort of make sense when */
                /* one or the other is numeric */
                /* have unlikely numeric variables, so that */
                /* $1 == $2 comparisons sort of make sense when */
                /* one or the other is numeric */
-               if (isnumber(vp->sval)) {
+               if (isanumber(vp->sval)) {
                        vp->fval = atof(vp->sval);
                        if (!(vp->tval & CON))  /* don't change type of a constant */
                                vp->tval |= NUM;
                        vp->fval = atof(vp->sval);
                        if (!(vp->tval & CON))  /* don't change type of a constant */
                                vp->tval |= NUM;
@@ -197,9 +206,9 @@ register cell *vp;
                if (!(vp->tval&FLD))
                        strfree(vp->sval);
                if ((long)vp->fval==vp->fval)
                if (!(vp->tval&FLD))
                        strfree(vp->sval);
                if ((long)vp->fval==vp->fval)
-                       sprintf(s, "%.20g", vp->fval);
+                       (void)sprintf(s, "%.20g", vp->fval);
                else
                else
-                       sprintf(s, *OFMT, vp->fval);
+                       (void)sprintf(s, *OFMT, vp->fval);
                vp->sval = tostring(s);
                vp->tval &= ~FLD;
                vp->tval |= STR;
                vp->sval = tostring(s);
                vp->tval &= ~FLD;
                vp->tval |= STR;