forked from github/server
eliminate some more strlcat calls.
This commit is contained in:
parent
9f391039b5
commit
b297b4d43c
|
@ -124,7 +124,7 @@ const char *write_regionname(const region * r, const faction * f, char *buffer,
|
||||||
int nx = r->x, ny = r->y;
|
int nx = r->x, ny = r->y;
|
||||||
pnormalize(&nx, &ny, pl);
|
pnormalize(&nx, &ny, pl);
|
||||||
adjust_coordinates(f, &nx, &ny, pl);
|
adjust_coordinates(f, &nx, &ny, pl);
|
||||||
slprintf(buf, size, "%s (%d,%d)", rname(r, lang), nx, ny);
|
snprintf(buf, size, "%s (%d,%d)", rname(r, lang), nx, ny);
|
||||||
}
|
}
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
/* util includes */
|
/* util includes */
|
||||||
#include <util/attrib.h>
|
#include <util/attrib.h>
|
||||||
#include <util/base36.h>
|
#include <util/base36.h>
|
||||||
#include <util/bsdstring.h>
|
|
||||||
#include <util/event.h>
|
#include <util/event.h>
|
||||||
#include <util/language.h>
|
#include <util/language.h>
|
||||||
#include <util/lists.h>
|
#include <util/lists.h>
|
||||||
|
@ -217,7 +216,7 @@ ship *new_ship(const ship_type * stype, region * r, const struct locale *lang)
|
||||||
sname = parameters[P_SHIP];
|
sname = parameters[P_SHIP];
|
||||||
}
|
}
|
||||||
assert(sname);
|
assert(sname);
|
||||||
slprintf(buffer, sizeof(buffer), "%s %s", sname, itoa36(sh->no));
|
snprintf(buffer, sizeof(buffer), "%s %s", sname, itoa36(sh->no));
|
||||||
sh->name = strdup(buffer);
|
sh->name = strdup(buffer);
|
||||||
shash(sh);
|
shash(sh);
|
||||||
if (r) {
|
if (r) {
|
||||||
|
@ -283,7 +282,7 @@ void free_ships(void)
|
||||||
|
|
||||||
const char *write_shipname(const ship * sh, char *ibuf, size_t size)
|
const char *write_shipname(const ship * sh, char *ibuf, size_t size)
|
||||||
{
|
{
|
||||||
slprintf(ibuf, size, "%s (%s)", sh->name, itoa36(sh->no));
|
snprintf(ibuf, size, "%s (%s)", sh->name, itoa36(sh->no));
|
||||||
return ibuf;
|
return ibuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
/* util includes */
|
/* util includes */
|
||||||
#include <util/base36.h>
|
#include <util/base36.h>
|
||||||
#include <util/bsdstring.h>
|
|
||||||
#include <util/language.h>
|
#include <util/language.h>
|
||||||
|
|
||||||
/* libc includes */
|
/* libc includes */
|
||||||
|
@ -237,5 +236,5 @@ int default_score(const item_type *itype) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_score(char *buffer, size_t size, score_t score) {
|
void write_score(char *buffer, size_t size, score_t score) {
|
||||||
slprintf(buffer, size, "%lld", score);
|
snprintf(buffer, size, "%lld", score);
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ static double attack_chance; /* rules.monsters.attack_chance, or default 0.4 */
|
||||||
|
|
||||||
static void give_peasants(unit *u, const item_type *itype, int reduce) {
|
static void give_peasants(unit *u, const item_type *itype, int reduce) {
|
||||||
char buf[64];
|
char buf[64];
|
||||||
slprintf(buf, sizeof(buf), "%s 0 %d %s", LOC(u->faction->locale, keyword(K_GIVE)), reduce, LOC(u->faction->locale, itype->rtype->_name));
|
snprintf(buf, sizeof(buf), "%s 0 %d %s", LOC(u->faction->locale, keyword(K_GIVE)), reduce, LOC(u->faction->locale, itype->rtype->_name));
|
||||||
unit_addorder(u, parse_order(buf, u->faction->locale));
|
unit_addorder(u, parse_order(buf, u->faction->locale));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
23
src/names.c
23
src/names.c
|
@ -262,7 +262,7 @@ static void dragon_name(unit * u)
|
||||||
rnd = num_postfix / 6;
|
rnd = num_postfix / 6;
|
||||||
rnd = (rng_int() % rnd) + ter * rnd;
|
rnd = (rng_int() % rnd) + ter * rnd;
|
||||||
}
|
}
|
||||||
sprintf(zText, "dragon_postfix_%d", rnd);
|
snprintf(zText, sizeof(zText), "dragon_postfix_%d", rnd);
|
||||||
|
|
||||||
str = locale_getstring(default_locale, zText);
|
str = locale_getstring(default_locale, zText);
|
||||||
assert(str != NULL);
|
assert(str != NULL);
|
||||||
|
@ -271,28 +271,25 @@ static void dragon_name(unit * u)
|
||||||
const char *no_article = strchr((const char *)str, ' ');
|
const char *no_article = strchr((const char *)str, ' ');
|
||||||
assert(no_article);
|
assert(no_article);
|
||||||
/* TODO: localization */
|
/* TODO: localization */
|
||||||
sprintf(name, "Die %sn von %s", no_article + 1, rname(u->region,
|
snprintf(name, sizeof(name), "Die %sn von %s", no_article + 1, rname(u->region,
|
||||||
default_locale));
|
default_locale));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
char n[32];
|
char n[32];
|
||||||
size_t sz;
|
|
||||||
|
|
||||||
sz = strlcpy(n, silbe1[rng_int() % SIL1], sizeof(n));
|
snprintf(n, sizeof(n), "%s%s%s", silbe1[rng_int() % SIL1], silbe2[rng_int() % SIL1], silbe3[rng_int() % SIL1]);
|
||||||
sz += strlcat(n, silbe2[rng_int() % SIL2], sizeof(n));
|
|
||||||
sz += strlcat(n, silbe3[rng_int() % SIL3], sizeof(n));
|
|
||||||
if (rng_int() % 5 > 2) {
|
if (rng_int() % 5 > 2) {
|
||||||
sprintf(name, "%s, %s", n, str); /* "Name, der Titel" */
|
sprintf(name, "%s, %s", n, str); /* "Name, der Titel" */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sz = strlcpy(name, (const char *)str, sizeof(name)); /* "Der Titel Name" */
|
|
||||||
name[0] = (char)toupper(name[0]); /* TODO: UNICODE - should use towupper() */
|
|
||||||
sz += strlcat(name, " ", sizeof(name));
|
|
||||||
sz += strlcat(name, n, sizeof(name));
|
|
||||||
}
|
|
||||||
if (rng_int() % 3 == 0) {
|
if (rng_int() % 3 == 0) {
|
||||||
sz += strlcat(name, " von ", sizeof(name));
|
/* TODO: localization */
|
||||||
sz += strlcat(name, (const char *)rname(u->region, default_locale), sizeof(name));
|
snprintf(name, sizeof(name), "%s %s von %s", n, str, rname(u->region, default_locale));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
snprintf(name, sizeof(name), "%s %s", n, str);
|
||||||
|
}
|
||||||
|
name[0] = (char)toupper(name[0]); /* TODO: UNICODE - should use towupper() */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
/* util includes */
|
/* util includes */
|
||||||
#include <util/attrib.h>
|
#include <util/attrib.h>
|
||||||
#include <util/bsdstring.h>
|
|
||||||
#include <util/language.h>
|
#include <util/language.h>
|
||||||
#include <util/lists.h>
|
#include <util/lists.h>
|
||||||
#include <util/log.h>
|
#include <util/log.h>
|
||||||
|
@ -62,10 +61,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include <util/rng.h>
|
#include <util/rng.h>
|
||||||
|
|
||||||
/* libc includes */
|
/* libc includes */
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include <attributes/iceberg.h>
|
#include <attributes/iceberg.h>
|
||||||
|
@ -234,9 +233,9 @@ void find_manual(region * r, unit * u)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
slprintf(zLocation, sizeof(zLocation), "manual_location_%d",
|
snprintf(zLocation, sizeof(zLocation), "manual_location_%d",
|
||||||
(int)(rng_int() % 4));
|
(int)(rng_int() % 4));
|
||||||
slprintf(zBook, sizeof(zLocation), "manual_title_%s", skillnames[skill]);
|
snprintf(zBook, sizeof(zLocation), "manual_title_%s", skillnames[skill]);
|
||||||
|
|
||||||
msg = msg_message("find_manual", "unit location book", u, zLocation, zBook);
|
msg = msg_message("find_manual", "unit location book", u, zLocation, zBook);
|
||||||
if (msg) {
|
if (msg) {
|
||||||
|
|
|
@ -61,7 +61,6 @@
|
||||||
#include <util/assert.h>
|
#include <util/assert.h>
|
||||||
#include <util/attrib.h>
|
#include <util/attrib.h>
|
||||||
#include <util/base36.h>
|
#include <util/base36.h>
|
||||||
#include <util/bsdstring.h>
|
|
||||||
#include <util/event.h>
|
#include <util/event.h>
|
||||||
#include <util/gamedata.h>
|
#include <util/gamedata.h>
|
||||||
#include <util/language.h>
|
#include <util/language.h>
|
||||||
|
@ -4643,7 +4642,7 @@ int sp_clonecopy(castorder * co)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
slprintf(name, sizeof(name), (const char *)LOC(mage->faction->locale,
|
snprintf(name, sizeof(name), (const char *)LOC(mage->faction->locale,
|
||||||
"clone_of"), unitname(mage));
|
"clone_of"), unitname(mage));
|
||||||
clone =
|
clone =
|
||||||
create_unit(target_region, mage->faction, 1, get_race(RC_CLONE), 0, name,
|
create_unit(target_region, mage->faction, 1, get_race(RC_CLONE), 0, name,
|
||||||
|
|
Loading…
Reference in New Issue