if (cp[strlen (cp) - 1] == '$')
if (cp[cplen - 1] == '$')
nis_getnames (const_nis_name name){  nis_name *getnames = NULL;  char local_domain[NIS_MAXNAMELEN + 1];  char *path, *cp;  int count, pos, have_point;  strncpy (local_domain, nis_local_directory (), NIS_MAXNAMELEN);  local_domain[NIS_MAXNAMELEN] = '\0';  count = 1;  if ((getnames = malloc ((count + 1) * sizeof (char *))) == NULL)      return NULL;  /* Do we have a fully qualified NIS+ name ? If yes, give it back */  if (name[strlen (name) - 1] == '.')    {      if ((getnames[0] = strdup (name)) == NULL)	{	  free (getnames);	  return NULL;	}      getnames[1] = NULL;      return getnames;    }  /* Get the search path, where we have to search "name" */  path = getenv ("NIS_PATH");  if (path == NULL)    path = strdupa ("$");  else    path = strdupa (path);  have_point = (strchr (name, '.') != NULL);  pos = 0;  cp = strtok (path, ":");  while (cp)    {      if (strcmp (cp, "$") == 0)	{	  char *cptr = local_domain;	  char *tmp;	  while ((have_point && *cptr != '\0') || (count_dots (cptr) >= 2))	    {	      if (pos >= count)		{		  count += 5;		  getnames = realloc (getnames, (count + 1) * sizeof (char *));		}	      tmp = malloc (strlen (cptr) + strlen (local_domain) +			    strlen (name) + 2);	      if (tmp == NULL)		return NULL;	      getnames[pos] = tmp;	      tmp = stpcpy (tmp, name);	      *tmp++ = '.';	      if (cptr[1] != '\0')		stpcpy (tmp, cptr);	      else		++cptr;	      ++pos;	      while (*cptr != '.' && *cptr != '\0')		++cptr;	      if (cptr[0] != '\0' && cptr[1] != '\0')		/* If we have only ".", don't remove the "." */		++cptr;	    }	}      else	{	  char *tmp;	  if (cp[strlen (cp) - 1] == '$')	    {	      char *p;	      tmp = malloc (strlen (cp) + strlen (local_domain) +			    strlen (name) + 2);	      if (tmp == NULL)		return NULL;	      p = stpcpy (tmp, name);	      *p++ = '.';	      p = stpcpy (p, cp);	      --p;	      if (p[-1] != '.')		*p++ = '.';	      stpcpy (p, local_domain);	    }	  else	    {	      char *p;	      tmp = malloc (strlen (cp) + strlen (name) + 2);	      if (tmp == NULL)		return NULL;	      p = stpcpy (tmp, name);	      *p++ = '.';	      stpcpy (p, cp);	    }	  if (pos >= count)	    {	      count += 5;	      getnames = realloc (getnames, (count + 1) * sizeof (char *));	      if (getnames == NULL)		return NULL;	    }	  getnames[pos] = tmp;	  ++pos;	}      cp = strtok (NULL, ":");    }  getnames[pos] = NULL;  return getnames;}