summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvimboss <devnull@localhost>2006-10-10 16:44:07 +0000
committervimboss <devnull@localhost>2006-10-10 16:44:07 +0000
commit34fedad64db2975291c588ea2d81798074f4f32e (patch)
treec86b2ef48078e41f6254387d4e3be2a8f067c7a7
parent622e957cfc481470ff26fb8a5a85e5cbc2204eea (diff)
downloadvim-34fedad64db2975291c588ea2d81798074f4f32e.tar.gz
updated for version 7.0-130v7.0.130v7-0-130
-rw-r--r--runtime/doc/options.txt14
-rw-r--r--src/fileio.c24
-rw-r--r--src/option.c8
-rw-r--r--src/option.h3
-rw-r--r--src/os_win32.c6
-rw-r--r--src/version.c2
6 files changed, 56 insertions, 1 deletions
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 8fb22f85..eadd215c 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -4792,10 +4792,22 @@ A jump table for the options with a short description can be found at |Q_op|.
completion with CTRL-X CTRL-O. |i_CTRL-X_CTRL-O|
See |complete-functions| for an explanation of how the function is
invoked and what it should return.
- This option is usually set by a filetype plugin.
+ This option is usually set by a filetype plugin:
|:filetype-plugin-on|
+ *'opendevice* *'odev* *'noopendevice* *'noodev*
+'opendevice' 'odev' boolean (default off)
+ global
+ {not in Vi}
+ {only for MS-DOS, MS-Windows and OS/2}
+ Enable reading and writing from devices. This may get Vim stuck on a
+ device that can be opened but doesn't actually do the I/O. Therefore
+ it is off by default.
+ Note that on MS-Windows editing "aux.h", "lpt1.txt" and the like also
+ result in editing a device.
+
+
*'operatorfunc'* *'opfunc'*
'operatorfunc' 'opfunc' string (default: empty)
global
diff --git a/src/fileio.c b/src/fileio.c
index 42181e17..7bab84e5 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -419,6 +419,20 @@ readfile(fname, sfname, from, lines_to_skip, lines_to_read, eap, flags)
}
#endif
+#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
+ /*
+ * MS-Windows allows opening a device, but we will probably get stuck
+ * trying to read it.
+ */
+ if (!p_odev && mch_nodetype(fname) == NODE_WRITABLE)
+ {
+ filemess(curbuf, fname, (char_u *)_("is a device (disabled with 'opendevice' option"), 0);
+ msg_end();
+ msg_scroll = msg_save;
+ return FAIL;
+ }
+#endif
+
/* set default 'fileformat' */
if (set_options)
{
@@ -3163,6 +3177,16 @@ buf_write(buf, fname, sfname, start, end, eap, append, forceit,
}
if (c == NODE_WRITABLE)
{
+# if defined(MSDOS) || defined(MSWIN) || defined(OS2)
+ /* MS-Windows allows opening a device, but we will probably get stuck
+ * trying to write to it. */
+ if (!p_odev)
+ {
+ errnum = (char_u *)"E796: ";
+ errmsg = (char_u *)_("writing to device disabled with 'opendevice' option");
+ goto fail;
+ }
+# endif
device = TRUE;
newfile = TRUE;
perm = -1;
diff --git a/src/option.c b/src/option.c
index 1f47c60b..aa8a70e6 100644
--- a/src/option.c
+++ b/src/option.c
@@ -1810,6 +1810,14 @@ static struct vimoption
{"open", NULL, P_BOOL|P_VI_DEF,
(char_u *)NULL, PV_NONE,
{(char_u *)FALSE, (char_u *)0L}},
+ {"opendevice", "odev", P_BOOL|P_VI_DEF,
+#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
+ (char_u *)&p_odev, PV_NONE,
+#else
+ (char_u *)NULL, PV_NONE,
+#endif
+ {(char_u *)FALSE, (char_u *)FALSE}
+ },
{"operatorfunc", "opfunc", P_STRING|P_VI_DEF|P_SECURE,
(char_u *)&p_opfunc, PV_NONE,
{(char_u *)"", (char_u *)0L} },
diff --git a/src/option.h b/src/option.h
index 28c58152..c322f3a1 100644
--- a/src/option.h
+++ b/src/option.h
@@ -618,6 +618,9 @@ EXTERN int p_more; /* 'more' */
#ifdef FEAT_MZSCHEME
EXTERN long p_mzq; /* 'mzquantum */
#endif
+#if defined(MSDOS) || defined(MSWIN) || defined(OS2)
+EXTERN int p_odev; /* 'opendevice' */
+#endif
EXTERN char_u *p_opfunc; /* 'operatorfunc' */
EXTERN char_u *p_para; /* 'paragraphs' */
EXTERN int p_paste; /* 'paste' */
diff --git a/src/os_win32.c b/src/os_win32.c
index af659065..cc0b326c 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -2702,6 +2702,12 @@ mch_nodetype(char_u *name)
HANDLE hFile;
int type;
+ /* We can't open a file with a name "\\.\con" or "\\.\prn" and trying to
+ * read from it later will cause Vim to hang. Thus return NODE_WRITABLE
+ * here. */
+ if (STRNCMP(name, "\\\\.\\", 4) == 0)
+ return NODE_WRITABLE;
+
hFile = CreateFile(name, /* file name */
GENERIC_WRITE, /* access mode */
0, /* share mode */
diff --git a/src/version.c b/src/version.c
index cab8d687..87f74ac1 100644
--- a/src/version.c
+++ b/src/version.c
@@ -667,6 +667,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 130,
+/**/
129,
/**/
128,