Closed vkichline closed 1 year ago
Hello, Here the corrected code:
: path-join { a a# b b# -- a n }
b c@ [char] / = if 0 to a# then
a# b# + { r# } r# cell+ cell+ allocate throw { r }
2 cells +to r
begin b b# starts./ while
2 +to b -2 +to b#
a# b# + to r#
repeat
begin b b# starts../ a# 0<> and while
3 +to b -3 +to b#
a a# dirname to a# to a
a# b# + to r#
repeat
a r a# cmove b r a# + b# cmove
r# r cell - !
r r# ;
Version 7.0.7.12 resolves this issue, better than my suggestion above. Thank you.
Thanks for ueforth! I've been enjoying it immensely! I ran into an issue and would like to share my findings. I was unable to include one file from another using full paths. For example, if file1.fs contains: "include /sd/file2.fs", entering "include /sd/file1.fs" will fail. I found the cause in common/including.fs, in the word path-join. The third line determines if the file name is a full path, and if so zeros the directory name length. However, the combined string length has already been calculated and is not corrected. This results in the correct string being returned, but with an excessive length, resulting in a file not found error. I found that simply moving the third line of path-join to the beginning of the word fixes the problem. There are a few other very minor issues in this word; slightly too much memory is allocated from the heap for paths that begin with ./ and ../ . I would be happy to prepare a pull request if you like.