Changeset: 80e18603a4a0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=80e18603a4a0
Modified Files:
        NT/monetdb_config.h.in
        configure.ag
        gdk/gdk_align.c
        gdk/gdk_atoms.c
        gdk/gdk_bat.c
        gdk/gdk_batop.c
        gdk/gdk_bbp.c
        gdk/gdk_hash.c
        gdk/gdk_heap.c
        gdk/gdk_imprints.c
        gdk/gdk_logger.c
        gdk/gdk_orderidx.c
        gdk/gdk_private.h
        gdk/gdk_project.c
        gdk/gdk_storage.c
        gdk/gdk_string.c
        sql/backends/monet5/sql_result.c
        sql/server/sql_semantic.c
        sql/test/emptydb/Tests/check.stable.out.32bit
Branch: default
Log Message:

Merge with Aug2018 branch.


diffs (truncated from 765 to 300 lines):

diff --git a/NT/monetdb_config.h.in b/NT/monetdb_config.h.in
--- a/NT/monetdb_config.h.in
+++ b/NT/monetdb_config.h.in
@@ -877,6 +877,16 @@ c99_snprintf(char *outBuf, size_t size, 
 }
 #endif
 
+static inline char *
+stpcpy(char *restrict dst, const char *restrict src)
+{
+       size_t i;
+       for (i = 0; src[i]; i++)
+               dst[i] = src[i];
+       dst[i] = 0;
+       return dst + i;
+}
+
 /* type used by connect */
 #define socklen_t int
 
diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -2590,6 +2590,7 @@ AC_CHECK_FUNCS([\
        setsid \
        shutdown \
        sigaction \
+       stpcpy \
        strcasestr \
        strncasecmp \
        strptime \
@@ -2844,6 +2845,18 @@ typedef enum {
 @%:@define static_assert(expr, mesg)   ((void) 0)
 @%:@endif
 
+@%:@ifndef HAVE_STPCPY
+static inline char *
+stpcpy(char *restrict dst, const char *restrict src)
+{
+       size_t i;
+       for (i = 0; src[i]; i++)
+               dst[i] = src[i];
+       dst[i] = 0;
+       return dst + i;
+}
+@%:@endif
+
 @%:@if defined(HAVE___INT128)
 typedef __int128 hge;
 typedef unsigned __int128 uhge;
diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c
--- a/gdk/gdk_align.c
+++ b/gdk/gdk_align.c
@@ -177,7 +177,7 @@ BATmaterialize(BAT *b)
        IMPSdestroy(b);
        OIDXdestroy(b);
 
-       snprintf(b->theap.filename, sizeof(b->theap.filename), "%s.tail", 
BBP_physical(b->batCacheid));
+       stpconcat(b->theap.filename, BBP_physical(b->batCacheid), ".tail", 
NULL);
        if (HEAPalloc(&b->theap, cnt, sizeof(oid)) != GDK_SUCCEED) {
                b->theap = tail;
                return GDK_FAIL;
@@ -275,7 +275,7 @@ VIEWreset(BAT *b)
                assert(tp || tvp || !b->ttype);
 
                tail.farmid = BBPselectfarm(b->batRole, b->ttype, offheap);
-               snprintf(tail.filename, sizeof(tail.filename), "%s.tail", nme);
+               stpconcat(tail.filename, nme, ".tail", NULL);
                if (b->ttype && HEAPalloc(&tail, cnt, Tsize(b)) != GDK_SUCCEED)
                        goto bailout;
                if (b->tvheap) {
@@ -283,7 +283,7 @@ VIEWreset(BAT *b)
                        if (th == NULL)
                                goto bailout;
                        th->farmid = BBPselectfarm(b->batRole, b->ttype, 
varheap);
-                       snprintf(th->filename, sizeof(th->filename), 
"%s.theap", nme);
+                       stpconcat(th->filename, nme, ".tail", NULL);
                        if (ATOMheap(b->ttype, th, cnt) != GDK_SUCCEED)
                                goto bailout;
                }
diff --git a/gdk/gdk_atoms.c b/gdk/gdk_atoms.c
--- a/gdk/gdk_atoms.c
+++ b/gdk/gdk_atoms.c
@@ -401,8 +401,10 @@ TYPE##ToStr(char **dst, size_t *len, con
 {                                                                      \
        atommem(TYPE##Strlen);                                          \
        if (is_##TYPE##_nil(*src)) {                                    \
-               if (external)                                           \
-                       return snprintf(*dst, *len, "nil");             \
+               if (external) {                                         \
+                       strcpy(*dst, "nil");                            \
+                       return 3;                                       \
+               }                                                       \
                strcpy(*dst, str_nil);                                  \
                return 1;                                               \
        }                                                               \
@@ -481,14 +483,19 @@ bitToStr(char **dst, size_t *len, const 
        atommem(6);
 
        if (is_bit_nil(*src)) {
-               if (external)
-                       return snprintf(*dst, *len, "nil");
+               if (external) {
+                       strcpy(*dst, "nil");
+                       return 3;
+               }
                strcpy(*dst, str_nil);
                return 1;
        }
-       if (*src)
-               return snprintf(*dst, *len, "true");
-       return snprintf(*dst, *len, "false");
+       if (*src) {
+               strcpy(*dst, "true");
+               return 4;
+       }
+       strcpy(*dst, "false");
+       return 5;
 }
 
 ssize_t
@@ -538,14 +545,16 @@ batToStr(char **dst, size_t *len, const 
 
        if (is_bat_nil(b) || (s = BBPname(b)) == NULL || *s == 0) {
                atommem(4);
-               if (external)
-                       return snprintf(*dst, *len, "nil");
+               if (external) {
+                       strcpy(*dst, "nil");
+                       return 3;
+               }
                strcpy(*dst, str_nil);
                return 1;
        }
        i = strlen(s) + 3;
        atommem(i);
-       return snprintf(*dst, *len, "<%s>", s);
+       return stpconcat(*dst, "<", s, ">", NULL) - *dst;
 }
 
 
@@ -989,8 +998,10 @@ dblToStr(char **dst, size_t *len, const 
 
        atommem(dblStrlen);
        if (is_dbl_nil(*src)) {
-               if (external)
-                       return snprintf(*dst, *len, "nil");
+               if (external) {
+                       strcpy(*dst, "nil");
+                       return 3;
+               }
                strcpy(*dst, str_nil);
                return 1;
        }
@@ -1059,8 +1070,10 @@ fltToStr(char **dst, size_t *len, const 
 
        atommem(fltStrlen);
        if (is_flt_nil(*src)) {
-               if (external)
-                       return snprintf(*dst, *len, "nil");
+               if (external) {
+                       strcpy(*dst, "nil");
+                       return 3;
+               }
                strcpy(*dst, str_nil);
                return 1;
        }
@@ -1134,8 +1147,10 @@ OIDtoStr(char **dst, size_t *len, const 
        atommem(oidStrlen);
 
        if (is_oid_nil(*src)) {
-               if (external)
-                       return snprintf(*dst, *len, "nil");
+               if (external) {
+                       strcpy(*dst, "nil");
+                       return 3;
+               }
                strcpy(*dst, str_nil);
                return 1;
        }
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -116,14 +116,12 @@ BATcreatedesc(oid hseq, int tt, bool hea
        assert(bn->batCacheid > 0);
 
        const char *nme = BBP_physical(bn->batCacheid);
-       snprintf(bn->theap.filename, sizeof(bn->theap.filename),
-                "%s.tail", nme);
+       stpconcat(bn->theap.filename, nme, ".tail", NULL);
        bn->theap.farmid = BBPselectfarm(role, bn->ttype, offheap);
        if (heapnames && ATOMneedheap(tt)) {
                if ((bn->tvheap = (Heap *) GDKzalloc(sizeof(Heap))) == NULL)
                        goto bailout;
-               snprintf(bn->tvheap->filename, sizeof(bn->tvheap->filename),
-                        "%s.theap", nme);
+               stpconcat(bn->tvheap->filename, nme, ".theap", NULL);
                bn->tvheap->parentid = bn->batCacheid;
                bn->tvheap->farmid = BBPselectfarm(role, bn->ttype, varheap);
        }
@@ -737,10 +735,10 @@ COLcopy(BAT *b, int tt, bool writable, i
                        thp = (Heap) {
                                .farmid = BBPselectfarm(role, b->ttype, 
varheap),
                        };
-                       snprintf(bthp.filename, sizeof(bthp.filename),
-                                "%s.tail", BBP_physical(bn->batCacheid));
-                       snprintf(thp.filename, sizeof(thp.filename), "%s.theap",
-                                BBP_physical(bn->batCacheid));
+                       stpconcat(bthp.filename, BBP_physical(bn->batCacheid),
+                                 ".tail", NULL);
+                       stpconcat(thp.filename, BBP_physical(bn->batCacheid),
+                                 ".theap", NULL);
                        if ((b->ttype && HEAPcopy(&bthp, &b->theap) != 
GDK_SUCCEED) ||
                            (bn->tvheap && HEAPcopy(&thp, b->tvheap) != 
GDK_SUCCEED)) {
                                HEAPfree(&thp, true);
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -30,8 +30,8 @@ unshare_string_heap(BAT *b)
                        return GDK_FAIL;
                h->parentid = b->batCacheid;
                h->farmid = BBPselectfarm(b->batRole, TYPE_str, varheap);
-               snprintf(h->filename, sizeof(h->filename),
-                        "%s.theap", BBP_physical(b->batCacheid));
+               stpconcat(h->filename, BBP_physical(b->batCacheid),
+                         ".theap", NULL);
                if (HEAPcopy(h, b->tvheap) != GDK_SUCCEED) {
                        HEAPfree(h, true);
                        GDKfree(h);
@@ -479,8 +479,8 @@ append_varsized_bat(BAT *b, BAT *n, BAT 
                        return GDK_FAIL;
                h->parentid = b->batCacheid;
                h->farmid = BBPselectfarm(b->batRole, b->ttype, varheap);
-               snprintf(h->filename, sizeof(h->filename),
-                        "%s.theap", BBP_physical(b->batCacheid));
+               stpconcat(h->filename, BBP_physical(b->batCacheid),
+                         ".theap", NULL);
                if (HEAPcopy(h, b->tvheap) != GDK_SUCCEED) {
                        HEAPfree(h, true);
                        GDKfree(h);
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -482,7 +482,7 @@ fixstroffheap(BAT *b, int *restrict offs
                h2 = *b->tvheap;
                if (GDKmove(h2.farmid, srcdir, bnme, "theap", BAKDIR, bnme, 
"theap") != GDK_SUCCEED)
                        GDKfatal("fixstroffheap: cannot make backup of 
%s.theap\n", nme);
-               snprintf(h2.filename, sizeof(h2.filename), "%s.theap", nme);
+               stpconcat(h2.filename, nme, ".theap", NULL);
                h2.base = NULL;
                if (HEAPalloc(&h2, h2.size, 1) != GDK_SUCCEED)
                        GDKfatal("fixstroffheap: allocating new string heap "
@@ -492,7 +492,7 @@ fixstroffheap(BAT *b, int *restrict offs
                h2.free = b->tvheap->free;
                /* load old offset heap and copy contents to new heap */
                h1 = *b->tvheap;
-               snprintf(h1.filename, sizeof(h1.filename), "%s.theap", 
filename);
+               stpconcat(h1.filename, filename, ".theap", NULL);
                h1.base = NULL;
                h1.dirty = false;
                if (HEAPload(&h1, filename, "theap", false) != GDK_SUCCEED)
@@ -519,7 +519,7 @@ fixstroffheap(BAT *b, int *restrict offs
                GDKfatal("fixstroffheap: cannot make backup of %s.tail\n", nme);
        /* load old offset heap */
        h1 = b->theap;
-       snprintf(h1.filename, sizeof(h1.filename), "%s.tail", filename);
+       stpconcat(h1.filename, filename, ".tail", NULL);
        h1.base = NULL;
        h1.dirty = false;
        if (HEAPload(&h1, filename, "tail", false) != GDK_SUCCEED)
@@ -528,7 +528,7 @@ fixstroffheap(BAT *b, int *restrict offs
 
        /* create new offset heap */
        h3 = b->theap;
-       snprintf(h3.filename, sizeof(h3.filename), "%s.tail", nme);
+       stpconcat(h3.filename, nme, ".tail", NULL);
        if (HEAPalloc(&h3, b->batCapacity, width) != GDK_SUCCEED)
                GDKfatal("fixstroffheap: allocating new tail heap "
                         "for BAT %d failed\n", b->batCacheid);
@@ -702,7 +702,7 @@ fixfltheap(BAT *b)
                GDKfatal("fixfltheap: cannot make backup of %s.tail\n", nme);
        /* load old heap */
        h1 = b->theap;
-       snprintf(h1.filename, sizeof(h1.filename), "%s.tail", filename);
+       stpconcat(h1.filename, filename, ".tail", NULL);
        h1.base = NULL;
        h1.dirty = false;
        if (HEAPload(&h1, filename, "tail", false) != GDK_SUCCEED)
@@ -711,7 +711,7 @@ fixfltheap(BAT *b)
 
        /* create new heap */
        h2 = b->theap;
-       snprintf(h2.filename, sizeof(h2.filename), "%s.tail", nme);
+       stpconcat(h2.filename, nme, ".tail", NULL);
        if (HEAPalloc(&h2, b->batCapacity, b->twidth) != GDK_SUCCEED)
                GDKfatal("fixfltheap: allocating new tail heap "
                         "for BAT %d failed\n", b->batCacheid);
@@ -967,8 +967,7 @@ heapinit(BAT *b, const char *buf, int *h
        b->theap.free = (size_t) free;
        b->theap.size = (size_t) size;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to