[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Nano-devel] minor bug in justify_format()
From: |
David Lawrence Ramsey |
Subject: |
[Nano-devel] minor bug in justify_format() |
Date: |
Sun, 2 Mar 2003 22:54:31 -0800 (PST) |
To reproduce:
1. Start with a new buffer.
2. Type "test" followed by any number of spaces.
3. Justify the line, which will remove the spaces.
4. Press ^C to check the cursor position display. totsize hasn't been
decremented properly to account for the removed spaces.
I traced it down to lines 2101-2102. In this case, front and back both
point to null characters, but at different memory locations, and (back -
line->data - strlen->line->data)) is 0, meaning that totsize's value
doesn't change and the null_at call places a null at the end of the
string, where a null is anyway. The attached patch appears to fix it.
It's also available at:
http://pooka_regent.tripod.com/patches/nano/nanototsize-patch.txt
_____________________________________________________________
Sluggy.Net: The Sluggy Freelance Community!
_____________________________________________________________
Select your own custom email address for FREE! Get address@hidden w/No Ads,
6MB, POP & more! http://www.everyone.net/selectmail?campaign=tag
diff -urN nano/ChangeLog nano-fixed/ChangeLog
--- nano/ChangeLog 2003-02-23 14:12:54.000000000 -0500
+++ nano-fixed/ChangeLog 2003-03-02 23:07:15.000000000 -0500
@@ -1,6 +1,10 @@
CVS code -
- General:
- Translation updates (see po/ChangeLog for details).
+- nano.c:
+ justify_format()
+ - If we shave spaces off the end of the line, make sure totsize
+ is properly updated. (DLR)
GNU nano 1.2.0 - 2003.02.19
- General:
diff -urN nano/nano.c nano-fixed/nano.c
--- nano/nano.c 2003-02-19 17:27:53.000000000 -0500
+++ nano-fixed/nano.c 2003-03-02 23:01:31.000000000 -0500
@@ -2098,8 +2098,12 @@
/* Now back is the new end of line->data. */
if (back != front) {
- totsize += back - line->data - strlen(line->data);
- null_at(&line->data, back - line->data);
+ if (*front == '\0')
+ totsize += back - front;
+ else {
+ totsize += back - line->data - strlen(line->data);
+ null_at(&line->data, back - line->data);
+ }
#ifndef NANO_SMALL
if (mark_beginbuf == line && back - line->data < mark_beginx)
mark_beginx = back - line->data;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Nano-devel] minor bug in justify_format(),
David Lawrence Ramsey <=