]> git.mxchange.org Git - flightgear.git/commitdiff
don't truncate strings output by print() to 1024 bytes. This was apparently
authormfranz <mfranz>
Sun, 28 Jan 2007 12:16:37 +0000 (12:16 +0000)
committermfranz <mfranz>
Sun, 28 Jan 2007 12:16:37 +0000 (12:16 +0000)
done for performance reasons, but print() should be able to output any
valid string, and when SG_LOG uses strings and streams already, then we
can use that here, too. (Not discussed with Andy yet.)

src/Scripting/NasalSys.cxx

index a270a27d189934ecc0b130bb995640838a9043e3..9c79b94203e110ff8c0e0da75c83f276cd043b93 100644 (file)
@@ -232,24 +232,15 @@ static naRef f_setprop(naContext c, naRef me, int argc, naRef* args)
 // make sure it appears.  Is there better way to do this?
 static naRef f_print(naContext c, naRef me, int argc, naRef* args)
 {
-#define BUFLEN 1024
-    char buf[BUFLEN + 1];
-    buf[BUFLEN] = 0; // extra nul to handle strncpy brain damage
-    buf[0] = 0; // Zero-length in case there are no arguments
-    char* p = buf;
-    int buflen = BUFLEN;
+    string buf;
     int n = argc;
     for(int i=0; i<n; i++) {
         naRef s = naStringValue(c, args[i]);
         if(naIsNil(s)) continue;
-        strncpy(p, naStr_data(s), buflen);
-        p += naStr_len(s);
-        buflen = BUFLEN - (p - buf);
-        if(buflen <= 0) break;
+        buf += naStr_data(s);
     }
     SG_LOG(SG_GENERAL, SG_ALERT, buf);
-    return naNil();
-#undef BUFLEN
+    return naNum(buf.length());
 }
 
 // fgcommand() extension function.  Executes a named command via the