shithub: mc

Download patch

ref: 1a3a60b609e8a20d0ea2290027827f45384a0d97
parent: a516d33035721f153e62c9b48d65a82a520dc539
parent: 99da1640c0a97150d6c0bc76dd4a305c2959219e
author: Ori Bernstein <[email protected]>
date: Thu Nov 24 21:22:10 EST 2011

Merge branch 'master' of git+ssh://eigenstate.org/git/ori/mc2

--- a/parse/type.c
+++ b/parse/type.c
@@ -167,13 +167,14 @@
     int i;
     char *p;
     char *end;
+    char *sep;
 
     p = buf;
     end = p + len;
+    sep = "";
     for (i = 0; i < name->name.nparts; i++) {
-        p += snprintf(p, end - p, name->name.parts[i]);
-        if (i < name->name.nparts - 1)
-            p += snprintf(p, end - p, ".");
+        p += snprintf(p, end - p, "%s%s", sep, name->name.parts[i]);
+        sep = ".";
     }
     return len - (end - p);
 }
@@ -183,9 +184,11 @@
     char *p;
     char *end;
     int i;
+    char *sep;
 
     p = buf;
     end = p + len;
+    sep = "";
     if (!t) {
         p += snprintf(p, end - p, "tynil");
         return len - (end - p);
@@ -227,9 +230,9 @@
         case Tyfunc:
             p += snprintf(p, end - p, "(");
             for (i = 1; i < t->nsub; i++) {
+                p += snprintf(p, end - p, "%s", sep);
                 p += tybfmt(p, end - p, t->fnsub[i]);
-                if (i < t->nsub - 1)
-                    p += snprintf(p, end - p, ", ");
+                sep = ", ";
             }
             p += snprintf(p, end - p, " -> ");
             p += tybfmt(p, end - p, t->fnsub[0]);
@@ -238,9 +241,9 @@
         case Tytuple:
             p += snprintf(p, end - p, "[");
             for (i = 1; i < t->nsub; i++) {
+                p += snprintf(p, end - p, "%s", sep);
                 p += tybfmt(p, end - p, t->tusub[i]);
-                if (i < t->nsub - 1)
-                    p += snprintf(p, end - p, ", ");
+                sep = ", ";
             }
             p += snprintf(p, end - p, "]");
             break;