Browse Source

Bugfix: cgpu_match: Handle digits in dname (x6500)

Luke Dashjr 12 years ago
parent
commit
0287a1db66
1 changed files with 16 additions and 4 deletions
  1. 16 4
      miner.c

+ 16 - 4
miner.c

@@ -579,6 +579,7 @@ bool cgpu_match(const char * const pattern, const struct cgpu_info * const cgpu)
 	if (!strcasecmp(pattern, "all"))
 	if (!strcasecmp(pattern, "all"))
 		return true;
 		return true;
 	
 	
+	const struct device_drv * const drv = cgpu->drv;
 	const char *p = pattern, *p2;
 	const char *p = pattern, *p2;
 	size_t L;
 	size_t L;
 	int n, i, c = -1;
 	int n, i, c = -1;
@@ -586,12 +587,24 @@ bool cgpu_match(const char * const pattern, const struct cgpu_info * const cgpu)
 	int proc_first = -1, proc_last = -1;
 	int proc_first = -1, proc_last = -1;
 	struct cgpu_info *device;
 	struct cgpu_info *device;
 	
 	
-	while (p[0] && p[0] != '@' && 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]) || p[1] == '-'))
+		// d#
 		++p;
 		++p;
+	else
+	if (isdigit(p[0]) || p[0] == '@' || p[0] == '-')
+		// # or @
+		{}
+	else
+		return false;
 	
 	
 	L = p - pattern;
 	L = p - pattern;
-	while (L && isspace(pattern[L-1]))
-		--L;
+	while (isspace(p[0]))
+		++p;
 	if (p[0] == '@')
 	if (p[0] == '@')
 	{
 	{
 		// Serial/path
 		// Serial/path
@@ -673,7 +686,6 @@ bool cgpu_match(const char * const pattern, const struct cgpu_info * const cgpu)
 	
 	
 	if (L > 1 || tolower(pattern[0]) != 'd' || !p[0])
 	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)) ||
 		if ((L == 3 && !strncasecmp(pattern, drv->name, 3)) ||
 			(!L) ||
 			(!L) ||
 			(L == strlen(drv->dname) && !strncasecmp(pattern, drv->dname, L)))
 			(L == strlen(drv->dname) && !strncasecmp(pattern, drv->dname, L)))