From e9a94a29bd0bbaba1495713965817f27ea1d8df8 Mon Sep 17 00:00:00 2001
From: Dirk Zimoch <dirk.zimoch@psi.ch>
Date: Wed, 22 Feb 2017 10:37:26 +0100
Subject: [PATCH] remove all whitespace at end of line, including CR and NL

---
 runScript.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/runScript.c b/runScript.c
index fc273628..1fe840bd 100644
--- a/runScript.c
+++ b/runScript.c
@@ -267,7 +267,7 @@ int runScript(const char* filename, const char* args)
             if ((line_raw = realloc(line_raw, line_raw_size *= 2)) == NULL) goto error;
             if (fgets(line_raw + len, line_raw_size - len, file) == NULL) break;
         }
-        if (line_raw[len-1] == '\n') line_raw[--len] = 0; /* get rid of '\n' */
+        while (len > 0 && isspace((unsigned char)line_raw[len-1])) line_raw[--len] = 0; /* get rid of '\n' and friends */
         if (runScriptDebug)
                 printf("runScript raw line (%ld chars): '%s'\n", len, line_raw);
         /* expand and check the buffer size (different epics versions write different may number of bytes)*/
-- 
GitLab