reds: Reuse strspn and strcspn functions

These functions are in the standard C library, not well known
but quite useful for parsing strings.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Jonathon Jongsma <jjongsma@redhat.com>
This commit is contained in:
Frediano Ziglio 2018-06-26 10:51:40 +01:00
parent 0d38a122d6
commit 6842f799db

View File

@ -3549,19 +3549,14 @@ static const char* parse_video_codecs(const char *codecs, char **encoder,
if (!codecs) {
return NULL;
}
while (*codecs == ';') {
codecs++;
}
codecs += strspn(codecs, ";");
if (!*codecs) {
return NULL;
}
int n;
*encoder = *codec = NULL;
if (sscanf(codecs, "%m[0-9a-zA-Z_]:%m[0-9a-zA-Z_]%n", encoder, codec, &n) != 2) {
while (*codecs != '\0' && *codecs != ';') {
codecs++;
}
return codecs;
return codecs + strcspn(codecs, ";");
}
return codecs + n;
}