/*
buffer is the size of an unformatted IPv6 address in printable format.
*/
- char buffer[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"];
-
while (at2 != NULL)
{
if (req->ai_flags & AI_CANONNAME)
tmpbuflen *= 2;
tmpbuf = __alloca (tmpbuflen);
- if (tmpbuf == NULL)
- return -EAI_MEMORY;
-
rc = __gethostbyaddr_r (at2->addr,
((at2->family == AF_INET6)
? sizeof(struct in6_addr)
return -EAI_SYSTEM;
}
- if (h == NULL)
- c = inet_ntop (at2->family, at2->addr, buffer, sizeof(buffer));
- else
+ if (h != NULL)
c = h->h_name;
+ else
+ {
+ /* We have to try to get the canonical in some other
+ way. If we are looking for either AF_INET or
+ AF_INET6 try the other line. */
+ if (req->ai_family == AF_UNSPEC)
+ {
+ struct addrinfo *p = NULL;
+ struct addrinfo **end = &p;
+ struct addrinfo localreq = *req;
+ struct addrinfo *runp;
+
+ localreq.ai_family = AF_INET + AF_INET6 - at2->family;
+ (void) gaih_inet (name, service, &localreq, end);
+
+ runp = p;
+ while (runp != NULL)
+ {
+ if (p->ai_canonname != name)
+ {
+ c = strdupa (p->ai_canonname);
+ break;
+ }
+ runp = runp->ai_next;
+ }
+
+ freeaddrinfo (p);
+ }
+
+ /* If this code is used the missing canonical name is
+ substituted with the name passed in by the user. */
+ if (c == NULL)
+ c = name;
+ }
if (c == NULL)
return GAIH_OKIFUNSPEC | -EAI_NONAME;
last_i = i;
if (hints->ai_family == AF_UNSPEC && (i & GAIH_OKIFUNSPEC))
- continue;
+ {
+ ++g;
+ continue;
+ }
- if (p)
- freeaddrinfo (p);
+ freeaddrinfo (p);
return -(i & GAIH_EAI);
}
if (pai == NULL && last_i == 0)
return 0;
- if (p)
- freeaddrinfo (p);
+ freeaddrinfo (p);
return last_i ? -(last_i & GAIH_EAI) : EAI_NONAME;
}
#define match_char(ch1, ch2) if (ch1 != ch2) return NULL
#if defined __GNUC__ && __GNUC__ >= 2
-# define match_string(cs1, s2) \
+# ifdef USE_IN_EXTENDED_LOCALE_MODEL
+# define match_string(cs1, s2) \
+ ({ size_t len = strlen (cs1); \
+ int result = __strncasecmp_l ((cs1), (s2), len, locale) == 0; \
+ if (result) (s2) += len; \
+ result; })
+# else
+# define match_string(cs1, s2) \
({ size_t len = strlen (cs1); \
int result = strncasecmp ((cs1), (s2), len) == 0; \
if (result) (s2) += len; \
result; })
+# endif
#else
/* Oh come on. Get a reasonable compiler. */
# define match_string(cs1, s2) \
# define LOCALE_PARAM_PROTO , __locale_t locale
# define LOCALE_PARAM_DECL __locale_t locale;
# define HELPER_LOCALE_ARG , current
+# define ISSPACE(Ch) __isspace_l (Ch, locale)
#else
# define LOCALE_PARAM
# define LOCALE_ARG
# else
# define HELPER_LOCALE_ARG
# endif
+# define ISSPACE(Ch) isspace (Ch)
#endif
{
/* A white space in the format string matches 0 more or white
space in the input string. */
- if (isspace (*fmt))
+ if (ISSPACE (*fmt))
{
- while (isspace (*rp))
+ while (ISSPACE (*rp))
++rp;
++fmt;
continue;
case 'n':
case 't':
/* Match any white space. */
- while (isspace (*rp))
+ while (ISSPACE (*rp))
++rp;
break;
case 'p':