aboutsummaryrefslogtreecommitdiff
path: root/src/port/sprompt.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/port/sprompt.c')
-rw-r--r--src/port/sprompt.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/port/sprompt.c b/src/port/sprompt.c
index 146fb0004ef..02164d497a5 100644
--- a/src/port/sprompt.c
+++ b/src/port/sprompt.c
@@ -144,9 +144,11 @@ simple_prompt(const char *prompt, char *destination, size_t destlen, bool echo)
} while (buflen > 0 && buf[buflen - 1] != '\n');
}
- if (length > 0 && destination[length - 1] == '\n')
- /* remove trailing newline */
- destination[length - 1] = '\0';
+ /* strip trailing newline, including \r in case we're on Windows */
+ while (length > 0 &&
+ (destination[length - 1] == '\n' ||
+ destination[length - 1] == '\r'))
+ destination[--length] = '\0';
if (!echo)
{