Apache OpenOffice (AOO) Bugzilla – Issue 64399
Mac OS X: remove macxp_tempnam
Last modified: 2006-05-08 13:40:41 UTC
Short fairy-tale In the past, there was buggy tempnam function call on Mac OS X. Thus macxp_tempnam was invented to implement correct behaviour. It is not needed now because both Panther and Tiger got it right and tempnam returns "random" results as it should. Simple test: macmini:~/q oo$ cat tempnamtest.c int main () { int i; for (i=0; i<10; i++) printf("tempnam (%d) = %s\n", i, tempnam("/tmp", "foo")); } macmini:~/q oo$ ./a.out tempnam (0) = /tmp/fooFoaDRI tempnam (1) = /tmp/fooTSO6AP tempnam (2) = /tmp/foo5voroG tempnam (3) = /tmp/foond6vwe tempnam (4) = /tmp/fooD3gjoS tempnam (5) = /tmp/foocl1sXe tempnam (6) = /tmp/foolHMhzs tempnam (7) = /tmp/foo269FwW tempnam (8) = /tmp/fooZc73lU tempnam (9) = /tmp/foouXeRHw macmini:~/q oo$ There is the only place where this function is called - module psprint. I'll remove it completely.
.
Pavel, The Patrick's donated code modifies the temporary file behaviour in OOo so that the default dir for tempfiles is /tmp. It may be still that the default temp dir in OOo for Mac is set to /var/tmp. While this works, it is not optimal, because /var/tmp is not automatically cleaned by Mac OS X, but /tmp is. While removing the macxp_tempnam, could you please check this and make the necessary changes if needed?
mox: Where do you got the information about "/var/tmp"? Have you read the code in CVS?
The tmpfile code is confusing to me. The Patricks code (with the explanations) are in http://porting.openoffice.org/servlets/ReadMsg?list=dev&msgNo=15387 When running OOo 2.0.2 for Mac, the /tmp is used for some OOo stuff, but when documents are opened, they show up in /var/tmp/, in folder like: sv9jj.tmp. Those files are cleaned by OOo when the application is closed, but obviously not when OOo crashes or in other unusual circumstances. So the problem does exist. Looking at the Patricks diff, the important parts are: 1) Mac OS X does not have TEMP environment variable, TMPDIR should be used instead. 2) The P_tmpdir (defined in stdio.h) should not be used as the last fallback (because it points to /var/tmp). Instead "/tmp" should be used as the last fallback.
mox: but this is unrelated issue, right?
mox: nevertheless, it is still worth separate issue to investigate why there are two behaviors for tmp file creation...
mox: I think that the /var/tmp comes from const char *TempDirImpl( char *pBuf ) (as defined in tools/source/fsys/unx.cxx). because it is using P_tmpdir as a last resort.
Yep you filed the separate issues.
macxp_tempnam removed in pj54. Please verify.
Verified. James M.
Seen in m167.