diff test/call_suite/main.c @ 504:f263eb7a206e

- call_suite: made output more consistent with dyncall sig style
author Tassilo Philipp
date Fri, 08 Apr 2022 20:33:14 +0200
parents e3bf15207d93
children ed7d1f5e7973
line wrap: on
line diff
--- a/test/call_suite/main.c	Fri Apr 08 17:45:46 2022 +0200
+++ b/test/call_suite/main.c	Fri Apr 08 20:33:14 2022 +0200
@@ -36,18 +36,26 @@
 static int invoke(char const* signature, void* t)
 {
   DCCallVM   * p = (DCCallVM*) G_callvm;
-  char const * sig = signature;
-  char         rtype;
+  const char * sig = signature;
+  const char * rtype;
   char         atype;
   int          pos = 0;
   int          s = 0;
 
   clear_V();
   
-  rtype = *sig++;
   dcReset(p);
 
-  while ( (atype = *sig++) != '\0') {
+  /* locate return type in sig; if no ')' separator, test failed */
+  rtype = strchr(sig, ')');
+  if(!rtype) {
+    printf("cannot locate rtype in sig '%s' ;", signature);
+    return 0;
+  }
+
+  ++rtype;
+
+  while ( (atype = *sig++) != ')') {
     pos++;
     switch(atype) {
       case 'c':  dcArgChar    (p,K_c[pos]); break;
@@ -67,7 +75,7 @@
     }
   }
   
-  switch(rtype) 
+  switch(*rtype) 
   {
     case 'v':                           dcCallVoid    (p,t); s=1;         break; /*TODO:check that no return-arg was touched.*/
     case 'c':  s = (                    dcCallChar    (p,t) == K_c[pos]); break;
@@ -83,14 +91,15 @@
     case 'p':  s = (                    dcCallPointer (p,t) == K_p[pos]); break;
     case 'f':  s = (                    dcCallFloat   (p,t) == K_f[pos]); break;
     case 'd':  s = (                    dcCallDouble  (p,t) == K_d[pos]); break;
-    default: printf("unknown rtype '%c'", rtype); return 0;
+    default: printf("unknown rtype '%s'", rtype); return 0;
   }
 
   if (!s) { printf("rval wrong;"); return 0; }
+
   /* test: */
-  sig = signature+1;
+  sig = signature;
   pos = 1;
-  while ( (atype = *sig++) != '\0') {
+  while ( (atype = *sig++) != ')') {
     switch(atype) {
       case 'c':  s = ( V_c[pos] == K_c[pos] ); if (!s) printf("'%c':%d: %d != %d ; ",     atype, pos, V_c[pos], K_c[pos]); break;
       case 's':  s = ( V_s[pos] == K_s[pos] ); if (!s) printf("'%c':%d: %d != %d ; ",     atype, pos, V_s[pos], K_s[pos]); break;