rev 158 - trunk/src

SVN User <[email protected]>
Newsgroups gmane.comp.lang.prothon.cvs
Message-ID <[email protected]>
Author: bcollins
Date: 2004-03-27 13:44:40 -0500 (Sat, 27 Mar 2004)
New Revision: 158

Modified:
   trunk/src/interp.c
   trunk/src/sys.c
Log:
Better Sys.platform for systems supporting uname().


Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c	2004-03-27 17:09:34 UTC (rev 157)
+++ trunk/src/interp.c	2004-03-27 18:44:40 UTC (rev 158)
@@ -62,10 +62,6 @@
 #include <apr_strings.h>
 #include <apr_dso.h>
 
-#ifndef WIN32
-#include <dlfcn.h>
-#endif
-
 #define STACK_PADDING 4
 
 static DECLARE_PR_LOCK(start_main_lock);

Modified: trunk/src/sys.c
===================================================================
--- trunk/src/sys.c	2004-03-27 17:09:34 UTC (rev 157)
+++ trunk/src/sys.c	2004-03-27 18:44:40 UTC (rev 158)
@@ -53,31 +53,30 @@
 
 // sys.c
 
-#include <prothon/prothon.h>
-#include "object.h"
-#include "interp.h"
-#include "clist.h"
-
 #include <stdlib.h>
 #include <stdio.h>
-#include <apr_strings.h>
 
 #ifndef WIN32
+#include <sys/utsname.h>
 #include <unistd.h>
 #include <limits.h>
 #include <stdint.h>
-#endif
-
-#ifdef WIN32
+#else
 #include <io.h>
 #include <direct.h>
 #endif
 
+#include <prothon/prothon.h>
+#include "object.h"
+#include "interp.h"
+#include "clist.h"
+
 #include <apr_pools.h>
 #include <apr_file_info.h>
 #include <apr_fnmatch.h>
 #include <apr_file_io.h>
 #include <apr_portable.h>
+#include <apr_strings.h>
 
 static obj_p sys_exit(isp ist, obj_p self, int pcnt, obj_p* parms, obj_p dlocals) {
 	if (!has_proto(ist, parms[1], OBJ(INT_PROTO))) {
@@ -192,10 +191,19 @@
 	 * platform aswell. */
 #if defined(WIN32)
 	set_attr(ist, sys_module, sym(ist, "platform"), new_string_obj("win32"));
-#elif defined(__unix__)
-	set_attr(ist, sys_module, sym(ist, "platform"), new_string_obj("unix"));
 #else
-	set_attr(ist, sys_module, sym(ist, "platform"), new_string_obj("unknown"));
+	{
+		struct utsname uts;
+
+		if (uname(&uts)) {
+			set_attr(ist, sys_module, sym(ist, "platform"), new_string_obj("unknown"));
+		} else {
+			char plt_buf[1024];
+			apr_snprintf(plt_buf, sizeof(plt_buf), "%s %s (%s)",
+				     uts.sysname, uts.release, uts.machine);
+			set_attr(ist, sys_module, sym(ist, "platform"), new_string_obj(plt_buf));
+		}
+	}
 #endif
 	set_attr(ist, sys_module, sym(ist, "ps1"), new_string_obj(">>> "));
 	set_attr(ist, sys_module, sym(ist, "ps2"), new_string_obj("... "));
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.