[Spice-devel] [PATCH spice-gtk 3/5] Move strtok_r from glib-compat to spice-uri
Victor Toso
lists at victortoso.com
Thu Mar 17 10:30:21 UTC 2016
Hi,
On Thu, Mar 17, 2016 at 11:19:34AM +0100, Pavel Grunt wrote:
> It is not glib specific and it is only used in spice-uri
True but I bet string utils in glib and handle this too.
Could you include a FIXME somewhere ?
Acked-by: Victor Toso <victortoso at redhat.com>
> ---
> src/glib-compat.c | 31 -------------------------------
> src/glib-compat.h | 4 ----
> src/spice-uri.c | 29 +++++++++++++++++++++++++++++
> 3 files changed, 29 insertions(+), 35 deletions(-)
>
> diff --git a/src/glib-compat.c b/src/glib-compat.c
> index 41a7f52..622620b 100644
> --- a/src/glib-compat.c
> +++ b/src/glib-compat.c
> @@ -110,34 +110,3 @@ g_queue_free_full (GQueue *queue,
> g_queue_free (queue);
> }
> #endif
> -
> -
> -#ifndef HAVE_STRTOK_R
> -G_GNUC_INTERNAL
> -char *strtok_r(char *s, const char *delim, char **save_ptr)
> -{
> - char *token;
> -
> - if (s == NULL)
> - s = *save_ptr;
> -
> - /* Scan leading delimiters. */
> - s += strspn (s, delim);
> - if (*s == '\0')
> - return NULL;
> -
> - /* Find the end of the token. */
> - token = s;
> - s = strpbrk (token, delim);
> - if (s == NULL)
> - /* This token finishes the string. */
> - *save_ptr = strchr (token, '\0');
> - else
> - {
> - /* Terminate the token and make *SAVE_PTR point past it. */
> - *s = '\0';
> - *save_ptr = s + 1;
> - }
> - return token;
> -}
> -#endif
> diff --git a/src/glib-compat.h b/src/glib-compat.h
> index 512ea55..51eef5c 100644
> --- a/src/glib-compat.h
> +++ b/src/glib-compat.h
> @@ -62,8 +62,4 @@ g_queue_free_full (GQueue *queue,
> } G_STMT_END
> #endif
>
> -#ifndef HAVE_STRTOK_R
> -char* strtok_r(char *s, const char *delim, char **save_ptr);
> -#endif
> -
> #endif /* GLIB_COMPAT_H */
> diff --git a/src/spice-uri.c b/src/spice-uri.c
> index e2c5c9a..d925973 100644
> --- a/src/spice-uri.c
> +++ b/src/spice-uri.c
> @@ -60,6 +60,35 @@ enum {
> SPICE_URI_PORT
> };
>
> +#ifndef HAVE_STRTOK_R
> +static char *strtok_r(char *s, const char *delim, char **save_ptr)
> +{
> + char *token;
> +
> + if (s == NULL)
> + s = *save_ptr;
> +
> + /* Scan leading delimiters. */
> + s += strspn (s, delim);
> + if (*s == '\0')
> + return NULL;
> +
> + /* Find the end of the token. */
> + token = s;
> + s = strpbrk (token, delim);
> + if (s == NULL)
> + /* This token finishes the string. */
> + *save_ptr = strchr (token, '\0');
> + else
> + {
> + /* Terminate the token and make *SAVE_PTR point past it. */
> + *s = '\0';
> + *save_ptr = s + 1;
> + }
> + return token;
> +}
> +#endif
> +
> G_GNUC_INTERNAL
> SpiceURI* spice_uri_new(void)
> {
> --
> 2.7.3
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
More information about the Spice-devel
mailing list