projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
STDIO fix
[unix-history]
/
usr
/
src
/
contrib
/
ed
/
e.c
diff --git
a/usr/src/contrib/ed/e.c
b/usr/src/contrib/ed/e.c
index
5497e1e
..
09c351a
100644
(file)
--- a/
usr/src/contrib/ed/e.c
+++ b/
usr/src/contrib/ed/e.c
@@
-9,14
+9,14
@@
*/
#ifndef lint
*/
#ifndef lint
-static char sccsid[] = "@(#)e.c 5.
2
(Berkeley) %G%";
+static char sccsid[] = "@(#)e.c 5.
4
(Berkeley) %G%";
#endif /* not lint */
#include <sys/types.h>
#include <sys/stat.h>
#endif /* not lint */
#include <sys/types.h>
#include <sys/stat.h>
-#include <db.h>
#include <fcntl.h>
#include <fcntl.h>
+#include <limits.h>
#include <regex.h>
#include <setjmp.h>
#include <stdio.h>
#include <regex.h>
#include <setjmp.h>
#include <stdio.h>
@@
-24,6
+24,10
@@
static char sccsid[] = "@(#)e.c 5.2 (Berkeley) %G%";
#include <string.h>
#include <unistd.h>
#include <string.h>
#include <unistd.h>
+#ifdef DBI
+#include <db.h>
+#endif
+
#include "ed.h"
#include "extern.h"
#include "ed.h"
#include "extern.h"
@@
-45,11
+49,13
@@
e(inputt, errnum)
l_which = ss;
l_temp = filename(inputt, errnum);
l_which = ss;
l_temp = filename(inputt, errnum);
- if (sigint_flag)
- SIGINT_ACTION;
if (*errnum == 1) {
if (*errnum == 1) {
+ sigspecial++;
free(filename_current);
filename_current = l_temp;
free(filename_current);
filename_current = l_temp;
+ sigspecial--;
+ if (sigint_flag && (!sigspecial))
+ SIGINT_ACTION;
} else
if (*errnum == -2)
while (((ss = getc(inputt)) != '\n') || (ss == EOF));
} else
if (*errnum == -2)
while (((ss = getc(inputt)) != '\n') || (ss == EOF));
@@
-74,18
+80,24
@@
e(inputt, errnum)
ungetc(ss, inputt);
d(inputt, errnum); /* delete the whole buffer */
}
ungetc(ss, inputt);
d(inputt, errnum); /* delete the whole buffer */
}
- if (sigint_flag)
- SIGINT_ACTION;
/* An 'e' clears all traces of last doc'mt, even in 'g'. */
u_clr_stk();
if (*errnum < 0)
return;
*errnum = 0;
/* An 'e' clears all traces of last doc'mt, even in 'g'. */
u_clr_stk();
if (*errnum < 0)
return;
*errnum = 0;
+#ifdef STDIO
+ if (fhtmp > NULL) {
+ fclose(fhtmp);
+ unlink(template);
+ }
+#endif
+#ifdef DBI
if (dbhtmp != NULL) {
(dbhtmp->close) (dbhtmp);
unlink(template);
}
if (dbhtmp != NULL) {
(dbhtmp->close) (dbhtmp);
unlink(template);
}
+#endif
name_set = 1;
e2(inputt, errnum);
name_set = 1;
e2(inputt, errnum);
@@
-102,16
+114,32
@@
e2(inputt, errnum)
FILE *inputt;
int *errnum;
{
FILE *inputt;
int *errnum;
{
+ char *tmp_path;
+#ifdef DBI
RECNOINFO l_dbaccess;
RECNOINFO l_dbaccess;
+#endif
+ sigspecial++;
+#ifndef MEMORY
if (template == NULL) {
template = (char *) calloc(FILENAME_LEN, sizeof(char));
if (template == NULL)
ed_exit(4);
}
/* create the buffer using the method favored at compile time */
if (template == NULL) {
template = (char *) calloc(FILENAME_LEN, sizeof(char));
if (template == NULL)
ed_exit(4);
}
/* create the buffer using the method favored at compile time */
- bcopy("/tmp/_4.4bsd_ed_XXXXXX\0", template, 22);
+ tmp_path = getenv("TMPDIR");
+ sprintf(template, "%s/_4.4bsd_ed_XXXXXX", tmp_path ? tmp_path : "/tmp");
mktemp(template);
mktemp(template);
+#endif
+#ifdef STDIO
+ fhtmp = fopen(template, "w+");
+ if (fhtmp == NULL) {
+ ed_exit(5); /* unable to create buffer */
+ }
+ fwrite("R", sizeof(char), 1, fhtmp);
+ file_seek = 0;
+#endif
+#ifdef DBI
(l_dbaccess.bval) = (u_char) '\0';
(l_dbaccess.cachesize) = 0;
(l_dbaccess.flags) = R_NOKEY;
(l_dbaccess.bval) = (u_char) '\0';
(l_dbaccess.cachesize) = 0;
(l_dbaccess.flags) = R_NOKEY;
@@
-119,12
+147,19
@@
e2(inputt, errnum)
(l_dbaccess.reclen) = 0;
dbhtmp = dbopen(template, O_CREAT | O_RDWR,
S_IRUSR | S_IWUSR, (DBTYPE) DB_RECNO, &l_dbaccess);
(l_dbaccess.reclen) = 0;
dbhtmp = dbopen(template, O_CREAT | O_RDWR,
S_IRUSR | S_IWUSR, (DBTYPE) DB_RECNO, &l_dbaccess);
+ if (dbhtmp == NULL) {
+ ed_exit(5); /* unable to create buffer */
+ }
+#endif
current = top;
start = top;
End = bottom;
current = top;
start = top;
End = bottom;
- if (sigint_flag)
+ sigspecial--;
+ if (sigint_flag &&(!sigspecial))
SIGINT_ACTION;
SIGINT_ACTION;
+
+ change_flag = 1;
if (name_set) {
/* So 'r' knows the filename is already read in. */
filename_flag = 1;
if (name_set) {
/* So 'r' knows the filename is already read in. */
filename_flag = 1;