gnash-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-commit] gnash ChangeLog server/asobj/Date.cpp testsuite...


From: Udo Giacomozzi
Subject: [Gnash-commit] gnash ChangeLog server/asobj/Date.cpp testsuite...
Date: Thu, 25 Oct 2007 15:25:51 +0000

CVSROOT:        /cvsroot/gnash
Module name:    gnash
Changes by:     Udo Giacomozzi <udog>   07/10/25 15:25:51

Modified files:
        .              : ChangeLog 
        server/asobj   : Date.cpp 
        testsuite/actionscript.all: Date.as toString_valueOf.as 

Log message:
        * server/asobj/Date.cpp: date_valueof() returns human readable date  
for SWF > 5 (fixes bug #21414)* testsuite/actionscript.all/Date.as: 1 PASS* 
testsuite/actionscript.all/toString_valueOf.as: 2 PASSes

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.4708&r2=1.4709
http://cvs.savannah.gnu.org/viewcvs/gnash/server/asobj/Date.cpp?cvsroot=gnash&r1=1.49&r2=1.50
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Date.as?cvsroot=gnash&r1=1.28&r2=1.29
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/toString_valueOf.as?cvsroot=gnash&r1=1.25&r2=1.26

Patches:
Index: ChangeLog
===================================================================
RCS file: /cvsroot/gnash/gnash/ChangeLog,v
retrieving revision 1.4708
retrieving revision 1.4709
diff -u -b -r1.4708 -r1.4709
--- ChangeLog   25 Oct 2007 14:21:01 -0000      1.4708
+++ ChangeLog   25 Oct 2007 15:25:50 -0000      1.4709
@@ -1,3 +1,10 @@
+2007-10-25 Udo Giacomozzi <address@hidden>
+
+       * server/asobj/Date.cpp: date_valueof() returns human readable date
+         for SWF > 5 (fixes bug #21414)        
+       * testsuite/actionscript.all/Date.as: 1 PASS
+       * testsuite/actionscript.all/toString_valueOf.as: 2 PASSes
+
 2007-10-25 Sandro Santilli <address@hidden>
 
        * testsuite/swfdec/PASSING: new swfdec tests passing

Index: server/asobj/Date.cpp
===================================================================
RCS file: /cvsroot/gnash/gnash/server/asobj/Date.cpp,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -b -r1.49 -r1.50
--- server/asobj/Date.cpp       31 Aug 2007 21:53:31 -0000      1.49
+++ server/asobj/Date.cpp       25 Oct 2007 15:25:50 -0000      1.50
@@ -145,6 +145,8 @@
 static double rogue_date_args(const fn_call& fn, unsigned maxargs);
 #endif
 
+static int minutes_east_of_gmt(struct tm &tm);
+
 // Select functions to implement _localtime_r and _gmtime_r
 // For localtime we use the glibc stuff; for UTC we prefer our own routines
 // because the C library does not provide a function to convert
@@ -340,6 +342,50 @@
        {
        }
 
+  as_value tostring()
+  {
+    char buffer[40]; // 32 chars + slop
+    char monthname[][12] =
+      
{"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};    
+    char dayweekname[][7] = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
+
+  
+    /// NAN and infinities all print as "Invalid Date"
+    if (isnan(value) || isinf(value)) {
+      strcpy(buffer, "Invalid Date");
+      return as_value((char *)&buffer);
+    }
+  
+    // The date value split out to year, month, day, hour etc and millisecs
+    struct tm tm;
+    double msec;
+    // Time zone offset (including DST) as hours and minutes east of GMT
+    int tzhours, tzminutes; 
+  
+    local_date_to_tm_msec(value, tm, msec);
+  
+    // At the meridian we need to print "GMT+0100" when Daylight Saving
+    // Time is in force, "GMT+0000" when it isn't, and other values for
+    // other places around the globe when DST is/isn't in force there.
+  
+    // Split offset into hours and minutes
+    tzminutes = minutes_east_of_gmt(tm);
+    tzhours = tzminutes / 60, tzminutes %= 60;
+  
+    // If timezone is negative, both hours and minutes will be negative
+    // but for the purpose of printing a string, only the hour needs to
+    // produce a minus sign.
+    if (tzminutes < 0) tzminutes = -tzminutes;
+  
+    snprintf((char *)&buffer, sizeof(buffer),
+      "%s %s %d %02d:%02d:%02d GMT%+03d%02d %d",
+      dayweekname[tm.tm_wday], monthname[tm.tm_mon],
+      tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec,
+      tzhours, tzminutes, tm.tm_year+1900);
+  
+    return as_value((char *)&buffer);
+  }
+
 private:
 };
 
@@ -1159,47 +1205,12 @@
 /// local time.
 
 static as_value date_tostring(const fn_call& fn) {
-       char buffer[40]; // 32 chars + slop
-       char monthname[][12] =
-               
{"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
-       char dayweekname[][7] = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
-
-       boost::intrusive_ptr<date_as_object> date = 
ensureType<date_as_object>(fn.this_ptr);
-
-       /// NAN and infinities all print as "Invalid Date"
-       if (isnan(date->value) || isinf(date->value)) {
-               strcpy(buffer, "Invalid Date");
-               return as_value((char *)&buffer);
-       }
-
-       // The date value split out to year, month, day, hour etc and millisecs
-       struct tm tm;
-       double msec;
-       // Time zone offset (including DST) as hours and minutes east of GMT
-       int tzhours, tzminutes; 
-
-       local_date_to_tm_msec(date->value, tm, msec);
 
-       // At the meridian we need to print "GMT+0100" when Daylight Saving
-       // Time is in force, "GMT+0000" when it isn't, and other values for
-       // other places around the globe when DST is/isn't in force there.
-
-       // Split offset into hours and minutes
-       tzminutes = minutes_east_of_gmt(tm);
-       tzhours = tzminutes / 60, tzminutes %= 60;
-
-       // If timezone is negative, both hours and minutes will be negative
-       // but for the purpose of printing a string, only the hour needs to
-       // produce a minus sign.
-       if (tzminutes < 0) tzminutes = -tzminutes;
+  boost::intrusive_ptr<date_as_object> 
+    date = ensureType<date_as_object>(fn.this_ptr);
 
-       snprintf((char *)&buffer, sizeof(buffer),
-               "%s %s %d %02d:%02d:%02d GMT%+03d%02d %d",
-               dayweekname[tm.tm_wday], monthname[tm.tm_mon],
-               tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec,
-               tzhours, tzminutes, tm.tm_year+1900);
+  return date->tostring();
 
-       return as_value((char *)&buffer);
 }
 
 // Date.UTC(year:Number,month[,day[,hour[,minute[,second[,millisecond]]]]]
@@ -1339,6 +1350,10 @@
 
 static as_value date_valueof(const fn_call& fn) {
        boost::intrusive_ptr<date_as_object> date = 
ensureType<date_as_object>(fn.this_ptr);
+  
+  if (fn.env().get_version() > 5)
+    return as_value(date->tostring());
+  else
        return as_value(date->value);
 }
 

Index: testsuite/actionscript.all/Date.as
===================================================================
RCS file: /cvsroot/gnash/gnash/testsuite/actionscript.all/Date.as,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -b -r1.28 -r1.29
--- testsuite/actionscript.all/Date.as  25 Oct 2007 09:33:51 -0000      1.28
+++ testsuite/actionscript.all/Date.as  25 Oct 2007 15:25:51 -0000      1.29
@@ -21,7 +21,7 @@
 // compile this test case with Ming makeswf, and then
 // execute it like this gnash -1 -r 0 -v out.swf
 
-rcsid="$Id: Date.as,v 1.28 2007/10/25 09:33:51 udog Exp $";
+rcsid="$Id: Date.as,v 1.29 2007/10/25 15:25:51 udog Exp $";
 
 #include "check.as"
 
@@ -510,6 +510,6 @@
 var foo = "foo "+d;   
 // correct: "foo Tue Feb 15 00:00:00 GMT+0100 2000"
 // but this probably depends on time zone, so just check for some fixed part..
-xcheck_equals(foo.indexOf("Feb"), 8);
+check_equals(foo.indexOf("Feb"), 8);
 
 totals();

Index: testsuite/actionscript.all/toString_valueOf.as
===================================================================
RCS file: /cvsroot/gnash/gnash/testsuite/actionscript.all/toString_valueOf.as,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- testsuite/actionscript.all/toString_valueOf.as      29 Sep 2007 16:23:00 
-0000      1.25
+++ testsuite/actionscript.all/toString_valueOf.as      25 Oct 2007 15:25:51 
-0000      1.26
@@ -417,8 +417,8 @@
 d3 = d1 + d2; // in SWF5 this should result in a number, in SWF6 or higher, in 
a string
 exp = d1.toString() + d2.toString();
 #if OUTPUT_VERSION > 5 
-  xcheck_equals(typeof(d3), 'string');
-  xcheck_equals(d3, exp);
+  check_equals(typeof(d3), 'string');
+  check_equals(d3, exp);
 #else
   check_equals(typeof(d3), 'number');
   check_equals(d3, 1);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]