diff options
author | Steve Slaven <bpk@hoopajoo.net> | 2006-01-31 21:57:12 (GMT) |
---|---|---|
committer | Steve Slaven <bpk@hoopajoo.net> | 2006-01-31 21:57:12 (GMT) |
commit | 827b9fbbfdbe50060ff6cb8f49d75b7dafd972f3 (patch) | |
tree | ecb17cef065a5539c3cf1d35cb6354260a07c63c | |
parent | 1ed524b2b0f76d43e66c68835ea8c647a0a8beab (diff) | |
download | powwow-827b9fbbfdbe50060ff6cb8f49d75b7dafd972f3.zip powwow-827b9fbbfdbe50060ff6cb8f49d75b7dafd972f3.tar.gz powwow-827b9fbbfdbe50060ff6cb8f49d75b7dafd972f3.tar.bz2 |
Better handling of line continuation (Elestir)
-rw-r--r-- | cmd.c | 16 |
1 files changed, 7 insertions, 9 deletions
@@ -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; |