summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-01-16 10:08:02 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-01-16 10:08:02 +0800
commit3b4e5cd6bab0cb7ac8bc1ac445d7d86ca558e38a (patch)
treecd7c89d1004f6e504cb6a3b51a6cf5967ab02a4c
parent0a4593f5d3e134e1af91f6bf00e5e80f3f67c6ae (diff)
downloadpttbbs-3b4e5cd6bab0cb7ac8bc1ac445d7d86ca558e38a.tar
pttbbs-3b4e5cd6bab0cb7ac8bc1ac445d7d86ca558e38a.tar.gz
pttbbs-3b4e5cd6bab0cb7ac8bc1ac445d7d86ca558e38a.tar.bz2
pttbbs-3b4e5cd6bab0cb7ac8bc1ac445d7d86ca558e38a.tar.lz
pttbbs-3b4e5cd6bab0cb7ac8bc1ac445d7d86ca558e38a.tar.xz
pttbbs-3b4e5cd6bab0cb7ac8bc1ac445d7d86ca558e38a.tar.zst
pttbbs-3b4e5cd6bab0cb7ac8bc1ac445d7d86ca558e38a.zip
- pfterm: fixed resize crash issue. GREAT THANKS TO kcwu.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3837 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--mbbsd/pfterm.c49
1 files changed, 31 insertions, 18 deletions
diff --git a/mbbsd/pfterm.c b/mbbsd/pfterm.c
index 2d405311..ea1348e3 100644
--- a/mbbsd/pfterm.c
+++ b/mbbsd/pfterm.c
@@ -13,6 +13,7 @@
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
+#include <assert.h>
#else
@@ -422,8 +423,8 @@ initscr(void)
#endif
memset(&ft, sizeof(ft), 0);
- resizeterm(FTSZ_DEFAULT_ROW, FTSZ_DEFAULT_COL);
ft.attr = ft.rattr = FTATTR_DEFAULT;
+ resizeterm(FTSZ_DEFAULT_ROW, FTSZ_DEFAULT_COL);
// clear both pages
ft.mi = 0; clrscr();
@@ -503,7 +504,13 @@ resizeterm(int rows, int cols)
ft.cmap[mi][i][cols] = 0;
ft.amap[mi][i][cols] = 0;
}
-
+ } else {
+ // we have to deal one case:
+ // expand x, shrink x, expand y ->
+ // now new allocated lines will have small x(col) instead of mcol.
+ // the solution is to modify mcols here, or change the malloc above
+ // to max(ft.mcols, cols).
+ ft.mcols = cols;
}
}
@@ -2381,16 +2388,15 @@ fterm_rawflush(void)
int main(int argc, char* argv[])
{
char buf[512];
- char *a1 = NULL;
initscr();
if (argc < 2)
{
+#if 0
// DBCS test
- a1 = ANSI_COLOR(1;33) "代刚" ANSI_COLOR(34) "いゅ"
+ char *a1 = ANSI_COLOR(1;33) "代刚" ANSI_COLOR(34) "いゅ"
ANSI_COLOR(7) "代刚" ANSI_RESET "代刚"
"代刚a" ANSI_RESET "\n";
-#if 0
outstr(a1);
move(0, 2);
outstr("いゅ1");
@@ -2422,22 +2428,29 @@ int main(int argc, char* argv[])
getchar();
#endif
-#if 0
+#if 1
// test resize
- clear();
- move(1, 0);
- outs("test resize\n");
- refresh();
- getchar();
-
- resizeterm(26, 81);
- move(2, 0);
- outs("2nd line\n");
- refresh();
- getchar();
+ clear(); move(1, 0); outs("test resize\n");
+ doupdate(); getchar();
+ // expand X
+ resizeterm(25,200);
+ clear(); move(20, 0); clrtoeol(); outs("200x25");
+ doupdate(); getchar();
+ // resize back
+ resizeterm(25,80);
+ clear(); move(20, 0); clrtoeol(); outs("80x25");
+ doupdate(); getchar();
+ // expand Y
+ resizeterm(60,80);
+ clear(); move(20, 0); clrtoeol(); outs("80x60");
+ doupdate(); getchar();
+ // see if you crash here.
+ resizeterm(60,200);
+ clear(); move(20, 0); clrtoeol(); outs("200x60");
+ doupdate(); getchar();
#endif
-#if 1
+#if 0
// test optimization
clear();
move(1, 0);