Browse Source

JSRequire will change '\0' to '\n' locally to avoid a bug with EOF

rsredsq 10 years ago
parent
commit
93cfd07217
2 changed files with 2 additions and 1 deletions
  1. 1 1
      Source/Atomic/IO/File.cpp
  2. 1 0
      Source/AtomicJS/Javascript/JSRequire.cpp

+ 1 - 1
Source/Atomic/IO/File.cpp

@@ -539,7 +539,7 @@ void File::ReadText(String& text)
 
 
     Read((void*)text.CString(), size_);
     Read((void*)text.CString(), size_);
 
 
-    text[size_] = '\n';
+    text[size_] = '\0';
 }
 }
 
 
 // ATOMIC BEGIN
 // ATOMIC BEGIN

+ 1 - 0
Source/AtomicJS/Javascript/JSRequire.cpp

@@ -133,6 +133,7 @@ namespace Atomic
             vm->SetLastModuleSearchFile(jsfile->GetFullPath());
             vm->SetLastModuleSearchFile(jsfile->GetFullPath());
             String source;
             String source;
             jsfile->ReadText(source);
             jsfile->ReadText(source);
+            source.At(source.Length() - 1) = '\n';
             duk_push_string(ctx, source.CString());
             duk_push_string(ctx, source.CString());
             return 1;
             return 1;
         }
         }