vi editor

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

vi editor

Steven Baldasty
Using OpenBSD 3.9 (i386) to write a script:

$ vi
:set number
:set leftright

Then vi stops responding.

Reply | Threaded
Open this post in threaded view
|

Re: vi editor

Vladas Urbonas
On 16/05/06, Steven Baldasty <[hidden email]> wrote:
>
> Using OpenBSD 3.9 (i386) to write a script:
>
> $ vi
> :set number
> :set leftright
>
> Then vi stops responding.


The same happens for me (i386).

OpenBSD 3.9-current (GENERIC) #668: Fri Mar 31 16:57:46 MST 2006

Reply | Threaded
Open this post in threaded view
|

Re: vi editor

Jun-ichiro itojun Hagino 2.0
> > Using OpenBSD 3.9 (i386) to write a script:
> >
> > $ vi
> > :set number
> > :set leftright
> >
> > Then vi stops responding.
>
> The same happens for me (i386).
>
> OpenBSD 3.9-current (GENERIC) #668: Fri Mar 31 16:57:46 MST 2006

        nvi's "leftright" and "number" are not really tested (even before
        openbsd import), it seems.
        (and i did not test those at all for nvi-m17n, because i don't use
        those modes:-)

itojun

Reply | Threaded
Open this post in threaded view
|

Re: vi editor

Miod Vallat
In reply to this post by Steven Baldasty
> Using OpenBSD 3.9 (i386) to write a script:
>
> $ vi
> :set number
> :set leftright
>
> Then vi stops responding.

This is known as PR #3154, but nobody has been working on a fix yet.

Miod

Reply | Threaded
Open this post in threaded view
|

Re: vi editor

Otto Moerbeek
In reply to this post by Steven Baldasty
On Mon, 15 May 2006, Steven Baldasty wrote:

> Using OpenBSD 3.9 (i386) to write a script:
>
> $ vi
> :set number
> :set leftright
>
> Then vi stops responding.
>
>

This is a long standing bug.
See http://cvs.openbsd.org/cgi-bin/query-pr-wrapper?full=yes&numbers=3154
 
Volunteers welcome!

        -Otto

Reply | Threaded
Open this post in threaded view
|

Re: vi editor

Steven Baldasty
In reply to this post by Steven Baldasty
On 5/15/06, Steven Baldasty <[hidden email]> wrote:
> Using OpenBSD 3.9 (i386) to write a script:
>
> $ vi
> :set number
> :set leftright
>
> Then vi stops responding.
>
Thank you all for your feedback. I will rummage around the source code
if I have time, but here are some data that may prove useful to
whoever eventually solves it.

It seems the curser must be on an empty line for the problem to occur
(as would be the case when entering vi with no arguments). Vi works
with a file fine until the curser enteres an empty line.

Leaving an empty line created by pressing ENTER in edit mode also
causes the problem.

I suspect line.c may contain the problem.

Reply | Threaded
Open this post in threaded view
|

Re: vi editor

Otto Moerbeek
On Tue, 16 May 2006, Steven Baldasty wrote:

> On 5/15/06, Steven Baldasty <[hidden email]> wrote:
> > Using OpenBSD 3.9 (i386) to write a script:
> >
> > $ vi
> > :set number
> > :set leftright
> >
> > Then vi stops responding.
> >
> Thank you all for your feedback. I will rummage around the source code
> if I have time, but here are some data that may prove useful to
> whoever eventually solves it.
>
> It seems the curser must be on an empty line for the problem to occur
> (as would be the case when entering vi with no arguments). Vi works
> with a file fine until the curser enteres an empty line.
>
> Leaving an empty line created by pressing ENTER in edit mode also
> causes the problem.
>
> I suspect line.c may contain the problem.

This seems to resolve the problem, please test,

        -Otto

