RPGHacker / asar

(Now) official repository of the SNES assembler Asar, originally created by Alcaro
Other
204 stars 43 forks source link

`stdincludes.txt` not loaded when called through `PATH` #326

Open exodustx0 opened 2 months ago

exodustx0 commented 2 months ago

The manual (for both v1.90 and v2) states:

When a file with [the name stdincludes.txt] exists next to the Asar executable, Asar automatically opens it and adds every line in it as an include search path [...]

This is not true if asar is called through PATH, due to argv[0] just being asar.

randomdude999 commented 2 months ago

ugh, that's true. is there a better way to do this? anything more portable than readlink(/proc/self/exe)?

Alcaro commented 2 months ago

does #ifdef count as portable?

exodustx0 commented 2 months ago

does #ifdef count as portable?

Note that, for the Windows implementation, the path may not fit in MAX_PATH-length buffer when long path support is enabled. Also, I'm not sure what you're doing with the first argument to GetModuleFileNameA, but the documentation suggests passing in NULL to get the current process's executable path.

Alcaro commented 2 months ago

Yes, passing NULL gets the current EXE's path.

That is not necessarily the path Asar is in, if it's compiled as a DLL. That's what that first argument does.

MAX_PATH, however, is a valid objection.

exodustx0 commented 2 months ago

I wasn't aware DLLs have inconsistent path reporting through GetModuleFileName.

Alcaro commented 2 months ago

what are you talking about. there's nothing inconsistent there, GetModuleFileName returns the exe's path just fine if called from a dll with hmodule=null

it's just that that's not the path the dll is looking for. dlls don't need to be beside the exe, go look up where kernel32.dll is located

exodustx0 commented 2 months ago

I misinterpreted your earlier message.