diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-04-18 22:07:08 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2005-04-18 22:07:08 +0800 |
commit | d9268ea3021f7112244a894a33882edcc408bf1a (patch) | |
tree | 291838fcf20d715ec99c05716124a071c456108a | |
parent | fee7749052ac9aab275c17be9e6bf923394b63f0 (diff) | |
download | pttbbs-d9268ea3021f7112244a894a33882edcc408bf1a.tar pttbbs-d9268ea3021f7112244a894a33882edcc408bf1a.tar.gz pttbbs-d9268ea3021f7112244a894a33882edcc408bf1a.tar.bz2 pttbbs-d9268ea3021f7112244a894a33882edcc408bf1a.tar.lz pttbbs-d9268ea3021f7112244a894a33882edcc408bf1a.tar.xz pttbbs-d9268ea3021f7112244a894a33882edcc408bf1a.tar.zst pttbbs-d9268ea3021f7112244a894a33882edcc408bf1a.zip |
1. make tty_read more clear and reable
2. hack to prevent ^W SIGSEGV when parent is incorrect.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2697 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r-- | mbbsd/bbs.c | 5 | ||||
-rw-r--r-- | mbbsd/board.c | 1 | ||||
-rw-r--r-- | mbbsd/io.c | 12 | ||||
-rw-r--r-- | mbbsd/mbbsd.c | 6 |
4 files changed, 10 insertions, 14 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c index 5ed39f8f..4aa5d213 100644 --- a/mbbsd/bbs.c +++ b/mbbsd/bbs.c @@ -251,7 +251,7 @@ readdoent(int num, fileheader_t * ent) int whereami(int ent, const fileheader_t * fhdr, const char *direct) { - boardheader_t *bh, *p[WHEREAMI_LEVEL], *root; + boardheader_t *bh, *p[WHEREAMI_LEVEL]; int i, j; if (!currutmp->brc_id) @@ -260,9 +260,8 @@ whereami(int ent, const fileheader_t * fhdr, const char *direct) move(1, 0); clrtobot(); bh = getbcache(currutmp->brc_id); - root = getbcache(1); p[0] = bh; - for (i = 0; i+1 < WHEREAMI_LEVEL && p[i]->parent>1; i++) + for (i = 0; i+1 < WHEREAMI_LEVEL && p[i]->parent>1 && p[i]->parent < numboards; i++) p[i + 1] = getbcache(p[i]->parent); j = i; prints("§Ú¦bþ?\n%-40.40s %.13s\n", p[j]->title + 7, p[j]->BM); diff --git a/mbbsd/board.c b/mbbsd/board.c index 743a8bb6..78bbd92b 100644 --- a/mbbsd/board.c +++ b/mbbsd/board.c @@ -1221,6 +1221,7 @@ root_board(void) { init_brdbuf(); class_bid = 1; +/* class_bid = 0; */ LIST_BRD(); choose_board(0); return 0; @@ -189,17 +189,13 @@ dogetch(void) do { len = tty_read(inbuf, IBUFSIZE); - /* len = 0: abort, < 1: read more */ + /* tty_read will handle abort_bbs. + * len <= 0: read more */ #ifdef CONVERT - if(len > 0) { + if(len > 0) len = input_wrapper(inbuf, len); - if(len == 0) len = -1; - } #endif - } while (len < 0); - - if (len == 0) - abort_bbs(0); + } while (len <= 0); ibufsize = len; icurrchar = 0; diff --git a/mbbsd/mbbsd.c b/mbbsd/mbbsd.c index 227e0f01..cc8afba3 100644 --- a/mbbsd/mbbsd.c +++ b/mbbsd/mbbsd.c @@ -1595,15 +1595,15 @@ telnet_init(void) /* tty_read * read from tty, process telnet commands if raw connection. - * return: >1 = length, -1 means read more, 0 = abort/EOF. + * return: >0 = length, <=0 means read more, abort/eof is automatically processed. */ ssize_t tty_read(unsigned char *buf, size_t max) { ssize_t l = read(0, buf, max); - if(l < 0 && !(errno == EINTR || errno == EAGAIN)) - return 0; /* 0 will abort BBS. */ + if(l == 0 || (l < 0 && !(errno == EINTR || errno == EAGAIN))) + abort_bbs(0); if(!raw_connection) return l; |