2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
5 * %sccs.include.redist.c%
9 static char sccsid
[] = "$Id: ex_edit.c,v 8.13 1993/12/03 15:40:48 bostic Exp $ (Berkeley) $Date: 1993/12/03 15:40:48 $";
12 #include <sys/types.h>
22 * ex_edit -- :e[dit][!] [+cmd] [file]
23 * :vi[sual][!] [+cmd] [file]
25 * Edit a file; if none specified, re-edit the current file. The second
26 * form of the command can only be executed while in vi mode. See the
27 * hack in ex.c:ex_cmd().
30 * Historic vi didn't permit the '+' command form without specifying
31 * a file name as well.
46 * If the name has been changed, we edit that file, not
49 if (frp
->cname
!= NULL
) {
50 if ((frp
= file_add(sp
, frp
, frp
->cname
, 1)) == NULL
)
52 set_alt_name(sp
, sp
->frp
->cname
);
57 if ((frp
= file_add(sp
, sp
->frp
, ap
->bp
, 1)) == NULL
)
59 set_alt_name(sp
, ap
->bp
);
66 * Check for modifications.
69 * Contrary to POSIX 1003.2-1992, autowrite did not affect :edit.
71 if (F_ISSET(ep
, F_MODIFIED
) &&
72 ep
->refcnt
<= 1 && !F_ISSET(cmdp
, E_FORCE
)) {
74 "Modified since last write; write or use ! to override.");
79 if (file_init(sp
, frp
, NULL
, F_ISSET(cmdp
, E_FORCE
)))