X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/ecbf4ad016f15bf117a8e2697201439e1e470d7b..2718f34d650eae65503d49059ff40533fcd9a942:/usr/src/contrib/ed/e.c diff --git a/usr/src/contrib/ed/e.c b/usr/src/contrib/ed/e.c index 5497e1e04c..09c351a21d 100644 --- a/usr/src/contrib/ed/e.c +++ b/usr/src/contrib/ed/e.c @@ -9,14 +9,14 @@ */ #ifndef lint -static char sccsid[] = "@(#)e.c 5.2 (Berkeley) %G%"; +static char sccsid[] = "@(#)e.c 5.4 (Berkeley) %G%"; #endif /* not lint */ #include #include -#include #include +#include #include #include #include @@ -24,6 +24,10 @@ static char sccsid[] = "@(#)e.c 5.2 (Berkeley) %G%"; #include #include +#ifdef DBI +#include +#endif + #include "ed.h" #include "extern.h" @@ -45,11 +49,13 @@ e(inputt, errnum) l_which = ss; l_temp = filename(inputt, errnum); - if (sigint_flag) - SIGINT_ACTION; if (*errnum == 1) { + sigspecial++; 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)); @@ -74,18 +80,24 @@ e(inputt, errnum) 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; +#ifdef STDIO + if (fhtmp > NULL) { + fclose(fhtmp); + unlink(template); + } +#endif +#ifdef DBI if (dbhtmp != NULL) { (dbhtmp->close) (dbhtmp); unlink(template); } +#endif name_set = 1; e2(inputt, errnum); @@ -102,16 +114,32 @@ e2(inputt, errnum) FILE *inputt; int *errnum; { + char *tmp_path; +#ifdef DBI 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 */ - 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); +#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; @@ -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); + if (dbhtmp == NULL) { + ed_exit(5); /* unable to create buffer */ + } +#endif current = top; start = top; End = bottom; - if (sigint_flag) + sigspecial--; + if (sigint_flag &&(!sigspecial)) SIGINT_ACTION; + + change_flag = 1; if (name_set) { /* So 'r' knows the filename is already read in. */ filename_flag = 1;