more sbstring conversions

This commit is contained in:
Enno Rehling 2018-11-30 10:26:49 +01:00 committed by Enno Rehling
parent 892b07c64c
commit 08cf00e700

View file

@ -1075,9 +1075,8 @@ static void report_region_edges(struct stream *out, const region * r, faction *
static void report_region_schemes(struct stream *out, const region * r, faction * f) { static void report_region_schemes(struct stream *out, const region * r, faction * f) {
char buf[4096]; char buf[4096];
char *bufp = buf; sbstring sbs;
size_t size = sizeof(buf); sbs_init(&sbs, buf, sizeof(buf));
int bytes;
if (r->seen.mode >= seen_unit && is_astral(r) && if (r->seen.mode >= seen_unit && is_astral(r) &&
!is_cursed(r->attribs, &ct_astralblock)) { !is_cursed(r->attribs, &ct_astralblock)) {
@ -1086,32 +1085,22 @@ static void report_region_schemes(struct stream *out, const region * r, faction
region_list *rl2; region_list *rl2;
if (rl) { if (rl) {
bufp = buf;
size = sizeof(buf) - 1;
/* this localization might not work for every language but is fine for de and en */ /* this localization might not work for every language but is fine for de and en */
bytes = (int)str_strlcpy(bufp, LOC(f->locale, "nr_schemes_prefix"), size); sbs_strcat(&sbs, LOC(f->locale, "nr_schemes_prefix"));
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
rl2 = rl; rl2 = rl;
while (rl2) { while (rl2) {
bytes = (int)f_regionid(rl2->data, f, bufp, size); char rbuf[REPORTWIDTH];
if (wrptr(&bufp, &size, bytes) != 0) f_regionid(rl2->data, f, rbuf, sizeof(rbuf));
WARN_STATIC_BUFFER(); sbs_strcat(&sbs, rbuf);
rl2 = rl2->next; rl2 = rl2->next;
if (rl2) { if (rl2) {
bytes = (int)str_strlcpy(bufp, ", ", size); sbs_strcat(&sbs, ", ");
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
} }
} }
bytes = (int)str_strlcpy(bufp, LOC(f->locale, "nr_schemes_postfix"), size); sbs_strcat(&sbs,LOC(f->locale, "nr_schemes_postfix"));
if (wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
free_regionlist(rl); free_regionlist(rl);
/* Schreibe Paragraphen */ /* Schreibe Paragraphen */
newline(out); newline(out);
*bufp = 0;
paragraph(out, buf, 0, 0, 0); paragraph(out, buf, 0, 0, 0);
} }
} }