Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/psql/prompt.c')
-rw-r--r--src/bin/psql/prompt.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/bin/psql/prompt.c b/src/bin/psql/prompt.c
index 4514cf8551c..59afbc793a9 100644
--- a/src/bin/psql/prompt.c
+++ b/src/bin/psql/prompt.c
@@ -264,6 +264,7 @@ get_prompt(promptStatus_t status, ConditionalStack cstack)
FILE *fd;
char *file = pg_strdup(p + 1);
int cmdend;
+ int buflen;
cmdend = strcspn(file, "`");
file[cmdend] = '\0';
@@ -274,8 +275,10 @@ get_prompt(promptStatus_t status, ConditionalStack cstack)
buf[0] = '\0';
pclose(fd);
}
- if (strlen(buf) > 0 && buf[strlen(buf) - 1] == '\n')
- buf[strlen(buf) - 1] = '\0';
+ buflen = strlen(buf);
+ while (buflen > 0 && (buf[buflen - 1] == '\n' ||
+ buf[buflen - 1] == '\r'))
+ buf[--buflen] = '\0';
free(file);
p += cmdend + 1;
break;