Changeset: 03f9f530e1b6 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/03f9f530e1b6
Modified Files:
        clients/Tests/exports.stable.out
        clients/mapiclient/dump.c
        clients/odbc/driver/SQLPrepare.c
        monetdb5/modules/atoms/json.c
        sql/backends/monet5/sql_execute.c
        sql/backends/monet5/sql_gencode.c
Branch: nested
Log Message:

Merge with default branch.


diffs (truncated from 2755 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
@@ -1362,6 +1362,8 @@ char *prompt_getlogin(void);
 struct dirent *readdir(DIR *dir);
 void rewinddir(DIR *dir);
 char *simple_prompt(const char *prompt, int maxlen, int echo, const char *def);
+size_t strlconcat(char *restrict dst, size_t n, const char *restrict src, ...) 
__attribute__((__access__(write_only, 1, 2))) __attribute__(()) 
__attribute__((__sentinel__));
+ssize_t strtconcat(char *restrict dst, size_t n, const char *restrict src, 
...) __attribute__((__access__(write_only, 1, 2))) __attribute__(()) 
__attribute__((__sentinel__));
 char *utf16toutf8(const uint16_t *src);
 const uint8_t utf8d[364];
 uint16_t *utf8toutf16(const char *src);
diff --git a/clients/mapiclient/dump.c b/clients/mapiclient/dump.c
--- a/clients/mapiclient/dump.c
+++ b/clients/mapiclient/dump.c
@@ -1614,7 +1614,7 @@ describe_sequence(Mapi mid, const char *
                        sname = malloc(len);
                        if (sname == NULL)
                                goto bailout;
-                       strcpy_len(sname, tname, len);
+                       strtcpy(sname, tname, len);
                        tname += len;
                } else if ((sname = get_schema(mid)) == NULL) {
                        return 1;
@@ -2178,7 +2178,7 @@ dump_table(Mapi mid, const char *schema,
                                fprintf(stderr, "malloc failure\n");
                                return 1;
                        }
-                       strcpy_len(sname, tname, len);
+                       strtcpy(sname, tname, len);
                        tname += len;
                } else if ((sname = get_schema(mid)) == NULL) {
                        return 1;
@@ -2612,7 +2612,7 @@ dump_functions(Mapi mid, stream *sqlf, c
                                to_free = malloc(len);
                                if (to_free == NULL)
                                        goto bailout;
-                               strcpy_len(to_free, fname, len);
+                               strtcpy(to_free, fname, len);
                                fname += len;
                        } else if ((to_free = get_schema(mid)) == NULL) {
                                return 1;
diff --git a/clients/mapiclient/msqldump.c b/clients/mapiclient/msqldump.c
--- a/clients/mapiclient/msqldump.c
+++ b/clients/mapiclient/msqldump.c
@@ -305,7 +305,7 @@ main(int argc, char **argv)
 #ifdef HAVE_CTIME_R
                ctime_r(&t, buf);
 #else
-               strcpy_len(buf, ctime(&t), sizeof(buf));
+               strtcpy(buf, ctime(&t), sizeof(buf));
 #endif
 #endif
                if ((p = strrchr(buf, '\n')) != NULL)
diff --git a/clients/mapilib/connect_unix.c b/clients/mapilib/connect_unix.c
--- a/clients/mapilib/connect_unix.c
+++ b/clients/mapilib/connect_unix.c
@@ -181,7 +181,7 @@ connect_socket_unix(Mapi mid)
        userver = (struct sockaddr_un) {
                .sun_family = AF_UNIX,
        };
-       strcpy_len(userver.sun_path, sockname, sizeof(userver.sun_path));
+       strtcpy(userver.sun_path, sockname, sizeof(userver.sun_path));
 
        if (connect(s, (struct sockaddr *) &userver, sizeof(struct 
sockaddr_un)) == SOCKET_ERROR) {
                closesocket(s);
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -1550,7 +1550,7 @@ add_error(struct MapiResultSet *result, 
             (error[4] >= 'A' && error[4] <= 'Z'))) {
                if (result->errorstr == NULL) {
                        /* remember SQLSTATE for first error */
-                       strcpy_len(result->sqlstate, error,
+                       strtcpy(result->sqlstate, error,
                                   sizeof(result->sqlstate));
                }
                /* skip SQLSTATE */
@@ -2657,7 +2657,7 @@ mapi_param_store(MapiHdl hdl)
                                free(val);
                                break;
                        default:
-                               strcpy_len(hdl->query + k, src, lim - k);
+                               strtcpy(hdl->query + k, src, lim - k);
                                break;
                        }
                }
@@ -3687,7 +3687,7 @@ mapi_query_part(MapiHdl hdl, const char 
        if (hdl->query == NULL) {
                hdl->query = malloc(size + 1);
                if (hdl->query) {
-                       strcpy_len(hdl->query, query, size + 1);
+                       strtcpy(hdl->query, query, size + 1);
                }
        } else {
                size_t sz = strlen(hdl->query);
@@ -3695,7 +3695,7 @@ mapi_query_part(MapiHdl hdl, const char 
 
                if (sz < 512 &&
                    (q = realloc(hdl->query, sz + size + 1)) != NULL) {
-                       strcpy_len(q + sz, query, size + 1);
+                       strtcpy(q + sz, query, size + 1);
                        hdl->query = q;
                }
        }
@@ -4071,7 +4071,7 @@ unquote(const char *msg, char **str, con
                }
                len = s - msg;
                *str = malloc(len + 1);
-               strcpy_len(*str, msg, len + 1);
+               strtcpy(*str, msg, len + 1);
 
                if (next)
                        *next = p;
diff --git a/clients/odbc/driver/ODBCError.c b/clients/odbc/driver/ODBCError.c
--- a/clients/odbc/driver/ODBCError.c
+++ b/clients/odbc/driver/ODBCError.c
@@ -246,7 +246,7 @@ newODBCError(const char *SQLState, const
        };
 
        if (SQLState) {
-               strcpy_len(error->sqlState, SQLState, sizeof(error->sqlState));
+               strtcpy(error->sqlState, SQLState, sizeof(error->sqlState));
        }
 
        if (msg) {
diff --git a/clients/odbc/driver/ODBCUtil.c b/clients/odbc/driver/ODBCUtil.c
--- a/clients/odbc/driver/ODBCUtil.c
+++ b/clients/odbc/driver/ODBCUtil.c
@@ -67,7 +67,7 @@ dupODBCstring(const SQLCHAR *inStr, size
 
        if (tmp == NULL)
                return NULL;
-       strcpy_len(tmp, (const char *) inStr, length + 1);
+       strtcpy(tmp, (const char *) inStr, length + 1);
        return tmp;
 }
 
diff --git a/clients/odbc/driver/ODBCUtil.h b/clients/odbc/driver/ODBCUtil.h
--- a/clients/odbc/driver/ODBCUtil.h
+++ b/clients/odbc/driver/ODBCUtil.h
@@ -85,7 +85,7 @@ extern char *dupODBCstring(const SQLCHAR
                        ret;                                            \
                }                                                       \
                if (buf && (buflen) > 0) {                              \
-                       _l = strcpy_len((char *) (buf), (str) ? (const char *) 
(str) : "", (buflen)); \
+                       _l = strlcpy((char *) (buf), (str) ? (const char *) 
(str) : "", (buflen)); \
                } else {                                                \
                        _l = (str) ? (lent) (strlen) : 0;               \
                }                                                       \
diff --git a/clients/odbc/driver/SQLBrowseConnect.c 
b/clients/odbc/driver/SQLBrowseConnect.c
--- a/clients/odbc/driver/SQLBrowseConnect.c
+++ b/clients/odbc/driver/SQLBrowseConnect.c
@@ -39,10 +39,6 @@
 #include <odbcinst.h>
 #endif
 
-#ifndef HAVE_SQLGETPRIVATEPROFILESTRING
-#define 
SQLGetPrivateProfileString(section,entry,default,buffer,bufferlen,filename)    
((int) strcpy_len(buffer,default,bufferlen))
-#endif
-
 static void
 suggest_settings(ODBCDbc *dbc, char **buf, size_t *pos, size_t *cap, char 
touched_as, const char *prefix)
 {
@@ -122,7 +118,7 @@ MNDBBrowseConnect(ODBCDbc *dbc,
        // note that we leave out level 1, they have already been provided
 
        if (buf && pos) {
-               size_t n = strcpy_len((char*)OutConnectionString, buf, 
BufferLength);
+               size_t n = strlcpy((char*)OutConnectionString, buf, 
BufferLength);
                if (StringLength2Ptr)
                        *StringLength2Ptr = (SQLSMALLINT)n;
        }
diff --git a/clients/odbc/driver/SQLColumnPrivileges.c 
b/clients/odbc/driver/SQLColumnPrivileges.c
--- a/clients/odbc/driver/SQLColumnPrivileges.c
+++ b/clients/odbc/driver/SQLColumnPrivileges.c
@@ -205,7 +205,7 @@ MNDBColumnPrivileges(ODBCStmt *stmt,
        }
 
        /* add the ordering (exclude table_cat as it is the same for all rows) 
*/
-       pos += strcpy_len(query + pos, " order by \"TABLE_SCHEM\", 
\"TABLE_NAME\", \"COLUMN_NAME\", \"PRIVILEGE\"", querylen - pos);
+       pos += strlcpy(query + pos, " order by \"TABLE_SCHEM\", \"TABLE_NAME\", 
\"COLUMN_NAME\", \"PRIVILEGE\"", querylen - pos);
        assert(pos < querylen);
 
        /* debug: fprintf(stdout, "SQLColumnPrivileges query (pos: %zu, len: 
%zu):\n%s\n\n", pos, strlen(query), query); */
diff --git a/clients/odbc/driver/SQLColumns.c b/clients/odbc/driver/SQLColumns.c
--- a/clients/odbc/driver/SQLColumns.c
+++ b/clients/odbc/driver/SQLColumns.c
@@ -246,7 +246,7 @@ MNDBColumns(ODBCStmt *stmt,
        }
 
        /* add the ordering (exclude table_cat as it is the same for all rows) 
*/
-       pos += strcpy_len(query + pos, " order by \"TABLE_SCHEM\", 
\"TABLE_NAME\", \"ORDINAL_POSITION\"", querylen - pos);
+       pos += strlcpy(query + pos, " order by \"TABLE_SCHEM\", \"TABLE_NAME\", 
\"ORDINAL_POSITION\"", querylen - pos);
        if (pos >= querylen)
                fprintf(stderr, "pos >= querylen, %zu > %zu\n", pos, querylen);
        assert(pos < querylen);
diff --git a/clients/odbc/driver/SQLConnect.c b/clients/odbc/driver/SQLConnect.c
--- a/clients/odbc/driver/SQLConnect.c
+++ b/clients/odbc/driver/SQLConnect.c
@@ -40,7 +40,7 @@
 #endif
 
 #ifndef HAVE_SQLGETPRIVATEPROFILESTRING
-#define 
SQLGetPrivateProfileString(section,entry,default,buffer,bufferlen,filename)    
((int) strcpy_len(buffer,default,bufferlen))
+#define 
SQLGetPrivateProfileString(section,entry,default,buffer,bufferlen,filename)    
((int) strlcpy(buffer,default,bufferlen))
 #endif
 
 static SQLRETURN
diff --git a/clients/odbc/driver/SQLDriverConnect.c 
b/clients/odbc/driver/SQLDriverConnect.c
--- a/clients/odbc/driver/SQLDriverConnect.c
+++ b/clients/odbc/driver/SQLDriverConnect.c
@@ -58,7 +58,7 @@ ODBCGetKeyAttr(const SQLCHAR **conn, SQL
        *key = (char *) malloc(len + 1);
        if (*key == NULL)
                return -1;
-       strcpy_len(*key, (char *) p, len + 1);
+       strtcpy(*key, (char *) p, len + 1);
        (*conn)++;
        (*nconn)--;
        p = *conn;
@@ -78,7 +78,7 @@ ODBCGetKeyAttr(const SQLCHAR **conn, SQL
                        *key = NULL;
                        return -1;
                }
-               strcpy_len(*attr, (char *) p, len + 1);
+               strtcpy(*attr, (char *) p, len + 1);
                (*conn)++;
                (*nconn)--;
                /* should check that *nconn == 0 || **conn == ';' */
@@ -94,7 +94,7 @@ ODBCGetKeyAttr(const SQLCHAR **conn, SQL
                        *key = NULL;
                        return -1;
                }
-               strcpy_len(*attr, (char *) p, len + 1);
+               strtcpy(*attr, (char *) p, len + 1);
        }
        if (*nconn > 0 && **conn) {
                (*conn)++;
@@ -192,7 +192,7 @@ MNDBDriverConnect(ODBCDbc *dbc,
        scratch_alloc = buildConnectionString(dsn ? dsn : "DEFAULT", settings);
        if (!scratch_alloc)
                goto failure;
-       out_len = strcpy_len((char*)OutConnectionString, scratch_alloc, 
BufferLength);
+       out_len = strlcpy((char*)OutConnectionString, scratch_alloc, 
BufferLength);
        if (StringLength2Ptr)
                *StringLength2Ptr = (SQLSMALLINT)out_len;
        if (out_len + 1 > (size_t)BufferLength) {
diff --git a/clients/odbc/driver/SQLGetConnectAttr.c 
b/clients/odbc/driver/SQLGetConnectAttr.c
--- a/clients/odbc/driver/SQLGetConnectAttr.c
+++ b/clients/odbc/driver/SQLGetConnectAttr.c
@@ -98,7 +98,7 @@ MNDBGetConnectAttr(ODBCDbc *dbc,
                        addDbcError(dbc, "HY090", NULL, 0);
                        return SQL_ERROR;
                }
-               strcpy_len((char *) ValuePtr, "", BufferLength);
+               strtcpy((char *) ValuePtr, "", BufferLength);
                if (StringLengthPtr) {
                        *(StringLengthPtr) = (SQLINTEGER) 0;
                }
diff --git a/clients/odbc/driver/SQLGetDiagField.c 
b/clients/odbc/driver/SQLGetDiagField.c
--- a/clients/odbc/driver/SQLGetDiagField.c
+++ b/clients/odbc/driver/SQLGetDiagField.c
@@ -36,7 +36,7 @@
                        size_t _l;                                      \
                        if (len < 0)                                    \
                                return SQL_ERROR;                       \
-                       _l = strcpy_len((char *) buf, str, len);        \
+                       _l = strlcpy((char *) buf, str, len);   \
                        if (lenp)                                       \
                                *lenp = (SQLSMALLINT) _l;               \
                        if (buf == NULL || _l >= (size_t) len)          \
@@ -156,9 +156,9 @@ MNDBGetDiagField(SQLSMALLINT HandleType,
                 */
                SQLSMALLINT msgLen;
                if (dbc && dbc->dsn)
-                       msgLen = (SQLSMALLINT) strconcat_len((char *) 
DiagInfoPtr, BufferLength, ODBCErrorMsgPrefix, "[", dbc->dsn, "]", msg, NULL);
+                       msgLen = (SQLSMALLINT) strlconcat((char *) DiagInfoPtr, 
BufferLength, ODBCErrorMsgPrefix, "[", dbc->dsn, "]", msg, NULL);
                else
-                       msgLen = (SQLSMALLINT) strconcat_len((char *) 
DiagInfoPtr, BufferLength, ODBCErrorMsgPrefix, msg, NULL);
+                       msgLen = (SQLSMALLINT) strlconcat((char *) DiagInfoPtr, 
BufferLength, ODBCErrorMsgPrefix, msg, NULL);
                if (StringLengthPtr)
                        *StringLengthPtr = msgLen;
                if (DiagInfoPtr == NULL || msgLen >= BufferLength)
diff --git a/clients/odbc/driver/SQLGetDiagRec.c 
b/clients/odbc/driver/SQLGetDiagRec.c
--- a/clients/odbc/driver/SQLGetDiagRec.c
+++ b/clients/odbc/driver/SQLGetDiagRec.c
@@ -103,7 +103,7 @@ MNDBGetDiagRec(SQLSMALLINT HandleType,
                /* copy only the first SQL_SQLSTATE_SIZE (5) chars in
                 * the buffer and make it null terminated
                 */
-               strcpy_len((char *) SQLState, state, SQL_SQLSTATE_SIZE + 1);
+               strtcpy((char *) SQLState, state, SQL_SQLSTATE_SIZE + 1);
        }
 
        if (NativeErrorPtr)
@@ -118,9 +118,9 @@ MNDBGetDiagRec(SQLSMALLINT HandleType,
         * and used to determine where the error originated
         */
        if (dbc && dbc->dsn)
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to