Changeset: c040613f6d7a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c040613f6d7a
Modified Files:
        gdk/gdk_atoms.c
Branch: inet4+6
Log Message:

Accept 32 hex digits without colon for IPv6 address.


diffs (27 lines):

diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c
--- a/gdk/gdk_atoms.c
+++ b/gdk/gdk_atoms.c
@@ -1514,6 +1514,23 @@ INET6fromString(const char *svalue, size
                        GDKerror("Invalid IPv6 address.");
                        goto bailout;
                }
+       } else if (strlen(s) == 32 && strspn(s, "0123456789abcdefABCDEF") == 
32) {
+               /* special case: 32 hex digits without [ ] */
+               for (int i = 0; i < 8; i++) {
+                       uint16_t val = 0;
+                       for (int j = 12; j >= 0; j -= 4) {
+                               if ('0' <= *s && *s <= '9')
+                                       val |= (*s - '0') << j;
+                               else if ('a' <= *s && *s <= 'f')
+                                       val |= (*s - 'a' + 10) << j;
+                               else if ('A' <= *s && *s <= 'F')
+                                       val |= (*s - 'A' + 10) << j;
+                               s++;
+                       }
+                       i6.oct[i] = val;
+               }
+               **retval = i6;
+               return (ssize_t) (s - svalue);
        }
        int dcolpos = -1;
        int i;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to