Issue 64399 - Mac OS X: remove macxp_tempnam
Summary: Mac OS X: remove macxp_tempnam
Status: CLOSED FIXED
Alias: None
Product: porting
Classification: Code
Component: MacOSX (show other issues)
Version: current
Hardware: All All
: P4 Trivial (vote)
Target Milestone: DevTools
Assignee: pavel
QA Contact: issues@porting
URL:
Keywords:
Depends on:
Blocks: 64421
  Show dependency tree
 
Reported: 2006-04-14 17:18 UTC by pavel
Modified: 2006-05-08 13:40 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description pavel 2006-04-14 17:18:52 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.
Comment 1 pavel 2006-04-14 21:14:10 UTC
.
Comment 2 moxfox 2006-04-15 18:40:29 UTC
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?
Comment 3 pavel 2006-04-15 18:51:19 UTC
mox: Where do you got the information about "/var/tmp"? Have you read the code
in CVS?
Comment 4 moxfox 2006-04-15 20:24:33 UTC
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.
Comment 5 pavel 2006-04-15 20:46:05 UTC
mox: but this is unrelated issue, right?
Comment 6 pavel 2006-04-15 20:50:04 UTC
mox: nevertheless, it is still worth separate issue to investigate why there are
two behaviors for tmp file creation...
Comment 7 pavel 2006-04-15 23:15:23 UTC
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.
Comment 8 moxfox 2006-04-16 01:22:38 UTC
Yep you filed the separate issues.
Comment 9 pavel 2006-04-25 11:55:06 UTC
macxp_tempnam removed in pj54.

Please verify.
Comment 10 jjmckenzie 2006-04-30 07:25:57 UTC
Verified.

James M.
Comment 11 pavel 2006-05-08 13:40:41 UTC
Seen in m167.