From 827b9fbbfdbe50060ff6cb8f49d75b7dafd972f3 Mon Sep 17 00:00:00 2001 From: Steve Slaven Date: Tue, 31 Jan 2006 21:57:12 +0000 Subject: Better handling of line continuation (Elestir) 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; -- cgit v0.10.2