On 18/08/2010 12:05, Mike Williams wrote:
On 18/08/2010 10:09, Benjamin R. Haskell wrote:
On Wed, 18 Aug 2010, Christian Brabandt wrote:

Hi Bram!

On Mi, 18 Aug 2010, Bram Moolenaar wrote:


Christian Brabandt wrote:

On Mo, 16 Aug 2010, Christian Brabandt wrote:

Anyway, I noticed another problem. I cannot edit my .vimrc from
within gvim. When writing it, gvim simply crashes.

I found the problem. It can be reproduced on Windows using this
commandline:

gvim -u NONE -U NONE -N -c "echo strftime('%a %Y\-%m\-%d %R')"

Thanks for figuring that out. Perhaps someone knows how to fix it?
Which gvim version is this with?

As Benjamin said, it's %R and also %T that triggers it. My environment
is 32bit WinXP using the official built gvim73.exe from www.vim.org.

BTW: a self compiled mingw-Version does not crash. It simply returns
the empty string for %R and %T

Via the PHP caveats on strftime (non-)portability[1] that specifically
mentioned %T and %R on Windows, I also found that %e and %D crash Vim.

This seems to just be due to bad strftime() error-handling
characteristics. '%0', '%.', and '%-' also crash it (probably any
invalid format specifiers).

Full list of valid format specifiers for the strftime provided by Visual
Studio 2010 is at [2], if it's useful for debugging.

It is by design in the recent VC CRT libraries (VS2005 onwards?) Any
unsupported format specifier will result in a crash. On Windows, or at
least builds that use recent VC CRT libraries, VIM needs to validate the
format string that it only contains supported format specifiers. I'm
guessing mingw is using older versions of the Windows CRT or has its own
version.

Attached is a patch to check for allowed specifiers for Windows. Not sure if any other platforms need a similar check (I doubt it). Don't know if need extra code to cope with multi-byte format strings. Don't know if having the check function in eval.c is the right thing to do. Does stop the crash for me.

Have at it.

Mike
--
Dose anyone half a spill cheker?

--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
diff --git a/src/eval.c b/src/eval.c
--- a/src/eval.c
+++ b/src/eval.c
@@ -16693,6 +16693,28 @@
 }
 
 #ifdef HAVE_STRFTIME
+    static int
+check_strftime(format, specifiers)
+    char_u     *format;
+    char_u     *specifiers;
+{
+    while (*format)
+    {
+        if (*format++ == '%')
+        {
+# ifdef WIN32
+            /* Win32 extension flag */
+            if (*format == '#')
+                format++;
+# endif
+            if (vim_strbyte(specifiers, *format) == NULL)
+                return FALSE;
+            format++;
+        }
+    }
+    return TRUE;
+}
+
 /*
  * "strftime({format}[, {time}])" function
  */
@@ -16729,7 +16751,12 @@
        if (conv.vc_type != CONV_NONE)
            p = string_convert(&conv, p, NULL);
 # endif
-       if (p != NULL)
+       if (p != NULL
+# ifdef WIN32
+#define WIN32_STRFTIME_SPECIFIERS   ((char_u*)"aAbBcdHIJmMpSUwWxXyYzZ%")
+            && check_strftime(p, WIN32_STRFTIME_SPECIFIERS)
+# endif
+            )
            (void)strftime((char *)result_buf, sizeof(result_buf),
                                                          (char *)p, curtime);
        else

Raspunde prin e-mail lui