From f704820575d91e73d30c0f0d61de3abb5d018056 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 19 Mar 1996 22:00:44 +0000 Subject: [PATCH] moved fqdn stuff into parse.lex (FQHOST) --- parse.yacc | 51 +++++++-------------------------------------------- 1 file changed, 7 insertions(+), 44 deletions(-) diff --git a/parse.yacc b/parse.yacc index 23429a3fe..ee53cb5b6 100644 --- a/parse.yacc +++ b/parse.yacc @@ -107,7 +107,6 @@ extern int usergr_matches __P((char *, char *)); static int find_alias __P((char *, int)); static int add_alias __P((char *, int)); static int more_aliases __P((size_t)); -static char *dotcat __P((char *, char *)); void yyerror __P((char *)); void yyerror(s) @@ -135,8 +134,9 @@ void yyerror(s) %start file /* special start symbol */ %token ALIAS /* an UPPERCASE alias name */ %token NTWKADDR /* w.x.y.z */ +%token FQHOST /* foo.bar.com */ %token NETGROUP /* a netgroup (+NAME) */ -%token USERGROUP /* a usergroup (*NAME) */ +%token USERGROUP /* a usergroup (%NAME) */ %token NAME /* a mixed-case name */ %token COMMAND /* an absolute pathname */ %token COMMENT /* comment and/or carriage return */ @@ -147,7 +147,7 @@ void yyerror(s) %token ':' '=' ',' '!' '.' /* union member tokens */ %token ERROR -%type fqdn cmnd +%type cmnd %% @@ -203,29 +203,18 @@ hostspec : ALL { host_matches = TRUE; (void) free($1); } - | ALIAS { - if (find_alias($1, HOST)) + | FQHOST { + if (strcasecmp(host, $1) == 0) host_matches = TRUE; (void) free($1); } - | fqdn { - if (strcasecmp($1, host) == 0) + | ALIAS { + if (find_alias($1, HOST)) host_matches = TRUE; (void) free($1); } ; -fqdn : NAME '.' NAME { - $$ = dotcat($1, $3); - (void) free($1); - (void) free($3); - } - | fqdn '.' NAME { - $$ = dotcat($1, $3); - (void) free($3); - } - ; - opcmndlist : opcmnd | opcmndlist ',' opcmnd ; @@ -480,29 +469,3 @@ void reset_aliases() (void) free(aliases); naliases = nslots = 0; } - - -static char *dotcat(s1, s2) - char *s1; - char *s2; -{ - int len1; /* length of param 1 */ - int fulllen; /* length of params 1, 2, '.' */ - char *s; /* string to return */ - - /* how much space do we need? */ - len1 = strlen(s1); - fulllen = len1 + 1 + strlen(s2); - - /* allocate the space */ - s = (char *) malloc(fulllen + 1); - if (s == NULL) - yyerror("unable to allocate memory"); - - /* cat s1.s2 -> s efficient */ - (void) strcpy(s, s1); - *(s + len1) = '.'; - (void) strcpy(s + len1 + 1, s2); - - return(s); -} -- 2.40.0