]> git.mxchange.org Git - flightgear.git/commitdiff
Same bug, different place. Don't treat a length of zero as "please
authorandy <andy>
Tue, 26 Apr 2005 20:57:06 +0000 (20:57 +0000)
committerandy <andy>
Tue, 26 Apr 2005 20:57:06 +0000 (20:57 +0000)
strlen() it", because real files and properties can have lengths of
zero.

src/Scripting/NasalSys.cxx
src/Scripting/NasalSys.hxx

index ccb1e926a9d95e4d1b3764f9ade45efa5b78d22e..e8374bc719101dc7d2fb5b095b575d5371f6ab8f 100644 (file)
@@ -90,7 +90,7 @@ FGNasalScript* FGNasalSys::parseScript(const char* src, const char* name)
         name = buf;
     }
 
-    script->_code = parse(name, src);
+    script->_code = parse(name, src, strlen(src));
     if(naIsNil(script->_code)) {
         delete script;
         return 0;
@@ -454,7 +454,6 @@ void FGNasalSys::initModule(const char* moduleName, const char* fileName,
 
 naRef FGNasalSys::parse(const char* filename, const char* buf, int len)
 {
-    if(len == 0) len = strlen(buf);
     int errLine = -1;
     naRef srcfile = naNewString(_context);
     naStr_fromdata(srcfile, (char*)filename, strlen(filename));
@@ -477,7 +476,7 @@ bool FGNasalSys::handleCommand(const SGPropertyNode* arg)
     // location in the property tree.  arg->getPath() returns an empty
     // string.
     const char* nasal = arg->getStringValue("script");
-    naRef code = parse("<command>", nasal);
+    naRef code = parse("<command>", nasal, strlen(nasal));
     if(naIsNil(code)) return false;
     
     // Cache the command argument for inspection via cmdarg().  For
index 01404a06470163f66b731e92b79bea3160c4f29a..bf6a0abf6d7f57fd6b32de4ace1dfa034c53172c 100644 (file)
@@ -59,7 +59,7 @@ private:
     void readScriptFile(SGPath file, const char* lib);
     void hashset(naRef hash, const char* key, naRef val);
     void logError();
-    naRef parse(const char* filename, const char* buf, int len=0);
+    naRef parse(const char* filename, const char* buf, int len);
     naRef genPropsModule();
     naRef propNodeGhost(SGPropertyNode* handle);