bugs found with gcc

This commit is contained in:
Enno Rehling 2007-06-27 20:51:56 +00:00
parent 857df3f300
commit 13a019335e
3 changed files with 11 additions and 9 deletions

View File

@ -3284,9 +3284,9 @@ simplename(region * r)
{ {
int i; int i;
static char name[17]; static char name[17];
const char * cp = rname(r, NULL); const xmlChar * cp = rname(r, NULL);
for (i=0;*cp && i!=16;++i, ++cp) { for (i=0;*cp && i!=16;++i, ++cp) {
int c = *(unsigned char*)cp; int c = *cp;
while (c && !isalpha(c) && !isspace(c)) { while (c && !isalpha(c) && !isspace(c)) {
++cp; ++cp;
c = *(unsigned char*)cp; c = *(unsigned char*)cp;

View File

@ -106,6 +106,7 @@ addfaction(const char *email, const xmlChar * password,
{ {
faction * f = calloc(sizeof(faction), 1); faction * f = calloc(sizeof(faction), 1);
const char * pass = itoa36(rng_int()); const char * pass = itoa36(rng_int());
char buf[128];
assert(frace && frace != new_race[RC_ORC]); assert(frace && frace != new_race[RC_ORC]);
@ -135,7 +136,7 @@ addfaction(const char *email, const xmlChar * password,
addlist(&factions, f); addlist(&factions, f);
fhash(f); fhash(f);
sprintf(buf, "%s %s", LOC(loc, "factiondefault"), factionid(f)); snprintf(buf, sizeof(buf), "%s %s", LOC(loc, "factiondefault"), factionid(f));
set_string(&f->name, (const xmlChar*)buf); set_string(&f->name, (const xmlChar*)buf);
return f; return f;

View File

@ -45,6 +45,7 @@
/* util includes */ /* util includes */
#include <util/attrib.h> #include <util/attrib.h>
#include <util/bsdstring.h>
#include <util/functions.h> #include <util/functions.h>
#include <util/rng.h> #include <util/rng.h>
@ -290,12 +291,12 @@ racename(const struct locale *loc, const unit *u, const race * rc)
const char * prefix = raceprefix(u); const char * prefix = raceprefix(u);
if (prefix!=NULL) { if (prefix!=NULL) {
static char lbuf[80]; static xmlChar lbuf[80];
char * s = lbuf; xmlChar * s = lbuf;
strcpy(lbuf, locale_string(loc, mkname("prefix", prefix))); s += xstrlcpy(lbuf, LOC(loc, mkname("prefix", prefix)), sizeof(lbuf));
s += strlen(lbuf); xstrlcpy(s, LOC(loc, rc_name(rc, u->number != 1)), sizeof(lbuf)-(s-lbuf));
strcpy(s, LOC(loc, rc_name(rc, u->number != 1))); assert(s[0]<=0x7F || !"unicode/not implemented");
s[0] = (char)tolower(s[0]); s[0] = (xmlChar)tolower(s[0]);
return lbuf; return lbuf;
} }
return LOC(loc, rc_name(rc, u->number != 1)); return LOC(loc, rc_name(rc, u->number != 1));