version 1.10, 2002/05/27 03:14:22 |
version 1.11, 2003/05/14 01:34:35 |
|
|
* SUCH DAMAGE. |
* SUCH DAMAGE. |
*/ |
*/ |
|
|
|
#include "defs.h" |
|
|
#ifndef lint |
#ifndef lint |
#if 0 |
#if 0 |
static char RCSid[] = |
static char RCSid[] __attribute__((__unused__)) = |
"$From: lookup.c,v 6.8 1996/07/19 16:49:55 michaelc Exp $"; |
"$From: lookup.c,v 1.4 1999/08/04 15:57:33 christos Exp $"; |
#else |
#else |
static char RCSid[] = |
static char RCSid[] __attribute__((__unused__)) = |
"$OpenBSD$"; |
"$OpenBSD$"; |
#endif |
#endif |
|
|
static char sccsid[] = "@(#)lookup.c 5.1 (Berkeley) 6/6/85"; |
static char sccsid[] __attribute__((__unused__)) = |
|
"@(#)lookup.c 5.1 (Berkeley) 6/6/85"; |
|
|
static char copyright[] = |
static char copyright[] __attribute__((__unused__)) = |
"@(#) Copyright (c) 1983 Regents of the University of California.\n\ |
"@(#) Copyright (c) 1983 Regents of the University of California.\n\ |
All rights reserved.\n"; |
All rights reserved.\n"; |
#endif /* not lint */ |
#endif /* not lint */ |
|
|
#include "defs.h" |
|
|
|
/* symbol types */ |
/* symbol types */ |
#define VAR 1 |
#define VAR 1 |
#define CONST 2 |
#define CONST 2 |
|
|
* Define a variable from a command line argument. |
* Define a variable from a command line argument. |
*/ |
*/ |
void |
void |
define(name) |
define(char *name) |
char *name; |
|
{ |
{ |
char *cp, *s; |
char *cp, *s; |
struct namelist *nl; |
struct namelist *nl; |
|
|
*/ |
*/ |
|
|
struct namelist * |
struct namelist * |
lookup(name, action, value) /* %% in name. Ignore quotas in name */ |
lookup(char *name, int action, struct namelist *value) |
char *name; |
|
int action; |
|
struct namelist *value; |
|
{ |
{ |
unsigned int n; |
unsigned int n; |
char *cp; |
char *cp; |
|
|
if (action != LOOKUP) { |
if (action != LOOKUP) { |
if (action != INSERT || s->s_type != CONST) { |
if (action != INSERT || s->s_type != CONST) { |
(void) snprintf(ebuf, sizeof(ebuf), |
(void) snprintf(ebuf, sizeof(ebuf), |
"%s redefined", name); |
"%.*s redefined", |
|
(int)(sizeof(ebuf) - |
|
sizeof(" redefined")), name); |
yyerror(ebuf); |
yyerror(ebuf); |
} |
} |
} |
} |
|
|
} |
} |
|
|
if (action == LOOKUP) { |
if (action == LOOKUP) { |
(void) snprintf(ebuf, sizeof(ebuf), "%s undefined", name); |
(void) snprintf(ebuf, sizeof(ebuf), "%.*s undefined", |
|
(int)(sizeof(ebuf) - sizeof(" undefined")), |
|
name); |
yyerror(ebuf); |
yyerror(ebuf); |
return(NULL); |
return(NULL); |
} |
} |