Commit ceea3b9a authored by adachan@apple.com's avatar adachan@apple.com
Browse files

Rolling out r41818 since it broke the windows build.

        Error: ..\..\runtime\DatePrototype.cpp(30) : fatal error C1083: Cannot open include file: 'langinfo.h': No such file or directory

        * runtime/DatePrototype.cpp:
        (JSC::formatLocaleDate):



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@41823 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 45073e96
2009-03-18 Gustavo Noronha Silva <gns@gnome.org> and Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
2009-03-18 Ada Chan <adachan@apple.com>
 
Reviewed by Darin Adler.
https://bugs.webkit.org/show_bug.cgi?id=24674
Crashes in !PLATFORM(MAC)'s formatLocaleDate, in very specific situations
Make sure strftime never returns 2-digits years to avoid ambiguity and
a crash.
Rolling out r41818 since it broke the windows build.
Error: ..\..\runtime\DatePrototype.cpp(30) : fatal error C1083: Cannot open include file: 'langinfo.h': No such file or directory
 
* runtime/DatePrototype.cpp:
(JSC::formatLocaleDate):
......@@ -27,7 +27,6 @@
#include "ObjectPrototype.h"
#include "DateInstance.h"
#include <float.h>
#include <langinfo.h>
#include <limits.h>
#include <locale.h>
#include <math.h>
......@@ -182,7 +181,7 @@ static JSCell* formatLocaleDate(ExecState* exec, DateInstance*, double timeInMil
static JSCell* formatLocaleDate(ExecState* exec, const GregorianDateTime& gdt, LocaleDateTimeFormat format)
{
static const nl_item formats[] = { D_T_FMT, D_FMT, T_FMT };
static const char* const formatStrings[] = { "%#c", "%#x", "%X" };
// Offset year if needed
struct tm localTM = gdt;
......@@ -191,20 +190,10 @@ static JSCell* formatLocaleDate(ExecState* exec, const GregorianDateTime& gdt, L
if (yearNeedsOffset)
localTM.tm_year = equivalentYearForDST(year) - 1900;
// We do not allow strftime to generate dates with 2-digits years,
// both to avoid ambiguity, and a crash in strncpy, for years that
// need offset.
char* formatString = strdup(nl_langinfo(formats[format]));
char* yPos = strchr(formatString, 'y');
if (yPos)
*yPos = 'Y';
// Do the formatting
const int bufsize = 128;
char timebuffer[bufsize];
size_t ret = strftime(timebuffer, bufsize, formatString, &localTM);
free(formatString);
size_t ret = strftime(timebuffer, bufsize, formatStrings[format], &localTM);
if (ret == 0)
return jsEmptyString(exec);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment