From: Tim Vaughan Date: Mon, 30 May 2016 11:18:01 +0000 (+1200) Subject: Fixed library loading bug. X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=29785f65f11afea63d4f5ca5a505e62fecdd5299;p=forth.jl.git Fixed library loading bug. --- diff --git a/src/forth.jl b/src/forth.jl index 9439dea..1a65ff6 100644 --- a/src/forth.jl +++ b/src/forth.jl @@ -994,7 +994,14 @@ INCLUDE_CFA = defPrimWord("INCLUDE", () -> begin wordLen = mem[wordAddr-1] word = getString(wordAddr, wordLen) - push!(sources, open(word, "r")) + fname = word + if !isfile(fname) + fname = Pkg.dir("forth","src",word) + if !isfile(fname) + error("No file named $word found in current directory or package source directory.") + end + end + push!(sources, open(fname, "r")) # Clear input buffer mem[NUMTIB] = 0 @@ -1009,8 +1016,8 @@ initialized = false initFileName = nothing if isfile("lib.4th") initFileName = "lib.4th" -elseif isfile(Pkg.dir("forth/src/lib.4th")) - initFileName = Pkg.dir("forth/src/lib.4th") +elseif isfile(Pkg.dir("forth","src", "lib.4th")) + initFileName = Pkg.dir("forth","src","lib.4th") end function run(;initialize=true)