r7135: make typeof() complient with ECMA 11.4.3
authorAndrew Tridgell <tridge@samba.org>
Tue, 31 May 2005 04:12:55 +0000 (04:12 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:17:21 +0000 (13:17 -0500)
(This used to be commit 29ab4cc6cb244255ab75af7ae2076b51209f4f2d)

source4/scripting/ejs/smbcalls.c

index 02b40c46d89d0ffc80298bb120e347c1a10ee538..fc2c16a456a0bc0f4bce908107fccd642954979d 100644 (file)
@@ -35,20 +35,20 @@ static int ejs_typeof(MprVarHandle eid, int argc, struct MprVar **argv)
                MprType type;
                const char *name;
        } types[] = {
-               { MPR_TYPE_UNDEFINED, "undefined" },
-               { MPR_TYPE_NULL, "null" },
-               { MPR_TYPE_BOOL, "boolean" },
-               { MPR_TYPE_CFUNCTION, "function" },
-               { MPR_TYPE_FLOAT, "float" },
-               { MPR_TYPE_INT, "int" },
-               { MPR_TYPE_INT64, "int64" },
-               { MPR_TYPE_OBJECT, "object" },
-               { MPR_TYPE_FUNCTION, "function" },
-               { MPR_TYPE_STRING, "string" },
+               { MPR_TYPE_UNDEFINED,        "undefined" },
+               { MPR_TYPE_NULL,             "object" },
+               { MPR_TYPE_BOOL,             "boolean" },
+               { MPR_TYPE_CFUNCTION,        "function" },
+               { MPR_TYPE_FLOAT,            "number" },
+               { MPR_TYPE_INT,              "number" },
+               { MPR_TYPE_INT64,            "number" },
+               { MPR_TYPE_OBJECT,           "object" },
+               { MPR_TYPE_FUNCTION,         "function" },
+               { MPR_TYPE_STRING,           "string" },
                { MPR_TYPE_STRING_CFUNCTION, "function" }
        };
        int i;
-       const char *type = "unknown";
+       const char *type = NULL;
 
        if (argc != 1) return -1;
        
@@ -58,6 +58,7 @@ static int ejs_typeof(MprVarHandle eid, int argc, struct MprVar **argv)
                        break;
                }
        }
+       if (type == NULL) return -1;
 
        ejsSetReturnString(eid, type);
        return 0;