Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0c43030

Browse files
committed
Re-enable inet code.
1 parentf4389d5 commit0c43030

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

‎src/backend/utils/adt/inet.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*is for IP V4 CIDR notation, but prepared for V6: just
44
*add the necessary bits where the comments indicate.
55
*
6-
*$Id: inet.c,v 1.3 1998/10/12 04:07:46 momjian Exp $
6+
*$Id: inet.c,v 1.4 1998/10/17 03:59:13 momjian Exp $
77
*/
88

99
#include<sys/types.h>
@@ -57,9 +57,7 @@ inet_in(char *src)
5757
}
5858
/* First, try for an IP V4 address: */
5959
ip_family(dst)=AF_INET;
60-
#ifdefBAD
6160
bits=inet_net_pton(ip_family(dst),src,&ip_v4addr(dst),ip_addrsize(dst),NULL);
62-
#endif
6361
if ((bits<0)|| (bits>32))
6462
{
6563
/* Go for an IPV6 address here, before faulting out: */
@@ -86,15 +84,13 @@ inet_out(inet *src)
8684

8785
if (ip_family(src)==AF_INET)
8886
{
89-
#ifdefBAD
9087
/* It's an IP V4 address: */
9188
if (inet_net_ntop(AF_INET,&ip_v4addr(src),4,ip_bits(src),
9289
tmp,sizeof(tmp))<0)
9390
{
9491
elog(ERROR,"unable to print address (%s)",strerror(errno));
9592
return (NULL);
9693
}
97-
#endif
9894
}
9995
else
10096
{

‎src/backend/utils/adt/inet_net_pton.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
#if defined(LIBC_SCCS)&& !defined(lint)
19-
staticconstcharrcsid[]="$Id: inet_net_pton.c,v 1.4 1998/10/12 15:56:34 momjian Exp $";
19+
staticconstcharrcsid[]="$Id: inet_net_pton.c,v 1.5 1998/10/17 03:59:14 momjian Exp $";
2020

2121
#endif
2222

@@ -100,34 +100,32 @@ inet_net_pton_ipv4(const char *src, u_char *dst, size_t size)
100100

101101
ch=*src++;
102102
if (ch=='0'&& (src[0]=='x'||src[0]=='X')
103-
&&isascii(src[1])&&isxdigit(src[1]))
104-
{
103+
&&isascii(src[1])&&isxdigit(src[1])) {
105104
/* Hexadecimal: Eat nybble string. */
106105
if (size <=0)
107106
gotoemsgsize;
108-
tmp=0;
109107
dirty=0;
110-
src++;/* skip x or X. */
111-
while ((ch=*src++)!='\0'&&
112-
isascii(ch)&&isxdigit(ch))
113-
{
108+
src++;/* skip x or X. */
109+
while ((ch=*src++)!='\0'&&isascii(ch)&&isxdigit(ch)) {
114110
if (isupper(ch))
115111
ch=tolower(ch);
116112
n=strchr(xdigits,ch)-xdigits;
117113
assert(n >=0&&n <=15);
118-
tmp= (tmp <<4) |n;
114+
if (dirty==0)
115+
tmp=n;
116+
else
117+
tmp= (tmp <<4) |n;
119118
if (++dirty==2) {
120119
if (size-- <=0)
121120
gotoemsgsize;
122121
*dst++= (u_char)tmp;
123-
tmp=0,dirty=0;
122+
dirty=0;
124123
}
125124
}
126-
if (dirty) {
125+
if (dirty) {/* Odd trailing nybble? */
127126
if (size-- <=0)
128127
gotoemsgsize;
129-
tmp <<=4;
130-
*dst++= (u_char)tmp;
128+
*dst++= (u_char) (tmp <<4);
131129
}
132130
}
133131
elseif (isascii(ch)&&isdigit(ch))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp