Dominique wrote:
> cppcheck static analyzer gives this warning which
> is a bug in Vim:
>
> [vim/src/quickfix.c:649]: (warning) Logical disjunction always
> evaluates to true: EXPR != '\n' || EXPR != '\r'.
>
> Code in quickfix.c looks liks this:
>
> 640 if (linelen == IOSIZE - 1 && (IObuff[linelen - 1] != '\n'
> 641 #ifdef USE_CRNL
> 642 || IObuff[linelen - 1] != '\r'
> 643 #endif
> 644 ))
>
> It looks wrong indeed when USE_CRNL is defined.
> Maybe it was meant to be:
>
> 640 if (linelen == IOSIZE - 1 && (IObuff[linelen - 1] != '\n'
> 641 #ifdef USE_CRNL
> 642 && IObuff[linelen - 1] != '\r'
> 643 #endif
> 644 ))
>
> But I'm not even sure this is correct either. With CRNL, there
> are 2 characters \r\n for end of line. So maybe it was mean to be:
>
> 640 if (linelen == IOSIZE - 1 && (IObuff[linelen - 1] != '\n'
> 641 #ifdef USE_CRNL
> 642 || IObuff[linelen - 2] != '\r'
> 643 #endif
> 644 ))
>
> Code with the bug was introduced in this recent checkin:
>
> ===
> commit 6be8c8e165204b8aa4eeb8a52be87a58d8b41b9e
> Author: Bram Moolenaar <[email protected]>
> Date: Sat Apr 30 13:17:09 2016 +0200
>
> patch 7.4.1802
> Problem: Quickfix doesn't handle long lines well, they are split.
> Solution: Drop characters after a limit. (Anton Lindqvist)
> ===
Further down there is this code:
if (growbuf[growbuflen - 1] == '\n'
#ifdef USE_CRNL
|| growbuf[growbuflen - 1] == '\r'
#endif
)
break;
Thus it's really checking for NL or CR. Apparently using || instead of
&& was a mistake, because of the unequal check.
It's easier to read like this:
640 if (linelen == IOSIZE - 1 && !(IObuff[linelen - 1] == '\n'
641 #ifdef USE_CRNL
642 || IObuff[linelen - 1] == '\r'
643 #endif
644 ))
--
I wonder how much deeper the ocean would be without sponges.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.