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
diff --git a/firmware/common/sscanf.c b/firmware/common/sscanf.c
index c710a10..66bf0dd 100644
--- a/firmware/common/sscanf.c
+++ b/firmware/common/sscanf.c
@@ -51,6 +51,26 @@
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),
void (*pop)(void *userp),
void *userp,
@@ -175,6 +195,11 @@
break;
}
break;
+ case 's':
+ n_chars += skip_spaces(peek, pop, userp);
+ n_chars += parse_chars(peek,pop, userp,va_arg(ap, char *) );
+ n++;
+ break;
case '\0':
return n;
default:
@@ -188,7 +213,7 @@
{
n_chars += skip_spaces(peek, pop, userp);
if ((*peek)(userp) != ch)
- return n;
+ continue;
else
{
(*pop)(userp);