mirror of
https://gitlab.uni-freiburg.de/opensourcevdi/spice
synced 2026-01-08 12:24:55 +00:00
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:
parent
0d38a122d6
commit
6842f799db
@ -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;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user