aboutsummaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/buffer.c b/buffer.c
index 93c7930..6ceaacf 100644
--- a/buffer.c
+++ b/buffer.c
@@ -424,6 +424,15 @@ string_null_terminate (char *str, int len, int capacity)
void
chomp (char *str)
{
+ rm_trailing_chars (str, "\r\n");
+}
+
+/*
+ * Remove trailing chars
+ */
+void
+rm_trailing_chars (char *str, const char *what_to_delete)
+{
bool modified;
do {
const int len = strlen (str);
@@ -431,7 +440,7 @@ chomp (char *str)
if (len > 0)
{
char *cp = str + (len - 1);
- if (*cp == '\n' || *cp == '\r')
+ if (strchr (what_to_delete, *cp) != NULL)
{
*cp = '\0';
modified = true;