For now, avoid returning strerrno()-based exception string in FD.open() to
authorMatthew Mondor <mmondor@pulsar-zone.net>
Thu, 7 Jul 2005 00:11:17 +0000 (00:11 +0000)
committerMatthew Mondor <mmondor@pulsar-zone.net>
Thu, 7 Jul 2005 00:11:17 +0000 (00:11 +0000)
prevent having the nls table always loaded by libc, until I fix libc to either
ignore/disable locale support or to cache nls info.

tests/js-test/src/classes/js_fd.c

index 0943b4c..eab9813 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: js_fd.c,v 1.31 2005/07/04 13:52:42 mmondor Exp $ */
+/* $Id: js_fd.c,v 1.32 2005/07/07 00:11:17 mmondor Exp $ */
 
 /*
  * Copyright (c) 2005, Matthew Mondor
@@ -48,6 +48,7 @@
  * - rename(2), unlink(2) etc would be useful, but we need another class
  *   for this (maybe a VFS static class?)  Maybe even something calling
  *   execve(2) and fork(2), those primitives... popen(3) also.
+ * - Also opendir(3) and friends wrapper...
  * - Error numbers for errno should be placed in a separate class, Errno?
  */
 
@@ -83,7 +84,6 @@
 #define QUEUE_EXCEPTION(s)     do {                                    \
        JS_SetPendingException(cx,                                      \
            STRING_TO_JSVAL(JS_NewStringCopyZ(cx, (s))));               \
-       (void) fprintf(stderr, " * %s\n", (s));                         \
 } while (/* CONSTCOND */0)
 
 
@@ -1134,7 +1134,17 @@ fd_m_open(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
        /* We can finally attempt to open(2) */
        if ((fd = open(bytes, flags, mode)) == -1) {
                jsfd->error = errno;
-               QUEUE_EXCEPTION(strerror(errno));
+               /*
+                * XXX strerror() seems to always need to load up the
+                * nls table file, which is way silly for performance.
+                * This is related to locale stuff, and should be able
+                * to simply be disabled, even.
+                * Since this event occurs often in httpd.js, let's just
+                * output a fixed string for now.
+                * I should actually fix NetBSD libc on this matter.
+                */
+/*             QUEUE_EXCEPTION(strerror(errno));       */
+               QUEUE_EXCEPTION("open() error");
                JS_free(cx, jsfd->u.file.path);
                return JS_FALSE;
        }
@@ -1966,10 +1976,33 @@ fd_m_fstat(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
        DEFINE_INT_PROP("st_uid", st.st_uid);
        DEFINE_INT_PROP("st_gid", st.st_gid);
        DEFINE_INT_PROP("st_rdev", st.st_rdev);
-       /* Dates... XXX Should probably provide JS-friendly Date? */
        /*
-        * XXX Note: there are  off_t and int64_t fields which won't properly
-        * be converted
+        * XXX
+        * The three times in struct stat are struct timespec (seconds since
+        * epoch, and nanoseconds in current second.  I should probably
+        * provide exactly the same, making sure that it be in GMT, possibly.
+        * Or, I could leave the application convert it to GMT.  However, I
+        * then need a new object for storage of the two values, unless I
+        * converted them into a string with some field separator character.
+        * For now, I'll just care about the seconds and return those, and
+        * will return them in GMT.  This is currently used by httpd.js to
+        * verify if a file was modified before sending it again, or before
+        * needing to read and parse scripts again.
+        */
+       /*
+        * XXX Seems that I am exceeding the JavaScript maximum integer size!
+        * Will I need to create my own arithmetic types!?
+        * This seems to be related to the way jsval are stored.
+        * jsval probably should be a structure or union, at the expense
+        * of some performance loss perhaps.
+        * I now return time in minutes instead!
+        */
+       DEFINE_INT_PROP("st_atime", st.st_atime / 60);
+       DEFINE_INT_PROP("st_mtime", st.st_mtime / 60);
+       DEFINE_INT_PROP("st_ctime", st.st_ctime / 60);
+       /*
+        * XXX Note: there are off_t and int64_t fields which won't properly
+        * be converted.
         */
        DEFINE_INT_PROP("st_size", st.st_size);
        DEFINE_INT_PROP("st_blocks", st.st_blocks);