[Scummvm-cvs-logs] CVS: scummvm/gob game.cpp,1.36,1.37 inter_v1.cpp,1.10,1.11 util.cpp,1.22,1.23 util.h,1.9,1.10

Max Horn fingolfin at users.sourceforge.net
Sun Jan 29 11:19:01 CET 2006


Update of /cvsroot/scummvm/scummvm/gob
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15175

Modified Files:
	game.cpp inter_v1.cpp util.cpp util.h 
Log Message:
Remove the custom strstr in favor of the ANSI strstr/strchr functions

Index: game.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/game.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- game.cpp	29 Jan 2006 02:27:10 -0000	1.36
+++ game.cpp	29 Jan 2006 19:18:15 -0000	1.37
@@ -1122,7 +1122,6 @@
 	int16 descIndex;
 	int16 timeVal;
 	char *str;
-	int16 pos;
 	int16 savedCollStackSize;
 	int16 i;
 	int16 counter;
@@ -1546,12 +1545,12 @@
 				continue;
 
 			if ((_collisionAreas[i].flags & 0x0f) > 8) {
+				char *ptr;
 				strcpy(_tempStr,
 				    _vm->_global->_inter_variables + _collisionAreas[i].key);
-				while ((pos =
-					_vm->_util->strstr(" ", _tempStr)) != 0) {
-					_vm->_util->cutFromStr(_tempStr, pos - 1, 1);
-					pos = _vm->_util->strstr(" ", _tempStr);
+				while ((ptr = strchr(_tempStr, ' ')) != 0) {
+					_vm->_util->cutFromStr(_tempStr, (ptr - _tempStr), 1);
+					ptr = strchr(_tempStr, ' ');
 				}
 				strcpy(_vm->_global->_inter_variables + _collisionAreas[i].key, _tempStr);
 			}
@@ -1565,7 +1564,7 @@
 				if ((_collisionAreas[i].flags & 0x0f) < 7)
 					_vm->_util->prepareStr(_tempStr);
 
-				pos = 0;
+				int16 pos = 0;
 				do {
 					strcpy(_collStr, str);
 					pos += strlen(str) + 1;

Index: inter_v1.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/inter_v1.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- inter_v1.cpp	18 Jan 2006 17:39:34 -0000	1.10
+++ inter_v1.cpp	29 Jan 2006 19:18:15 -0000	1.11
@@ -1032,8 +1032,9 @@
 	evalExpr(0);
 	resVar = _vm->_parse->parseVarIndex();
 
-	pos = _vm->_util->strstr(_vm->_global->_inter_resStr, _vm->_global->_inter_variables + strVar);
-	WRITE_VAR_OFFSET(resVar, pos - 1);
+	char *res = strstr(_vm->_global->_inter_variables + strVar, _vm->_global->_inter_resStr);
+	pos = res ? (res - (_vm->_global->_inter_variables + strVar)) : 0;
+	WRITE_VAR_OFFSET(resVar, pos);
 	return false;
 }
 

Index: util.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/util.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- util.cpp	29 Jan 2006 02:27:10 -0000	1.22
+++ util.cpp	29 Jan 2006 19:18:15 -0000	1.23
@@ -368,25 +368,6 @@
 	//log_write("res = %s\n", str);
 }
 
-int16 Util::strstr(const char *str1, char *str2) {
-	char c;
-	uint16 len1;
-	uint16 i;
-
-	//log_write("strstr: str1 = %s, str2 = %s\n", str1, str2);
-
-	for (i = 0, len1 = strlen(str1); strlen(str2 + i) >= len1; i++) {
-		c = str2[i + len1];
-		str2[i + len1] = 0;
-		if (strcmp(str2 + i, str1) == 0) {
-			str2[i + len1] = c;
-			return i + 1;
-		}
-		str2[i + len1] = c;
-	}
-	return 0;
-}
-
 void Util::listInsertFront(List * list, void *data) {
 	ListNode *node;
 
@@ -454,7 +435,7 @@
 
 void Util::prepareStr(char *str) {
 	uint16 i;
-	int16 j;
+	char *start, *end;
 	char buf[300];
 
 	strcpy(buf, trStr1);
@@ -470,22 +451,19 @@
 	while (strlen(str) > 0 && str[strlen(str) - 1] == ' ')
 		cutFromStr(str, strlen(str) - 1, 1);
 
-	i = strstr(" ", str);
-
-	while (1) {
-		if (i == 0)
-			return;
+	start = strchr(str, ' ');
 
-		if (str[i] == ' ') {
-			cutFromStr(str, i - 1, 1);
+	while (start != 0) {
+		if (*(start+1) == ' ') {
+			cutFromStr(str, start - str, 1);
 			continue;
 		}
 
-		j = strstr(" ", str + i);
-		if (j != 0)
-			i += j;
+		end = strchr(start + 1, ' ');
+		if (end != 0)
+			start = end + 1;
 		else
-			i = 0;
+			start = 0;
 	}
 }
 

Index: util.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/util.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- util.h	29 Jan 2006 02:27:10 -0000	1.9
+++ util.h	29 Jan 2006 19:18:15 -0000	1.10
@@ -70,17 +70,16 @@
 
 	Video::FontDesc *loadFont(const char *path);
 	void freeFont(Video::FontDesc * fontDesc);
-	void insertStr(const char *str1, char *str2, int16 pos);
-	void cutFromStr(char *str, int16 from, int16 cutlen);
-	int16 strstr(const char *str1, char *str2);
+	static void insertStr(const char *str1, char *str2, int16 pos);
+	static void cutFromStr(char *str, int16 from, int16 cutlen);
 	void waitEndFrame();
 	void setFrameRate(int16 rate);
 
-	void listInsertBack(List * list, void *data);
-	void listInsertFront(List * list, void *data);
-	void listDropFront(List * list);
-	void deleteList(List * list);
-	void prepareStr(char *str);
+	static void listInsertBack(List * list, void *data);
+	static void listInsertFront(List * list, void *data);
+	static void listDropFront(List * list);
+	static void deleteList(List * list);
+	static void prepareStr(char *str);
 	void waitMouseRelease(char drawMouse);
 
 	static const char trStr1[];





More information about the Scummvm-git-logs mailing list