aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Slaven <bpk@hoopajoo.net>2005-04-05 06:06:10 (GMT)
committerSteve Slaven <bpk@hoopajoo.net>2005-04-05 06:06:10 (GMT)
commitae84e27d71229fcd2303cad3838bca4237377f9a (patch)
tree66946689a94916f82ddede1cff2d9f5f1ad916ea
parentb9ce293e642edb309005e32a50b8cdecd6ba82d0 (diff)
downloadpowwow-ae84e27d71229fcd2303cad3838bca4237377f9a.zip
powwow-ae84e27d71229fcd2303cad3838bca4237377f9a.tar.gz
powwow-ae84e27d71229fcd2303cad3838bca4237377f9a.tar.bz2
Added line-continuation support to the #ex command
-rw-r--r--cmd.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/cmd.c b/cmd.c
index b525e8f..5abd0fc 100644
--- a/cmd.c
+++ b/cmd.c
@@ -1301,7 +1301,8 @@ static void cmd_eval __P1 (char *,arg)
static void cmd_exe __P1 (char *,arg)
{
char kind;
- long start, end, i = 1;
+ char *clear;
+ long offset, start, end, i = 1;
FILE *fp;
ptr pbuf = (ptr)0;
@@ -1319,10 +1320,25 @@ static void cmd_exe __P1 (char *,arg)
ptrdel(pbuf);
return;
}
- while (!error && (!start || i<=end) && fgets(buf, BUFSIZE, fp))
- if (!start || i++>=start) {
- buf[strlen(buf)-1] = '\0';
- parse_user_input(buf, 0);
+ offset = 0;
+ /* We may go in to a loop if a single function is more than 4k, but if that's
+ * the case then maybe you should break it down a little bit :p */
+ 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) {
+ buf[strlen(buf)-1] = '\0';
+ parse_user_input(buf, 0);
+ offset = 0;
+ }
}
if (kind == '!') pclose(fp); else fclose(fp);