aboutsummaryrefslogtreecommitdiff
path: root/common/exf.c
diff options
context:
space:
mode:
Diffstat (limited to 'common/exf.c')
-rw-r--r--common/exf.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/common/exf.c b/common/exf.c
index 6579ab2118d3..1fcf7f6da498 100644
--- a/common/exf.c
+++ b/common/exf.c
@@ -10,7 +10,7 @@
#include "config.h"
#ifndef lint
-static const char sccsid[] = "$Id: exf.c,v 10.62 2013/07/01 23:28:13 zy Exp $";
+static const char sccsid[] = "$Id: exf.c,v 10.64 2015/04/05 15:21:55 zy Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -37,11 +37,11 @@ static const char sccsid[] = "$Id: exf.c,v 10.62 2013/07/01 23:28:13 zy Exp $";
#include "common.h"
-static int file_backup __P((SCR *, char *, char *));
-static void file_cinit __P((SCR *));
-static void file_encinit __P((SCR *));
-static void file_comment __P((SCR *));
-static int file_spath __P((SCR *, FREF *, struct stat *, int *));
+static int file_backup(SCR *, char *, char *);
+static void file_cinit(SCR *);
+static void file_encinit(SCR *);
+static void file_comment(SCR *);
+static int file_spath(SCR *, FREF *, struct stat *, int *);
/*
* file_add --
@@ -56,7 +56,7 @@ static int file_spath __P((SCR *, FREF *, struct stat *, int *));
* vi now remembers the last location in any file that it has ever edited,
* not just the previously edited file.
*
- * PUBLIC: FREF *file_add __P((SCR *, char *));
+ * PUBLIC: FREF *file_add(SCR *, char *);
*/
FREF *
file_add(
@@ -118,7 +118,7 @@ file_add(
* let go of any previous file. Don't release the previous file until
* absolutely sure we have the new one.
*
- * PUBLIC: int file_init __P((SCR *, FREF *, char *, int));
+ * PUBLIC: int file_init(SCR *, FREF *, char *, int);
*/
int
file_init(
@@ -259,6 +259,8 @@ file_init(
DB_RECNO, &oinfo)) == NULL) {
msgq_str(sp,
M_SYSERR, rcv_name == NULL ? oname : rcv_name, "%s");
+ if (F_ISSET(frp, FR_NEWFILE))
+ goto err;
/*
* !!!
* Historically, vi permitted users to edit files that couldn't
@@ -340,6 +342,8 @@ file_init(
break;
case LOCK_UNAVAIL:
readonly = 1;
+ if (F_ISSET(sp, SC_READONLY))
+ break;
msgq_str(sp, M_INFO, oname,
"239|%s already locked, session is read-only");
break;
@@ -625,7 +629,7 @@ file_cinit(SCR *sp)
* file_end --
* Stop editing a file.
*
- * PUBLIC: int file_end __P((SCR *, EXF *, int));
+ * PUBLIC: int file_end(SCR *, EXF *, int);
*/
int
file_end(
@@ -737,7 +741,7 @@ file_end(
* semantics for whether or not writes would happen. That's
* why all the flags.
*
- * PUBLIC: int file_write __P((SCR *, MARK *, MARK *, char *, int));
+ * PUBLIC: int file_write(SCR *, MARK *, MARK *, char *, int);
*/
int
file_write(
@@ -841,7 +845,6 @@ file_write(
return (1);
/* Open the file. */
- SIGBLOCK;
if ((fd = open(name, oflags,
S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH)) < 0) {
if (errno == EACCES && LF_ISSET(FS_FORCE)) {
@@ -873,11 +876,9 @@ file_write(
errno = EACCES;
}
msgq_str(sp, M_SYSERR, name, "%s");
- SIGUNBLOCK;
return (1);
}
success_open:
- SIGUNBLOCK;
/* Try and get a lock. */
if (!noname && file_lock(sp, NULL, fd, 0) == LOCK_UNAVAIL)
@@ -1246,7 +1247,7 @@ file_encinit(SCR *sp)
if (looks_utf8(buf, blen) > 1)
o_set(sp, O_FILEENCODING, OS_STRDUP, "utf-8", 0);
else if (!O_ISSET(sp, O_FILEENCODING) ||
- !strncasecmp(O_STR(sp, O_FILEENCODING), "utf-8", 5))
+ !strcasecmp(O_STR(sp, O_FILEENCODING), "utf-8"))
o_set(sp, O_FILEENCODING, OS_STRDUP, codeset(), 0);
conv_enc(sp, O_FILEENCODING, 0);
@@ -1302,7 +1303,7 @@ file_comment(SCR *sp)
* First modification check routine. The :next, :prev, :rewind, :tag,
* :tagpush, :tagpop, ^^ modifications check.
*
- * PUBLIC: int file_m1 __P((SCR *, int, int));
+ * PUBLIC: int file_m1(SCR *, int, int);
*/
int
file_m1(
@@ -1343,7 +1344,7 @@ file_m1(
* Second modification check routine. The :edit, :quit, :recover
* modifications check.
*
- * PUBLIC: int file_m2 __P((SCR *, int));
+ * PUBLIC: int file_m2(SCR *, int);
*/
int
file_m2(
@@ -1375,7 +1376,7 @@ file_m2(
* file_m3 --
* Third modification check routine.
*
- * PUBLIC: int file_m3 __P((SCR *, int));
+ * PUBLIC: int file_m3(SCR *, int);
*/
int
file_m3(
@@ -1411,7 +1412,7 @@ file_m3(
* is not set, write the file. A routine so there's a place to put the
* comment.
*
- * PUBLIC: int file_aw __P((SCR *, int));
+ * PUBLIC: int file_aw(SCR *, int);
*/
int
file_aw(
@@ -1472,7 +1473,7 @@ file_aw(
* If the user edits a temporary file, there may be times when there is no
* alternative file name. A name argument of NULL turns it off.
*
- * PUBLIC: void set_alt_name __P((SCR *, char *));
+ * PUBLIC: void set_alt_name(SCR *, char *);
*/
void
set_alt_name(
@@ -1491,7 +1492,7 @@ set_alt_name(
* file_lock --
* Get an exclusive lock on a file.
*
- * PUBLIC: lockr_t file_lock __P((SCR *, char *, int, int));
+ * PUBLIC: lockr_t file_lock(SCR *, char *, int, int);
*/
lockr_t
file_lock(