Re: [PATCH] tempname: new try_tempname function

2015-02-04 Thread Andreas Grünbacher
2015-02-03 17:19 GMT+01:00 Paul Eggert : > Thanks, that looks good; please install. Done, thanks. Andreas

Re: [PATCH] tempname: new try_tempname function

2015-02-03 Thread Paul Eggert
On 02/03/2015 12:23 AM, Andreas Gruenbacher wrote: Here's one (hopefully last) update. Thanks, that looks good; please install.

[PATCH] tempname: new try_tempname function

2015-02-03 Thread Andreas Gruenbacher
From: Andreas Gruenbacher 2015-02-03 2:11 GMT+01:00 Paul Eggert : > Thanks, one further suggestion. The above can be simplified to: > > if (__lxstat64 (_STAT_VER, tmpl, &st) == 0) > __set_errno (EEXIST); > return errno == ENOENT ? 0 : -1; Here's one (hopefully last) update. Andreas --

Re: [PATCH] tempname: new try_tempname function

2015-02-02 Thread Paul Eggert
Andreas Grünbacher wrote: + if (__lxstat64 (_STAT_VER, tmpl, &st) < 0) +{ + if (errno == ENOENT) + return 0; +} + else +__set_errno (EEXIST); + return -1; Thanks, one further suggestion. The above can be simplified to: if (__lxstat64 (_STAT_VER, tmpl, &st) == 0)

Re: [PATCH] tempname: new try_tempname function

2015-02-02 Thread Andreas Grünbacher
ghtly. New version attached. Thanks, Andreas From 8abda1c9752d07c9450057acd1aa9ec3220f9a28 Mon Sep 17 00:00:00 2001 From: Andreas Gruenbacher Date: Sat, 31 Jan 2015 23:49:13 +0100 Subject: [PATCH] tempname: new try_tempname function The way how gen_tempname() creates files is not always sufficien

Re: [PATCH] tempname: new try_tempname function

2015-02-02 Thread Paul Eggert
On 01/31/2015 02:49 PM, Andreas Gruenbacher wrote: +static int +try_file (char *tmpl, void *flags) +{ + return __open (tmpl, +(* (int *) flags & ~O_ACCMODE) +| O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); +} Please avoid the cast by changing the body to look l

Re: [PATCH] tempname: new try_tempname function

2015-02-02 Thread Andreas Grünbacher
Paul and all, is this change okay? I need this so that I can get patch to behave consistently across platforms on failures. Thanks, Andreas

[PATCH] tempname: new try_tempname function

2015-01-31 Thread Andreas Gruenbacher
The way how gen_tempname() creates files is not always sufficient. For example, it may make sense to create directories when creating the temporary file or directory fails with errno set to ENOENT. Add a try_tempname() variant of gen-tempname() that allows to do all that, and implement gen_tempnam

Re: [PATCH] tempname: new try_tempname function

2015-01-31 Thread Paul Eggert
Andreas Grünbacher wrote: Well, try_file() passes the flags on to open() for gen_tempfile's GT_FILE mode. Ah, sorry, I missed that. For some uses (like mine), a create mode parameter wouldn't hurt, either. Then I suggest just passing a generic (void const *) argument to the TRY function.

Re: [PATCH] tempname: new try_tempname function

2015-01-31 Thread Andreas Grünbacher
2015-01-31 23:20 GMT+01:00 Paul Eggert : > Thanks for this improvement. However, I don't see why the new > __gen_tempname needs a FLAGS argument, as the new little functions now take > care of the flags. Well, try_file() passes the flags on to open() for gen_tempfile's GT_FILE mode. I don't think

Re: [PATCH] tempname: new try_tempname function

2015-01-31 Thread Paul Eggert
Thanks for this improvement. However, I don't see why the new __gen_tempname needs a FLAGS argument, as the new little functions now take care of the flags.

[PATCH] tempname: new try_tempname function

2015-01-31 Thread Andreas Gruenbacher
The way how gen_tempname() creates files is not always sufficient. For example, it may make sense to create directories when creating the temporary file or directory fails with errno set to ENOENT. Add a try_tempname() variant of gen-tempname() that allows to do all that and implement gen_tempname