make '' default to file beginning if no large movements yet
[unix-history] / usr / src / usr.bin / rdist / lookup.c
index bd80871..85c4bb0 100644 (file)
@@ -1,6 +1,23 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley.  The name of the
+ * University may not 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 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)lookup.c    4.5 (Berkeley) 84/02/16";
-#endif
+static char sccsid[] = "@(#)lookup.c   5.4 (Berkeley) %G%";
+#endif /* not lint */
 
 #include "defs.h"
 
 
 #include "defs.h"
 
@@ -92,6 +109,7 @@ lookup(name, action, value)
        register unsigned n;
        register char *cp;
        register struct syment *s;
        register unsigned n;
        register char *cp;
        register struct syment *s;
+       char buf[256];
 
        if (debug)
                printf("lookup(%s, %d, %x)\n", name, action, value);
 
        if (debug)
                printf("lookup(%s, %d, %x)\n", name, action, value);
@@ -105,14 +123,19 @@ lookup(name, action, value)
                if (strcmp(name, s->s_name))
                        continue;
                if (action != LOOKUP) {
                if (strcmp(name, s->s_name))
                        continue;
                if (action != LOOKUP) {
-                       if (action != INSERT || s->s_type != CONST)
-                               fatal("%s redefined\n", name);
+                       if (action != INSERT || s->s_type != CONST) {
+                               (void)sprintf(buf, "%s redefined", name);
+                               yyerror(buf);
+                       }
                }
                return(s->s_value);
        }
 
                }
                return(s->s_value);
        }
 
-       if (action == LOOKUP)
-               fatal("%s not defined", name);
+       if (action == LOOKUP) {
+               (void)sprintf(buf, "%s undefined", name);
+               yyerror(buf);
+               return(NULL);
+       }
 
        s = ALLOC(syment);
        if (s == NULL)
 
        s = ALLOC(syment);
        if (s == NULL)