52 lines
1.1 KiB
Diff
52 lines
1.1 KiB
Diff
![]() |
--- ed-0.2/buf.c.chmou Sat Nov 19 13:37:59 1994
|
||
|
+++ ed-0.2/buf.c Mon Nov 27 11:46:54 2000
|
||
|
@@ -194,21 +194,17 @@
|
||
|
|
||
|
extern int newline_added;
|
||
|
|
||
|
-char sfn[15] = ""; /* scratch file name */
|
||
|
-
|
||
|
/* open_sbuf: open scratch file */
|
||
|
int
|
||
|
open_sbuf ()
|
||
|
{
|
||
|
- char *mktemp ();
|
||
|
int u;
|
||
|
|
||
|
isbinary = newline_added = 0;
|
||
|
u = umask(077);
|
||
|
- strcpy (sfn, "/tmp/ed.XXXXXX");
|
||
|
- if (mktemp (sfn) == NULL || (sfp = fopen (sfn, "w+")) == NULL)
|
||
|
+ if ((sfp = tmpfile()) == NULL)
|
||
|
{
|
||
|
- fprintf (stderr, "%s: %s\n", sfn, strerror (errno));
|
||
|
+ fprintf (stderr, "%s\n", strerror (errno));
|
||
|
sprintf (errmsg, "Cannot open temp file");
|
||
|
umask(u);
|
||
|
return ERR;
|
||
|
@@ -226,14 +222,14 @@
|
||
|
{
|
||
|
if (fclose (sfp) < 0)
|
||
|
{
|
||
|
- fprintf (stderr, "%s: %s\n", sfn, strerror (errno));
|
||
|
+ fprintf (stderr, "Cannot close temp file: %s\n", strerror (errno));
|
||
|
sprintf (errmsg, "Cannot close temp file");
|
||
|
return ERR;
|
||
|
}
|
||
|
sfp = NULL;
|
||
|
- unlink (sfn);
|
||
|
}
|
||
|
sfseek = seek_write = 0;
|
||
|
+
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
@@ -246,7 +242,6 @@
|
||
|
if (sfp)
|
||
|
{
|
||
|
fclose (sfp);
|
||
|
- unlink (sfn);
|
||
|
}
|
||
|
exit (n);
|
||
|
}
|