*** /tmp/,RCSt1008665	Wed Oct 24 16:25:51 1990
--- res_query.c	Wed Oct 24 16:25:27 1990
***************
*** 39,44 ****
--- 39,46 ----
  #define MAXPACKET	1024
  #endif
  
+ #define SUFFIX_CHECK
+ 
  extern int errno;
  int h_errno;
  
***************
*** 226,234 ****
  			nbuf[n] = '\0';
  		} else
  			longname = name;
! 	} else
  		(void)sprintf(nbuf, "%.*s.%.*s",
  		    MAXDNAME, name, MAXDNAME, domain);
  
  	return (res_query(longname, class, type, answer, anslen));
  }
--- 228,253 ----
  			nbuf[n] = '\0';
  		} else
  			longname = name;
! 	} else {
! #ifdef SUFFIX_CHECK
! 		/*
! 		 * Check to see if the domain that we're about to
! 		 * append is already present as the suffix of name.
! 		 * If so, assume that adding the suffix will be a
! 		 * waste of time.... so punt.
! 		 * [tytso:19901024.1625EDT]
! 		 */
! 		int	offset = strlen(name) - strlen(domain);
! 		
! 		if ((offset >= 0 ) && !strcasecmp(name+offset, domain) &&
! 		    ((offset == 0) || (*(name+offset-1)=='.')))
! 			return(-1); /* Tell res_search to try again */
! #endif
! 		
  		(void)sprintf(nbuf, "%.*s.%.*s",
  		    MAXDNAME, name, MAXDNAME, domain);
+ 	}
+ 	
  
  	return (res_query(longname, class, type, answer, anslen));
  }
