fix temp file issue.
From FreeBSD
This commit is contained in:
parent
6f3424413a
commit
adfc78ceb2
@ -1,9 +1,10 @@
|
||||
# $OpenBSD: Makefile,v 1.5 2004/11/24 11:08:02 espie Exp $
|
||||
# $OpenBSD: Makefile,v 1.6 2006/01/27 22:45:52 brad Exp $
|
||||
|
||||
COMMENT= "easy to use text editor"
|
||||
|
||||
VERSION= 1.4.6
|
||||
DISTNAME= ee-${VERSION}
|
||||
PKGNAME= ${DISTNAME}p1
|
||||
CATEGORIES= editors
|
||||
|
||||
HOMEPAGE= http://mahon.cwx.net/
|
||||
@ -24,7 +25,7 @@ MAKE_ENV= SYSCONFDIR=${SYSCONFDIR}
|
||||
NO_REGRESS= Yes
|
||||
|
||||
do-install:
|
||||
perl -i -pe 's:%%SYSCONFDIR%%:${SYSCONFDIR}:g' ${WRKSRC}/ee.1
|
||||
@perl -i -pe 's:%%SYSCONFDIR%%:${SYSCONFDIR}:g' ${WRKSRC}/ee.1
|
||||
${INSTALL} ${WRKDIST}/ee ${PREFIX}/bin/ee
|
||||
${INSTALL_DATA} ${WRKDIST}/ee.1 ${PREFIX}/man/man1/ee.1
|
||||
|
||||
|
@ -1,7 +1,16 @@
|
||||
$OpenBSD: patch-ee_c,v 1.2 2002/12/13 07:52:10 pvalchev Exp $
|
||||
--- ee.c.orig Fri Aug 17 17:14:49 2001
|
||||
+++ ee.c Thu Dec 12 00:22:09 2002
|
||||
@@ -929,7 +929,7 @@ int temp_int;
|
||||
$OpenBSD: patch-ee_c,v 1.3 2006/01/27 22:45:52 brad Exp $
|
||||
--- ee.c.orig Fri Sep 20 20:46:16 2002
|
||||
+++ ee.c Sat Jan 14 19:59:25 2006
|
||||
@@ -300,7 +300,7 @@ void finish P_((void));
|
||||
int quit P_((int noverify));
|
||||
void edit_abort P_((int arg));
|
||||
void delete_text P_((void));
|
||||
-int write_file P_((char *file_name));
|
||||
+int write_file P_((char *file_name, int warn_if_exists));
|
||||
int search P_((int display_message));
|
||||
void search_prompt P_((void));
|
||||
void del_char P_((void));
|
||||
@@ -931,7 +931,7 @@ int temp_int;
|
||||
int
|
||||
out_char(window, character, column) /* output non-printing character */
|
||||
WINDOW *window;
|
||||
@ -10,7 +19,7 @@ $OpenBSD: patch-ee_c,v 1.2 2002/12/13 07:52:10 pvalchev Exp $
|
||||
int column;
|
||||
{
|
||||
int i1, i2;
|
||||
@@ -977,7 +977,7 @@ int column;
|
||||
@@ -979,7 +979,7 @@ int column;
|
||||
|
||||
int
|
||||
len_char(character, column) /* return the length of the character */
|
||||
@ -19,7 +28,64 @@ $OpenBSD: patch-ee_c,v 1.2 2002/12/13 07:52:10 pvalchev Exp $
|
||||
int column; /* the column must be known to provide spacing for tabs */
|
||||
{
|
||||
int length;
|
||||
@@ -4069,7 +4069,7 @@ Format() /* format the paragraph accordi
|
||||
@@ -1694,7 +1694,7 @@ char *cmd_str1;
|
||||
cmd_str = cmd_str2 = get_string(file_write_prompt_str, TRUE);
|
||||
}
|
||||
tmp_file = resolve_name(cmd_str);
|
||||
- write_file(tmp_file);
|
||||
+ write_file(tmp_file, 1);
|
||||
if (tmp_file != cmd_str)
|
||||
free(tmp_file);
|
||||
}
|
||||
@@ -2401,7 +2401,7 @@ finish() /* prepare to exit edit session
|
||||
file_name = tmp_file;
|
||||
}
|
||||
|
||||
- if (write_file(file_name))
|
||||
+ if (write_file(file_name, 1))
|
||||
{
|
||||
text_changes = FALSE;
|
||||
quit(0);
|
||||
@@ -2477,8 +2477,9 @@ delete_text()
|
||||
}
|
||||
|
||||
int
|
||||
-write_file(file_name)
|
||||
+write_file(file_name, warn_if_exists)
|
||||
char *file_name;
|
||||
+int warn_if_exists;
|
||||
{
|
||||
char cr;
|
||||
char *tmp_point;
|
||||
@@ -2488,7 +2489,8 @@ char *file_name;
|
||||
int write_flag = TRUE;
|
||||
|
||||
charac = lines = 0;
|
||||
- if ((in_file_name == NULL) || strcmp(in_file_name, file_name))
|
||||
+ if (warn_if_exists &&
|
||||
+ ((in_file_name == NULL) || strcmp(in_file_name, file_name)))
|
||||
{
|
||||
if ((temp_fp = fopen(file_name, "r")))
|
||||
{
|
||||
@@ -3734,7 +3736,7 @@ int arg;
|
||||
{
|
||||
string = get_string(file_write_prompt_str, TRUE);
|
||||
tmp_file = resolve_name(string);
|
||||
- write_file(tmp_file);
|
||||
+ write_file(tmp_file, 1);
|
||||
if (tmp_file != string)
|
||||
free(tmp_file);
|
||||
free(string);
|
||||
@@ -3771,7 +3773,7 @@ int arg;
|
||||
string = tmp_file;
|
||||
}
|
||||
}
|
||||
- if (write_file(string))
|
||||
+ if (write_file(string, 1))
|
||||
{
|
||||
in_file_name = string;
|
||||
text_changes = FALSE;
|
||||
@@ -4080,7 +4082,7 @@ Format() /* format the paragraph accordi
|
||||
}
|
||||
|
||||
unsigned char *init_name[3] = {
|
||||
@ -28,3 +94,34 @@ $OpenBSD: patch-ee_c,v 1.2 2002/12/13 07:52:10 pvalchev Exp $
|
||||
NULL,
|
||||
".init.ee"
|
||||
};
|
||||
@@ -4382,17 +4384,25 @@ spell_op() /* check spelling of words in
|
||||
void
|
||||
ispell_op()
|
||||
{
|
||||
- char name[128];
|
||||
+ char template[128], *name;
|
||||
char string[256];
|
||||
- int pid;
|
||||
+ int fd;
|
||||
|
||||
if (restrict_mode())
|
||||
{
|
||||
return;
|
||||
}
|
||||
- pid = getpid();
|
||||
- sprintf(name, "/tmp/ee.%d", pid);
|
||||
- if (write_file(name))
|
||||
+ (void)sprintf(template, "/tmp/ee.XXXXXXXX");
|
||||
+ name = mktemp(&template[0]);
|
||||
+ fd = open(name, O_CREAT | O_EXCL | O_RDWR, 0600);
|
||||
+ if (fd < 0) {
|
||||
+ wmove(com_win, 0, 0);
|
||||
+ wprintw(com_win, create_file_fail_msg, name);
|
||||
+ wrefresh(com_win);
|
||||
+ return;
|
||||
+ }
|
||||
+ close(fd);
|
||||
+ if (write_file(name, 0))
|
||||
{
|
||||
sprintf(string, "ispell %s", name);
|
||||
sh_command(string);
|
||||
|
Loading…
Reference in New Issue
Block a user