(rea, turn): Use a different buffer for message text. Just for

clarity.
This commit is contained in:
Markus Armbruster 2005-06-12 10:11:04 +00:00
parent ff27a2644f
commit cb454a1f56
2 changed files with 11 additions and 9 deletions

View file

@ -63,7 +63,8 @@ rea(void)
int teles;
int size;
unsigned int nbytes;
s_char buf[4096]; /* buf is message text */
char buf[1024];
char msgbuf[4096]; /* message text */
int lasttype;
int lastcnum;
time_t lastdate;
@ -163,12 +164,12 @@ rea(void)
skip:
while (tgm.tel_length > 0) {
nbytes = tgm.tel_length;
if (nbytes > sizeof(buf) - 1)
nbytes = sizeof(buf) - 1;
(void)fread(buf, sizeof(s_char), nbytes, telfp);
buf[nbytes] = 0;
if (nbytes > sizeof(msgbuf) - 1)
nbytes = sizeof(msgbuf) - 1;
(void)fread(msgbuf, sizeof(s_char), nbytes, telfp);
msgbuf[nbytes] = 0;
if (readit)
uprnf(buf);
uprnf(msgbuf);
tgm.tel_length -= nbytes;
}
}

View file

@ -49,7 +49,8 @@ turn(void)
FILE *fptr;
struct telstr tgm;
char *p;
char buf[MAXTELSIZE + 1];
char buf[1024];
char msgbuf[MAXTELSIZE + 1]; /* message text */
char *msgfilepath;
p = getstarg(player->argp[1], "on, off or motd? ", buf);
@ -75,7 +76,7 @@ turn(void)
pr("Enter a new message of the day.\n");
time(&tgm.tel_date);
tgm.tel_length = getele("The World", buf);
tgm.tel_length = getele("The World", msgbuf);
if (tgm.tel_length < 0) {
pr("Ignored\n");
@ -106,7 +107,7 @@ turn(void)
pr("Logins disabled.\n");
if ((fwrite(&tgm, sizeof(tgm), 1, fptr) != 1) ||
(fwrite(buf, tgm.tel_length, 1, fptr) != 1)) {
(fwrite(msgbuf, tgm.tel_length, 1, fptr) != 1)) {
fclose(fptr);
pr("Something went wrong writing the message file.\n");
logerror("Could not properly write message file (%s).\n",