As i can see, at the end, when called SetProtection, for non working version if called with 0x0000000F , and after that delete fail.
And for working version, SetProtection is called with 0x00000002, and then Delete didn't fail.
Also for working version i see there ExamineFH() before SetProtection is called, while in non-working vesion, there is ExamineObject(). So maybe those functions reacts different somehow which cause different SetProtection bits ?
SetProtection is called indirectly (via mch_setperm) in several places in Vim.
Yeah, i checked all the places where mch_setperm called : its is fileio.c only.
So i purely commented them out for tests: no changes. SetProtection still called which mean its inderectly called not from Vim, but from other DOS functions (seems so). Maybe when Examine called (and wchich replaced automatically on ExamineObject on compiling stage or so), dunno. But as far as i can tell, commenting out all calls to mch_setperm didn't stop SetProtect being called when i exit from vim.
The only explains i have that 7.1 version from os4depot works there, are :
1. it was build over clib2 (i checked, its indeed clib2, not newlib version) 2. it was compiled with much older DOS sdk.
The values $2 and $f are interesting. $2 is HSPARWD and $f is HSPA.
8 7 6 5 4 3 2 1 <- Bit number h s p a r w e d <- corresponding protection flag
0 = flag set 1 = flag clear
Only the owner rwed flags are reversed (0 = enabled, 1 = disabled), the hspa and group and other rwed flags are set the normal way (0 = disabled, 1 = enabled).
Ok ! Some good and intersting news related to that strange issue.
I build vim with clib2 (as done for 7.1 version on os4depot), and that bug disappear !
I.e. everything deletes on exit fine, and final SetProtection also 0x00000002 and not 0x0000000f as in case when build with Newlib.
Any ideas ?:)
It is probabaly os_amiga.c still, just as it works with clib2 as expected, and set some strange 0 to protection only with newlib (and what DOS function do it?), it is probabaly newlib/dos doing something nasty there ?
It's also called from f_setperm(..) in evalfunc.c.
I even test it all with 7.1 sources (not mui gui, etc), there is no f_setfperm was at this time. So it definately called from some other dos function when need it.
Some Belgian company full of laywers, update to os from which is probabaly unpossible to get anymore, taking aside any new SDK on which no one work :) clib2 from other side is free, opensourced , and hosted on adtools page together with latest binutils and gcc ports.
It can be that it also not newlib itself guilty, but code done in "wrong" for newlib way or something ..
Some Belgian company full of laywers, update to os from which is probabaly unpossible to get anymore, taking aside any new SDK on which no one work :) clib2 from other side is free, opensourced , and hosted on adtools page together with latest binutils and gcc ports.
@kas1e The empty filepermissions bug occurs because of a bug with dup2().
If the original file descriptor is closed before the duplicated one then the back reference got lost somehow (I forget the fine details) and the file permission got cleared.
This was reported by me in BZ 9294 (found whilst porting perl) and is fixed in newlib 53.34
@broadblues Its something else, because vim doesn't call dup2() anywhere (there is in code only one place, but its not used for amigaos builds, i tested it twice to be sure).
It has some plain dup() calls, but they all ifdefed via #HAVE_DUP, which is not enabled for amiga builds, so dup() also in no use.
Also i do all my tests on newlib.library 53.50 , so bug definately not in dup2() and happens even on latest beta builds.
I retest also your test-case code from BZ 9294, and it indeed works with 53.50, so it mean that its another scenario of the same bug.
What functions of dos (or of newlib?) call SetProtection as well inderectly ? I mean, it can be bug just in Examine() in newlib, if it call SetProtection by itself. Or, it can be bug with SetCurrentDir or something which is called before that SetProtection bug happens based with above snoopy logs.
Uploaded new version of vim_mui to os4depot: which rebuilded now with clib2 instead of newlib, as newlib still have a bug with file permission got cleared, which in end lead to non-deleted swap files in VIM. clib2 will be used until fixed version of newlib will be publicaly available, or we will add workoround to VIM's code.
In other words, swap file deletion on exit/close will works now.