mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-24 02:03:35 +08:00
Update.
* resolv/inet_pton.c (inet_pton4): Little optimizations. (inet_pton6): Likewise.
This commit is contained in:
parent
554b880018
commit
61fab08af7
@ -1,5 +1,8 @@
|
|||||||
1999-04-29 Ulrich Drepper <drepper@cygnus.com>
|
1999-04-29 Ulrich Drepper <drepper@cygnus.com>
|
||||||
|
|
||||||
|
* resolv/inet_pton.c (inet_pton4): Little optimizations.
|
||||||
|
(inet_pton6): Likewise.
|
||||||
|
|
||||||
* nss/getXXbyYY_r.c: Include assert.h.
|
* nss/getXXbyYY_r.c: Include assert.h.
|
||||||
* nss/getXXbyYY.c: Likewise.
|
* nss/getXXbyYY.c: Likewise.
|
||||||
|
|
||||||
|
@ -81,7 +81,6 @@ inet_pton4(src, dst)
|
|||||||
const char *src;
|
const char *src;
|
||||||
u_char *dst;
|
u_char *dst;
|
||||||
{
|
{
|
||||||
static const char digits[] = "0123456789";
|
|
||||||
int saw_digit, octets, ch;
|
int saw_digit, octets, ch;
|
||||||
u_char tmp[INADDRSZ], *tp;
|
u_char tmp[INADDRSZ], *tp;
|
||||||
|
|
||||||
@ -89,10 +88,9 @@ inet_pton4(src, dst)
|
|||||||
octets = 0;
|
octets = 0;
|
||||||
*(tp = tmp) = 0;
|
*(tp = tmp) = 0;
|
||||||
while ((ch = *src++) != '\0') {
|
while ((ch = *src++) != '\0') {
|
||||||
const char *pch;
|
|
||||||
|
|
||||||
if ((pch = strchr(digits, ch)) != NULL) {
|
if (ch >= '0' && ch <= '9') {
|
||||||
u_int new = *tp * 10 + (pch - digits);
|
u_int new = *tp * 10 + (ch - '0');
|
||||||
|
|
||||||
if (new > 255)
|
if (new > 255)
|
||||||
return (0);
|
return (0);
|
||||||
@ -136,14 +134,13 @@ inet_pton6(src, dst)
|
|||||||
const char *src;
|
const char *src;
|
||||||
u_char *dst;
|
u_char *dst;
|
||||||
{
|
{
|
||||||
static const char xdigits_l[] = "0123456789abcdef",
|
static const char xdigits[] = "0123456789abcdef";
|
||||||
xdigits_u[] = "0123456789ABCDEF";
|
|
||||||
u_char tmp[IN6ADDRSZ], *tp, *endp, *colonp;
|
u_char tmp[IN6ADDRSZ], *tp, *endp, *colonp;
|
||||||
const char *xdigits, *curtok;
|
const char *curtok;
|
||||||
int ch, saw_xdigit;
|
int ch, saw_xdigit;
|
||||||
u_int val;
|
u_int val;
|
||||||
|
|
||||||
memset((tp = tmp), '\0', IN6ADDRSZ);
|
tp = memset(tmp, '\0', IN6ADDRSZ);
|
||||||
endp = tp + IN6ADDRSZ;
|
endp = tp + IN6ADDRSZ;
|
||||||
colonp = NULL;
|
colonp = NULL;
|
||||||
/* Leading :: requires some special handling. */
|
/* Leading :: requires some special handling. */
|
||||||
@ -153,11 +150,10 @@ inet_pton6(src, dst)
|
|||||||
curtok = src;
|
curtok = src;
|
||||||
saw_xdigit = 0;
|
saw_xdigit = 0;
|
||||||
val = 0;
|
val = 0;
|
||||||
while ((ch = *src++) != '\0') {
|
while ((ch = tolower (*src++)) != '\0') {
|
||||||
const char *pch;
|
const char *pch;
|
||||||
|
|
||||||
if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
|
pch = strchr(xdigits, ch);
|
||||||
pch = strchr((xdigits = xdigits_u), ch);
|
|
||||||
if (pch != NULL) {
|
if (pch != NULL) {
|
||||||
val <<= 4;
|
val <<= 4;
|
||||||
val |= (pch - xdigits);
|
val |= (pch - xdigits);
|
||||||
|
Loading…
Reference in New Issue
Block a user