[m-dev.] For review: io.m
Fergus Henderson
fjh at cs.mu.oz.au
Thu Jun 5 11:33:26 AEST 1997
Thomas Charles CONWAY, you wrote:
>
> -% returns a unique temporary filename.
> :- pred io__tmpnam(string, io__state, io__state).
> :- mode io__tmpnam(out, di, uo) is det.
> + % io__tmpnam(Name, IO0, IO) binds `Name' to a temporary
> + % file name which is different to the name of any existing file.
> + % It will reside in /tmp if the TMPDIR environment variable
> + % is not set, or in the directory specified by TMPDIR if it
> + % is set.
> +
> +:- pred io__tmpnam(string, string, string, io__state, io__state).
> +:- mode io__tmpnam(in, in, out, di, uo) is det.
> + % io__tmpnam(Dir, Prefix, Name, IO0, IO) binds `Name' to a
> + % temporary file name which is unique. It will reside in the
> + % directory specified by `Dir' and have a prefix using up to the
> + % first 5 characters of `Prefix'.
Please change "unique" here too.
> +#ifdef IO_HAVE_TEMPNAM
> + String tmp;
> +
> + tmp = tempnam(Dir, Prefix);
> + if (tmp == NULL) {
> + fatal_error(""unable to create temporary filename"");
> + }
> + incr_saved_hp_atomic(LVALUE_CAST(Word *,FileName),
> + (strlen((String) tmp) + sizeof(Word)) / sizeof(Word));
The cast to (String) here is unnecessary. `tmp' is already a String.
> + i=0;
s/i=0/i = 0/
Also, a more meaningful variable name would be better:
s/i/num_tries/g
Otherwise that looks good.
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
More information about the developers
mailing list