summaryrefslogtreecommitdiffstats
path: root/mbbsd
diff options
context:
space:
mode:
authorptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2007-01-11 04:54:42 +0800
committerptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2007-01-11 04:54:42 +0800
commit3a682078f1139a4bf98bd6c45ebe7c4529c37fe1 (patch)
tree9d8bbf20dc6f505347ee4a1f396b3522b5539fd0 /mbbsd
parentc0ec6aa1cfa1ab6dc7db2453d68bb5b33c8d3644 (diff)
downloadpttbbs-3a682078f1139a4bf98bd6c45ebe7c4529c37fe1.tar
pttbbs-3a682078f1139a4bf98bd6c45ebe7c4529c37fe1.tar.gz
pttbbs-3a682078f1139a4bf98bd6c45ebe7c4529c37fe1.tar.bz2
pttbbs-3a682078f1139a4bf98bd6c45ebe7c4529c37fe1.tar.lz
pttbbs-3a682078f1139a4bf98bd6c45ebe7c4529c37fe1.tar.xz
pttbbs-3a682078f1139a4bf98bd6c45ebe7c4529c37fe1.tar.zst
pttbbs-3a682078f1139a4bf98bd6c45ebe7c4529c37fe1.zip
fix a bug on stamp file which does unnecessary memset sometimes.
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@3471 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd')
-rw-r--r--mbbsd/bbs.c9
-rw-r--r--mbbsd/record.c12
2 files changed, 14 insertions, 7 deletions
diff --git a/mbbsd/bbs.c b/mbbsd/bbs.c
index e984f30c..4dbae34b 100644
--- a/mbbsd/bbs.c
+++ b/mbbsd/bbs.c
@@ -512,7 +512,7 @@ cancelpost(const fileheader_t *fh, int by_BM, char *newpath)
memcpy(&postfile, fh, sizeof(fileheader_t));
setbpath(newpath, brd);
- stampfile(newpath, &postfile);
+ stampfile_u(newpath, &postfile);
nick[0] = '\0';
while (fgets(genbuf, sizeof(genbuf), fin)) {
@@ -760,7 +760,7 @@ static int
do_general(int isbid)
{
bid_t bidinfo;
- fileheader_t postfile, fh;
+ fileheader_t postfile;
char fpath[80], buf[80];
int aborted, defanony, ifuseanony, i;
char genbuf[200], *owner;
@@ -944,11 +944,10 @@ do_general(int isbid)
}
strcpy(genbuf, fpath);
setbpath(fpath, currboard);
- stampfile(fpath, &fh);
- strcpy(postfile.filename, fh.filename);
+ stampfile_u(fpath, &postfile);
// Ptt: stamp file again to make it order
// fix the bug that search failure in getindex
- //
+ // stampfile_u is used when you don't want to clear other fields
if (append_record(buf, &postfile, sizeof(postfile)) == -1)
{
unlink(genbuf);
diff --git a/mbbsd/record.c b/mbbsd/record.c
index 0015e7a4..7a2fc429 100644
--- a/mbbsd/record.c
+++ b/mbbsd/record.c
@@ -463,7 +463,9 @@ apply_record(const char *fpath, int (*fptr) (void *item, void *optarg), int size
/* mail / post 時,依據時間建立檔案,加上郵戳 */
int
-stampfile(char *fpath, fileheader_t * fh)
+stampfile_u(char *fpath, fileheader_t * fh)
+ // Ptt: stampfile_u: won't clear fileheader
+ // stampfile: will clear fileheader
{
register char *ip = fpath;
time4_t dtime = COMMON_TIME;
@@ -488,7 +490,6 @@ stampfile(char *fpath, fileheader_t * fh)
} while ((fp = open(fpath, O_CREAT | O_EXCL | O_WRONLY, 0644)) == -1);
close(fp);
#endif
- memset(fh, 0, sizeof(fileheader_t));
strlcpy(fh->filename, ip, sizeof(fh->filename));
ptime = localtime4(&dtime);
snprintf(fh->date, sizeof(fh->date),
@@ -496,6 +497,13 @@ stampfile(char *fpath, fileheader_t * fh)
return 0;
}
+inline int
+stampfile(char *fpath, fileheader_t * fh)
+{
+ memset(fh, 0, sizeof(fileheader_t));
+ return stampfile_u(fpath, fh);
+}
+
void
stampdir(char *fpath, fileheader_t * fh)
{