forked from len0rd/rockbox
Some fixes and additions to sscanf - Still has bugs but it works for doom currently. As a note: this function is only used by doom to my knowledge.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11740 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
9516afce64
commit
1e0fb0246b
1 changed files with 26 additions and 1 deletions
|
@ -51,6 +51,26 @@ static int parse_dec(int (*peek)(void *userp),
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int parse_chars(int (*peek)(void *userp),
|
||||||
|
void (*pop)(void *userp),
|
||||||
|
void *userp,
|
||||||
|
char *vp)
|
||||||
|
{
|
||||||
|
int n = 0;
|
||||||
|
char *pt=vp;
|
||||||
|
|
||||||
|
while (!isspace((*peek)(userp)))
|
||||||
|
{
|
||||||
|
*(pt++) = (*peek)(userp);
|
||||||
|
n++;
|
||||||
|
(*pop)(userp);
|
||||||
|
}
|
||||||
|
|
||||||
|
(*pt)='\0';
|
||||||
|
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
|
||||||
static int parse_hex(int (*peek)(void *userp),
|
static int parse_hex(int (*peek)(void *userp),
|
||||||
void (*pop)(void *userp),
|
void (*pop)(void *userp),
|
||||||
void *userp,
|
void *userp,
|
||||||
|
@ -174,6 +194,11 @@ static int scan(int (*peek)(void *userp),
|
||||||
literal = true;
|
literal = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
case 's':
|
||||||
|
n_chars += skip_spaces(peek, pop, userp);
|
||||||
|
n_chars += parse_chars(peek,pop, userp,va_arg(ap, char *) );
|
||||||
|
n++;
|
||||||
break;
|
break;
|
||||||
case '\0':
|
case '\0':
|
||||||
return n;
|
return n;
|
||||||
|
@ -188,7 +213,7 @@ static int scan(int (*peek)(void *userp),
|
||||||
{
|
{
|
||||||
n_chars += skip_spaces(peek, pop, userp);
|
n_chars += skip_spaces(peek, pop, userp);
|
||||||
if ((*peek)(userp) != ch)
|
if ((*peek)(userp) != ch)
|
||||||
return n;
|
continue;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
(*pop)(userp);
|
(*pop)(userp);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue