diff options
Diffstat (limited to 'mbbsd/mail.c')
-rw-r--r-- | mbbsd/mail.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/mbbsd/mail.c b/mbbsd/mail.c index 9f731530..2cc3e886 100644 --- a/mbbsd/mail.c +++ b/mbbsd/mail.c @@ -535,14 +535,17 @@ multi_send(char *title) break; } else { if (listing) { - strtok(ptr = genbuf + 3, " \n\r"); - do { + char *strtok_pos; + ptr = genbuf + 3; + for (ptr = strtok_r(ptr, " \n\r", &strtok_pos); + ptr; + ptr = strtok_r(NULL, " \n\r", &strtok_pos)) { if (searchuser(ptr, ptr) && !InNameList(ptr) && strcmp(cuser.userid, ptr)) { AddNameList(ptr); reciper++; } - } while ((ptr = (char *)strtok(NULL, " \n\r"))); + } } else if (!strncmp(genbuf + 3, "[通告]", 6)) listing = 1; } @@ -1121,7 +1124,6 @@ int mail_reply(int ent, fileheader_t * fhdr, const char *direct) { char uid[STRLEN]; - char *t; FILE *fp; char genbuf[512]; int oent = ent; @@ -1137,14 +1139,17 @@ mail_reply(int ent, fileheader_t * fhdr, const char *direct) /* find the author */ strlcpy(quote_user, fhdr->owner, sizeof(quote_user)); if (strchr(quote_user, '.')) { + char *t; + char *strtok_pos; genbuf[0] = '\0'; if ((fp = fopen(quote_file, "r"))) { fgets(genbuf, sizeof(genbuf), fp); fclose(fp); } - t = strtok(genbuf, str_space); - if (t && (!strcmp(t, str_author1) || !strcmp(t, str_author2))) - strlcpy(uid, strtok(NULL, str_space), sizeof(uid)); // XXX if strtok return NULL + t = strtok_r(genbuf, str_space, &strtok_pos); + if (t && (strcmp(t, str_author1)==0 || strcmp(t, str_author2)==0) + && (t=strtok_r(NULL, str_space, &strtok_pos)) != NULL) + strlcpy(uid, t, sizeof(uid)); else { vmsg("錯誤: 找不到作者。"); quote_user[0]='\0'; |