aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Slaven <bpk@hoopajoo.net>2006-01-31 21:57:12 (GMT)
committerSteve Slaven <bpk@hoopajoo.net>2006-01-31 21:57:12 (GMT)
commit827b9fbbfdbe50060ff6cb8f49d75b7dafd972f3 (patch)
treeecb17cef065a5539c3cf1d35cb6354260a07c63c
parent1ed524b2b0f76d43e66c68835ea8c647a0a8beab (diff)
downloadpowwow-827b9fbbfdbe50060ff6cb8f49d75b7dafd972f3.zip
powwow-827b9fbbfdbe50060ff6cb8f49d75b7dafd972f3.tar.gz
powwow-827b9fbbfdbe50060ff6cb8f49d75b7dafd972f3.tar.bz2
Better handling of line continuation (Elestir)
-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;