mac-parts: better management of comma.

from "PowerPC Microprocessor CHRP binding", "11.1.2. Open Method Algorithm":

"If the argument string contains a comma, or if the argument string begins with a decimal digit, the 
partition component is deemed to be present."

Signed-off-by: Laurent Vivier <Laurent@vivier.eu>



git-svn-id: svn://coreboot.org/openbios/trunk/openbios-devel@588 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
Laurent Vivier
2009-09-21 23:00:42 +00:00
parent 428b4b807f
commit 7d35d36bd4

View File

@@ -54,14 +54,20 @@ macparts_open( macparts_info_t *di )
DPRINTF("partition %s\n", str);
if( str ) {
char *tmp;
char *comma = strchr(str, ',');
parnum = atol(str);
if( *str == 0 || *str == ',' )
parnum = -1;
tmp = str;
while (*tmp && *tmp != ',')
tmp++;
if (*tmp == ',')
tmp++;
if (comma) {
tmp = comma + 1;
} else {
if (*str >= '0' && *str <= '9') {
tmp = (char*)"";
} else {
tmp = str;
parnum = -1;
}
}
if (strcmp(tmp, "%BOOT") == 0)
want_bootcode = 1;
free(str);