summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwens <wens@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-07-05 22:52:26 +0800
committerwens <wens@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-07-05 22:52:26 +0800
commit1bbc108350cce991c081015da516ad230aa8fe58 (patch)
treeaed3172e26c0fb127c1ba3a143ecf48d5bc51e45
parent1347f95d83b908cd4e61904154feed6ae9ab7389 (diff)
downloadpttbbs-1bbc108350cce991c081015da516ad230aa8fe58.tar
pttbbs-1bbc108350cce991c081015da516ad230aa8fe58.tar.gz
pttbbs-1bbc108350cce991c081015da516ad230aa8fe58.tar.bz2
pttbbs-1bbc108350cce991c081015da516ad230aa8fe58.tar.lz
pttbbs-1bbc108350cce991c081015da516ad230aa8fe58.tar.xz
pttbbs-1bbc108350cce991c081015da516ad230aa8fe58.tar.zst
pttbbs-1bbc108350cce991c081015da516ad230aa8fe58.zip
Change Vector_search
fix namecomplete case error git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4385 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--common/sys/vector.c4
-rw-r--r--mbbsd/friend.c6
-rw-r--r--mbbsd/mail.c4
-rw-r--r--mbbsd/name.c7
4 files changed, 12 insertions, 9 deletions
diff --git a/common/sys/vector.c b/common/sys/vector.c
index fc99bdc8..af39b410 100644
--- a/common/sys/vector.c
+++ b/common/sys/vector.c
@@ -173,7 +173,7 @@ Vector_search(const struct Vector *self, const char *name)
int i;
for (i=0; i<self->length; i++)
if (strcasecmp(self->base + self->size * i, name) == 0)
- return 1;
- return 0;
+ return i;
+ return -1;
}
diff --git a/mbbsd/friend.c b/mbbsd/friend.c
index 2d210369..abb736c7 100644
--- a/mbbsd/friend.c
+++ b/mbbsd/friend.c
@@ -493,7 +493,7 @@ friend_edit(int type)
if (uident[0] == 'a') {
move(1, 0);
usercomplete(msg_uid, uident);
- if (uident[0] && searchuser(uident, uident) && !Vector_search(&namelist, uident)) {
+ if (uident[0] && searchuser(uident, uident) && Vector_search(&namelist, uident) < 0) {
friend_add(uident, type, NULL);
dirty = 1;
}
@@ -510,13 +510,13 @@ friend_edit(int type)
} else if (uident[0] == 'e' && count) {
move(1, 0);
namecomplete2(&namelist, msg_uid, uident);
- if (uident[0] && Vector_search(&namelist, uident)) {
+ if (uident[0] && Vector_search(&namelist, uident) >= 0) {
friend_editdesc(uident, type);
}
} else if (uident[0] == 'd' && count) {
move(1, 0);
namecomplete2(&namelist, msg_uid, uident);
- if (uident[0] && Vector_search(&namelist, uident)) {
+ if (uident[0] && Vector_search(&namelist, uident) >= 0) {
friend_delete(uident, type);
dirty = 1;
}
diff --git a/mbbsd/mail.c b/mbbsd/mail.c
index 8dc9ad30..019f4695 100644
--- a/mbbsd/mail.c
+++ b/mbbsd/mail.c
@@ -562,7 +562,7 @@ multi_list(struct Vector *namelist, int *recipient)
if (!searchuser(uid, uid))
outs(err_uid);
- else if (!Vector_search(namelist, uid)) {
+ else if (Vector_search(namelist, uid) < 0) {
Vector_add(namelist, uid);
(*recipient)++;
}
@@ -639,7 +639,7 @@ multi_send(char *title)
for (ptr = strtok_r(ptr, " \n\r", &strtok_pos);
ptr;
ptr = strtok_r(NULL, " \n\r", &strtok_pos)) {
- if (searchuser(ptr, ptr) && !Vector_search(&namelist, ptr) &&
+ if (searchuser(ptr, ptr) && Vector_search(&namelist, ptr) < 0 &&
strcmp(cuser.userid, ptr)) {
Vector_add(&namelist, ptr);
recipient++;
diff --git a/mbbsd/name.c b/mbbsd/name.c
index cae27f1b..131b4d67 100644
--- a/mbbsd/name.c
+++ b/mbbsd/name.c
@@ -15,7 +15,7 @@ ToggleVector(struct Vector *list, int *recipient, const char *listfile, const ch
if (space) *space = '\0';
if (!genbuf[0])
continue;
- if (!Vector_search(list, genbuf)) {
+ if (Vector_search(list, genbuf) < 0) {
Vector_add(list, genbuf);
(*recipient)++;
} else {
@@ -70,6 +70,7 @@ static int
nc_cb_peek(int key, VGET_RUNTIME *prt, void *instance)
{
struct namecomplete_int * nc_int = (struct namecomplete_int *) instance;
+ int tmp;
prt->buf[prt->iend] = 0;
@@ -83,7 +84,9 @@ nc_cb_peek(int key, VGET_RUNTIME *prt, void *instance)
case KEY_ENTER:
if (Vector_length(&nc_int->sublist) == 1)
strlcpy(prt->buf, Vector_get(&nc_int->sublist, 0), prt->len);
- else if (!Vector_search(&nc_int->sublist, prt->buf))
+ else if ((tmp = Vector_search(&nc_int->sublist, prt->buf)) >= 0)
+ strlcpy(prt->buf, Vector_get(&nc_int->sublist, tmp), prt->len);
+ else
prt->buf[0] = '\0';
prt->icurr = prt->iend = strlen(prt->buf);
break;