discuss-gnuradio
[Top][All Lists]
Advanced

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

Re: [Discuss-gnuradio] GUI problems with 3.7


From: Tom Rondeau
Subject: Re: [Discuss-gnuradio] GUI problems with 3.7
Date: Sat, 22 Jun 2013 14:35:18 -0400

On Sat, Jun 22, 2013 at 8:48 AM, Sylvain Munaut <address@hidden> wrote:
> Hi,
>
>>> Huh ... but strcmp will stop comparing at the end of any of the two
>>> strings anyway.
>>
>> No, that's not true. If that were the case then string "abc" would be
>> equal to string "ab", and strcmp knows that they are different (I
>> tested this to be sure; it returns 99, while strcmp("abc", "abc")
>> returns 0, as it should). I even tested this adding a new line onto
>> one of the strings and strcmp reads them both through completely and
>> tests that, not just the length of the shortest string.
>
> Sorry I wasn't clear.
>
> I didn't mean that it will return a match. I meant that it will stop
> scanning through the strings as soon as one ends.
> Whatever the result of the last comparaison it did will be used to
> determine the return value.
> In the case of "ab" vs "abc" the last comparaison is between '\0' and 'c'.
>
> Cheers,
>
>    Sylvain

Ok, I see your point now. The problem was arising in that the file
that we write to .gnuradio/prefs is just straight text, and we read in
the whole file. When we write it, there's no new line. But some
systems (those that were having some of the issues) were adding an
extra newline after reading it. Strange, and wrong, and I'm not sure
what was doing it. But that new line was making the comparison fail.
Using strncmp allows us to ignore that by only checking the length of
the string we're actually interested in. (An alternative would be to
only read in the first line of the file and remove any newline
characters.)

Tom



reply via email to

[Prev in Thread] Current Thread [Next in Thread]