Changeset: e683bcaf9027 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e683bcaf9027
Modified Files:
        clients/mapiclient/mclient.c
        clients/mapilib/mapi.c
        monetdb5/mal/Tests/tst251.stable.out
        monetdb5/modules/atoms/mtime.c
        sql/backends/monet5/sql_scenario.c
Branch: default
Log Message:

Merge with Apr2019 branch.


diffs (115 lines):

diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -27,6 +27,7 @@
 #ifdef HAVE_STRINGS_H
 #include <strings.h>           /* strcasecmp */
 #endif
+#include <sys/stat.h>
 
 #ifdef HAVE_LIBREADLINE
 #include <readline/readline.h>
@@ -3241,6 +3242,18 @@ usage(const char *prog, int xit)
 /* hardwired defaults, only used if monet environment cannot be found */
 #define defaultPort 50000
 
+static inline bool
+isfile(FILE *fp)
+{
+       struct stat stb;
+       if (fstat(fileno(fp), &stb) < 0 ||
+           (stb.st_mode & S_IFMT) != S_IFREG) {
+               fclose(fp);
+               return false;
+       }
+       return true;
+}
+
 int
 main(int argc, char **argv)
 {
@@ -3559,7 +3572,8 @@ main(int argc, char **argv)
        has_fileargs = optind != argc;
 
        if (dbname == NULL && has_fileargs &&
-           (fp = fopen(argv[optind], "r")) == NULL) {
+           ((fp = fopen(argv[optind], "r")) == NULL || !isfile(fp))) {
+               fp = NULL;
                dbname = strdup(argv[optind]);
                optind++;
                has_fileargs = optind != argc;
diff --git a/clients/mapilib/mapi.c b/clients/mapilib/mapi.c
--- a/clients/mapilib/mapi.c
+++ b/clients/mapilib/mapi.c
@@ -3649,7 +3649,7 @@ slice_row(const char *reply, char *null,
        i = 0;
        anchors = length == 0 ? NULL : malloc(length * sizeof(*anchors));
        lens = length == 0 ? NULL : malloc(length * sizeof(*lens));
-       do {
+       for (;;) {
                if (i >= length) {
                        length = i + 1;
                        REALLOC(anchors, length);
@@ -3663,9 +3663,17 @@ slice_row(const char *reply, char *null,
                }
                lens[i] = len;
                anchors[i++] = start;
-               while (reply && *reply && isspace((unsigned char) *reply))
+               if (reply == NULL)
+                       break;
+               while (*reply && isspace((unsigned char) *reply))
+                       reply++;
+               if (*reply == ',') {
                        reply++;
-       } while (reply && *reply && *reply != endchar);
+                       while (*reply && isspace((unsigned char) *reply))
+                               reply++;
+               } else if (*reply == 0 || *reply == endchar)
+                       break;
+       }
        *anchorsp = anchors;
        *lensp = lens;
        return i;
@@ -4774,8 +4782,6 @@ unquote(const char *msg, char **str, con
                /* skip over trailing junk (presumably white space) */
                while (*p && *p != ',' && *p != endchar)
                        p++;
-               if (*p == ',')
-                       p++;
                if (next)
                        *next = p;
                *str = start;
@@ -4797,8 +4803,7 @@ unquote(const char *msg, char **str, con
                        ;
                if (s < msg || !isspace((unsigned char) *s))    /* gone one too 
far */
                        s++;
-               if (*p == ',' || *p == '\t') {
-                       /* there is more to come; skip over separator */
+               if (*p == '\t') {
                        p++;
                }
                len = s - msg;
diff --git a/monetdb5/mal/Tests/tst251.stable.out 
b/monetdb5/mal/Tests/tst251.stable.out
--- a/monetdb5/mal/Tests/tst251.stable.out
+++ b/monetdb5/mal/Tests/tst251.stable.out
@@ -43,7 +43,7 @@ stdout of test 'tst251` in directory 'mo
 [ 0,   "hello" ]
 [ 1,   "brave" ]
 [ 2,   "world" ]
-[ 3    ]
+[ 3,   ""      ]
 [ 4,   nil     ]
 [ 5,   "!"     ]
 
diff --git a/monetdb5/modules/atoms/mtime.c b/monetdb5/modules/atoms/mtime.c
--- a/monetdb5/modules/atoms/mtime.c
+++ b/monetdb5/modules/atoms/mtime.c
@@ -3784,7 +3784,7 @@ MTIMEtimestamp_to_str(str *s, const time
        (void)mktime(&t); /* corrects the tm_wday etc */
        (void)msec;
        if ((sz = strftime(buf, sizeof(buf), *format, &t)) == 0)
-               throw(MAL, "mtime.timestamp_to_str", "failed to convert 
timestampt to string using format '%s'\n", *format);
+               throw(MAL, "mtime.timestamp_to_str", "failed to convert 
timestamp to string using format '%s'\n", *format);
        *s = GDKmalloc(sz + 1);
        if (*s == NULL)
                throw(MAL, "mtime.timestamp_to_str", SQLSTATE(HY001) 
MAL_MALLOC_FAIL);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to