[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r24033 - gnunet/src/regex
From: |
gnunet |
Subject: |
[GNUnet-SVN] r24033 - gnunet/src/regex |
Date: |
Thu, 27 Sep 2012 11:03:30 +0200 |
Author: grothoff
Date: 2012-09-27 11:03:30 +0200 (Thu, 27 Sep 2012)
New Revision: 24033
Modified:
gnunet/src/regex/regex.c
Log:
-fixes
Modified: gnunet/src/regex/regex.c
===================================================================
--- gnunet/src/regex/regex.c 2012-09-27 07:51:04 UTC (rev 24032)
+++ gnunet/src/regex/regex.c 2012-09-27 09:03:30 UTC (rev 24033)
@@ -2953,7 +2953,7 @@
static void
iptobinstr (const int af, const void *addr, char *str)
{
- unsigned int i;
+ int i;
switch (af)
{
@@ -2965,20 +2965,22 @@
str += 31;
for (i = 31; i >= 0; i--)
{
- *str-- = (b & 1) + '0';
+ *str = (b & 1) + '0';
+ str--;
b >>= 1;
}
break;
}
case AF_INET6:
{
- struct in6_addr b = *(struct in6_addr *) addr;
+ struct in6_addr b = *(const struct in6_addr *) addr;
str[128] = '\0';
str += 127;
for (i = 127; i >= 0; i--)
{
- *str-- = (b.s6_addr[i / 8] & 1) + '0';
+ *str = (b.s6_addr[i / 8] & 1) + '0';
+ str--;
b.s6_addr[i / 8] >>= 1;
}
break;
@@ -3003,9 +3005,9 @@
if (1 != inet_pton (AF_INET, netmask, &a))
return 0;
-
- for (len = 32, t = htonl (~a.s_addr); t & 1; t >>= 1, len--) ;
-
+ len = 32;
+ for (t = htonl (~a.s_addr); 0 != t; t >>= 1)
+ len--;
return len;
}
@@ -3027,7 +3029,8 @@
pfxlen = ipv4netmasktoprefixlen (netmask);
iptobinstr (AF_INET, ip, rxstr);
rxstr[pfxlen] = '\0';
- strcat (rxstr, "(0|1)*");
+ if (pfxlen < 32)
+ strcat (rxstr, "(0|1)+");
}
@@ -3041,9 +3044,10 @@
*/
void
GNUNET_REGEX_ipv6toregex (const struct in6_addr *ipv6,
- const unsigned int prefixlen, char *rxstr)
+ unsigned int prefixlen, char *rxstr)
{
iptobinstr (AF_INET6, ipv6, rxstr);
rxstr[prefixlen] = '\0';
- strcat (rxstr, "(0|1)*");
+ if (prefixlen < 128)
+ strcat (rxstr, "(0|1)+");
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r24033 - gnunet/src/regex,
gnunet <=