From 5db915715f800d0858346bfbb5eea6aff4287ebd Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 14 Aug 2001 23:29:55 +0000 Subject: Update. 2001-08-14 Jakub Jelinek * resolv/nss_dns/dns-host.c (RESOLVSORT): Define. (addrsort): New function. * resolv/gethnamaddr.c (RESOLVSORT): Define. 2001-08-14 Jakub Jelinek * string/strsignal.c (free_mem): Remove. 2001-08-14 Andreas Jaeger * inet/inet_ntoa.c (free_mem): Remove, it's not used anymore. Closes PR libc/2477, reported by Dylan Alex Simon . 2001-08-14 Ulrich Drepper * locale/Makefile (aux): Add xlocale. * locale/xlocale.c: New file. * include/locale.c (_nl_C_locobj): Declare. * iconv/gconv_charset.h: Use __tolower_l, __isdigit_l, __isspace_l with _nl_C_locobj instead of tolower, isdigit, isspace. * iconv/gconv_conf.c: Likewise. * iconv/gconv_int.h: Likewise. * iconv/gconv_open.c: Likewise. * locale/newlocale.c: Minor cleanups. --- resolv/nss_dns/dns-host.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'resolv/nss_dns') diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c index 54645f1208..2102f63758 100644 --- a/resolv/nss_dns/dns-host.c +++ b/resolv/nss_dns/dns-host.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. +/* Copyright (C) 1996-2000, 2001 Free Software Foundation, Inc. This file is part of the GNU C Library. Extended from original form by Ulrich Drepper , 1996. @@ -86,6 +86,8 @@ #include #include +#define RESOLVSORT + /* Maximum number of aliases we allow. */ #define MAX_NR_ALIASES 48 #define MAX_NR_ADDRS 48 @@ -330,6 +332,51 @@ _nss_dns_gethostbyaddr_r (const void *addr, socklen_t len, int af, return NSS_STATUS_SUCCESS; } +#ifdef RESOLVSORT +static void addrsort (char **ap, int num); + +static void +addrsort (char **ap, int num) +{ + int i, j; + char **p; + short aval[MAX_NR_ADDRS]; + int needsort = 0; + + p = ap; + if (num > MAX_NR_ADDRS) + num = MAX_NR_ADDRS; + for (i = 0; i < num; i++, p++) + { + for (j = 0 ; (unsigned)j < _res.nsort; j++) + if (_res.sort_list[j].addr.s_addr == + (((struct in_addr *)(*p))->s_addr & _res.sort_list[j].mask)) + break; + aval[i] = j; + if (needsort == 0 && i > 0 && j < aval[i-1]) + needsort = i; + } + if (!needsort) + return; + + while (needsort++ < num) + for (j = needsort - 2; j >= 0; j--) + if (aval[j] > aval[j+1]) + { + char *hp; + + i = aval[j]; + aval[j] = aval[j+1]; + aval[j+1] = i; + + hp = ap[j]; + ap[j] = ap[j+1]; + ap[j+1] = hp; + } + else + break; +} +#endif static enum nss_status getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype, -- cgit v1.2.1