Re: [PATCH spice-server 1/3] reds: Reuse strspn and strcspn functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, 2018-06-27 at 08:00 +0100, Frediano Ziglio wrote:
> These functions are in the standard C library, not well known
> but quite useful for parsing strings.

The fact that they're not well known makes it slightly more difficult
to  read the code (for me at least), but sure.

(Since I'm looking at this function, I have a minor followup patch to
change the name that i'll send in reply)

Acked-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>


> 
> Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> ---
>  server/reds.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/server/reds.c b/server/reds.c
> index 4b2c9919..4d343b25 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -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;
>  }
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux Virtualization]     [Linux Virtualization]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]