=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mg/file.c,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- src/usr.bin/mg/file.c 2005/10/13 19:46:45 1.40 +++ src/usr.bin/mg/file.c 2005/10/13 20:23:01 1.41 @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.40 2005/10/13 19:46:45 kjell Exp $ */ +/* $OpenBSD: file.c,v 1.41 2005/10/13 20:23:01 kjell Exp $ */ /* This file is in the public domain. */ @@ -6,9 +6,10 @@ * File commands. */ -#include #include "def.h" +#include + /* * Insert a file into the current buffer. Real easy - just call the * insertfile routine with the file name. @@ -205,7 +206,7 @@ readin(char *fname) { MGWIN *wp; - int status, i; + int status, i, ro = FALSE; PF *ael; /* might be old */ @@ -236,8 +237,17 @@ } } - /* We need to set the READONLY flag after we insert the file. */ + /* + * We need to set the READONLY flag after we insert the file, + * unless the file is a directory. + */ if (access(fname, W_OK) && errno != ENOENT) + ro = TRUE; +#ifndef NO_DIRED + if (fisdir(fname) == TRUE) + ro = TRUE; +#endif + if (ro == TRUE) curbp->b_flag |= BFREADONLY; else curbp->b_flag &=~ BFREADONLY;