aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmd.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/cmd.c b/cmd.c
index 7edb507..678d626 100644
--- a/cmd.c
+++ b/cmd.c
@@ -1336,15 +1336,13 @@ static void cmd_exe __P1 (char *,arg)
while (!error && (!start || i<=end) && fgets(buf + offset, BUFSIZE - offset, fp))
/* If it ends with \\\n then it's a line continuation, so clear
* the \\\n and do another fgets */
- if( buf[ strlen( buf ) - 2 ] == '\\' ) {
- /* Clear all \n prefixed with a literal backslash '\\' */
- while( clear = strstr( buf, "\\\n" ) ) {
- clear[ 0 ] = ' ';
- clear[ 1 ] = ' ';
- }
- offset = strlen( buf );
- }else{
- if (!start || i++>=start) {
+ if (buf[offset + strlen(buf + offset) - 2] == '\\') {
+ /* Clear \n prefixed with a literal backslash '\\' */
+ if (clear = strstr(buf + offset, "\\\n"))
+ *clear = '\0';
+ offset += strlen(buf + offset);
+ } else {
+ if (!start || i++ >= start) {
buf[strlen(buf)-1] = '\0';
parse_user_input(buf, 0);
offset = 0;