Changeset: dedb4c1b64ce for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=dedb4c1b64ce
Added Files:
        sql/test/BugTracker-2015/Tests/string-to-inet.Bug-3666.sql
        sql/test/BugTracker-2015/Tests/string-to-inet.Bug-3666.stable.err
        sql/test/BugTracker-2015/Tests/string-to-inet.Bug-3666.stable.out
Modified Files:
        clients/Tests/exports.stable.out
        monetdb5/modules/atoms/inet.c
        sql/test/BugTracker-2015/Tests/All
Branch: Oct2014
Log Message:

Do not modify input arguments.
This fixes bug 3666.


diffs (truncated from 498 to 300 lines):

diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -1291,33 +1291,33 @@ int IDfromString(str src, int *len, iden
 str IDprelude(void *ret);
 int IDtoString(str *retval, int *len, identifier handle);
 str ILIKEsubjoin(bat *r1, bat *r2, const bat *lid, const bat *rid, const bat 
*slid, const bat *srid, const str *esc);
-str INET_comp_CS(bit *retval, inet *val1, inet *val2);
-str INET_comp_CSE(bit *retval, inet *val1, inet *val2);
-str INET_comp_CW(bit *retval, inet *val1, inet *val2);
-str INET_comp_CWE(bit *retval, inet *val1, inet *val2);
-str INET_comp_EQ(bit *retval, inet *val1, inet *val2);
-str INET_comp_GE(bit *retval, inet *val1, inet *val2);
-str INET_comp_GT(bit *retval, inet *val1, inet *val2);
-str INET_comp_LE(bit *retval, inet *val1, inet *val2);
-str INET_comp_LT(bit *retval, inet *val1, inet *val2);
-str INET_comp_NEQ(bit *retval, inet *val1, inet *val2);
+str INET_comp_CS(bit *retval, const inet *val1, const inet *val2);
+str INET_comp_CSE(bit *retval, const inet *val1, const inet *val2);
+str INET_comp_CW(bit *retval, const inet *val1, const inet *val2);
+str INET_comp_CWE(bit *retval, const inet *val1, const inet *val2);
+str INET_comp_EQ(bit *retval, const inet *val1, const inet *val2);
+str INET_comp_GE(bit *retval, const inet *val1, const inet *val2);
+str INET_comp_GT(bit *retval, const inet *val1, const inet *val2);
+str INET_comp_LE(bit *retval, const inet *val1, const inet *val2);
+str INET_comp_LT(bit *retval, const inet *val1, const inet *val2);
+str INET_comp_NEQ(bit *retval, const inet *val1, const inet *val2);
 str INET_fromstr(inet *ret, str *s);
-str INET_inet(inet *d, inet *s);
-str INET_isnil(bit *retval, inet *val);
-str INETabbrev(str *retval, inet *val);
-str INETbroadcast(inet *retval, inet *val);
-int INETcompare(inet *l, inet *r);
-int INETfromString(str src, int *len, inet **retval);
-str INEThost(str *retval, inet *val);
-str INEThostmask(inet *retval, inet *val);
-str INETmasklen(int *retval, inet *val);
-str INETnetmask(inet *retval, inet *val);
-str INETnetwork(inet *retval, inet *val);
+str INET_inet(inet *d, const inet *s);
+str INET_isnil(bit *retval, const inet *val);
+str INETabbrev(str *retval, const inet *val);
+str INETbroadcast(inet *retval, const inet *val);
+int INETcompare(const inet *l, const inet *r);
+int INETfromString(const char *src, int *len, inet **retval);
+str INEThost(str *retval, const inet *val);
+str INEThostmask(inet *retval, const inet *val);
+str INETmasklen(int *retval, const inet *val);
+str INETnetmask(inet *retval, const inet *val);
+str INETnetwork(inet *retval, const inet *val);
 str INETnew(inet *retval, str *in);
 inet *INETnull(void);
-str INETsetmasklen(inet *retval, inet *val, int *mask);
-str INETtext(str *retval, inet *val);
-int INETtoString(str *retval, int *len, inet *handle);
+str INETsetmasklen(inet *retval, const inet *val, const int *mask);
+str INETtext(str *retval, const inet *val);
+int INETtoString(str *retval, int *len, const inet *handle);
 str INSPECTatom_names(bat *ret);
 str INSPECTatom_sizes(bat *ret);
 str INSPECTatom_sup_names(bat *ret);
diff --git a/monetdb5/modules/atoms/inet.c b/monetdb5/modules/atoms/inet.c
--- a/monetdb5/modules/atoms/inet.c
+++ b/monetdb5/modules/atoms/inet.c
@@ -67,31 +67,31 @@ typedef struct _inet {
 #define inet_export extern
 #endif
 
-inet_export int INETfromString(str src, int *len, inet **retval);
-inet_export int INETtoString(str *retval, int *len, inet *handle);
-inet_export int INETcompare(inet *l, inet *r);
-inet_export str INETnew(inet * retval, str *in);
-inet_export str INET_isnil(bit *retval, inet * val);
-inet_export str INET_comp_EQ(bit *retval, inet * val1, inet *val2);
-inet_export str INET_comp_NEQ(bit *retval, inet * val1, inet *val2);
-inet_export str INET_comp_LT(bit *retval, inet * val1, inet *val2);
-inet_export str INET_comp_GT(bit *retval, inet * val1, inet *val2);
-inet_export str INET_comp_LE(bit *retval, inet * val1, inet *val2);
-inet_export str INET_comp_GE(bit *retval, inet * val1, inet *val2);
-inet_export str INET_comp_CW(bit *retval, inet * val1, inet *val2);
-inet_export str INET_comp_CWE(bit *retval, inet * val1, inet *val2);
-inet_export str INET_comp_CS(bit *retval, inet * val1, inet *val2);
-inet_export str INET_comp_CSE(bit *retval, inet * val1, inet *val2);
-inet_export str INETbroadcast(inet * retval, inet *val);
-inet_export str INEThost(str *retval, inet *val);
-inet_export str INETmasklen(int *retval, inet *val);
-inet_export str INETsetmasklen(inet *retval, inet *val, int *mask);
-inet_export str INETnetmask(inet *retval, inet *val);
-inet_export str INEThostmask(inet *retval, inet *val);
-inet_export str INETnetwork(inet *retval, inet *val);
-inet_export str INETtext(str *retval, inet *val);
-inet_export str INETabbrev(str *retval, inet *val);
-inet_export str INET_inet(inet *d, inet *s);
+inet_export int INETfromString(const char *src, int *len, inet **retval);
+inet_export int INETtoString(str *retval, int *len, const inet *handle);
+inet_export int INETcompare(const inet *l, const inet *r);
+inet_export str INETnew(inet *retval, str *in);
+inet_export str INET_isnil(bit *retval, const inet *val);
+inet_export str INET_comp_EQ(bit *retval, const inet *val1, const inet *val2);
+inet_export str INET_comp_NEQ(bit *retval, const inet *val1, const inet *val2);
+inet_export str INET_comp_LT(bit *retval, const inet *val1, const inet *val2);
+inet_export str INET_comp_GT(bit *retval, const inet *val1, const inet *val2);
+inet_export str INET_comp_LE(bit *retval, const inet *val1, const inet *val2);
+inet_export str INET_comp_GE(bit *retval, const inet *val1, const inet *val2);
+inet_export str INET_comp_CW(bit *retval, const inet *val1, const inet *val2);
+inet_export str INET_comp_CWE(bit *retval, const inet *val1, const inet *val2);
+inet_export str INET_comp_CS(bit *retval, const inet *val1, const inet *val2);
+inet_export str INET_comp_CSE(bit *retval, const inet *val1, const inet *val2);
+inet_export str INETbroadcast(inet *retval, const inet *val);
+inet_export str INEThost(str *retval, const inet *val);
+inet_export str INETmasklen(int *retval, const inet *val);
+inet_export str INETsetmasklen(inet *retval, const inet *val, const int *mask);
+inet_export str INETnetmask(inet *retval, const inet *val);
+inet_export str INEThostmask(inet *retval, const inet *val);
+inet_export str INETnetwork(inet *retval, const inet *val);
+inet_export str INETtext(str *retval, const inet *val);
+inet_export str INETabbrev(str *retval, const inet *val);
+inet_export str INET_inet(inet *d, const inet *s);
 inet_export str INET_fromstr(inet *ret, str *s);
 inet_export inet *INETnull(void);
 
@@ -104,7 +104,7 @@ static inet inet_nil = {0,0,0,0,0,0,0,1}
  * Returns the number of chars read
  */
 int
-INETfromString(str src, int *len, inet **retval)
+INETfromString(const char *src, int *len, inet **retval)
 {
        int i, last, type;
        long parse;
@@ -133,9 +133,8 @@ INETfromString(str src, int *len, inet *
        for (i = 0; src[i] != '\0'; i++) {
                if (src[i] == '.' || src[i] == '/') {
                        sep = src[i];
-                       src[i] = '\0';
                        parse = strtol(src + last, &endptr, 10);
-                       if (*endptr != '\0' || last >= i) {
+                       if (*endptr != sep || last >= i) {
                                GDKerror("Error while parsing, unexpected 
string '%s'", endptr);
                                goto error;
                        }
@@ -219,9 +218,9 @@ error: /* catch exception: return NULL *
  * Returns the length of the string
  */
 int
-INETtoString(str *retval, int *len, inet *handle)
+INETtoString(str *retval, int *len, const inet *handle)
 {
-       inet *value = (inet *)handle;
+       const inet *value = (const inet *)handle;
 
        if (*len < 19) {
                if (*retval != NULL)
@@ -259,7 +258,7 @@ INETnew(inet *retval, str *in)
 }
 
 int
-INETcompare(inet *l, inet *r)
+INETcompare(const inet *l, const inet *r)
 {
        bit res = 0;
        if (in_isnil(l))
@@ -280,7 +279,7 @@ INETcompare(inet *l, inet *r)
  * Returns whether val represents a nil inet value
  */
 str
-INET_isnil(bit *retval, inet * val)
+INET_isnil(bit *retval, const inet *val)
 {
        *retval = in_isnil(val);
 
@@ -290,7 +289,7 @@ INET_isnil(bit *retval, inet * val)
  * Returns whether val1 and val2 are equal.
  */
 str
-INET_comp_EQ(bit *retval, inet * val1, inet * val2)
+INET_comp_EQ(bit *retval, const inet *val1, const inet *val2)
 {
        if (in_isnil(val1) || in_isnil(val2)) {
                *retval = bit_nil;
@@ -308,7 +307,7 @@ INET_comp_EQ(bit *retval, inet * val1, i
  * Returns whether val1 and val2 are not equal.
  */
 str
-INET_comp_NEQ(bit *retval, inet * val1, inet * val2)
+INET_comp_NEQ(bit *retval, const inet *val1, const inet *val2)
 {
        if (in_isnil(val1) || in_isnil(val2)) {
                *retval = bit_nil;
@@ -326,7 +325,7 @@ INET_comp_NEQ(bit *retval, inet * val1, 
  * Returns whether val1 is smaller than val2.
  */
 str
-INET_comp_LT(bit *retval, inet * val1, inet * val2)
+INET_comp_LT(bit *retval, const inet *val1, const inet *val2)
 {
        if (in_isnil(val1) || in_isnil(val2)) {
                *retval = bit_nil;
@@ -358,7 +357,7 @@ INET_comp_LT(bit *retval, inet * val1, i
  * Returns whether val1 is greater than val2.
  */
 str
-INET_comp_GT(bit *retval, inet * val1, inet * val2)
+INET_comp_GT(bit *retval, const inet *val1, const inet *val2)
 {
        return (INET_comp_LT(retval, val2, val1));
 }
@@ -366,7 +365,7 @@ INET_comp_GT(bit *retval, inet * val1, i
  * Returns whether val1 is smaller than or equal to val2.
  */
 str
-INET_comp_LE(bit *retval, inet * val1, inet * val2)
+INET_comp_LE(bit *retval, const inet *val1, const inet *val2)
 {
        bit ret;
 
@@ -381,7 +380,7 @@ INET_comp_LE(bit *retval, inet * val1, i
  * Returns whether val1 is smaller than or equal to val2.
  */
 str
-INET_comp_GE(bit *retval, inet * val1, inet * val2)
+INET_comp_GE(bit *retval, const inet *val1, const inet *val2)
 {
        bit ret;
 
@@ -398,7 +397,7 @@ INET_comp_GE(bit *retval, inet * val1, i
  * Returns whether val1 is contained within val2
  */
 str
-INET_comp_CW(bit *retval, inet * val1, inet * val2)
+INET_comp_CW(bit *retval, const inet *val1, const inet *val2)
 {
        if (in_isnil(val1) || in_isnil(val2)) {
                *retval = bit_nil;
@@ -457,7 +456,7 @@ INET_comp_CW(bit *retval, inet * val1, i
  * Returns whether val1 is contained within or equal to val2
  */
 str
-INET_comp_CWE(bit *retval, inet * val1, inet * val2)
+INET_comp_CWE(bit *retval, const inet *val1, const inet *val2)
 {
        bit ret;
 
@@ -473,7 +472,7 @@ INET_comp_CWE(bit *retval, inet * val1, 
  * Returns whether val1 is contains val2
  */
 str
-INET_comp_CS(bit *retval, inet * val1, inet * val2)
+INET_comp_CS(bit *retval, const inet *val1, const inet *val2)
 {
        /* swap the input arguments and call the contained within function */
        return (INET_comp_CW(retval, val2, val1));
@@ -482,7 +481,7 @@ INET_comp_CS(bit *retval, inet * val1, i
  * Returns whether val1 contains or is equal to val2
  */
 str
-INET_comp_CSE(bit *retval, inet * val1, inet * val2)
+INET_comp_CSE(bit *retval, const inet *val1, const inet *val2)
 {
        /* swap the input arguments and call the contained within function */
        return (INET_comp_CWE(retval, val2, val1));
@@ -495,7 +494,7 @@ INET_comp_CSE(bit *retval, inet * val1, 
  * If the subnet mask is 32, the given input inet is returned.
  */
 str
-INETbroadcast(inet * retval, inet * val)
+INETbroadcast(inet *retval, const inet *val)
 {
        *retval = *val;
        if (!in_isnil(val) && val->mask != 32) {
@@ -540,7 +539,7 @@ INETbroadcast(inet * retval, inet * val)
  * this function never returns the netmask length.
  */
 str
-INEThost(str *retval, inet * val)
+INEThost(str *retval, const inet *val)
 {
        str ip;
 
@@ -559,7 +558,7 @@ INEThost(str *retval, inet * val)
  * Extract netmask length.
  */
 str
-INETmasklen(int *retval, inet * val)
+INETmasklen(int *retval, const inet *val)
 {
        if (in_isnil(val)) {
                *retval = int_nil;
@@ -572,7 +571,7 @@ INETmasklen(int *retval, inet * val)
  * Set netmask length for inet value.
  */
 str
-INETsetmasklen(inet * retval, inet * val, int *mask)
+INETsetmasklen(inet *retval, const inet *val, const int *mask)
 {
        if (*mask < 0 || *mask > 32)
                throw(ILLARG, "inet.setmask", "Illegal netmask length value: 
%d", *mask);
@@ -587,7 +586,7 @@ INETsetmasklen(inet * retval, inet * val
  * Construct netmask for network.
  */
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to