Fixes for Visual C++

snprintf and strncasecmp are not that.
_access needs to be fixed on gcc, next.
This commit is contained in:
Enno Rehling 2014-03-15 12:35:20 -07:00
parent 4e8dd5f509
commit 9fc926864e
14 changed files with 90 additions and 81 deletions

View File

@ -7,8 +7,12 @@ INCLUDE (CheckIncludeFiles)
INCLUDE (CheckSymbolExists)
CHECK_INCLUDE_FILES (stdbool.h HAVE_STDBOOL_H)
CHECK_INCLUDE_FILES (windows.h HAVE_WINDOWS_H)
CHECK_INCLUDE_FILES (io.h HAVE_IO_H)
CHECK_INCLUDE_FILES (strings.h HAVE_STRINGS_H)
CHECK_INCLUDE_FILES (unistd.h HAVE_UNISTD_H)
IF (HAVE_IO_H)
CHECK_SYMBOL_EXISTS (_access "io.h" HAVE__ACCESS)
ENDIF (HAVE_IO_H)
IF (HAVE_WINDOWS_H)
CHECK_SYMBOL_EXISTS (_sleep "windows.h" HAVE__SLEEP)
ENDIF(HAVE_WINDOWS_H)

View File

@ -4,6 +4,7 @@
#cmakedefine HAVE_STDBOOL_H 1
#cmakedefine HAVE_STRINGS_H 1
#cmakedefine HAVE_WINDOWS_H 1
#cmakedefine HAVE_IO_H 1
#cmakedefine HAVE_UNISTD_H 1
#cmakedefine HAVE__BOOL 1
#cmakedefine HAVE_STRCASECMP 1

View File

