[PATCH 1/3] Revert "Save latitude and longitude on XML even if location not set"

Anton Lundin glance at acc.umu.se
Tue May 6 23:47:22 PDT 2014


On 06 May, 2014 - Linus Torvalds wrote:

> On Tue, May 6, 2014 at 3:27 PM, Anton Lundin <glance at acc.umu.se> wrote:
> > This fixes the bug in #440 by accident, and introduces lots of empty
> > attributes and tags in the xml.
> > +
> > +       if (!text)
> > +               return;
> > +       while (isspace(*text))
> > +               text++;
> > +       len = strlen(text);
> > +       if (!len)
> > +               return;
> > +       while (len && isspace(text[len - 1]))
> > +               len--;
> 
> The code makes no sense.
> 

I concur. I just reverted back to it.

> As shown by the "if (!len)", empty strings shouldn't be shown.
> 
> But the "strip whitespace" can *make* the string empty.
> 
> So the "if (!len)" test is misplaced. Please just fix it.
> 

Its not really missplaced. The only way to create a totally empty string
is if it only contains spaces, and the code would call that empty by
searching from the start of the string.

> But what is worse, is that "len" is then apparently not used, and it
> just goes on to do
> 
>    quote(b, text, is_attribute);
> 
> because apparently when the code was changed to use "quote()" the use
> of "len" as a limiter of the string was lost. So that should be fixed
> too.
> 

As far as i can find, 22fcef2e introduced the code the way it is and it
haven't changed until the location fix changed it to output empty tags.


I'm sending a patch to remove any trailing spaces from the output.

//Anton

-- 
Anton Lundin	+46702-161604


More information about the subsurface mailing list