[NTDLL] Fix the MHz detecting code.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

I changed the code as it was a bit dangerous as it was : the 'cpu' 2.0 line
did match too many of the > 2.0 entries (like 'cpu MHz' or 'cpuid'). So I
changed to 'strcmp' instead of 'strncmp'.

               Lionel

Changelog:
 - fix the MHz detecting code

-- 
		 Lionel Ulmer - http://www.bbrox.org/
? misc/registry_hack.c
Index: misc/cpu.c
===================================================================
RCS file: /home/wine/wine/misc/cpu.c,v
retrieving revision 1.35
diff -u -r1.35 cpu.c
--- misc/cpu.c	28 Jul 2003 19:12:33 -0000	1.35
+++ misc/cpu.c	2 Aug 2003 20:58:37 -0000
@@ -273,15 +273,20 @@
 		/* NOTE: the ':' is the only character we can rely on */
 		if (!(value = strchr(line,':')))
 			continue;
+		
 		/* terminate the valuename */
-		*value++ = '\0';
-		/* skip any leading spaces */
+		s = value - 1;
+		while ((s >= line) && ((*s == ' ') || (*s == '\t'))) s--;
+		*(s + 1) = '\0';
+
+		/* and strip leading spaces from value */
+		value += 1;
 		while (*value==' ') value++;
 		if ((s=strchr(value,'\n')))
 			*s='\0';
 
 		/* 2.1 method */
-		if (!strncasecmp(line, "cpu family",strlen("cpu family"))) {
+		if (!strcasecmp(line, "cpu family")) {
 			if (isdigit (value[0])) {
 				switch (value[0] - '0') {
 				case 3: cachedsi.dwProcessorType = PROCESSOR_INTEL_386;
@@ -311,7 +316,7 @@
 			continue;
 		}
 		/* old 2.0 method */
-		if (!strncasecmp(line, "cpu",strlen("cpu"))) {
+		if (!strcasecmp(line, "cpu")) {
 			if (	isdigit (value[0]) && value[1] == '8' &&
 				value[2] == '6' && value[3] == 0
 			) {
@@ -334,42 +339,47 @@
 			}
 			continue;
 		}
-		if (!strncasecmp(line,"fdiv_bug",strlen("fdiv_bug"))) {
+		if (!strcasecmp(line,"fdiv_bug")) {
 			if (!strncasecmp(value,"yes",3))
 				PF[PF_FLOATING_POINT_PRECISION_ERRATA] = TRUE;
 
 			continue;
 		}
-		if (!strncasecmp(line,"fpu",strlen("fpu"))) {
+		if (!strcasecmp(line,"fpu")) {
 			if (!strncasecmp(value,"no",2))
 				PF[PF_FLOATING_POINT_EMULATED] = TRUE;
 
 			continue;
 		}
-		if (!strncasecmp(line,"processor",strlen("processor"))) {
+		if (!strcasecmp(line,"processor")) {
 			/* processor number counts up... */
 			unsigned int x;
 
 			if (sscanf(value,"%d",&x))
 				if (x+1>cachedsi.dwNumberOfProcessors)
 					cachedsi.dwNumberOfProcessors=x+1;
+			
+			continue;
 		}
-		if (!strncasecmp(line,"stepping",strlen("stepping"))) {
+		if (!strcasecmp(line,"stepping")) {
 			int	x;
 
 			if (sscanf(value,"%d",&x))
 				cachedsi.wProcessorRevision = x;
+
+			continue;
 		}
-		if (!strncasecmp(line, "cpu MHz",strlen("cpu MHz"))) {
+		if (!strcasecmp(line, "cpu MHz")) {
 			double cmz;
 			if (sscanf( value, "%lf", &cmz ) == 1) {
 				/* SYSTEMINFO doesn't have a slot for cpu speed, so store in a global */
 				cpuHz = cmz * 1000 * 1000;
 				TRACE("CPU speed read as %lld\n", cpuHz);
 			}
+			continue;
 		}
-		if (	!strncasecmp(line,"flags",strlen("flags"))	||
-			!strncasecmp(line,"features",strlen("features"))
+		if (	!strcasecmp(line,"flags")	||
+			!strcasecmp(line,"features")
 		) {
 			if (strstr(value,"cx8"))
 				PF[PF_COMPARE_EXCHANGE_DOUBLE] = TRUE;
@@ -387,7 +397,8 @@
 				PF[PF_XMMI64_INSTRUCTIONS_AVAILABLE] = TRUE;
 			if (strstr(value,"pae"))
 				PF[PF_PAE_ENABLED] = TRUE;
-
+			
+			continue;
 		}
 	}
 	fclose (f);

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux