diff options
author | dm <dm@cvs.openbsd.org> | 1996-02-03 12:13:04 +0000 |
---|---|---|
committer | dm <dm@cvs.openbsd.org> | 1996-02-03 12:13:04 +0000 |
commit | f34705a30c83ef27acf58b47c75c736e6858247a (patch) | |
tree | 2121eb2901c910af7604845f5538c2fc26d01ac3 /usr.bin/rdist/lookup.c | |
parent | fdb8a9c5e300099e2c65b848550471fb1d9f0cd4 (diff) |
rdist 6.1.1
Diffstat (limited to 'usr.bin/rdist/lookup.c')
-rw-r--r-- | usr.bin/rdist/lookup.c | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/usr.bin/rdist/lookup.c b/usr.bin/rdist/lookup.c index 69e15dd6304..1477ac1a938 100644 --- a/usr.bin/rdist/lookup.c +++ b/usr.bin/rdist/lookup.c @@ -1,6 +1,6 @@ /* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. + * Copyright (c) 1983 Regents of the University of California. + * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -32,8 +32,14 @@ */ #ifndef lint -/* from: static char sccsid[] = "@(#)lookup.c 8.1 (Berkeley) 6/9/93"; */ -static char *rcsid = "$Id: lookup.c,v 1.1 1995/10/18 08:45:59 deraadt Exp $"; +static char RCSid[] = +"$Id: lookup.c,v 1.2 1996/02/03 12:12:29 dm Exp $"; + +static char sccsid[] = "@(#)lookup.c 5.1 (Berkeley) 6/6/85"; + +static char copyright[] = +"@(#) Copyright (c) 1983 Regents of the University of California.\n\ + All rights reserved.\n"; #endif /* not lint */ #include "defs.h" @@ -54,7 +60,6 @@ static struct syment *hashtab[HASHSIZE]; /* * Define a variable from a command line argument. */ -void define(name) char *name; { @@ -62,10 +67,9 @@ define(name) register struct namelist *nl; struct namelist *value; - if (debug) - printf("define(%s)\n", name); + debugmsg(DM_CALL, "define(%s)", name); - cp = index(name, '='); + cp = strchr(name, '='); if (cp == NULL) value = NULL; else if (cp[1] == '\0') { @@ -75,6 +79,7 @@ define(name) *cp++ = '\0'; value = makenl(cp); } else { + value = NULL; nl = NULL; *cp++ = '\0'; do @@ -119,7 +124,7 @@ define(name) */ struct namelist * -lookup(name, action, value) +lookup(name, action, value) /* %% in name. Ignore quotas in name */ char *name; int action; struct namelist *value; @@ -127,10 +132,9 @@ lookup(name, action, value) register unsigned n; register char *cp; register struct syment *s; - char buf[256]; + char ebuf[BUFSIZ]; - if (debug) - printf("lookup(%s, %d, %x)\n", name, action, value); + debugmsg(DM_CALL, "lookup(%s, %d, %x)", name, action, value); n = 0; for (cp = name; *cp; ) @@ -142,26 +146,25 @@ lookup(name, action, value) continue; if (action != LOOKUP) { if (action != INSERT || s->s_type != CONST) { - (void)sprintf(buf, "%s redefined", name); - yyerror(buf); + (void) sprintf(ebuf, "%s redefined", name); + yyerror(ebuf); } } return(s->s_value); } if (action == LOOKUP) { - (void)sprintf(buf, "%s undefined", name); - yyerror(buf); + (void) sprintf(ebuf, "%s undefined", name); + yyerror(ebuf); return(NULL); } s = ALLOC(syment); - if (s == NULL) - fatal("ran out of memory\n"); s->s_next = hashtab[n]; hashtab[n] = s; s->s_type = action == INSERT ? VAR : CONST; s->s_name = name; s->s_value = value; + return(value); } |