From 37a0ca997d4e6fa7d798c2947f4e310d33149e6f Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 12 Apr 2024 13:57:03 -0400 Subject: [PATCH] Tweak y/n prompts --- ask.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/ask.c b/ask.c index b3cad99..fcde6fd 100644 --- a/ask.c +++ b/ask.c @@ -457,15 +457,21 @@ int main(int argc, char *argv[]) } if (yes) { - char *p2 = memcheck(calloc((prompt ? strlen(prompt) : 0)+5+1, sizeof(char))); - if (prompt) strcpy(p2, prompt); - strcat(p2, " [Y/n]"); - prompt = p2; + if (prompt) { + char *p2 = memcheck(calloc(strlen(prompt)+5+1, sizeof(char))); + sprintf(p2, "%s [Y/n]", prompt); + prompt = p2; + } else { + prompt = "[Y/n]"; + } } else if (no) { - char *p2 = memcheck(calloc((prompt ? strlen(prompt) : 0)+5+1, sizeof(char))); - if (prompt) strcpy(p2, prompt); - strcat(p2, " [y/N]"); - prompt = p2; + if (prompt) { + char *p2 = memcheck(calloc(strlen(prompt)+5+1, sizeof(char))); + sprintf(p2, "%s [y/N]", prompt); + prompt = p2; + } else { + prompt = "[y/N]"; + } } if (!prompt) prompt = "> ";