combined use of = and ==?
_is_checksum_term = c == '*';
The above line has me confused. Is there some reason why this would be written this way?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
bool TinyGPS::encode(char c)
{
bool valid_sentence = false;
#ifndef _GPS_NO_STATS
++_encoded_characters;
#endif
switch(c)
{
case ',': // term terminators
_parity ^= c;
case '\r':
case '\n':
case '*':
if (_term_offset < sizeof(_term))
{
_term[_term_offset] = 0;
valid_sentence = term_complete();
}
++_term_number;
_term_offset = 0;
_is_checksum_term = c == '*';
return valid_sentence;
case '$': // sentence begin
_term_number = _term_offset = 0;
_parity = 0;
_sentence_type = _GPS_SENTENCE_OTHER;
_is_checksum_term = false;
_gps_data_good = false;
return valid_sentence;
}
// ordinary characters
if (_term_offset < sizeof(_term) - 1)
_term[_term_offset++] = c;
if (!_is_checksum_term)
_parity ^= c;
return valid_sentence;
}
|
|
_is_checksum_term = (c == '*');
|
or
1 2 3 4
|
if (c == '*')
_is_checksum_term = 1;
else
_is_checksum_term = 0;
|
Thank you. That answers the question very well.
Topic archived. No new replies allowed.