Update of /cvsroot/monetdb/pathfinder/runtime
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv20437/runtime

Modified Files:
        pathfinder.mx pf_support.mx serialize.mx shttpd.c 
Log Message:
propagated changes of Thursday Feb 21 2008 - Friday Feb 22 2008
from the XQuery_0-22 branch to the development trunk


Index: shttpd.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/runtime/shttpd.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- shttpd.c    23 Aug 2007 12:47:24 -0000      1.33
+++ shttpd.c    22 Feb 2008 12:46:36 -0000      1.34
@@ -614,17 +614,17 @@
                return (0);
 
        va_start(ap, fmt);
-       n = vsnprintf(buf, buflen, fmt, ap);
+       n = vsnprintf(buf, buflen-1, fmt, ap);
        va_end(ap);
 
        if (n < 0) {
                elog(ERR_DEBUG, "%s: snprintf returned -1, "
                     "fmt [%s]", "Snprintf", fmt);
                n = 0;
-       } else if (n > (int) buflen - 1) {
+       } else if (n >= (int) buflen - 1) {
                elog(ERR_DEBUG, "%s: truncating from %d to %u [%s]",
-                   "Snprintf", n, buflen - 1, buf);
-               n = buflen - 1;
+                   "Snprintf", n, buflen - 2, buf);
+               n = buflen - 2;
                buf[n] = '\0';
        }
 
@@ -757,7 +757,7 @@
        n = strftime(msg, sizeof(msg),"%d/%b/%Y %H:%M:%S ", localtime(&now));
 
        va_start(ap, fmt);
-       n += vsnprintf(msg + n, sizeof(msg) - n, fmt, ap);
+       n += vsnprintf(msg + n, sizeof(msg) - n - 1, fmt, ap);
        va_end(ap);
 
        if (n > sizeof(msg) - 2)
@@ -1258,9 +1258,9 @@
            "HTTP/1.1 %d %s\r\n%s%s\r\n%d ",
            status, descr, headers, headers[0] == '\0' ? "" : "\r\n", status);
        va_start(ap, fmt);
-       n += vsnprintf(msg + n, sizeof(msg) - n, fmt, ap);
-       if (n > (int) sizeof(msg))
-               n = sizeof(msg);
+       n += vsnprintf(msg + n, sizeof(msg) - n - 1, fmt, ap);
+       if (n >= (int) sizeof(msg) - 1)
+               n = sizeof(msg) - 1;
        va_end(ap);
        mystrlcpy(c->local.buf, msg, sizeof(c->local.buf));
        c->local.nread = n;
@@ -1429,13 +1429,13 @@
                   strcmp(dp->d_name, HTPASSWD) == 0)
                        continue;
 
