Patch 7.3.799

76 views
Skip to first unread message

Bram Moolenaar

unread,
Feb 6, 2013, 6:15:41 AM2/6/13
to vim...@googlegroups.com

Patch 7.3.799
Problem: The color column is not correct when entering a buffer. (Ben
Fritz)
Solution: Call check_colorcolumn() if 'textwidth' changed. (Christian
Brabandt)
Files: src/buffer.c


*** ../vim-7.3.798/src/buffer.c 2012-11-20 12:16:54.000000000 +0100
--- src/buffer.c 2013-02-06 11:52:54.000000000 +0100
***************
*** 1441,1446 ****
--- 1441,1448 ----
enter_buffer(buf)
buf_T *buf;
{
+ long old_tw = curbuf->b_p_tw;
+
/* Copy buffer and window local option values. Not for a help buffer. */
buf_copy_options(buf, BCO_ENTER | BCO_NOHELP);
if (!buf->b_help)
***************
*** 1464,1469 ****
--- 1466,1473 ----

#ifdef FEAT_SYN_HL
curwin->w_s = &(buf->b_s);
+ if (old_tw != buf->b_p_tw)
+ check_colorcolumn(curwin);
#endif

/* Cursor on first line by default. */
*** ../vim-7.3.798/src/version.c 2013-01-31 21:09:10.000000000 +0100
--- src/version.c 2013-02-06 11:55:06.000000000 +0100
***************
*** 727,728 ****
--- 727,730 ----
{ /* Add new patch number below this line */
+ /**/
+ 799,
/**/

--
I wonder, do vegetarians eat fruit bats?

/// Bram Moolenaar -- Br...@Moolenaar.net -- 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 ///

Ben Fritz

unread,
Feb 6, 2013, 11:03:19 AM2/6/13
to vim...@googlegroups.com
On Wednesday, February 6, 2013 5:15:41 AM UTC-6, Bram Moolenaar wrote:
> Patch 7.3.799
>
> Problem: The color column is not correct when entering a buffer. (Ben
>
> Fritz)
>
> Solution: Call check_colorcolumn() if 'textwidth' changed. (Christian
>
> Brabandt)
>

Probably it's too late, but I only contributed to the discussion. John Szakmeister was the original reporter of the issue.

Tony Mechelynck

unread,
Feb 6, 2013, 11:45:20 AM2/6/13
to vim...@googlegroups.com, Bram Moolenaar
On 06/02/13 12:15, Bram Moolenaar wrote:
>
> Patch 7.3.799
> Problem: The color column is not correct when entering a buffer. (Ben
> Fritz)
> Solution: Call check_colorcolumn() if 'textwidth' changed. (Christian
> Brabandt)
> Files: src/buffer.c
[...]

I get the following warning in "tiny" build but not in "huge" build:

gcc -c -I. -Iproto -DHAVE_CONFIG_H -I/usr/local/include -O2
-fno-strength-reduce -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
-o objects/buffer.o buffer.c
buffer.c: In function �enter_buffer�:
buffer.c:1444:10: warning: unused variable �old_tw� [-Wunused-variable]

Build is successful (this is a warning, not an error).


Best regards,
Tony.
--
Every program has two purposes -- one for which it was written and
another for which it wasn't.

Bram Moolenaar

unread,
Feb 6, 2013, 12:45:14 PM2/6/13
to Tony Mechelynck, vim...@googlegroups.com

Tony Mechelynck wrote:

> On 06/02/13 12:15, Bram Moolenaar wrote:
> >
> > Patch 7.3.799
> > Problem: The color column is not correct when entering a buffer. (Ben
> > Fritz)
> > Solution: Call check_colorcolumn() if 'textwidth' changed. (Christian
> > Brabandt)
> > Files: src/buffer.c
> [...]
>
> I get the following warning in "tiny" build but not in "huge" build:
>
> gcc -c -I. -Iproto -DHAVE_CONFIG_H -I/usr/local/include -O2
> -fno-strength-reduce -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
> -o objects/buffer.o buffer.c
> buffer.c: In function �enter_buffer�:
> buffer.c:1444:10: warning: unused variable �old_tw� [-Wunused-variable]
>
> Build is successful (this is a warning, not an error).

Ah, we forgot an #ifdef. I'll fix it.

--
ROBIN: (warily) And if you get a question wrong?
ARTHUR: You are cast into the Gorge of Eternal Peril.
ROBIN: Oh ... wacho!
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

Christian Brabandt

unread,
Feb 13, 2013, 5:45:40 PM2/13/13
to vim...@googlegroups.com
Hi Bram!

On Mi, 06 Feb 2013, Bram Moolenaar wrote:

>
> Patch 7.3.799
> Problem: The color column is not correct when entering a buffer. (Ben
> Fritz)
> Solution: Call check_colorcolumn() if 'textwidth' changed. (Christian
> Brabandt)
> Files: src/buffer.c

This segfaults for me at Test 87 in test49.vim This patch fixes it:

diff --git a/src/buffer.c b/src/buffer.c
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -1442,7 +1442,7 @@
buf_T *buf;
{
#ifdef FEAT_SYN_HL
- long old_tw = curbuf->b_p_tw;
+ long old_tw = buf_valid(curbuf) ? curbuf->b_p_tw : 0;
#endif

/* Copy buffer and window local option values. Not for a help buffer. */


regards,
Christian
--
Ein liebes Wort hat oft die Macht, ein Wunder zu vollbringen; es
bringt aus Leid und dunkler Nacht ein Menschenherz zum Klingen.
-- Fischer-Friesenhausen

Bram Moolenaar

unread,
Feb 14, 2013, 4:49:04 AM2/14/13
to Christian Brabandt, vim...@googlegroups.com

Christian Brabandt wrote:

> Hi Bram!
>
> On Mi, 06 Feb 2013, Bram Moolenaar wrote:
>
> >
> > Patch 7.3.799
> > Problem: The color column is not correct when entering a buffer. (Ben
> > Fritz)
> > Solution: Call check_colorcolumn() if 'textwidth' changed. (Christian
> > Brabandt)
> > Files: src/buffer.c
>
> This segfaults for me at Test 87 in test49.vim This patch fixes it:
>
> diff --git a/src/buffer.c b/src/buffer.c
> --- a/src/buffer.c
> +++ b/src/buffer.c
> @@ -1442,7 +1442,7 @@
> buf_T *buf;
> {
> #ifdef FEAT_SYN_HL
> - long old_tw = curbuf->b_p_tw;
> + long old_tw = buf_valid(curbuf) ? curbuf->b_p_tw : 0;
> #endif
>
> /* Copy buffer and window local option values. Not for a help buffer. */

Any idea why it crashes for you and not for me?
Perhaps should run under valgrind.

--
ARTHUR: CHARGE!
[The mighty ARMY charges. Thundering noise of feet. Clatter of coconuts.
Shouts etc. Suddenly there is a wail of a siren and a couple of police
cars roar round in front of the charging ARMY and the POLICE leap out and
stop them. TWO POLICEMAN and the HISTORIAN'S WIFE. Black Marias skid up
behind them.]
HISTORIAN'S WIFE: They're the ones, I'm sure.

Christian Brabandt

unread,
Feb 14, 2013, 7:28:26 AM2/14/13
to vim...@googlegroups.com
Hi Bram!

On Do, 14 Feb 2013, Bram Moolenaar wrote:

> Any idea why it crashes for you and not for me?
> Perhaps should run under valgrind.

No and it doesn't segfault, if I only let test87 run. Problem is,
close_buffer() might close curbuf and curbuf can get freed(). Of course
then you can't access curbuf->b_p_tw in enter_buffer() anymore.

Valgrind confirms this:

==12456== Memcheck, a memory error detector
==12456== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==12456== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==12456== Command: ../vim -u unix.vim -U NONE --noplugin -s dotest.in test49.in
==12456== Parent PID: 12450
==12456==
==12456== Invalid read of size 8
==12456== at 0x40FB67: enter_buffer (buffer.c:1445)
==12456== by 0x40FB51: set_curbuf (buffer.c:1433)
==12456== by 0x40F8FC: do_buffer (buffer.c:1330)
==12456== by 0x40ED18: do_bufdel (buffer.c:872)
==12456== by 0x472768: ex_bunload (ex_docmd.c:5062)
==12456== by 0x46DE03: do_one_cmd (ex_docmd.c:2681)
==12456== by 0x46B3EF: do_cmdline (ex_docmd.c:1122)
==12456== by 0x454E8C: call_user_func (eval.c:22604)
==12456== by 0x43DB87: call_func (eval.c:8484)
==12456== by 0x43D73C: get_func_tv (eval.c:8326)
==12456== by 0x43905E: eval7 (eval.c:5160)
==12456== by 0x4388F7: eval6 (eval.c:4812)
==12456== by 0x438447: eval5 (eval.c:4628)
==12456== by 0x43774E: eval4 (eval.c:4321)
==12456== by 0x437592: eval3 (eval.c:4233)
==12456== Address 0xc68b550 is 5,360 bytes inside a block of size 7,064 free'd
==12456== at 0x4C2A739: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==12456== by 0x4DD924: vim_free (misc2.c:1744)
==12456== by 0x40E983: free_buffer (buffer.c:665)
==12456== by 0x40E5F0: close_buffer (buffer.c:499)
==12456== by 0x40FAE8: set_curbuf (buffer.c:1409)
==12456== by 0x40F8FC: do_buffer (buffer.c:1330)
==12456== by 0x40ED18: do_bufdel (buffer.c:872)
==12456== by 0x472768: ex_bunload (ex_docmd.c:5062)
==12456== by 0x46DE03: do_one_cmd (ex_docmd.c:2681)
==12456== by 0x46B3EF: do_cmdline (ex_docmd.c:1122)
==12456== by 0x454E8C: call_user_func (eval.c:22604)
==12456== by 0x43DB87: call_func (eval.c:8484)
==12456== by 0x43D73C: get_func_tv (eval.c:8326)
==12456== by 0x43905E: eval7 (eval.c:5160)
==12456== by 0x4388F7: eval6 (eval.c:4812)
==12456==

regards,
Christian
--
Der Fortschritt geschieht heute so schnell, da�, w�hrend jemand eine
Sache f�r g�nzlich undurchf�hrbar erkl�rt, er von einem anderen
unterbrochen wird, der sie schon realisiert hat.
-- Albert Einstein

Bram Moolenaar

unread,
Feb 14, 2013, 10:35:39 AM2/14/13
to Christian Brabandt, vim...@googlegroups.com
I think we should actually move the code to get the old value of
'textwidth' to the caller of enter_buffer(). It might be that there are
only one or two places where this is relevant. Perhaps it can be
combined with some other option value that might have changed and
require an action after entering another buffer?

--
"I love deadlines. I especially like the whooshing sound they
make as they go flying by."
-- Douglas Adams

Christian Brabandt

unread,
Feb 15, 2013, 2:44:26 PM2/15/13
to vim...@googlegroups.com
Hi Bram!

On Do, 14 Feb 2013, Bram Moolenaar wrote:

> I think we should actually move the code to get the old value of
> 'textwidth' to the caller of enter_buffer(). It might be that there are
> only one or two places where this is relevant.

Here is a patch

> Perhaps it can be combined with some other option value that might
> have changed and require an action after entering another buffer?

Not sure which ones need to be taken care of.

regards,
Christian
--
Phantasie ist etwas, das sich viele gar nicht vorstellen k�nnen.
-- Helmut Qualtinger
buf_check_tw.diff

Bram Moolenaar

unread,
Feb 15, 2013, 5:01:11 PM2/15/13
to Christian Brabandt, vim...@googlegroups.com

Christian Brabandt wrote:

> Hi Bram!
>
> On Do, 14 Feb 2013, Bram Moolenaar wrote:
>
> > I think we should actually move the code to get the old value of
> > 'textwidth' to the caller of enter_buffer(). It might be that there are
> > only one or two places where this is relevant.
>
> Here is a patch

Thanks!

> > Perhaps it can be combined with some other option value that might
> > have changed and require an action after entering another buffer?
>
> Not sure which ones need to be taken care of.

Never mind then.

--
To keep milk from turning sour: Keep it in the cow.
Reply all
Reply to author
Forward
0 new messages