summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-06-09 16:01:52 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-06-09 16:01:52 +0800
commit05634a014663f9b3a9d432945b465f0dc0fde2f4 (patch)
tree6384300c173a78c5a720bfd286639263b3abe707 /mbbsd
parent93ebcc5ba3a0a250b6f4a31fb0d9058b0f720445 (diff)
downloadpttbbs-05634a014663f9b3a9d432945b465f0dc0fde2f4.tar
pttbbs-05634a014663f9b3a9d432945b465f0dc0fde2f4.tar.gz
pttbbs-05634a014663f9b3a9d432945b465f0dc0fde2f4.tar.bz2
pttbbs-05634a014663f9b3a9d432945b465f0dc0fde2f4.tar.lz
pttbbs-05634a014663f9b3a9d432945b465f0dc0fde2f4.tar.xz
pttbbs-05634a014663f9b3a9d432945b465f0dc0fde2f4.tar.zst
pttbbs-05634a014663f9b3a9d432945b465f0dc0fde2f4.zip
pmore: backward method update.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2813 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/pmore.c49
1 files changed, 16 insertions, 33 deletions
diff --git a/mbbsd/pmore.c b/mbbsd/pmore.c
index 257cdf20..26ab541d 100644
--- a/mbbsd/pmore.c
+++ b/mbbsd/pmore.c
@@ -511,48 +511,31 @@ mf_determinemaxdisps(int backlines, int update_by_offset)
MFPROTO int
mf_backward(int lines)
{
- int flFirstLine = 1;
int real_moved = 0;
- // first, because we have to trace back to line beginning,
- // add one line.
- lines ++;
- // now try to rollback for lines
- if(lines == 1)
- {
- /* special case! just rollback to start */
- while ( mf.disps > mf.start &&
- *(mf.disps-1) != '\n')
- mf.disps --;
- mf.disps --;
- lines --;
- }
- else while(mf.disps > mf.start && lines > 0)
+ /* backward n lines means to find n times of '\n'. */
+
+ /* if we're already in a line break, add one mark. */
+ if (mf.disps < mf.end && *mf.disps == '\n')
+ lines++, real_moved --;
+
+ while (1)
{
- while (mf.disps > mf.start && *--mf.disps != '\n');
- if(flFirstLine)
+ if (mf.disps < mf.start || *mf.disps == '\n')
{
- flFirstLine = 0; lines--;
- continue;
+ real_moved ++;
+ if(lines-- <= 0 || mf.disps < mf.start)
+ break;
}
-
- if(mf.disps >= mf.start)
- mf.lineno--, lines--, real_moved++;
+ mf.disps --;
}
- if(mf.disps == mf.start)
- mf.lineno = 0;
- else
- mf.disps ++;
+ /* now disps points to previous 1 byte of new address */
+ mf.disps ++;
+ real_moved --;
+ mf.lineno -= real_moved;
return real_moved;
-
- /*
- if(lines > 0)
- return MFNAV_OK;
- else
- return MFNAV_EXCEED;
- */
}
MFPROTO int