From 3a6bc316edef6366d442912c6ba086b762e2966f Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 26 Apr 2005 20:57:06 +0000 Subject: [PATCH] Same bug, different place. Don't treat a length of zero as "please strlen() it", because real files and properties can have lengths of zero. --- src/Scripting/NasalSys.cxx | 5 ++--- src/Scripting/NasalSys.hxx | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Scripting/NasalSys.cxx b/src/Scripting/NasalSys.cxx index ccb1e926a..e8374bc71 100644 --- a/src/Scripting/NasalSys.cxx +++ b/src/Scripting/NasalSys.cxx @@ -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("", nasal); + naRef code = parse("", nasal, strlen(nasal)); if(naIsNil(code)) return false; // Cache the command argument for inspection via cmdarg(). For diff --git a/src/Scripting/NasalSys.hxx b/src/Scripting/NasalSys.hxx index 01404a064..bf6a0abf6 100644 --- a/src/Scripting/NasalSys.hxx +++ b/src/Scripting/NasalSys.hxx @@ -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);