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_file.c,v 8.6 1993/11/26 16:22:42 bostic Exp $ (Berkeley) $Date: 1993/11/26 16:22:42 $";
12 #include <sys/types.h>
22 * ex_file -- :f[ile] [name]
23 * Status line and change the file's name.
40 /* Make sure can allocate enough space. */
41 if ((p
= strdup((char *)cmdp
->argv
[0])) == NULL
) {
42 msgq(sp
, M_SYSERR
, NULL
);
46 /* If already have a file name, it becomes the alternate. */
51 /* Free any previously changed name. */
52 if (frp
->cname
!= NULL
)
53 FREE(frp
->cname
, frp
->clen
);
55 frp
->clen
= strlen(p
);
57 /* The read-only bit follows the file name; clear it. */
58 F_CLR(frp
, FR_RDONLY
);
60 /* Have to force a write if the file exists, next time. */
61 F_CLR(frp
, FR_CHANGEWRITE
);
66 status(sp
, ep
, sp
->lno
, 1);