Changeset: 1f12ee92f212 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/1f12ee92f212
Modified Files:
        monetdb5/modules/atoms/str.c
        monetdb5/modules/atoms/str.h
        monetdb5/modules/kernel/batstr.c
        monetdb5/modules/mal/txtsim.c
        sql/backends/monet5/UDF/udf/udf.c
        sql/backends/monet5/sql_cast.c
        sql/backends/monet5/sql_result.c
        sql/backends/monet5/sql_result.h
Branch: Jan2022
Log Message:

Use more const


diffs (truncated from 2228 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
@@ -3355,32 +3355,30 @@ STRtostr(str *res, const str *src)
 static str
 STRLength(int *res, const str *arg1)
 {
-       str s = *arg1;
+       const char *s = *arg1;
 
        *res = strNil(s) ? int_nil : UTF8_strlen(s);
        return MAL_SUCCEED;
 }
 
-
-
 static str
 STRBytes(int *res, const str *arg1)
 {
-       str s = *arg1;
+       const char *s = *arg1;
 
        *res = strNil(s) ? int_nil : str_strlen(s);
        return MAL_SUCCEED;
 }
 
 str
-str_tail(str *buf, size_t *buflen, str s, int off)
+str_tail(str *buf, size_t *buflen, const char *s, int off)
 {
        if (off < 0) {
                off += UTF8_strlen(s);
                if (off < 0)
                        off = 0;
        }
-       str tail = UTF8_strtail(s, off);
+       char *tail = UTF8_strtail(s, off);
        size_t nextlen = strlen(tail) + 1;
        CHECK_STR_BUFFER_LENGTH(buf, buflen, nextlen, "str.tail");
        strcpy(*buf, tail);
@@ -3390,7 +3388,8 @@ str_tail(str *buf, size_t *buflen, str s
 static str
 STRTail(str *res, const str *arg1, const int *offset)
 {
-       str buf = NULL, msg = MAL_SUCCEED, s = *arg1;
+       str buf = NULL, msg = MAL_SUCCEED;
+       const char *s = *arg1;
        int off = *offset;
 
        if (strNil(s) || is_int_nil(off)) {
@@ -3415,7 +3414,7 @@ STRTail(str *res, const str *arg1, const
 }
 
 str
-str_Sub_String(str *buf, size_t *buflen, str s, int off, int l)
+str_Sub_String(str *buf, size_t *buflen, const char *s, int off, int l)
 {
        size_t len;
 
@@ -3441,7 +3440,8 @@ str_Sub_String(str *buf, size_t *buflen,
 static str
 STRSubString(str *res, const str *arg1, const int *offset, const int *length)
 {
-       str buf = NULL, msg = MAL_SUCCEED, s = *arg1;
+       str buf = NULL, msg = MAL_SUCCEED;
+       const char *s = *arg1;
        int off = *offset, len = *length;
 
        if (strNil(s) || is_int_nil(off) || is_int_nil(len)) {
@@ -3506,7 +3506,7 @@ STRFromWChr(str *res, const int *c)
 
 /* return the Unicode code point of arg1 at position at */
 str
-str_wchr_at(int *res, str s, int at)
+str_wchr_at(int *res, const char *s, int at)
 {
        /* 64bit: should have lng arg */
        if (strNil(s) || is_int_nil(at) || at < 0) {
@@ -3532,7 +3532,7 @@ STRWChrAt(int *res, const str *arg1, con
 
 /* returns whether arg1 starts with arg2 */
 bit
-str_is_prefix(str s, str prefix)
+str_is_prefix(const char *s, const char *prefix)
 {
        return strncmp(s, prefix, strlen(prefix)) == 0;
 }
@@ -3540,14 +3540,14 @@ str_is_prefix(str s, str prefix)
 static str
 STRPrefix(bit *res, const str *arg1, const str *arg2)
 {
-       str s = *arg1, prefix = *arg2;
+       const char *s = *arg1, *prefix = *arg2;
 
        *res = (strNil(s) || strNil(prefix)) ? bit_nil : str_is_prefix(s, 
prefix);
        return MAL_SUCCEED;
 }
 
 bit
-str_is_suffix(str s, str suffix)
+str_is_suffix(const char *s, const char *suffix)
 {
        size_t sl = strlen(s), sul = strlen(suffix);
 
@@ -3561,14 +3561,14 @@ str_is_suffix(str s, str suffix)
 static str
 STRSuffix(bit *res, const str *arg1, const str *arg2)
 {
-       str s = *arg1, suffix = *arg2;
+       const char *s = *arg1, *suffix = *arg2;
 
        *res = (strNil(s) || strNil(suffix)) ? bit_nil : str_is_suffix(s, 
suffix);
        return MAL_SUCCEED;
 }
 
 str
-str_lower(str *buf, size_t *buflen, str s)
+str_lower(str *buf, size_t *buflen, const char *s)
 {
        return convertCase(UTF8_toLowerFrom, UTF8_toLowerTo, buf, buflen, s, 
"str.lower");
 }
@@ -3576,7 +3576,8 @@ str_lower(str *buf, size_t *buflen, str 
 static str
 STRLower(str *res, const str *arg1)
 {
-       str buf = NULL, msg = MAL_SUCCEED, s = *arg1;
+       str buf = NULL, msg = MAL_SUCCEED;
+       const char *s = *arg1;
 
        if (strNil(s)) {
                *res = GDKstrdup(str_nil);
@@ -3606,7 +3607,7 @@ STRLower(str *res, const str *arg1)
 }
 
 str
-str_upper(str *buf, size_t *buflen, str s)
+str_upper(str *buf, size_t *buflen, const char *s)
 {
        return convertCase(UTF8_toUpperFrom, UTF8_toUpperTo, buf, buflen, s, 
"str.upper");
 }
@@ -3614,7 +3615,8 @@ str_upper(str *buf, size_t *buflen, str 
 static str
 STRUpper(str *res, const str *arg1)
 {
-       str buf = NULL, msg = MAL_SUCCEED, s = *arg1;
+       str buf = NULL, msg = MAL_SUCCEED;
+       const char *s = *arg1;
 
        if (strNil(s)) {
                *res = GDKstrdup(str_nil);
@@ -3644,7 +3646,7 @@ STRUpper(str *res, const str *arg1)
 }
 
 int
-str_search(str s, str s2)
+str_search(const char *s, const char *s2)
 {
        /* 64bit: should return lng */
        if ((s2 = strstr(s, s2)) != NULL)
@@ -3657,14 +3659,14 @@ str_search(str s, str s2)
 static str
 STRstrSearch(int *res, const str *haystack, const str *needle)
 {
-       str s = *haystack, s2 = *needle;
+       const char *s = *haystack, *s2 = *needle;
 
        *res = (strNil(s) || strNil(s2)) ? int_nil : str_search(s, s2);
        return MAL_SUCCEED;
 }
 
 int
-str_reverse_str_search(str s, str s2)
+str_reverse_str_search(const char *s, const char *s2)
 {
        /* 64bit: should return lng */
        size_t len = strlen(s), slen = strlen(s2);
@@ -3686,14 +3688,14 @@ str_reverse_str_search(str s, str s2)
 static str
 STRReverseStrSearch(int *res, const str *arg1, const str *arg2)
 {
-       str s = *arg1, s2 = *arg2;
+       const char *s = *arg1, *s2 = *arg2;
 
        *res = (strNil(s) || strNil(s2)) ? int_nil : str_reverse_str_search(s, 
s2);
        return MAL_SUCCEED;
 }
 
 str
-str_splitpart(str *buf, size_t *buflen, str s, str s2, int f)
+str_splitpart(str *buf, size_t *buflen, const char *s, const char *s2, int f)
 {
        size_t len;
        char *p = NULL;
@@ -3729,7 +3731,8 @@ str_splitpart(str *buf, size_t *buflen, 
 static str
 STRsplitpart(str *res, str *haystack, str *needle, int *field)
 {
-       str buf = NULL, msg = MAL_SUCCEED, s = *haystack, s2 = *needle;
+       str buf = NULL, msg = MAL_SUCCEED;
+       const char *s = *haystack, *s2 = *needle;
        int f = *field;
 
        if (strNil(s) || strNil(s2) || is_int_nil(f)) {
@@ -3828,7 +3831,7 @@ const int whitespace[] = {
 #define NSPACES                (sizeof(whitespace) / sizeof(whitespace[0]))
 
 str
-str_strip(str *buf, size_t *buflen, str s)
+str_strip(str *buf, size_t *buflen, const char *s)
 {
        size_t len = strlen(s);
        size_t n = lstrip(s, len, whitespace, NSPACES);
@@ -3846,7 +3849,8 @@ str_strip(str *buf, size_t *buflen, str 
 static str
 STRStrip(str *res, const str *arg1)
 {
-       str buf = NULL, msg = MAL_SUCCEED, s = *arg1;
+       str buf = NULL, msg = MAL_SUCCEED;
+       const char *s = *arg1;
 
        if (strNil(s)) {
                *res = GDKstrdup(str_nil);
@@ -3870,7 +3874,7 @@ STRStrip(str *res, const str *arg1)
 }
 
 str
-str_ltrim(str *buf, size_t *buflen, str s)
+str_ltrim(str *buf, size_t *buflen, const char *s)
 {
        size_t len = strlen(s);
        size_t n = lstrip(s, len, whitespace, NSPACES);
@@ -3885,7 +3889,8 @@ str_ltrim(str *buf, size_t *buflen, str 
 static str
 STRLtrim(str *res, const str *arg1)
 {
-       str buf = NULL, msg = MAL_SUCCEED, s = *arg1;
+       str buf = NULL, msg = MAL_SUCCEED;
+       const char *s = *arg1;
 
        if (strNil(s)) {
                *res = GDKstrdup(str_nil);
@@ -3909,7 +3914,7 @@ STRLtrim(str *res, const str *arg1)
 }
 
 str
-str_rtrim(str *buf, size_t *buflen, str s)
+str_rtrim(str *buf, size_t *buflen, const char *s)
 {
        size_t len = strlen(s);
        size_t n = rstrip(s, len, whitespace, NSPACES);
@@ -3924,7 +3929,8 @@ str_rtrim(str *buf, size_t *buflen, str 
 static str
 STRRtrim(str *res, const str *arg1)
 {
-       str buf = NULL, msg = MAL_SUCCEED, s = *arg1;
+       str buf = NULL, msg = MAL_SUCCEED;
+       const char *s = *arg1;
 
        if (strNil(s)) {
                *res = GDKstrdup(str_nil);
@@ -3969,7 +3975,7 @@ illegal:
 }
 
 str
-str_strip2(str *buf, size_t *buflen, str s, str s2)
+str_strip2(str *buf, size_t *buflen, const char *s, const char *s2)
 {
        str msg = MAL_SUCCEED;
        size_t len, n, n2, n3;
@@ -4000,7 +4006,8 @@ str_strip2(str *buf, size_t *buflen, str
 static str
 STRStrip2(str *res, const str *arg1, const str *arg2)
 {
-       str buf = NULL, msg = MAL_SUCCEED, s = *arg1, s2 = *arg2;
+       str buf = NULL, msg = MAL_SUCCEED;
+       const char *s = *arg1, *s2 = *arg2;
 
        if (strNil(s) || strNil(s2)) {
                *res = GDKstrdup(str_nil);
@@ -4024,7 +4031,7 @@ STRStrip2(str *res, const str *arg1, con
 }
 
 str
-str_ltrim2(str *buf, size_t *buflen, str s, str s2)
+str_ltrim2(str *buf, size_t *buflen, const char *s, const char *s2)
 {
        str msg = MAL_SUCCEED;
        size_t len, n, n2, n3, nallocate;
@@ -4052,7 +4059,8 @@ str_ltrim2(str *buf, size_t *buflen, str
 static str
 STRLtrim2(str *res, const str *arg1, const str *arg2)
 {
-       str buf = NULL, msg = MAL_SUCCEED, s = *arg1, s2 = *arg2;
+       str buf = NULL, msg = MAL_SUCCEED;
+       const char *s = *arg1, *s2 = *arg2;
 
        if (strNil(s) || strNil(s2)) {
                *res = GDKstrdup(str_nil);
@@ -4076,7 +4084,7 @@ STRLtrim2(str *res, const str *arg1, con
 }
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to