src/unix.cpp
branchNewGRF_ports
changeset 6719 4cc327ad39d5
parent 6644 46753e40f3ee
child 6871 5a9dc001e1ad
--- a/src/unix.cpp	Tue Mar 27 23:27:27 2007 +0000
+++ b/src/unix.cpp	Sat Jun 02 19:59:29 2007 +0000
@@ -1,5 +1,7 @@
 /* $Id$ */
 
+/** @file unix.cpp */
+
 #include "stdafx.h"
 #include "openttd.h"
 #include "functions.h"
@@ -27,7 +29,7 @@
 #include <exec/types.h>
 ULONG __stack = (1024*1024)*2; // maybe not that much is needed actually ;)
 
-// The system supplied definition of SIG_IGN does not match
+/* The system supplied definition of SIG_IGN does not match */
 #undef SIG_IGN
 #define SIG_IGN (void (*)(int))1
 #endif /* __MORPHOS__ */
@@ -39,7 +41,7 @@
 
 #if defined(__APPLE__)
 	#if defined(WITH_SDL)
-		//the mac implementation needs this file included in the same file as main()
+		/*the mac implementation needs this file included in the same file as main() */
 		#include <SDL.h>
 	#endif
 #endif
@@ -51,7 +53,7 @@
 #else
 	/* On MorphOS or AmigaOS paths look like: "Volume:directory/subdirectory" */
 	const char *s = strchr(path, ':');
-	return s[1] == '\0';
+	return s != NULL && s[1] == '\0';
 #endif
 }
 
@@ -85,8 +87,11 @@
 	if (FiosIsRoot(path)) {
 		snprintf(filename, lengthof(filename), "%s:%s", path, ent->d_name);
 	} else // XXX - only next line!
+#else
+	assert(path[strlen(path) - 1] == PATHSEPCHAR);
+	if (strlen(path) > 2) assert(path[strlen(path) - 2] != PATHSEPCHAR);
 #endif
-	snprintf(filename, lengthof(filename), "%s" PATHSEP "%s", path, ent->d_name);
+	snprintf(filename, lengthof(filename), "%s%s", path, ent->d_name);
 
 	return stat(filename, sb) == 0;
 }
@@ -104,11 +109,11 @@
 void ShowOSErrorBox(const char *buf)
 {
 #if defined(__APPLE__)
-	// this creates an NSAlertPanel with the contents of 'buf'
-	// this is the native and nicest way to do this on OSX
+	/* this creates an NSAlertPanel with the contents of 'buf'
+	 * this is the native and nicest way to do this on OSX */
 	ShowMacDialog( buf, "See readme for more info\nMost likely you are missing files from the original TTD", "Quit" );
 #else
-	// all systems, but OSX
+	/* all systems, but OSX */
 	fprintf(stderr, "\033[1;31mError: %s\033[0;39m\n", buf);
 #endif
 }
@@ -151,10 +156,10 @@
 }
 
 
-// multi os compatible sleep function
+/* multi os compatible sleep function */
 
 #ifdef __AMIGA__
-// usleep() implementation
+/* usleep() implementation */
 #	include <devices/timer.h>
 #	include <dos/dos.h>
 
@@ -174,7 +179,7 @@
 		ULONG signals;
 		ULONG TimerSigBit = 1 << TimerPort->mp_SigBit;
 
-		// send IORequest
+		/* send IORequest */
 		TimerRequest->tr_node.io_Command = TR_ADDREQUEST;
 		TimerRequest->tr_time.tv_secs    = (milliseconds * 1000) / 1000000;
 		TimerRequest->tr_time.tv_micro   = (milliseconds * 1000) % 1000000;
@@ -243,7 +248,7 @@
 	}
 
 	*outbuf = '\0';
-	// FIX: invalid characters will abort conversion, but they shouldn't occur?
+	/* FIX: invalid characters will abort conversion, but they shouldn't occur? */
 	return buf;
 }