Index: vi/vs_refresh.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/vs_refresh.c,v
retrieving revision 1.14
diff -u -p -r1.14 vs_refresh.c
--- vi/vs_refresh.c 11 Mar 2006 06:58:00 -0000 1.14
+++ vi/vs_refresh.c 17 May 2006 13:17:41 -0000
@@ -598,7 +598,7 @@ slow: for (smp = HMAP; smp->lno != LNO;
  * for the number option offset.
  */
  cnt = vs_columns(sp, NULL, LNO, &CNO, NULL);
- if (O_ISSET(sp, O_NUMBER))
+ if (O_ISSET(sp, O_NUMBER) && cnt > O_NUMBER_LENGTH)
  cnt -= O_NUMBER_LENGTH;
 
  /* Adjust the window towards the beginning of the line. */

Reply | Threaded
Open this post in threaded view
|

Re: vi editor

Vladas Urbonas
Otto Moerbeek wrote:

> On Tue, 16 May 2006, Steven Baldasty wrote:
>
>
>>On 5/15/06, Steven Baldasty <[hidden email]> wrote:
>>
>>>Using OpenBSD 3.9 (i386) to write a script:
>>>
>>>$ vi
>>>:set number
>>>:set leftright
>>>
>>>Then vi stops responding.
>>>
>>
>>Thank you all for your feedback. I will rummage around the source code
>>if I have time, but here are some data that may prove useful to
>>whoever eventually solves it.
>>
>>It seems the curser must be on an empty line for the problem to occur
>>(as would be the case when entering vi with no arguments). Vi works
>>with a file fine until the curser enteres an empty line.
>>
>>Leaving an empty line created by pressing ENTER in edit mode also
>>causes the problem.
>>
>>I suspect line.c may contain the problem.
>
>
> This seems to resolve the problem, please test,


Works fine for me,
OpenBSD 3.9-current (GENERIC_WITH_AZALIA_ENABLED) #3: Wed May 17
20:17:57 JST 2006

Otto, thank you for your personal reply!



>
> -Otto
>
> Index: vi/vs_refresh.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/vi/vi/vs_refresh.c,v
> retrieving revision 1.14
> diff -u -p -r1.14 vs_refresh.c
> --- vi/vs_refresh.c 11 Mar 2006 06:58:00 -0000 1.14
> +++ vi/vs_refresh.c 17 May 2006 13:17:41 -0000
> @@ -598,7 +598,7 @@ slow: for (smp = HMAP; smp->lno != LNO;
>   * for the number option offset.
>   */
>   cnt = vs_columns(sp, NULL, LNO, &CNO, NULL);
> - if (O_ISSET(sp, O_NUMBER))
> + if (O_ISSET(sp, O_NUMBER) && cnt > O_NUMBER_LENGTH)
>   cnt -= O_NUMBER_LENGTH;
>  
>   /* Adjust the window towards the beginning of the line. */

Reply | Threaded
Open this post in threaded view
|

Re: vi editor

Otto Moerbeek
On Wed, 17 May 2006, vladas wrote:

> Otto Moerbeek wrote:
> > This seems to resolve the problem, please test,
>
>
> Works fine for me,

Could you instead please test the following diff? It's a backport from
nvi 1.88.5.

        -Otto

Index: vi/vs_relative.c
===================================================================
RCS file: /cvs/src/usr.bin/vi/vi/vs_relative.c,v
retrieving revision 1.4
diff -u -p -r1.4 vs_relative.c
--- vi/vs_relative.c 8 Jan 2006 21:05:40 -0000 1.4
+++ vi/vs_relative.c 19 May 2006 09:25:55 -0000
@@ -113,6 +113,15 @@ vs_columns(sp, lp, lno, cnop, diffp)
  int ch, leftright, listset;
  char *p;
 
+ /*
+ * Initialize the screen offset.
+ */
+ scno = 0;
+
+ /* Leading number if O_NUMBER option set. */
+ if (O_ISSET(sp, O_NUMBER))
+ scno += O_NUMBER_LENGTH;
+
  /* Need the line to go any further. */
  if (lp == NULL) {
  (void)db_get(sp, lno, 0, &lp, &len);
@@ -124,7 +133,7 @@ vs_columns(sp, lp, lno, cnop, diffp)
  if (lp == NULL) {
 done: if (diffp != NULL) /* XXX */
  *diffp = 0;
- return (0);
+ return (scno);
  }
 
  /* Store away the values of the list and leftright edit options. */
@@ -136,7 +145,7 @@ done: if (diffp != NULL) /* XXX */
  * offsets.
  */
  p = lp;
- curoff = scno = 0;
+ curoff = 0;
 
  /* Leading number if O_NUMBER option set. */
  if (O_ISSET(sp, O_NUMBER))

Reply | Threaded
Open this post in threaded view
|

Re: vi editor

Otto Moerbeek
On Fri, 19 May 2006, Otto Moerbeek wrote:

> On Wed, 17 May 2006, vladas wrote:
>
> > Otto Moerbeek wrote:
> > > This seems to resolve the problem, please test,
> >
> >
> > Works fine for me,
>
> Could you instead please test the following diff? It's a backport from
> nvi 1.88.5.

Oops, make that 1.81.5

>
> -Otto
>
> Index: vi/vs_relative.c
> ===================================================================
> RCS file: /cvs/src/usr.bin/vi/vi/vs_relative.c,v
> retrieving revision 1.4
> diff -u -p -r1.4 vs_relative.c
> --- vi/vs_relative.c 8 Jan 2006 21:05:40 -0000 1.4
> +++ vi/vs_relative.c 19 May 2006 09:25:55 -0000
> @@ -113,6 +113,15 @@ vs_columns(sp, lp, lno, cnop, diffp)
>   int ch, leftright, listset;
>   char *p;
>  
> + /*
> + * Initialize the screen offset.
> + */
> + scno = 0;
> +
> + /* Leading number if O_NUMBER option set. */
> + if (O_ISSET(sp, O_NUMBER))
> + scno += O_NUMBER_LENGTH;
> +
>   /* Need the line to go any further. */
>   if (lp == NULL) {
>   (void)db_get(sp, lno, 0, &lp, &len);
> @@ -124,7 +133,7 @@ vs_columns(sp, lp, lno, cnop, diffp)
>   if (lp == NULL) {
>  done: if (diffp != NULL) /* XXX */
>   *diffp = 0;
> - return (0);
> + return (scno);
>   }
>  
>   /* Store away the values of the list and leftright edit options. */
> @@ -136,7 +145,7 @@ done: if (diffp != NULL) /* XXX */
>   * offsets.
>   */
>   p = lp;
> - curoff = scno = 0;
> + curoff = 0;
>  
>   /* Leading number if O_NUMBER option set. */
>   if (O_ISSET(sp, O_NUMBER))