On 18/08/2010 19:16, Benjamin R. Haskell wrote:
On Wed, 18 Aug 2010, Sergey Khorev wrote:

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.

Perhaps another options would be installation of custom validation
handler via _set_invalid_parameter_handler as described on
http://msdn.microsoft.com/en-us/library/ksazx244(v=VS.80).aspx

Unfortunately I cannot provide a patch at the moment. Maybe later if
no one outruns me.

It seems like a more-robust version of the patch already sent would be
to double the '%'s that precede invalid format specifiers (so the
strftime call still succeeds, it just wouldn't properly substitute the
ones it can't).

Degrees of failing. There is a school of thought that if you are gonna fail, fail in a really obvious way. Such as crashing? ;-)

The _set_invalid_parameter_handler approach might be simpler if the goal
is to just fail on invalid input.  (No need for Vim to check the input.)
Seems more maintainable than reïmplementing the parsing portion of strftime.

Indeed - smaller, simpler, localised.

At the bottom of the slippery slope (that input-checking starts down),
duplicating the entirety of strftime would allow non-strftime systems to
have the functionality.

Really don't want to do that due to the locale handling. And then someone suggests adding features for systems that don't support what their preferred extension is. I think there is far more useful things to work on than extending how to format date and time across multiple platforms.

2ps worth.

Mike
--
Adversity makes men, and prosperity makes monsters.

--
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

Raspunde prin e-mail lui