* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
* This code is derived from software contributed to Berkeley by
* Rodney Ruddock of the University of Guelph.
* %sccs.include.redist.c%
static char sccsid
[] = "@(#)e.c 8.1 (Berkeley) %G%";
* Places a new file in the buffer to be editted. The current contents
* of the buffer are deleted - no undo can be perfomed. A warning is
* issued once if no write has occurred since the last buffer
* modification (unless 'E' spec'd).
int l_which
; /* which is it? 'e' or 'E' */
l_temp
= filename(inputt
, errnum
);
filename_current
= l_temp
;
if (sigint_flag
&& (!sigspecial
))
while (((ss
= getc(inputt
)) != '\n') || (ss
== EOF
));
/* Note: 'E' will bypass this if stmt., which warns of no save. */
if ((change_flag
== 1L) && (l_which
== 'e')) {
strcpy(help_msg
, "warning: buffer changes not saved");
Start_default
= End_default
= 0;
if (Start
== NULL
&& bottom
== NULL
);
d(inputt
, errnum
); /* delete the whole buffer */
/* An 'e' clears all traces of last doc'mt, even in 'g'. */
(dbhtmp
->close
) (dbhtmp
);
* This is pulled out of e.c to make the "simulated 'e'" at startup easier to
template = (char *) calloc(FILENAME_LEN
, sizeof(char));
/* create the buffer using the method favored at compile time */
tmp_path
= getenv("TMPDIR");
sprintf(template, "%s/_4.4bsd_ed_XXXXXX", tmp_path
? tmp_path
: "/tmp");
fhtmp
= fopen(template, "w+");
ed_exit(5); /* unable to create buffer */
fwrite("R", sizeof(char), 1, fhtmp
);
/* open using btree only, recno will mess things up
* because of garbage collection and how recno operates
dbhtmp
= dbopen(template, O_CREAT
| O_RDWR
,
S_IRUSR
| S_IWUSR
, (DBTYPE
) DB_BTREE
, NULL
);
ed_exit(5); /* unable to create buffer */
if (sigint_flag
&&(!sigspecial
))
/* So 'r' knows the filename is already read in. */
gut_num
= line_number(bottom
) + 512;
gut
= malloc(sizeof(LINE
**) * gut_num
);
strcpy(help_msg
, "out of memory error");