You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2012/06/08 01:45:39 UTC

[lucy-commits] svn commit: r1347833 - /lucy/trunk/charmonizer/src/Charmonizer/Core/OperatingSystem.c

Author: marvin
Date: Thu Jun  7 23:45:39 2012
New Revision: 1347833

URL: http://svn.apache.org/viewvc?rev=1347833&view=rev
Log:
Simplify detection of /dev/null or equivalent.

Modified:
    lucy/trunk/charmonizer/src/Charmonizer/Core/OperatingSystem.c

Modified: lucy/trunk/charmonizer/src/Charmonizer/Core/OperatingSystem.c
URL: http://svn.apache.org/viewvc/lucy/trunk/charmonizer/src/Charmonizer/Core/OperatingSystem.c?rev=1347833&r1=1347832&r2=1347833&view=diff
==============================================================================
--- lucy/trunk/charmonizer/src/Charmonizer/Core/OperatingSystem.c (original)
+++ lucy/trunk/charmonizer/src/Charmonizer/Core/OperatingSystem.c Thu Jun  7 23:45:39 2012
@@ -39,47 +39,26 @@ static const char *obj_ext = "";
 static const char *local_command_start = "./";
 #endif
 
-static void
-S_probe_dev_null(void);
-
 void
 OS_init(void) {
     if (Util_verbosity) {
         printf("Initializing Charmonizer/Core/OperatingSystem...\n");
     }
 
-    S_probe_dev_null();
-}
-
-static void
-S_probe_dev_null(void) {
     if (Util_verbosity) {
         printf("Trying to find a bit-bucket a la /dev/null...\n");
     }
 
-#ifdef _WIN32
-    strcpy(dev_null, "nul");
-#else
-    {
-        const char *const options[] = {
-            "/dev/null",
-            "/dev/nul",
-            NULL
-        };
-        int i;
-
-        /* Iterate through names of possible devnulls trying to open them. */
-        for (i = 0; options[i] != NULL; i++) {
-            if (Util_can_open_file(options[i])) {
-                strcpy(dev_null, options[i]);
-                return;
-            }
-        }
-
+    if (Util_can_open_file("/dev/null")) {
+        strcpy(dev_null, "/dev/null");
+    }
+    else if (Util_can_open_file("nul")) {
+        strcpy(dev_null, "nul");
+    }
+    else {
         /* Bail out because we couldn't find anything like /dev/null. */
         Util_die("Couldn't find anything like /dev/null");
     }
-#endif
 }
 
 const char*