BSD 4_3_Reno release
[unix-history] / usr / src / usr.bin / tip / value.c
index ab3f9d6..2c74aae 100644 (file)
@@ -1,4 +1,26 @@
-/*     value.c 4.3     81/11/29        */
+/*
+ * Copyright (c) 1983 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that: (1) source distributions retain this entire copyright
+ * notice and comment, and (2) distributions including binaries display
+ * the following acknowledgement:  ``This product includes software
+ * developed by the University of California, Berkeley and its contributors''
+ * in the documentation or other materials provided with the distribution
+ * and in all advertising materials mentioning features or use of this
+ * software. Neither the name of the University nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)value.c    5.3 (Berkeley) 6/1/90";
+#endif /* not lint */
+
 #include "tip.h"
 
 #define MIDDLE 35
 #include "tip.h"
 
 #define MIDDLE 35
@@ -123,6 +145,7 @@ vtoken(s)
 {
        register value_t *p;
        register char *cp;
 {
        register value_t *p;
        register char *cp;
+       char *expand();
 
        if (cp = index(s, '=')) {
                *cp = '\0';
 
        if (cp = index(s, '=')) {
                *cp = '\0';
@@ -130,8 +153,11 @@ vtoken(s)
                        cp++;
                        if (p->v_type&NUMBER)
                                vassign(p, atoi(cp));
                        cp++;
                        if (p->v_type&NUMBER)
                                vassign(p, atoi(cp));
-                       else
+                       else {
+                               if (strcmp(s, "record") == 0)
+                                       cp = expand(cp);
                                vassign(p, cp);
                                vassign(p, cp);
+                       }
                        return;
                }
        } else if (cp = index(s, '?')) {
                        return;
                }
        } else if (cp = index(s, '?')) {
@@ -178,7 +204,7 @@ vprint(p)
                printf("%s=", p->v_name);
                col++;
                if (p->v_value) {
                printf("%s=", p->v_name);
                col++;
                if (p->v_value) {
-                       cp = interp(p->v_value);
+                       cp = interp(p->v_value, NULL);
                        col += size(cp);
                        printf("%s", cp);
                }
                        col += size(cp);
                        printf("%s", cp);
                }
@@ -282,3 +308,27 @@ vinterp(s, stop)
        *p = '\0';
        return (c == stop ? s-1 : NULL);
 }
        *p = '\0';
        return (c == stop ? s-1 : NULL);
 }
+
+/*
+ * assign variable s with value v (for NUMBER or STRING or CHAR types)
+ */
+
+vstring(s,v)
+       register char *s;
+       register char *v;
+{
+       register value_t *p;
+       char *expand();
+
+       p = vlookup(s); 
+       if (p == 0)
+               return (1);
+       if (p->v_type&NUMBER)
+               vassign(p, atoi(v));
+       else {
+               if (strcmp(s, "record") == 0)
+                       v = expand(v);
+               vassign(p, v);
+       }
+       return (0);
+}