Browse Source

Bugfix: cgpu_match: Handle digits in dname (x6500)

Conflicts:
	miner.c
Luke Dashjr 12 years ago
parent
commit
175410df16
1 changed files with 16 additions and 4 deletions
  1. 16 4
      miner.c

+ 16 - 4
miner.c

@@ -508,17 +508,30 @@ bool cgpu_match(const char * const pattern, const struct cgpu_info * const cgpu)
 	if (!strcasecmp(pattern, "all"))
 		return true;
 	
+	const struct device_drv * const drv = cgpu->drv;
 	const char *p = pattern, *p2;
 	size_t L;
 	int n, i, c = -1;
 	struct cgpu_info *device;
 	
-	while (p[0] && !isdigit(p[0]))
+	if (!(strncasecmp(drv->dname, p, (L = strlen(drv->dname)))
+	   && strncasecmp(drv-> name, p, (L = strlen(drv-> name)))))
+		// dname or name
+		p = &pattern[L];
+	else
+	if (p[0] == 'd' && isdigit(p[1]))
+		// d#
 		++p;
+	else
+	if (isdigit(p[0]))
+		// #
+		{}
+	else
+		return false;
 	
 	L = p - pattern;
-	while (L && isspace(pattern[L-1]))
-		--L;
+	while (isspace(p[0]))
+		++p;
 	n = strtol(p, (void*)&p2, 0);
 	if (L == 0)
 	{
@@ -533,7 +546,6 @@ bool cgpu_match(const char * const pattern, const struct cgpu_info * const cgpu)
 	
 	if (L > 1 || tolower(pattern[0]) != 'd' || !p[0])
 	{
-		const struct device_drv * const drv = cgpu->drv;
 		if ((L == 3 && !strncasecmp(pattern, drv->name, 3)) ||
 			(L == strlen(drv->dname) && !strncasecmp(pattern, drv->dname, L)))
 			{}  // Matched name or dname