From 6199c829bbce98e87d7ca826be71753dbac410fc Mon Sep 17 00:00:00 2001 From: rob Date: Tue, 30 Aug 2022 19:21:52 +1000 Subject: [PATCH] "cause" of death (rather than "method") buffer size isue on levelup text fix pluralisation of single-word objects (eg "leaf") --- io.c | 2 +- lf.c | 2 +- text.c | 8 +++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/io.c b/io.c index 137d975..04282d5 100755 --- a/io.c +++ b/io.c @@ -15413,7 +15413,7 @@ void tombstone(lifeform_t *lf) { wattroff(mainwin, A_BOLD); wattron(mainwin, A_BOLD); mvwprintw(mainwin, y, 0, HISCOREFORMAT, "Pos", "Score", "Name", "Job"); - wprintw(mainwin, "Method of death"); y++; + wprintw(mainwin, "Cause of death"); y++; wmove(mainwin, y, 0); wattroff(mainwin, A_BOLD); diff --git a/lf.c b/lf.c index 303a0d7..9f19e88 100755 --- a/lf.c +++ b/lf.c @@ -5783,7 +5783,7 @@ void enhanceskills(lifeform_t *lf) { for (i = 0; i < nposs; i++) { char this[2]; - snprintf(this, 1, "%c", getattrletter(poss[i])); + snprintf(this, 2, "%c", getattrletter(poss[i])); if (isalpha(this[0])) { if (i == 0) { snprintf(ques, BUFLEN, "Increase your %s", getattrname(poss[i])); diff --git a/text.c b/text.c index 78d06b6..cca1999 100755 --- a/text.c +++ b/text.c @@ -2373,7 +2373,9 @@ char *makeplural(char **text) { len = strlen(*text); assert(len > 0); - newtext = strdup(*text); // make copy + //newtext = strdup(*text); // make copy + // make copy with trailing space + asprintf(&newtext, "%s ", *text); for (pl = firstplural ; pl ; pl = pl->next) { strrep(&newtext, pl->singular, pl->plural, &rv); @@ -2382,6 +2384,10 @@ char *makeplural(char **text) { break; } } + // now remove trailing space + if ( newtext[strlen(newtext)-1] == ' ') { + newtext[strlen(newtext)-1] = '\0'; + } if (!done) { // default