diff --git a/execute.c b/execute.c index 805768a..b7b216a 100644 --- a/execute.c +++ b/execute.c @@ -14,6 +14,32 @@ int gasave = 256 ; /* global ASAVE size */ int gacount = 256 ; /* count until next ASAVE */ + +/* insert a # into the text here...we are in CMODE */ +static int inspound( void) { +/* if we are at the beginning of the line, no go */ + if( curwp->w_doto != 0) { + int i ; + + /* scan to see if all space before this is white space */ + for( i = curwp->w_doto - 1 ; i >= 0 ; i -= 1) { + int ch ; /* last character before input */ + + ch = lgetc( curwp->w_dotp, i) ; + if( ch != ' ' && ch != '\t') + break ; + } + + /* delete back first */ + if( i < 0) + while( getccol( FALSE) >= 1) + backdel( FALSE, 1) ; + } + +/* and insert the required pound */ + return linsert( 1, '#') ; +} + /* * This is the general command execution routine. It handles the fake binding * of all the keys to "self-insert". It also clears out the "thisflag" word, diff --git a/random.c b/random.c index 1f178d7..f1d3709 100644 --- a/random.c +++ b/random.c @@ -704,30 +704,6 @@ int insbrace(int n, int c) } #endif -int inspound(void) -{ /* insert a # into the text here...we are in CMODE */ - int ch; /* last character before input */ - int i; - - /* if we are at the beginning of the line, no go */ - if (curwp->w_doto == 0) - return linsert(1, '#'); - - /* scan to see if all space before this is white space */ - for (i = curwp->w_doto - 1; i >= 0; --i) { - ch = lgetc(curwp->w_dotp, i); - if (ch != ' ' && ch != '\t') - return linsert(1, '#'); - } - - /* delete back first */ - while (getccol(FALSE) >= 1) - backdel(FALSE, 1); - - /* and insert the required pound */ - return linsert(1, '#'); -} - /* * Delete blank lines around dot. What this command does depends if dot is * sitting on a blank line. If dot is sitting on a blank line, this command diff --git a/random.h b/random.h index a5e1899..85fa73a 100644 --- a/random.h +++ b/random.h @@ -30,7 +30,6 @@ int trim( int f, int n) ; int openline( int f, int n) ; int insert_newline( int f, int n) ; int insbrace( int n, int c) ; -int inspound( void) ; int deblank( int f, int n) ; int indent( int f, int n) ; int forwdel( int f, int n) ;