summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-03-10 22:32:44 +0800
committerkcwu <kcwu@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2005-03-10 22:32:44 +0800
commitcfab1250f4ddabd40f721ce8b340c50ebbe52177 (patch)
tree0b37f1b4be3990f8eb9f914ac57d3e7975d4e48f /util
parent6f6b25f482cb780a0136b387b68d2926e069b3e3 (diff)
downloadpttbbs-cfab1250f4ddabd40f721ce8b340c50ebbe52177.tar
pttbbs-cfab1250f4ddabd40f721ce8b340c50ebbe52177.tar.gz
pttbbs-cfab1250f4ddabd40f721ce8b340c50ebbe52177.tar.bz2
pttbbs-cfab1250f4ddabd40f721ce8b340c50ebbe52177.tar.lz
pttbbs-cfab1250f4ddabd40f721ce8b340c50ebbe52177.tar.xz
pttbbs-cfab1250f4ddabd40f721ce8b340c50ebbe52177.tar.zst
pttbbs-cfab1250f4ddabd40f721ce8b340c50ebbe52177.zip
fix bad code
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@2589 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util')
-rw-r--r--util/chesscountry.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/util/chesscountry.c b/util/chesscountry.c
index b85fe86e..605efdf3 100644
--- a/util/chesscountry.c
+++ b/util/chesscountry.c
@@ -102,13 +102,14 @@ main(void)
fgets(kingdom_name, 256, fp);
fputs(kingdom_name, ftmp);
- kingdom_name[strlen(kingdom_name) - 1] = 0;
+ chomp(kingdom_name);
while (fgets(buf, sizeof(buf), fp))
{
i = 0;
strcpy(str, buf);
p = strtok(buf, " ");
- if (*p != '#' && searchuser(p))
+ name[0] = '\0';
+ if (p && *p != '#' && searchuser(p))
{
strlcpy(userid, p, sizeof(userid));
i = 1;
@@ -130,6 +131,7 @@ main(void)
}
if (!strcmp("除名", name))
{
+ // XXX if userid="../../......."
sethomefile(buf, userid, photo_fname);
unlink(buf);
continue;
@@ -178,7 +180,7 @@ main(void)
}
else
{
- other[strlen(other) - 1] = 0;
+ chomp(other);
fprintf(fp1, "<被誰俘虜> %s", other);
}
fprintf(fp1, "\n<自我說明> \n");
@@ -191,6 +193,8 @@ main(void)
fclose(fp);
fclose(ftmp);
rename(file2, file1);
+ } else {
+ fclose(ftmp);
}
}
return 0;