[BACK]Return to lookup.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / rdist

Diff for /src/usr.bin/rdist/lookup.c between version 1.1 and 1.2

version 1.1, 1995/10/18 08:45:59 version 1.2, 1996/02/03 12:12:29
Line 1 
Line 1 
 /*  /*
  * Copyright (c) 1983, 1993   * Copyright (c) 1983 Regents of the University of California.
  *      The Regents of the University of California.  All rights reserved.   * All rights reserved.
  *   *
  * Redistribution and use in source and binary forms, with or without   * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions   * modification, are permitted provided that the following conditions
Line 32 
Line 32 
  */   */
   
 #ifndef lint  #ifndef lint
 /* from: static char sccsid[] = "@(#)lookup.c   8.1 (Berkeley) 6/9/93"; */  static char RCSid[] =
 static char *rcsid = "$Id$";  "$Id$";
   
   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 */  #endif /* not lint */
   
 #include "defs.h"  #include "defs.h"
Line 54 
Line 60 
 /*  /*
  * Define a variable from a command line argument.   * Define a variable from a command line argument.
  */   */
 void  
 define(name)  define(name)
         char *name;          char *name;
 {  {
Line 62 
Line 67 
         register struct namelist *nl;          register struct namelist *nl;
         struct namelist *value;          struct namelist *value;
   
         if (debug)          debugmsg(DM_CALL, "define(%s)", name);
                 printf("define(%s)\n", name);  
   
         cp = index(name, '=');          cp = strchr(name, '=');
         if (cp == NULL)          if (cp == NULL)
                 value = NULL;                  value = NULL;
         else if (cp[1] == '\0') {          else if (cp[1] == '\0') {
Line 75 
Line 79 
                 *cp++ = '\0';                  *cp++ = '\0';
                 value = makenl(cp);                  value = makenl(cp);
         } else {          } else {
                   value = NULL;
                 nl = NULL;                  nl = NULL;
                 *cp++ = '\0';                  *cp++ = '\0';
                 do                  do
Line 119 
Line 124 
  */   */
   
 struct namelist *  struct namelist *
 lookup(name, action, value)  lookup(name, action, value)     /* %% in name.  Ignore quotas in name */
         char *name;          char *name;
         int action;          int action;
         struct namelist *value;          struct namelist *value;
Line 127 
Line 132 
         register unsigned n;          register unsigned n;
         register char *cp;          register char *cp;
         register struct syment *s;          register struct syment *s;
         char buf[256];          char ebuf[BUFSIZ];
   
         if (debug)          debugmsg(DM_CALL, "lookup(%s, %d, %x)", name, action, value);
                 printf("lookup(%s, %d, %x)\n", name, action, value);  
   
         n = 0;          n = 0;
         for (cp = name; *cp; )          for (cp = name; *cp; )
Line 142 
Line 146 
                         continue;                          continue;
                 if (action != LOOKUP) {                  if (action != LOOKUP) {
                         if (action != INSERT || s->s_type != CONST) {                          if (action != INSERT || s->s_type != CONST) {
                                 (void)sprintf(buf, "%s redefined", name);                                  (void) sprintf(ebuf, "%s redefined", name);
                                 yyerror(buf);                                  yyerror(ebuf);
                         }                          }
                 }                  }
                 return(s->s_value);                  return(s->s_value);
         }          }
   
         if (action == LOOKUP) {          if (action == LOOKUP) {
                 (void)sprintf(buf, "%s undefined", name);                  (void) sprintf(ebuf, "%s undefined", name);
                 yyerror(buf);                  yyerror(ebuf);
                 return(NULL);                  return(NULL);
         }          }
   
         s = ALLOC(syment);          s = ALLOC(syment);
         if (s == NULL)  
                 fatal("ran out of memory\n");  
         s->s_next = hashtab[n];          s->s_next = hashtab[n];
         hashtab[n] = s;          hashtab[n] = s;
         s->s_type = action == INSERT ? VAR : CONST;          s->s_type = action == INSERT ? VAR : CONST;
         s->s_name = name;          s->s_name = name;
         s->s_value = value;          s->s_value = value;
   
         return(value);          return(value);
 }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2