comparison src/quickfix.c @ 9738:6818e3c96473 v7.4.2144

commit https://github.com/vim/vim/commit/796aa9c804f09276bd3cc45123f4a191a001dec2 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Aug 2 21:41:28 2016 +0200 patch 7.4.2144 Problem: On MS-Windows quickix does not handle a line with 1023 bytes ending in CR-LF properly. Solution: Don't consider CR a line break. (Ken Takata)
author Christian Brabandt <cb@256bit.org>
date Tue, 02 Aug 2016 21:45:05 +0200
parents fd9727ae3c49
children 67781bb0a61a
comparison
equal deleted inserted replaced
9737:35ce559b8553 9738:6818e3c96473
649 if (fgets((char *)IObuff, IOSIZE, state->fd) == NULL) 649 if (fgets((char *)IObuff, IOSIZE, state->fd) == NULL)
650 return QF_END_OF_INPUT; 650 return QF_END_OF_INPUT;
651 651
652 discard = FALSE; 652 discard = FALSE;
653 state->linelen = (int)STRLEN(IObuff); 653 state->linelen = (int)STRLEN(IObuff);
654 if (state->linelen == IOSIZE - 1 && !(IObuff[state->linelen - 1] == '\n' 654 if (state->linelen == IOSIZE - 1 && !(IObuff[state->linelen - 1] == '\n'))
655 #ifdef USE_CRNL
656 || IObuff[state->linelen - 1] == '\r'
657 #endif
658 ))
659 { 655 {
660 /* 656 /*
661 * The current line exceeds IObuff, continue reading using 657 * The current line exceeds IObuff, continue reading using
662 * growbuf until EOL or LINE_MAXLEN bytes is read. 658 * growbuf until EOL or LINE_MAXLEN bytes is read.
663 */ 659 */
678 if (fgets((char *)state->growbuf + growbuflen, 674 if (fgets((char *)state->growbuf + growbuflen,
679 state->growbufsiz - growbuflen, state->fd) == NULL) 675 state->growbufsiz - growbuflen, state->fd) == NULL)
680 break; 676 break;
681 state->linelen = (int)STRLEN(state->growbuf + growbuflen); 677 state->linelen = (int)STRLEN(state->growbuf + growbuflen);
682 growbuflen += state->linelen; 678 growbuflen += state->linelen;
683 if ((state->growbuf)[growbuflen - 1] == '\n' 679 if ((state->growbuf)[growbuflen - 1] == '\n')
684 #ifdef USE_CRNL
685 || (state->growbuf)[growbuflen - 1] == '\r'
686 #endif
687 )
688 break; 680 break;
689 if (state->growbufsiz == LINE_MAXLEN) 681 if (state->growbufsiz == LINE_MAXLEN)
690 { 682 {
691 discard = TRUE; 683 discard = TRUE;
692 break; 684 break;
706 * reading but discard everything until EOL or EOF is 698 * reading but discard everything until EOL or EOF is
707 * reached. 699 * reached.
708 */ 700 */
709 if (fgets((char *)IObuff, IOSIZE, state->fd) == NULL 701 if (fgets((char *)IObuff, IOSIZE, state->fd) == NULL
710 || (int)STRLEN(IObuff) < IOSIZE - 1 702 || (int)STRLEN(IObuff) < IOSIZE - 1
711 || IObuff[IOSIZE - 1] == '\n' 703 || IObuff[IOSIZE - 1] == '\n')
712 #ifdef USE_CRNL
713 || IObuff[IOSIZE - 1] == '\r'
714 #endif
715 )
716 break; 704 break;
717 } 705 }
718 706
719 state->linebuf = state->growbuf; 707 state->linebuf = state->growbuf;
720 state->linelen = growbuflen; 708 state->linelen = growbuflen;
755 if (status != QF_OK) 743 if (status != QF_OK)
756 return status; 744 return status;
757 745
758 /* remove newline/CR from the line */ 746 /* remove newline/CR from the line */
759 if (state->linelen > 0 && state->linebuf[state->linelen - 1] == '\n') 747 if (state->linelen > 0 && state->linebuf[state->linelen - 1] == '\n')
748 {
760 state->linebuf[state->linelen - 1] = NUL; 749 state->linebuf[state->linelen - 1] = NUL;
761 #ifdef USE_CRNL 750 #ifdef USE_CRNL
762 if (state->linelen > 0 && state->linebuf[state->linelen - 1] == '\r') 751 if (state->linelen > 1 && state->linebuf[state->linelen - 2] == '\r')
763 state->linebuf[state->linelen - 1] = NUL; 752 state->linebuf[state->linelen - 2] = NUL;
764 #endif 753 #endif
754 }
765 755
766 #ifdef FEAT_MBYTE 756 #ifdef FEAT_MBYTE
767 remove_bom(state->linebuf); 757 remove_bom(state->linebuf);
768 #endif 758 #endif
769 759