summaryrefslogtreecommitdiffstats
path: root/mbbsd/edit.c
diff options
context:
space:
mode:
authorvictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-02-16 09:05:14 +0800
committervictor <victor@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-02-16 09:05:14 +0800
commit42e7d7835361b5a07dadce5192af33585acbd578 (patch)
treee103f81f9e5dd1bc515e3096a771dacdc8407db9 /mbbsd/edit.c
parent7314728d7ce0c7fccd08b18bd113a34ffa66ef15 (diff)
downloadpttbbs-42e7d7835361b5a07dadce5192af33585acbd578.tar
pttbbs-42e7d7835361b5a07dadce5192af33585acbd578.tar.gz
pttbbs-42e7d7835361b5a07dadce5192af33585acbd578.tar.bz2
pttbbs-42e7d7835361b5a07dadce5192af33585acbd578.tar.lz
pttbbs-42e7d7835361b5a07dadce5192af33585acbd578.tar.xz
pttbbs-42e7d7835361b5a07dadce5192af33585acbd578.tar.zst
pttbbs-42e7d7835361b5a07dadce5192af33585acbd578.zip
fix block cutting's problem (free an freed pointer, oldcurrline)
remove never used code git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2513 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/edit.c')
-rw-r--r--mbbsd/edit.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/mbbsd/edit.c b/mbbsd/edit.c
index afcf76f7..ba012085 100644
--- a/mbbsd/edit.c
+++ b/mbbsd/edit.c
@@ -1676,8 +1676,10 @@ block_delete(void)
curr_buf->currln = curr_buf->curr_window_line = curr_buf->edit_margin = 0;
}
- if (end->next)
- (curr_buf->currline = end->next)->prev = begin->prev;
+ if (end->next) {
+ curr_buf->currline = end->next;
+ curr_buf->currline->prev = begin->prev;
+ }
else if (begin->prev) {
curr_buf->currline = (curr_buf->lastline = begin->prev);
curr_buf->currln--;
@@ -1768,10 +1770,6 @@ cancel_block:
static void
block_select(void)
{
- if (has_block_selection()) {
- block_prompt();
- return;
- }
curr_buf->blockln = curr_buf->currln;
curr_buf->blockpnt = curr_buf->currpnt;
curr_buf->blockline = curr_buf->currline;
@@ -2448,7 +2446,7 @@ vedit(char *fpath, int saveheader, int *islocal)
enter_edit_buffer();
- curr_buf->currline = curr_buf->top_of_win =
+ oldcurrline = curr_buf->currline = curr_buf->top_of_win =
curr_buf->firstline = curr_buf->lastline = alloc_line(WRAPMARGIN);
if (*fpath)
@@ -2457,11 +2455,12 @@ vedit(char *fpath, int saveheader, int *islocal)
if (*quote_file) {
do_quote();
*quote_file = '\0';
- // FIXME it's never used ??
- if (quote_file[79] == 'L')
- local_article = 1;
}
+ // if the currline is changed in do_quote, it should be reseted.
+ if (oldcurrline != curr_buf->currline)
+ curr_buf->firstline = adjustline(curr_buf->firstline, WRAPMARGIN);
+
/* No matter you quote or not, just start the cursor from (0,0) */
oldcurrline = curr_buf->currline = curr_buf->firstline;
curr_buf->currpnt = curr_buf->currln = curr_buf->curr_window_line = curr_buf->edit_margin = curr_buf->last_margin = 0;
@@ -2593,6 +2592,11 @@ vedit(char *fpath, int saveheader, int *islocal)
break;
case Ctrl('W'):
block_cut();
+ // oldcurrline is freed in block_cut, and currline is
+ // well adjusted now. This will avoid re-adjusting later.
+ // It's not a good implementation, try to find a better
+ // solution!
+ oldcurrline = curr_buf->currline;
break;
case Ctrl('Q'): /* Quit without saving */
ch = ask("µ²§ô¦ý¤£Àx¦s (Y/N)? [N]: ");
@@ -2645,7 +2649,16 @@ vedit(char *fpath, int saveheader, int *islocal)
break;
case 'l': /* block delete */
case ' ':
- block_select();
+ if (has_block_selection()) {
+ block_prompt();
+ // oldcurrline is freed in block_cut, and currline is
+ // well adjusted now. This will avoid re-adjusting later.
+ // It's not a good implementation, try to find a better
+ // solution!
+ oldcurrline = curr_buf->currline;
+ }
+ else
+ block_select();
break;
case 'u':
block_cancel();