-               (void) snprintf(file, sizeof(file),
+               (void) snprintf(file, sizeof(file)-1,
                    "%s%s%s",c->path, slash, dp->d_name);
                (void) mystat(file, &st);
                if (S_ISDIR(st.st_mode))
-                       snprintf(size,sizeof(size),"        %s","&lt;DIR&gt;");
+                       snprintf(size,sizeof(size)-1,"        
%s","&lt;DIR&gt;");
                else
-                       (void) snprintf(size, sizeof(size),"%10.2f kB",
+                       (void) snprintf(size, sizeof(size)-1,"%10.2f kB",
                            (float) st.st_size / 1024);
                (void) strftime(mod, sizeof(mod),
                    "%d-%b-%Y %H:%M", localtime(&st.st_mtime));
@@ -1544,7 +1544,7 @@
        fmt = "%a, %d %b %Y %H:%M:%S GMT";
        (void) strftime(date, sizeof(date), fmt, localtime(&now));
        (void) strftime(lm, sizeof(lm), fmt, localtime(&c->st.st_mtime));
-       (void) snprintf(etag, sizeof(etag), "%lx.%lx",
+       (void) snprintf(etag, sizeof(etag)-1, "%lx.%lx",
            (unsigned long) c->st.st_mtime, (unsigned long) c->st.st_size);
 
        /* Local read buffer should be empty */
@@ -1995,7 +1995,7 @@
                                u[LSIZ], d[LSIZ], ha1[LSIZ];
        FILE            *fp = NULL, *fp2 = NULL;
 
-       (void) snprintf(tmp, sizeof(tmp), "%s.tmp", fname);
+       (void) snprintf(tmp, sizeof(tmp)-1, "%s.tmp", fname);
 
        /* Create the file if does not exist */
        if ((fp = fopen(fname, "a+")))
@@ -2014,7 +2014,7 @@
                    strcmp(domain, d) == 0) {
                        found++;
                        md5(ha1, user, ":", domain, ":", pass, NULL);
-                       (void) snprintf(line, sizeof(line),
+                       (void) snprintf(line, sizeof(line)-1,
                            "%s:%s:%s\n", user, domain, ha1);
                }
                (void) fprintf(fp2, "%s", line);
@@ -2023,7 +2023,7 @@
        /* If new user, just add it */
        if (found == 0) {
                md5(ha1, user, ":", domain, ":", pass, NULL);
-               (void) snprintf(line, sizeof(line),
+               (void) snprintf(line, sizeof(line)-1,
                    "%s:%s:%s\n", user, domain, ha1);
                (void) fprintf(fp2, "%s", line);
        }
@@ -2144,14 +2144,14 @@
 
        if (STROPT(OPT_HTPASSWD)) {
                /* Use global passwords file */
-               (void) snprintf(name, sizeof(name), "%s", STROPT(OPT_HTPASSWD));
+               (void) snprintf(name, sizeof(name)-1, "%s", 
STROPT(OPT_HTPASSWD));
        } else {
                /* Try to find .htpasswd in requested directory */
                for (p = path, e = p + strlen(p) - 1; e > p; e--)
                        if (*e == '/')
                                break;
                assert(*e == '/');
-               (void) snprintf(name, sizeof(name), "%.*s/%s",
+               (void) snprintf(name, sizeof(name)-1, "%.*s/%s",
                    (int) (e - p), p, HTPASSWD);
 
                /* Fix directory separators */
@@ -2269,7 +2269,7 @@
        }
 
        /* Prepare command line */
-       (void) snprintf(cmdline, sizeof(cmdline), "%s%s%s",
+       (void) snprintf(cmdline, sizeof(cmdline)-1, "%s%s%s",
            line + 2, line[2] == '\0' ? "" : " ", prog);
 #if 0
        copypath(cmdline, cmdline, strlen(cmdline) + 1);
@@ -2554,7 +2554,7 @@
                        mystrlcpy(name, s, sizeof(name));
                }
 
-               (void) snprintf(ftry, sizeof(ftry), "%s%c%s", path,DIRSEP,name);
+               (void) snprintf(ftry, sizeof(ftry)-1, "%s%c%s", 
path,DIRSEP,name);
                if (mystat(ftry, &st) == 0) {
                        /* Found ! */
                        mystrlcpy(path, ftry, maxpath);
@@ -2590,13 +2590,13 @@
                c->query = mystrdup(c->query);
        }
        urldecode(c->uri, c->uri);
-       (void) snprintf(path, sizeof(path), "%s%s",STROPT(OPT_DOCROOT),c->uri);
+       (void) snprintf(path, sizeof(path)-1, 
"%s%s",STROPT(OPT_DOCROOT),c->uri);
        killdots(path + strlen(STROPT(OPT_DOCROOT)));
 
 #if EMBEDDED
        /* User may use the aliases - check URI for mount point */
        if ((mp = ismountpoint(c->uri)) != NULL) {
-               (void) snprintf(path, sizeof(path), "%s%s", mp->path,
+               (void) snprintf(path, sizeof(path)-1, "%s%s", mp->path,
                    c->uri + strlen(mp->mountpoint));
                killdots(path + strlen(mp->path));
        }
@@ -2604,7 +2604,7 @@
 
 #ifndef NO_AUTH
        if (checkauth(c, path) != 1) {
-               (void) snprintf(buf, sizeof(buf),
+               (void) snprintf(buf, sizeof(buf)-1,
                    "WWW-Authenticate: Digest qop=\"auth\", realm=\"%s\", "
                    "nonce=\"%lu\"", STROPT(OPT_REALM), (unsigned long) now);
 
@@ -2654,7 +2654,7 @@
        } else if (mystat(path, &c->st) != 0) {
                senderr(c, 404, "Not Found","", "Not Found");
        } else if (S_ISDIR(c->st.st_mode) && path[strlen(path) - 1] != '/') {
-               (void) snprintf(buf, sizeof(buf), "Location: %s/", c->uri);
+               (void) snprintf(buf, sizeof(buf)-1, "Location: %s/", c->uri);
                senderr(c, 301, "Moved Permanently", buf, "Moved, %s", buf);
        } else if (S_ISDIR(c->st.st_mode) &&
            useindex(c, path, sizeof(path) - 1) == -1 &&
@@ -2700,7 +2700,7 @@
 {
        char    fmt[32];
 
-       (void) snprintf(fmt, sizeof(fmt), "%%" LLFMT "s %%" LLFMT "s %%" LLFMT 
"s",
+       (void) snprintf(fmt, sizeof(fmt)-1, "%%" LLFMT "s %%" LLFMT "s %%" 
LLFMT "s",
            (long long)sizeof(c->method) - 1, (long long)sizeof(c->uri) - 1, 
(long long)sizeof(c->proto) - 1);
 
        /* Get the request line */
@@ -3376,9 +3376,9 @@
        char    buf[IO_MAX];
 
        va_start(ap, fmt);
-       len = vsnprintf(buf, sizeof(buf), fmt, ap);
-       if (len > (int) sizeof(buf))
-               len = sizeof(buf);
+       len = vsnprintf(buf, sizeof(buf) - 1, fmt, ap);
+       if (len >= (int) sizeof(buf) - 1)
+               len = sizeof(buf) - 1;
        else if (len == -1)
                len = 0;
        va_end(ap);

Index: pathfinder.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/runtime/pathfinder.mx,v
retrieving revision 1.401
retrieving revision 1.402
diff -u -d -r1.401 -r1.402
--- pathfinder.mx       19 Feb 2008 10:44:31 -0000      1.401
+++ pathfinder.mx       22 Feb 2008 12:46:34 -0000      1.402
@@ -4646,10 +4646,10 @@
 
 @= seqbase
     BATseqbase(ctx->@1, @2);
-    if (ctx->mode&XQ_DEBUG) m += snprintf(mil+m, XQUERY_BUFSIZE-l, 
"@1.seqbase(" @3 ");\n");
+    if (ctx->mode&XQ_DEBUG) m += snprintf(mil+m, XQUERY_BUFSIZE-m-1, 
"@1.seqbase(" @3 ");\n");
 @= bunappend
     if (BUNappend(ctx->@1, @2, FALSE) == NULL) return "xquery_method: 
allocation error while inserting in @1";
-    if (ctx->mode&XQ_DEBUG) m += snprintf(mil+m, XQUERY_BUFSIZE-l, 
"@1.append(" @4 @5 ");\n", @3 @2);
+    if (ctx->mode&XQ_DEBUG) m += snprintf(mil+m, XQUERY_BUFSIZE-m-1, 
"@1.append(" @4 @5 ");\n", @3 @2);
 @c
 /*
  * call a function ns:method(). try to use the function cache (ie re-use a 
cached MIL tree).
@@ -4725,13 +4725,13 @@
             }
 
             /* call UDF */
-            ret = snprintf(cur, XQUERY_BUFSIZE-(cur-mil), 
+            ret = snprintf(cur, XQUERY_BUFSIZE-(cur-mil)-1, 
                            PFudfMIL(), 
                            fun->proc, 0, 0, 0,0, 0, 0, 0, 0, fun->sig->name, 
fun->sig->name, 0, 0, 0, 0);
             if (ret > 0) cur += ret;
 
             /* destroy working set */
-            ret = snprintf(cur, XQUERY_BUFSIZE-(cur-mil), 
PFstopMIL(fun->sig->update));
+            ret = snprintf(cur, XQUERY_BUFSIZE-(cur-mil)-1, 
PFstopMIL(fun->sig->update));
             if (ret > 0) cur += ret;
 
             /* done! execute the script */
@@ -5080,7 +5080,7 @@
 @= find_bat
 {   Variable v = VARfind(&ctx->stk, "@1");
     char buf[256];
-    snprintf(buf, 256, "[EMAIL PROTECTED]", ctx->stk);
+    snprintf(buf, sizeof(buf)-1, "[EMAIL PROTECTED]", ctx->stk);
     ctx->@1 = NULL;
     if (v && v->binding.vtype == TYPE_bat) {
         ctx->@1 = BATdescriptor(v->binding.val.bval);

Index: serialize.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/runtime/serialize.mx,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -d -r1.106 -r1.107
--- serialize.mx        30 Jan 2008 15:54:32 -0000      1.106
+++ serialize.mx        22 Feb 2008 12:46:35 -0000      1.107
@@ -304,7 +304,7 @@
 
     (void)ctx;
     va_start (msgs, msg);
-    vsnprintf (errmsg, 1024, msg, msgs);
+    vsnprintf (errmsg, sizeof(errmsg)-1, msg, msgs);
     va_end (msgs);
 
     GDKerror("XML Generation: %s\n",errmsg);

Index: pf_support.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/runtime/pf_support.mx,v
retrieving revision 1.278
retrieving revision 1.279
diff -u -d -r1.278 -r1.279
--- pf_support.mx       17 Feb 2008 17:37:38 -0000      1.278
+++ pf_support.mx       22 Feb 2008 12:46:35 -0000      1.279
@@ -1426,7 +1426,11 @@
        # =>  we do not need to sort the input
        order := or(order,1);
 @= unique_iters
-               # unique iters
+       if (end_ctx.count() = 0) {
+               # unique iters optimization;
+               # must NOT be done in case we have end_ctx nodes, i.e., in
+               # case we "mis-use" a limited child-step to evaluate
+               # preceding-sibling as child(parent(ctx))!
                 var unq_items;
                 unq_items := item.reverse().kunique();
                 if ((item.count() - unq_items.count()) > 1000) {
@@ -1439,6 +1443,7 @@
                         # we now certainly have iter|item ordering
                         order := and(order,2);
                 }
+       }
 @= resolve_unique_iters
                 # undo memoization and remap iter values
                 if (unq_iter) {
@@ -7558,7 +7563,7 @@
        if (v) {
             /* give the view a name such that lng(bbname(v)) = lng(bbpname(b)) 
*/
            long_str buf;
-            snprintf(buf, sizeof(buf), "%s-%d", BBP_logical(bid), 
ABS(b->batCacheid));
+            snprintf(buf, sizeof(buf)-1, "%s-%d", BBP_logical(bid), 
ABS(b->batCacheid));
            BBPrename(v->batCacheid, buf);
            return GDK_SUCCEED;
         } else


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins

Reply via email to