[PATCH] Fix potentially broken white space truncation on certain Windows versions

Dirk Hohndel dirk at hohndel.org
Thu Mar 7 11:26:04 PST 2013


"Lubomir I. Ivanov" <neolit123 at gmail.com> writes:
> diff --git a/info.c b/info.c
> index 0517eac..4a4b41c 100644
> --- a/info.c
> +++ b/info.c
> @@ -48,7 +48,7 @@ static int text_changed(const char *old, const char *new)
>  static const char *skip_space(const char *str)
>  {
>  	if (str) {
> -		while (isspace(*str))
> +		while (g_ascii_isspace(*str))
>  			str++;

This could leave UTF-8 non-break space there, but no harm done (I think)
- same goes for the next few

> diff --git a/parse-xml.c b/parse-xml.c
> index 80a1244..4661321 100644
> --- a/parse-xml.c
> +++ b/parse-xml.c
> @@ -437,10 +437,10 @@ static void utf8_string(char *buffer, void *_res)
>  {
>  	int size;
>  	char *res;
> -	while (isspace(*buffer))
> +	while (g_ascii_isspace(*buffer))
>  		buffer++;
>  	size = strlen(buffer);
> -	while (size && isspace(buffer[size-1]))
> +	while (size && g_ascii_isspace(buffer[size-1]))

This is the one I worry about. But staring at it some more, it shouldn't
be able to break any UTF8 code points as those all have the high bit set
while ascii space always is 7bit. So we might not remove all spaces but
it should be safe to do this.


/D


More information about the subsurface mailing list