Skip to content
Snippets Groups Projects
Commit 2572c6d8 authored by rswindell's avatar rswindell
Browse files

If a Date object is passed as the default value to File.iniGetObject(), return

a Date object.
parent 0b5705a9
Branches
Tags
No related merge requests found
...@@ -44,6 +44,8 @@ ...@@ -44,6 +44,8 @@
#ifdef JAVASCRIPT #ifdef JAVASCRIPT
#include "jsdate.h" /* Yes, I know this is a private header file */
typedef struct typedef struct
{ {
FILE* fp; FILE* fp;
...@@ -455,6 +457,8 @@ js_iniGetValue(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rva ...@@ -455,6 +457,8 @@ js_iniGetValue(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rva
jsval dflt=argv[2]; jsval dflt=argv[2];
private_t* p; private_t* p;
JSObject* array; JSObject* array;
JSObject* dflt_obj;
JSObject* date_obj;
if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) { if((p=(private_t*)JS_GetPrivate(cx,obj))==NULL) {
JS_ReportError(cx,getprivate_failure,WHERE); JS_ReportError(cx,getprivate_failure,WHERE);
...@@ -483,6 +487,16 @@ js_iniGetValue(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rva ...@@ -483,6 +487,16 @@ js_iniGetValue(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rva
,iniReadFloat(p->fp,section,key,*JSVAL_TO_DOUBLE(dflt)),rval); ,iniReadFloat(p->fp,section,key,*JSVAL_TO_DOUBLE(dflt)),rval);
break; break;
case JSVAL_OBJECT: case JSVAL_OBJECT:
dflt_obj = JSVAL_TO_OBJECT(dflt);
if(js_DateIsValid(cx, dflt_obj)) {
date_obj = js_NewDateObjectMsec(cx
,(jsdouble)iniReadDateTime(p->fp,section,key
,(time_t)(js_DateGetMsecSinceEpoch(cx,dflt_obj)/1000.0))
*1000.0);
if(date_obj!=NULL)
*rval = OBJECT_TO_JSVAL(date_obj);
break;
}
array = JS_NewArrayObject(cx, 0, NULL); array = JS_NewArrayObject(cx, 0, NULL);
list=iniReadStringList(p->fp,section,key,",",JS_GetStringBytes(JS_ValueToString(cx,dflt))); list=iniReadStringList(p->fp,section,key,",",JS_GetStringBytes(JS_ValueToString(cx,dflt)));
for(i=0;list && list[i];i++) { for(i=0;list && list[i];i++) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment