Changeset: 90933e6c6b36 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/90933e6c6b36
Modified Files:
        monetdb5/modules/atoms/str.c
        monetdb5/modules/kernel/batstr.c
        monetdb5/modules/mal/pcre.c
        monetdb5/modules/mal/txtsim.c
        sql/backends/monet5/UDF/udf/udf.c
        sql/backends/monet5/UDF/udf/udf.h
        sql/backends/monet5/sql_user.c
        sql/backends/monet5/sql_user.h
Branch: Dec2023
Log Message:

Properly use const for str parameters to C stubs for MAL functions.
const str *val (which was used in many places) is not the same as const
* const *val (which is what it really is).
The pointer itself can be changed (i.e. val), but not *val and not
**val, since they belong to the caller.
This also fixes #7509.  But Lucas, please take a closer look.


diffs (truncated from 982 to 300 lines):

diff --git a/monetdb5/modules/atoms/str.c b/monetdb5/modules/atoms/str.c
--- a/monetdb5/modules/atoms/str.c
+++ b/monetdb5/modules/atoms/str.c
@@ -3488,7 +3488,7 @@ STRlike(const char *s, const char *pat, 
 }
 
 static str
-STRlikewrap3(bit *ret, const str *s, const str *pat, const str *esc)
+STRlikewrap3(bit *ret, const char *const *s, const char *const *pat, const 
char *const *esc)
 {
        if (strNil(*s) || strNil(*pat) || strNil(*esc))
                *ret = bit_nil;
@@ -3498,7 +3498,7 @@ STRlikewrap3(bit *ret, const str *s, con
 }
 
 static str
-STRlikewrap(bit *ret, const str *s, const str *pat)
+STRlikewrap(bit *ret, const char *const *s, const char *const *pat)
 {
        if (strNil(*s) || strNil(*pat))
                *ret = bit_nil;
@@ -3508,7 +3508,7 @@ STRlikewrap(bit *ret, const str *s, cons
 }
 
 static str
-STRtostr(str *res, const str *src)
+STRtostr(str *res, const char *const *src)
 {
        if (*src == 0)
                *res = GDKstrdup(str_nil);
@@ -3520,7 +3520,7 @@ STRtostr(str *res, const str *src)
 }
 
 static str
-STRLength(int *res, const str *arg1)
+STRLength(int *res, const char *const *arg1)
 {
        const char *s = *arg1;
 
@@ -3529,7 +3529,7 @@ STRLength(int *res, const str *arg1)
 }
 
 static str
-STRBytes(int *res, const str *arg1)
+STRBytes(int *res, const char *const *arg1)
 {
        const char *s = *arg1;
 
@@ -3553,7 +3553,7 @@ str_tail(str *buf, size_t *buflen, const
 }
 
 static str
-STRTail(str *res, const str *arg1, const int *offset)
+STRTail(str *res, const char *const *arg1, const int *offset)
 {
        str buf = NULL, msg = MAL_SUCCEED;
        const char *s = *arg1;
@@ -3609,7 +3609,7 @@ str_Sub_String(str *buf, size_t *buflen,
 }
 
 static str
-STRSubString(str *res, const str *arg1, const int *offset, const int *length)
+STRSubString(str *res, const char *const *arg1, const int *offset, const int 
*length)
 {
        str buf = NULL, msg = MAL_SUCCEED;
        const char *s = *arg1;
@@ -3698,7 +3698,7 @@ str_wchr_at(int *res, const char *s, int
 }
 
 static str
-STRWChrAt(int *res, const str *arg1, const int *at)
+STRWChrAt(int *res, const char *const *arg1, const int *at)
 {
        return str_wchr_at(res, *arg1, *at);
 }
@@ -3711,7 +3711,7 @@ str_lower(str *buf, size_t *buflen, cons
 }
 
 static inline str
-STRlower(str *res, const str *arg1)
+STRlower(str *res, const char *const *arg1)
 {
        str buf = NULL, msg = MAL_SUCCEED;
        const char *s = *arg1;
@@ -3752,7 +3752,7 @@ str_upper(str *buf, size_t *buflen, cons
 }
 
 static str
-STRupper(str *res, const str *arg1)
+STRupper(str *res, const char *const *arg1)
 {
        str buf = NULL, msg = MAL_SUCCEED;
        const char *s = *arg1;
@@ -3948,10 +3948,11 @@ STRstr_search(Client cntxt, MalBlkPtr mb
        (void) cntxt;
        (void) mb;
        bit *res = getArgReference(stk, pci, 0);
-       const str *haystack = getArgReference(stk, pci, 1),
-               *needle = getArgReference(stk, pci, 2);
+       const char *const *haystack = getArgReference(stk, pci, 1);
+       const char *const *needle = getArgReference(stk, pci, 2);
        bit icase = pci->argc == 4 && *getArgReference_bit(stk, pci, 3);
-       str s = *haystack, h = *needle, msg = MAL_SUCCEED;
+       const char *s = *haystack, *h = *needle;
+       char *msg = MAL_SUCCEED;
        if (strNil(s) || strNil(h)) {
                *res = bit_nil;
        } else {
@@ -4009,10 +4010,11 @@ STRrevstr_search(Client cntxt, MalBlkPtr
        (void) cntxt;
        (void) mb;
        bit *res = getArgReference(stk, pci, 0);
-       const str *haystack = getArgReference(stk, pci, 1);
-       const str *needle = getArgReference(stk, pci, 2);
+       const char *const *haystack = getArgReference(stk, pci, 1);
+       const char *const *needle = getArgReference(stk, pci, 2);
        bit icase = pci->argc == 4 && *getArgReference_bit(stk, pci, 3);
-       str s = *haystack, h = *needle, msg = MAL_SUCCEED;
+       const char *s = *haystack, *h = *needle;
+       char *msg = MAL_SUCCEED;
        if (strNil(s) || strNil(h)) {
                *res = bit_nil;
        } else {
@@ -4181,7 +4183,7 @@ str_strip(str *buf, size_t *buflen, cons
 
 /* remove all whitespace from either side of arg1 */
 static str
-STRStrip(str *res, const str *arg1)
+STRStrip(str *res, const char *const *arg1)
 {
        str buf = NULL, msg = MAL_SUCCEED;
        const char *s = *arg1;
@@ -4222,7 +4224,7 @@ str_ltrim(str *buf, size_t *buflen, cons
 
 /* remove all whitespace from the start (left) of arg1 */
 static str
-STRLtrim(str *res, const str *arg1)
+STRLtrim(str *res, const char *const *arg1)
 {
        str buf = NULL, msg = MAL_SUCCEED;
        const char *s = *arg1;
@@ -4263,7 +4265,7 @@ str_rtrim(str *buf, size_t *buflen, cons
 
 /* remove all whitespace from the end (right) of arg1 */
 static str
-STRRtrim(str *res, const str *arg1)
+STRRtrim(str *res, const char *const *arg1)
 {
        str buf = NULL, msg = MAL_SUCCEED;
        const char *s = *arg1;
@@ -4343,7 +4345,7 @@ str_strip2(str *buf, size_t *buflen, con
 /* remove the longest string containing only characters from arg2 from
  * either side of arg1 */
 static str
-STRStrip2(str *res, const str *arg1, const str *arg2)
+STRStrip2(str *res, const char *const *arg1, const char *const *arg2)
 {
        str buf = NULL, msg = MAL_SUCCEED;
        const char *s = *arg1, *s2 = *arg2;
@@ -4397,7 +4399,7 @@ str_ltrim2(str *buf, size_t *buflen, con
 /* remove the longest string containing only characters from arg2 from
  * the start (left) of arg1 */
 static str
-STRLtrim2(str *res, const str *arg1, const str *arg2)
+STRLtrim2(str *res, const char *const *arg1, const char *const *arg2)
 {
        str buf = NULL, msg = MAL_SUCCEED;
        const char *s = *arg1, *s2 = *arg2;
@@ -4451,7 +4453,7 @@ str_rtrim2(str *buf, size_t *buflen, con
 /* remove the longest string containing only characters from arg2 from
  * the end (right) of arg1 */
 static str
-STRRtrim2(str *res, const str *arg1, const str *arg2)
+STRRtrim2(str *res, const char *const *arg1, const char *const *arg2)
 {
        str buf = NULL, msg = MAL_SUCCEED;
        const char *s = *arg1, *s2 = *arg2;
@@ -4551,7 +4553,7 @@ str_lpad(str *buf, size_t *buflen, const
  * Result: '   hi'
  */
 static str
-STRLpad(str *res, const str *arg1, const int *len)
+STRLpad(str *res, const char *const *arg1, const int *len)
 {
        str buf = NULL, msg = MAL_SUCCEED;
        const char *s = *arg1;
@@ -4592,7 +4594,7 @@ str_rpad(str *buf, size_t *buflen, const
  * Result: 'hi   '
  */
 static str
-STRRpad(str *res, const str *arg1, const int *len)
+STRRpad(str *res, const char *const *arg1, const int *len)
 {
        str buf = NULL, msg = MAL_SUCCEED;
        const char *s = *arg1;
@@ -4633,7 +4635,7 @@ str_lpad3(str *buf, size_t *buflen, cons
  * Result: xyxhi
  */
 static str
-STRLpad3(str *res, const str *arg1, const int *len, const str *arg2)
+STRLpad3(str *res, const char *const *arg1, const int *len, const char *const 
*arg2)
 {
        str buf = NULL, msg = MAL_SUCCEED;
        const char *s = *arg1, *s2 = *arg2;
@@ -4675,7 +4677,7 @@ str_rpad3(str *buf, size_t *buflen, cons
  * Result: hixyx
  */
 static str
-STRRpad3(str *res, const str *arg1, const int *len, const str *arg2)
+STRRpad3(str *res, const char *const *arg1, const int *len, const char *const 
*arg2)
 {
        str buf = NULL, msg = MAL_SUCCEED;
        const char *s = *arg1, *s2 = *arg2;
@@ -4748,7 +4750,7 @@ str_substitute(str *buf, size_t *buflen,
 }
 
 static str
-STRSubstitute(str *res, const str *arg1, const str *arg2, const str *arg3,
+STRSubstitute(str *res, const char *const *arg1, const char *const *arg2, 
const char *const *arg3,
                          const bit *g)
 {
        str buf = NULL, msg = MAL_SUCCEED;
@@ -4777,7 +4779,7 @@ STRSubstitute(str *res, const str *arg1,
 }
 
 static str
-STRascii(int *ret, const str *s)
+STRascii(int *ret, const char *const *s)
 {
        return str_wchr_at(ret, *s, 0);
 }
@@ -4792,7 +4794,7 @@ str_substring_tail(str *buf, size_t *buf
 }
 
 static str
-STRsubstringTail(str *res, const str *arg1, const int *start)
+STRsubstringTail(str *res, const char *const *arg1, const int *start)
 {
        str buf = NULL, msg = MAL_SUCCEED;
        const char *s = *arg1;
@@ -4830,7 +4832,7 @@ str_sub_string(str *buf, size_t *buflen,
 }
 
 static str
-STRsubstring(str *res, const str *arg1, const int *start, const int *ll)
+STRsubstring(str *res, const char *const *arg1, const int *start, const int 
*ll)
 {
        str buf = NULL, msg = MAL_SUCCEED;
        const char *s = *arg1;
@@ -4859,7 +4861,7 @@ STRsubstring(str *res, const str *arg1, 
 }
 
 static str
-STRprefix(str *res, const str *arg1, const int *ll)
+STRprefix(str *res, const char *const *arg1, const int *ll)
 {
        str buf = NULL, msg = MAL_SUCCEED;
        const char *s = *arg1;
@@ -4895,7 +4897,7 @@ str_suffix(str *buf, size_t *buflen, con
 }
 
 static str
-STRsuffix(str *res, const str *arg1, const int *ll)
+STRsuffix(str *res, const char *const *arg1, const int *ll)
 {
        str buf = NULL, msg = MAL_SUCCEED;
        const char *s = *arg1;
@@ -4936,7 +4938,7 @@ str_locate2(const char *needle, const ch
 }
 
 static str
-STRlocate3(int *ret, const str *needle, const str *haystack, const int *start)
+STRlocate3(int *ret, const char *const *needle, const char *const *haystack, 
const int *start)
 {
        const char *s = *needle, *s2 = *haystack;
        int st = *start;
@@ -4948,7 +4950,7 @@ STRlocate3(int *ret, const str *needle, 
 }
 
 static str
-STRlocate(int *ret, const str *needle, const str *haystack)
+STRlocate(int *ret, const char *const *needle, const char *const *haystack)
 {
        const char *s = *needle, *s2 = *haystack;
 
@@ -4989,8 +4991,8 @@ str_insert(str *buf, size_t *buflen, con
 }
 
 static str
-STRinsert(str *res, const str *input, const int *start, const int *nchars,
-                 const str *input2)
+STRinsert(str *res, const char *const *input, const int *start, const int 
*nchars,
+                 const char *const *input2)
 {
        str buf = NULL, msg = MAL_SUCCEED;
        const char *s = *input, *s2 = *input2;
@@ -5019,7 +5021,7 @@ STRinsert(str *res, const str *input, co
 }
 
 static str
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to