Index: trunk/Common/Makefile
===================================================================
--- trunk/Common/Makefile	(revision 191)
+++ trunk/Common/Makefile	(revision 212)
@@ -1,19 +1,22 @@
 # $Id$
 
+OBJ=o
+STATIC=a
+AR_FLAGS=rcs 
 include $(PWD)/Platform/$(PLATFORM).mk
 
 .PHONY: all clean
-.SUFFIXES: .c .o
+.SUFFIXES: .c .$(OBJ)
 
-OBJS = string.o log.o dir.o
+OBJS = string.$(OBJ) log.$(OBJ) dir.$(OBJ)
 
-all: common.a
+all: common.$(STATIC)
 
-common.a: $(OBJS)
-	$(AR) rcs $@ $(OBJS)
+common.$(STATIC): $(OBJS)
+	$(AR) $(AR_FLAGS)$@ $(OBJS)
 
-.c.o:
+.c.$(OBJ):
 	$(CC) $(CFLAGS) -c -o $@ $<
 
 clean:
-	rm -f *.o *.a
+	rm -f *.o *.a *.lib
Index: trunk/Common/dir.c
===================================================================
--- trunk/Common/dir.c	(revision 191)
+++ trunk/Common/dir.c	(revision 212)
@@ -6,5 +6,7 @@
 
 #include <sys/stat.h>
+#ifndef _MSC_VER
 #include <dirent.h>
+#endif
 #include <stdlib.h>
 #include <string.h>
@@ -17,9 +19,12 @@
 
 char** cm_scandir(const char* path) {
+#ifdef _MSC_VER
+	return NULL;
+#else
 	DIR* dir = opendir(path);
 	if(dir != NULL) {
 		char** r = malloc(sizeof(*r));
+		struct dirent* d;
 		r[0] = NULL;
-		struct dirent* d;
 		while((d = readdir(dir)) != NULL) {
 			if(strcmp(d->d_name, ".") != 0 && strcmp(d->d_name, "..") != 0) {
@@ -61,3 +66,4 @@
 		return NULL;
 	}
+#endif
 }
Index: trunk/Common/log.c
===================================================================
--- trunk/Common/log.c	(revision 191)
+++ trunk/Common/log.c	(revision 212)
@@ -42,19 +42,20 @@
 
 void cm_log(const char* name, const char* log, ...) {
+	va_list args;
+	char namebuf[LOGNAME_LENGTH + 1];
+	int i;
+	char* result;
+	char cbuf[2];
 	if(!cm_do_log) return;
-	va_list args;
 	va_start(args, log);
-	char namebuf[LOGNAME_LENGTH + 1];
 	memset(namebuf, '.', LOGNAME_LENGTH);
 	namebuf[LOGNAME_LENGTH] = 0;
-	int i;
 	for(i = 0; name[i] != 0 && i < LOGNAME_LENGTH; i++) {
 		namebuf[i] = name[i];
 	}
 
-	char* result = malloc(1);
+	result = malloc(1);
 	result[0] = 0;
 
-	char cbuf[2];
 	cbuf[1] = 0;
 
@@ -70,12 +71,12 @@
 				int a = va_arg(args, int);
 				char buf[128];
+				char* tmp = result;
 				sprintf(buf, "%d", a);
-				char* tmp = result;
 				result = cm_strcat(tmp, buf);
 				free(tmp);
 			}
 		} else {
+			char* tmp = result;
 			cbuf[0] = log[i];
-			char* tmp = result;
 			result = cm_strcat(tmp, cbuf);
 			free(tmp);
Index: trunk/Common/string.c
===================================================================
--- trunk/Common/string.c	(revision 191)
+++ trunk/Common/string.c	(revision 212)
@@ -8,7 +8,8 @@
 
 char* cm_strcat(const char* a, const char* b) {
+	char* str;
 	if(a == NULL) a = "";
 	if(b == NULL) b = "";
-	char* str = malloc(strlen(a) + strlen(b) + 1);
+	str = malloc(strlen(a) + strlen(b) + 1);
 	memcpy(str, a, strlen(a));
 	memcpy(str + strlen(a), b, strlen(b));
@@ -27,6 +28,6 @@
 
 bool cm_endswith(const char* str, const char* end) {
+	int i;
 	if(strlen(str) < strlen(end)) return false;
-	int i;
 	for(i = strlen(str) - strlen(end); i < strlen(str); i++) {
 		if(str[i] != end[i - strlen(str) + strlen(end)]) return false;
@@ -36,6 +37,6 @@
 
 bool cm_nocase_endswith(const char* str, const char* end) {
+	int i;
 	if(strlen(str) < strlen(end)) return false;
-	int i;
 	for(i = strlen(str) - strlen(end); i < strlen(str); i++) {
 		if(tolower(str[i]) != tolower(end[i - strlen(str) + strlen(end)])) return false;
@@ -76,11 +77,11 @@
 	int i;
 	char** r = malloc(sizeof(*r));
-	r[0] = NULL;
 	char* b = malloc(1);
-	b[0] = 0;
 	char cbuf[2];
-	cbuf[1] = 0;
 	bool dq = false;
 	bool sq = false;
+	r[0] = NULL;
+	b[0] = 0;
+	cbuf[1] = 0;
 	for(i = 0;; i++) {
 		int j;
@@ -113,6 +114,6 @@
 				sq = !sq;
 			} else {
+				char* tmp = b;
 				cbuf[0] = str[i];
-				char* tmp = b;
 				b = cm_strcat(tmp, cbuf);
 				free(tmp);
@@ -125,8 +126,8 @@
 
 bool cm_strcaseequ(const char* a, const char* b) {
+	int i;
 	if(a == NULL) return false;
 	if(b == NULL) return false;
 	if(strlen(a) != strlen(b)) return false;
-	int i;
 	for(i = 0; a[i] != 0; i++) {
 		if(tolower(a[i]) != tolower(b[i])) return false;
@@ -155,6 +156,6 @@
 	int i;
 	char* result = malloc(1);
+	char cbuf[2];
 	result[0] = 0;
-	char cbuf[2];
 	cbuf[1] = 0;
 	for(i = 0; str[i] != 0; i++) {
@@ -184,6 +185,6 @@
 	int i;
 	char* result = malloc(1);
+	char cbuf[2];
 	result[0] = 0;
-	char cbuf[2];
 	cbuf[1] = 0;
 	for(i = 0; str[i] != 0; i++) {
@@ -191,6 +192,6 @@
 		if('!' <= str[i] && str[i] <= '@' && str[i] != '.' && str[i] != '-' && str[i] != '/' && !('0' <= str[i] && str[i] <= '9')) {
 			char code[4];
+			char* tmp = result;
 			sprintf(code, "%%%02X", str[i]);
-			char* tmp = result;
 			result = cm_strcat(tmp, code);
 			free(tmp);
