lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I am trying to understand the source code for 'require' in loadlib.c and would be grateful for some help. The reason is that 'require' does not behave for RISC OS in quite the way I want. The file-naming conventions of RISC OS are different from both Unix and Windows. This is partly taken care of by the flexibility of LUA_PATH_SEP in luaconf.h, but not entirely. There is no notion of filename-extension in RISC OS, and a file's type is instead a built-in attribute determined by six bits within the file itself. This means that for translating between RISC OS and Unix it is convenient to swap the characters '.' and '/'; the dot is the directory-separator in RISC OS. In loadlib.c an explicit "." appears in the functions 'findfile', 'll_searchpath' and 'loadfunc'; also an explicit '.' appears in function 'searcher_Croot'. But I am not sure which sense the dot has in these cases. Is it 'current directory' or 'filename-extension-introduction'?

At present 'require "foo"' works as it should for RISC OS, but 'require "foo.bar"' does not. I would like all dots in the argument string to 'require' to be passed through to the file-loading functions unchanged. I wondered whether the explicit mention of "." in the loadlib.c sources was the cause of my problem.