@ -68,7 +68,7 @@ static int fix_familiars(struct lua_State *L)
free(mage->spellbook);
mage->spellbook = 0;
snprintf(buffer, sizeof(buffer), "%s_familiar", u_race(u)->_name[0]);
_snprintf(buffer, sizeof(buffer), "%s_familiar", u_race(u)->_name[0]);
eq = get_equipment(buffer);
if (eq) {
equip_unit_mask(u, eq, EQUIP_SPELLS);

View File

@ -107,7 +107,7 @@ static int tolua_storage_tostring(lua_State * L)
{
gamedata *data = (gamedata *)tolua_tousertype(L, 1, 0);
char name[64];
snprintf(name, sizeof(name), "<storage enc=%d ver=%d>", data->encoding,
_snprintf(name, sizeof(name), "<storage enc=%d ver=%d>", data->encoding,
data->version);
lua_pushstring(L, name);
return 1;

View File

@ -316,7 +316,7 @@ const curse_type *ct_find(const char *c)
return type;
} else {
size_t k = MIN(strlen(c), strlen(type->cname));
if (!strncasecmp(c, type->cname, k)) {
if (!_memicmp(c, type->cname, k)) {
return type;
}
}

View File

@ -526,7 +526,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char *buf,
if (a_otherfaction && alliedunit(u, f, HELP_FSTEALTH)) {
faction *f = get_otherfaction(a_otherfaction);
bytes =
snprintf(bufp, size, ", %s (%s)", factionname(f),
_snprintf(bufp, size, ", %s (%s)", factionname(f),
factionname(u->faction));
if (bytes < 0 || wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
@ -550,7 +550,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char *buf,
&& effskill(u, SK_STEALTH) >= 6) {
bytes = (int)strlcpy(bufp, "? ", size);
} else {
bytes = snprintf(bufp, size, "%d ", u->number);
bytes = _snprintf(bufp, size, "%d ", u->number);
}
if (bytes < 0 || wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
@ -687,7 +687,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char *buf,
WARN_STATIC_BUFFER();
if (!dh) {
bytes = snprintf(bufp, size, "%s: ", LOC(f->locale, "nr_inventory"));
bytes = _snprintf(bufp, size, "%s: ", LOC(f->locale, "nr_inventory"));
if (bytes < 0 || wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
dh = 1;
@ -695,7 +695,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char *buf,
if (in == 1) {
bytes = (int)strlcpy(bufp, ic, size);
} else {
bytes = snprintf(bufp, size, "%d %s", in, ic);
bytes = _snprintf(bufp, size, "%d %s", in, ic);
}
if (bytes < 0 || wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
@ -707,7 +707,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char *buf,
if (book) {
quicklist *ql = book->spells;
int qi, header, maxlevel = effskill(u, SK_MAGIC);
int bytes = snprintf(bufp, size, ". Aura %d/%d", get_spellpoints(u), max_spellpoints(u->region, u));
int bytes = _snprintf(bufp, size, ". Aura %d/%d", get_spellpoints(u), max_spellpoints(u->region, u));
if (bytes < 0 || wrptr(&bufp, &size, bytes) != 0) {
WARN_STATIC_BUFFER();
}
@ -716,7 +716,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char *buf,
spellbook_entry * sbe = (spellbook_entry *) ql_get(ql, qi);
if (sbe->level <= maxlevel) {
if (!header) {
bytes = snprintf(bufp, size, ", %s: ", LOC(f->locale, "nr_spells"));
bytes = _snprintf(bufp, size, ", %s: ", LOC(f->locale, "nr_spells"));
header = 1;
} else {
bytes = (int)strlcpy(bufp, ", ", size);
@ -737,7 +737,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char *buf,
}
if (i != MAXCOMBATSPELLS) {
bytes =
snprintf(bufp, size, ", %s: ", LOC(f->locale, "nr_combatspells"));
_snprintf(bufp, size, ", %s: ", LOC(f->locale, "nr_combatspells"));
if (bytes < 0 || wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
@ -762,7 +762,7 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char *buf,
}
if (sl > 0) {
bytes = snprintf(bufp, size, " (%d)", sl);
bytes = _snprintf(bufp, size, " (%d)", sl);
if (bytes < 0 || wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
}
@ -1870,7 +1870,7 @@ f_regionid(const region * r, const faction * f, char *buffer, size_t size)
pnormalize(&nx, &ny, pl);
adjust_coordinates(f, &nx, &ny, pl, r);
len = strlcpy(buffer, rname(r, f?f->locale:0), size);
snprintf(buffer + len, size-len, " (%d,%d%s%s)", nx, ny, named ? "," : "", (named) ? name : "");
_snprintf(buffer + len, size-len, " (%d,%d%s%s)", nx, ny, named ? "," : "", (named) ? name : "");
buffer[size-1] = 0;
len=strlen(buffer);
}
@ -2149,7 +2149,7 @@ static void eval_resources(struct opstack **stack, const void *userdata)
while (res != NULL && size > 4) {
const char *rname =
resourcename(res->type, (res->number != 1) ? NMF_PLURAL : 0);
int bytes = snprintf(bufp, size, "%d %s", res->number, LOC(lang, rname));
int bytes = _snprintf(bufp, size, "%d %s", res->number, LOC(lang, rname));
if (bytes < 0 || wrptr(&bufp, &size, bytes) != 0 || size < sizeof(buf) / 2) {
WARN_STATIC_BUFFER();
break;
@ -2214,7 +2214,7 @@ static void eval_trail(struct opstack **stack, const void *userdata)
variant var;
char *bufp = buf;
#ifdef _SECURECRT_ERRCODE_VALUES_DEFINED
/* stupid MS broke snprintf */
/* stupid MS broke _snprintf */
int eold = errno;
#endif
@ -2224,7 +2224,7 @@ static void eval_trail(struct opstack **stack, const void *userdata)
region *r = regions->regions[i];
const char *trail = trailinto(r, lang);
const char *rn = f_regionid_s(r, report);
int bytes = snprintf(bufp, size, trail, rn);
int bytes = _snprintf(bufp, size, trail, rn);
if (bytes < 0 || wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();

View File

@ -2568,28 +2568,28 @@ static bool display_race(faction * f, unit * u, const race * rc)
}
}
if (rc->battle_flags & BF_EQUIPMENT) {
bytes = snprintf(bufp, size, " %s", LOC(f->locale, "stat_equipment"));
bytes = _snprintf(bufp, size, " %s", LOC(f->locale, "stat_equipment"));
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
}
if (rc->battle_flags & BF_RES_PIERCE) {
bytes = snprintf(bufp, size, " %s", LOC(f->locale, "stat_pierce"));
bytes = _snprintf(bufp, size, " %s", LOC(f->locale, "stat_pierce"));
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
}
if (rc->battle_flags & BF_RES_CUT) {
bytes = snprintf(bufp, size, " %s", LOC(f->locale, "stat_cut"));
bytes = _snprintf(bufp, size, " %s", LOC(f->locale, "stat_cut"));
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
}
if (rc->battle_flags & BF_RES_BASH) {
bytes = snprintf(bufp, size, " %s", LOC(f->locale, "stat_bash"));
bytes = _snprintf(bufp, size, " %s", LOC(f->locale, "stat_bash"));
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
}
bytes =
snprintf(bufp, size, " %d %s", at_count, LOC(f->locale,
_snprintf(bufp, size, " %d %s", at_count, LOC(f->locale,
(at_count == 1) ? "stat_attack" : "stat_attacks"));
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
@ -2606,12 +2606,12 @@ static bool display_race(faction * f, unit * u, const race * rc)
switch (rc->attack[a].type) {
case AT_STANDARD:
bytes =
snprintf(bufp, size, "%s (%s)",
_snprintf(bufp, size, "%s (%s)",
LOC(f->locale, "attack_standard"), rc->def_damage);
break;
case AT_NATURAL:
bytes =
snprintf(bufp, size, "%s (%s)",
_snprintf(bufp, size, "%s (%s)",
LOC(f->locale, "attack_natural"), rc->attack[a].data.dice);
break;
case AT_SPELL:
@ -2619,11 +2619,11 @@ static bool display_race(faction * f, unit * u, const race * rc)
case AT_DRAIN_ST:
case AT_DRAIN_EXP:
case AT_DAZZLE:
bytes = snprintf(bufp, size, "%s", LOC(f->locale, "attack_magical"));
bytes = _snprintf(bufp, size, "%s", LOC(f->locale, "attack_magical"));
break;
case AT_STRUCTURAL:
bytes =
snprintf(bufp, size, "%s (%s)",
_snprintf(bufp, size, "%s (%s)",
LOC(f->locale, "attack_structural"), rc->attack[a].data.dice);
break;
default:

View File

@ -139,4 +139,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <strings.h>
#endif
#ifdef HAVE_IO_H
#include <io.h>
#endif
#endif

View File

@ -285,17 +285,17 @@ static void nr_spell(FILE * F, spellbook_entry * sbe, const struct locale *lang)
bufp = buf;
if (sp->sptyp & SPELLLEVEL) {
bytes =
snprintf(bufp, size, " %d %s", itemanz, LOC(lang, resourcename(rtype,
_snprintf(bufp, size, " %d %s", itemanz, LOC(lang, resourcename(rtype,
itemanz != 1)));
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
if (costtyp == SPC_LEVEL || costtyp == SPC_LINEAR) {
bytes = snprintf(bufp, size, " * %s", LOC(lang, "nr_level"));
bytes = _snprintf(bufp, size, " * %s", LOC(lang, "nr_level"));
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
}
} else {
bytes = snprintf(bufp, size, "%d %s", itemanz, LOC(lang, resourcename(rtype, itemanz != 1)));
bytes = _snprintf(bufp, size, "%d %s", itemanz, LOC(lang, resourcename(rtype, itemanz != 1)));
if (wrptr(&bufp, &size, bytes) != 0) {
WARN_STATIC_BUFFER();
}
@ -352,17 +352,17 @@ static void nr_spell(FILE * F, spellbook_entry * sbe, const struct locale *lang)
/* Reihenfolge beachten: Erst REGION, dann STUFE! */
if (sp->sptyp & FARCASTING) {
bytes = snprintf(bufp, size, " [%s x y]", LOC(lang, parameters[P_REGION]));
bytes = _snprintf(bufp, size, " [%s x y]", LOC(lang, parameters[P_REGION]));
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
}
if (sp->sptyp & SPELLLEVEL) {
bytes = snprintf(bufp, size, " [%s n]", LOC(lang, parameters[P_LEVEL]));
bytes = _snprintf(bufp, size, " [%s n]", LOC(lang, parameters[P_LEVEL]));
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
}
bytes = (int)snprintf(bufp, size, " \"%s\"", spell_name(sp, lang));
bytes = (int)_snprintf(bufp, size, " \"%s\"", spell_name(sp, lang));
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
@ -388,24 +388,24 @@ static void nr_spell(FILE * F, spellbook_entry * sbe, const struct locale *lang)
if (cp == 'u') {
targetp = targets + 1;
locp = LOC(lang, targetp->vars);
bytes = (int)snprintf(bufp, size, " <%s>", locp);
bytes = (int)_snprintf(bufp, size, " <%s>", locp);
if (*params == '+') {
++params;
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
bytes = (int)snprintf(bufp, size, " [<%s> ...]", locp);
bytes = (int)_snprintf(bufp, size, " [<%s> ...]", locp);
}
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
} else if (cp == 's') {
targetp = targets + 2;
locp = LOC(lang, targetp->vars);
bytes = (int)snprintf(bufp, size, " <%s>", locp);
bytes = (int)_snprintf(bufp, size, " <%s>", locp);
if (*params == '+') {
++params;
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
bytes = (int)snprintf(bufp, size, " [<%s> ...]", locp);
bytes = (int)_snprintf(bufp, size, " [<%s> ...]", locp);
}
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
@ -422,12 +422,12 @@ static void nr_spell(FILE * F, spellbook_entry * sbe, const struct locale *lang)
} else if (cp == 'b') {
targetp = targets + 3;
locp = LOC(lang, targetp->vars);
bytes = (int)snprintf(bufp, size, " <%s>", locp);
bytes = (int)_snprintf(bufp, size, " <%s>", locp);
if (*params == '+') {
++params;
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
bytes = (int)snprintf(bufp, size, " [<%s> ...]", locp);
bytes = (int)_snprintf(bufp, size, " [<%s> ...]", locp);
}
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
@ -456,17 +456,17 @@ static void nr_spell(FILE * F, spellbook_entry * sbe, const struct locale *lang)
if (targetp->param) {
locp = LOC(lang, targetp->vars);
bytes =
(int)snprintf(bufp, size, " %s <%s>", parameters[targetp->param],
(int)_snprintf(bufp, size, " %s <%s>", parameters[targetp->param],
locp);
if (*params == '+') {
++params;
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
bytes = (int)snprintf(bufp, size, " [<%s> ...]", locp);
bytes = (int)_snprintf(bufp, size, " [<%s> ...]", locp);
}
} else {
bytes =
(int)snprintf(bufp, size, " %s", parameters[targetp->param]);
(int)_snprintf(bufp, size, " %s", parameters[targetp->param]);
}
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
@ -490,7 +490,7 @@ static void nr_spell(FILE * F, spellbook_entry * sbe, const struct locale *lang)
locp = LOC(lang, mkname("spellpar", substr));
syntaxp = substr + 1;
}
bytes = (int)snprintf(bufp, size, " <%s>", locp);
bytes = (int)_snprintf(bufp, size, " <%s>", locp);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
}
@ -939,11 +939,11 @@ static void describe(FILE * F, const seen_region * sr, faction * f)
WARN_STATIC_BUFFER();
if (sr->mode == see_travel) {
bytes = snprintf(bufp, size, " (%s)", LOC(f->locale, "see_travel"));
bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "see_travel"));
} else if (sr->mode == see_neighbour) {
bytes = snprintf(bufp, size, " (%s)", LOC(f->locale, "see_neighbour"));
bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "see_neighbour"));
} else if (sr->mode == see_lighthouse) {
bytes = snprintf(bufp, size, " (%s)", LOC(f->locale, "see_lighthouse"));
bytes = _snprintf(bufp, size, " (%s)", LOC(f->locale, "see_lighthouse"));
} else {
bytes = 0;
}
@ -965,7 +965,7 @@ static void describe(FILE * F, const seen_region * sr, faction * f)
saplings = rtrees(r, 1);
if (production(r)) {
if (trees > 0 || saplings > 0) {
bytes = snprintf(bufp, size, ", %d/%d ", trees, saplings);
bytes = _snprintf(bufp, size, ", %d/%d ", trees, saplings);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
@ -992,7 +992,7 @@ static void describe(FILE * F, const seen_region * sr, faction * f)
for (n = 0; n < numresults; ++n) {
if (result[n].number >= 0 && result[n].level >= 0) {
bytes = snprintf(bufp, size, ", %d %s/%d", result[n].number,
bytes = _snprintf(bufp, size, ", %d %s/%d", result[n].number,
LOC(f->locale, result[n].name), result[n].level);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
@ -1003,14 +1003,14 @@ static void describe(FILE * F, const seen_region * sr, faction * f)
/* peasants & silver */
if (rpeasants(r)) {
int n = rpeasants(r);
bytes = snprintf(bufp, size, ", %d", n);
bytes = _snprintf(bufp, size, ", %d", n);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
if (r->land->ownership) {
const char *str =
locale_string(f->locale, mkname("morale", itoa10(r->land->morale)));
bytes = snprintf(bufp, size, " %s", str);
bytes = _snprintf(bufp, size, " %s", str);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
}
@ -1039,7 +1039,7 @@ static void describe(FILE * F, const seen_region * sr, faction * f)
}
}
if (rmoney(r) && sr->mode >= see_travel) {
bytes = snprintf(bufp, size, ", %d ", rmoney(r));
bytes = _snprintf(bufp, size, ", %d ", rmoney(r));
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
bytes =
@ -1051,7 +1051,7 @@ static void describe(FILE * F, const seen_region * sr, faction * f)
/* Pferde */
if (rhorses(r)) {
bytes = snprintf(bufp, size, ", %d ", rhorses(r));
bytes = _snprintf(bufp, size, ", %d ", rhorses(r));
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
bytes =
@ -1083,7 +1083,7 @@ static void describe(FILE * F, const seen_region * sr, faction * f)
if (rule_region_owners()) {
const faction *owner = region_get_owner(r);
if (owner != NULL) {
bytes = snprintf(bufp, size, " Die Region ist im Besitz von %s.",
bytes = _snprintf(bufp, size, " Die Region ist im Besitz von %s.",
factionname(owner));
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
@ -1134,7 +1134,7 @@ static void describe(FILE * F, const seen_region * sr, faction * f)
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
f_regionid(r2, f, regname, sizeof(regname));
bytes = snprintf(bufp, size, trailinto(r2, f->locale), regname);
bytes = _snprintf(bufp, size, trailinto(r2, f->locale), regname);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
} else {
@ -1431,9 +1431,9 @@ static void durchreisende(FILE * F, const region * r, const faction * f)
}
/* TODO: finish localization */
if (maxtravel == 1) {
bytes = snprintf(bufp, size, " %s", LOC(f->locale, "has_moved_one"));
bytes = _snprintf(bufp, size, " %s", LOC(f->locale, "has_moved_one"));
} else {
bytes = snprintf(bufp, size, " %s", LOC(f->locale, "has_moved_many"));
bytes = _snprintf(bufp, size, " %s", LOC(f->locale, "has_moved_many"));
}
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
@ -1552,7 +1552,7 @@ report_template(const char *filename, report_context * ctx, const char *charset)
bufp = buf;
size = sizeof(buf) - 1;
bytes = snprintf(bufp, size, "%s %s; %s [%d,%d$",
bytes = _snprintf(bufp, size, "%s %s; %s [%d,%d$",
LOC(u->faction->locale, parameters[P_UNIT]),
unitid(u), u->name, u->number, get_money(u));
if (wrptr(&bufp, &size, bytes) != 0)
@ -1726,9 +1726,9 @@ static void allies(FILE * F, const faction * f)
int bytes;
size_t size = sizeof(buf);
if (!f->allies->next) {
bytes = snprintf(buf, size, "%s ", LOC(f->locale, "faction_help_one"));
bytes = _snprintf(buf, size, "%s ", LOC(f->locale, "faction_help_one"));
} else {
bytes = snprintf(buf, size, "%s ", LOC(f->locale, "faction_help_many"));
bytes = _snprintf(buf, size, "%s ", LOC(f->locale, "faction_help_many"));
}
size -= bytes;
show_allies(f, f->allies, buf + bytes, size);
@ -1741,9 +1741,9 @@ static void allies(FILE * F, const faction * f)
int bytes;
size_t size = sizeof(buf);
if (!g->allies->next) {
bytes = snprintf(buf, size, "%s %s ", g->name, LOC(f->locale, "group_help_one"));
bytes = _snprintf(buf, size, "%s %s ", g->name, LOC(f->locale, "group_help_one"));
} else {
bytes = snprintf(buf, size, "%s %s ", g->name, LOC(f->locale, "group_help_many"));
bytes = _snprintf(buf, size, "%s %s ", g->name, LOC(f->locale, "group_help_many"));
}
size -= bytes;
show_allies(f, g->allies, buf + bytes, size);
@ -1886,11 +1886,11 @@ nr_ship(FILE * F, const seen_region * sr, const ship * sh, const faction * f,
getshipweight(sh, &n, &p);
n = (n + 99) / 100; /* 1 Silber = 1 GE */
bytes = snprintf(bufp, size, "%s, %s, (%d/%d)", shipname(sh),
bytes = _snprintf(bufp, size, "%s, %s, (%d/%d)", shipname(sh),
LOC(f->locale, sh->type->name[0]), n, shipcapacity(sh) / 100);
} else {
bytes =
snprintf(bufp, size, "%s, %s", shipname(sh), LOC(f->locale,
_snprintf(bufp, size, "%s, %s", shipname(sh), LOC(f->locale,
sh->type->name[0]));
}
if (wrptr(&bufp, &size, bytes) != 0)
@ -1898,7 +1898,7 @@ nr_ship(FILE * F, const seen_region * sr, const ship * sh, const faction * f,
assert(sh->type->construction->improvement == NULL); /* sonst ist construction::size nicht ship_type::maxsize */
if (sh->size != sh->type->construction->maxsize) {
bytes = snprintf(bufp, size, ", %s (%d/%d)",
bytes = _snprintf(bufp, size, ", %s (%d/%d)",
LOC(f->locale, "nr_undercons"), sh->size,
sh->type->construction->maxsize);
if (wrptr(&bufp, &size, bytes) != 0)
@ -1908,7 +1908,7 @@ nr_ship(FILE * F, const seen_region * sr, const ship * sh, const faction * f,
int percent =
(sh->damage * 100 + DAMAGE_SCALE - 1) / (sh->size * DAMAGE_SCALE);
bytes =
snprintf(bufp, size, ", %d%% %s", percent, LOC(f->locale, "nr_damaged"));
_snprintf(bufp, size, ", %d%% %s", percent, LOC(f->locale, "nr_damaged"));
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
}
@ -1959,7 +1959,7 @@ nr_building(FILE * F, const seen_region * sr, const building * b,
lang = f->locale;
bytes =
snprintf(bufp, size, "%s, %s %d, ", buildingname(b), LOC(f->locale,
_snprintf(bufp, size, "%s, %s %d, ", buildingname(b), LOC(f->locale,
"nr_size"), b->size);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
@ -1974,7 +1974,7 @@ nr_building(FILE * F, const seen_region * sr, const building * b,
if (owner && owner->faction == f) {
/* illusion. report real type */
name = LOC(lang, bname);
bytes = snprintf(bufp, size, " (%s)", name);
bytes = _snprintf(bufp, size, " (%s)", name);
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
}
@ -2264,7 +2264,7 @@ report_plaintext(const char *filename, report_context * ctx,
bufp = buf;
size = sizeof(buf) - 1;
bytes = snprintf(buf, size, "%s:", LOC(f->locale, "nr_options"));
bytes = _snprintf(buf, size, "%s:", LOC(f->locale, "nr_options"));
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
for (op = 0; op != MAXOPTIONS; op++) {
@ -2315,14 +2315,14 @@ report_plaintext(const char *filename, report_context * ctx,
rnl(F);
centre(F, LOC(f->locale, pname), true);
snprintf(buf, sizeof(buf), "%s %d", LOC(f->locale, "nr_level"),
_snprintf(buf, sizeof(buf), "%s %d", LOC(f->locale, "nr_level"),
ptype->level);
centre(F, buf, true);
rnl(F);
bufp = buf;
size = sizeof(buf) - 1;
bytes = snprintf(bufp, size, "%s: ", LOC(f->locale, "nr_herbsrequired"));
bytes = _snprintf(bufp, size, "%s: ", LOC(f->locale, "nr_herbsrequired"));
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();

View File

@ -4671,7 +4671,7 @@ int sp_clonecopy(castorder * co)
return 0;
}
snprintf(name, sizeof(name), (const char *)LOC(mage->faction->locale,
_snprintf(name, sizeof(name), (const char *)LOC(mage->faction->locale,
"clone_of"), unitname(mage));
clone =
create_unit(target_region, mage->faction, 1, new_race[RC_CLONE], 0, name,

View File

@ -9,7 +9,7 @@
int wrptr(char **ptr, size_t * size, int bytes)
{
assert(bytes >= 0 || !"you're not using snprintf right, maybe?");
assert(bytes >= 0 || !"you're not using _snprintf right, maybe?");
if (bytes == 0) {
return 0;

View File

@ -75,17 +75,17 @@ cp_convert(const char *format, char *buffer, size_t length, int codepage)
void log_rotate(const char *filename, int maxindex)
{
int n;
if (access(filename, R_OK)==0) {
if (_access(filename, _A_RDONLY)==0) {
char buffer[2][MAX_PATH];
int src = 1;
assert(strlen(filename)<sizeof(buffer[0])-4);
for(n=0;n<maxindex;++n) {
sprintf(buffer[0], "%s.%d", filename, n);
if (access(filename, R_OK)!=0) {
if (_access(filename, _A_RDONLY)!=0) {
break;
}
}
if (access(buffer[0], R_OK)==0) {
if (_access(buffer[0], _A_RDONLY)==0) {
unlink(buffer[0]);
}
while(n--) {

View File

@ -28,7 +28,7 @@
const xmlChar *xml_i(double number)
{
static char buffer[128];
snprintf(buffer, sizeof(buffer), "%.0f", number);
_snprintf(buffer, sizeof(buffer), "%.0f", number);
return (const xmlChar *)buffer;
}

View File

@ -102,49 +102,49 @@ xml_link(report_context * ctx, const xmlChar * rel, const xmlChar * ref)
static const xmlChar *xml_ref_unit(const unit * u)
{
static char idbuf[20];
snprintf(idbuf, sizeof(idbuf), "unit_%d", u->no);
_snprintf(idbuf, sizeof(idbuf), "unit_%d", u->no);
return (const xmlChar *)idbuf;
}
static const xmlChar *xml_ref_faction(const faction * f)
{
static char idbuf[20];
snprintf(idbuf, sizeof(idbuf), "fctn_%d", f->no);
_snprintf(idbuf, sizeof(idbuf), "fctn_%d", f->no);
return (const xmlChar *)idbuf;
}
static const xmlChar *xml_ref_group(const group * g)
{
static char idbuf[20];
snprintf(idbuf, sizeof(idbuf), "grp_%d", g->gid);
_snprintf(idbuf, sizeof(idbuf), "grp_%d", g->gid);
return (const xmlChar *)idbuf;
}
static const xmlChar *xml_ref_prefix(const char *str)
{
static char idbuf[20];
snprintf(idbuf, sizeof(idbuf), "pref_%s", str);
_snprintf(idbuf, sizeof(idbuf), "pref_%s", str);
return (const xmlChar *)idbuf;
}
static const xmlChar *xml_ref_building(const building * b)
{
static char idbuf[20];
snprintf(idbuf, sizeof(idbuf), "bldg_%d", b->no);
_snprintf(idbuf, sizeof(idbuf), "bldg_%d", b->no);
return (const xmlChar *)idbuf;
}
static const xmlChar *xml_ref_ship(const ship * sh)
{
static char idbuf[20];
snprintf(idbuf, sizeof(idbuf), "shp_%d", sh->no);
_snprintf(idbuf, sizeof(idbuf), "shp_%d", sh->no);
return (const xmlChar *)idbuf;
}
static const xmlChar *xml_ref_region(const region * r)
{
static char idbuf[20];
snprintf(idbuf, sizeof(idbuf), "rgn_%d", r->uid);
_snprintf(idbuf, sizeof(idbuf), "rgn_%d", r->uid);
return (const xmlChar *)idbuf;
}
@ -736,7 +736,7 @@ static xmlNodePtr report_root(report_context * ctx)
node = xmlAddChild(xmlReport, xmlNewNode(xct->ns_atl, BAD_CAST "server"));
if (mailto) {
snprintf(zText, sizeof(zText), "mailto:%s?subject=%s", mailto, mailcmd);
_snprintf(zText, sizeof(zText), "mailto:%s?subject=%s", mailto, mailcmd);
child = xmlAddChild(node, xmlNewNode(xct->ns_atl, BAD_CAST "delivery"));
xmlNewNsProp(child, xct->ns_atl, BAD_CAST "method", BAD_CAST "mail");
xmlNewNsProp(child, xct->ns_atl, BAD_CAST "href", BAD_CAST zText);