Skip to content

Commit

Permalink
Revise line primitives linstr() and lover()
Browse files Browse the repository at this point in the history
  • Loading branch information
rfivet committed Aug 22, 2021
1 parent 62e1109 commit a370d74
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 24 deletions.
36 changes: 15 additions & 21 deletions line.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ void lchange(int flag)
}
}

/*
* insert spaces forward into text

/* insert spaces forward into text
*
* int f, n; default flag and numeric argument
*/
Expand All @@ -278,23 +278,18 @@ BINDABLE( insspace) {
return TRUE ;
}

/*
* linstr -- Insert a string at the current point
*/

int linstr( char *instr) {
int status = TRUE ;

/* linstr -- Insert a string at the current point */
boolean linstr( char *instr) {
boolean status = TRUE ;
if( instr != NULL) {
unicode_t tmpc ;

while( (tmpc = *instr++ & 0xFF)) {
status = (tmpc == '\n') ? lnewline() : linsert_byte( 1, tmpc) ;
int c ;

/* Insertion error? */
if( status != TRUE) {
while( (c = (unsigned char) *instr++)) {
status = (c == '\n') ? lnewline() : linsert_byte( 1, c) ;
if( status != TRUE) { /* Insertion error? */
mloutstr( "%Out of memory while inserting") ;
return status ;
break ;
}
}
}
Expand Down Expand Up @@ -432,14 +427,13 @@ static boolean lowrite( int c) {


/* lover -- Overwrite a string at the current point */
int lover( char *ostr) {
int status = TRUE ;

boolean lover( char *ostr) {
boolean status = TRUE ;
if( ostr != NULL) {
char tmpc ;
int c ;

while( (tmpc = *ostr++)) {
status = (tmpc == '\n' ? lnewline() : lowrite( tmpc)) ;
while( (c = (unsigned char) *ostr++)) {
status = (c == '\n') ? lnewline() : lowrite( c) ;
if( status != TRUE) { /* Insertion error? */
mloutstr( "%Out of memory while overwriting") ;
break ;
Expand Down
4 changes: 2 additions & 2 deletions line.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ BBINDABLE( forwchar) ;

void lfree( line_p lp) ;
void lchange( int flag) ;
int linstr( char *instr) ;
boolean linstr( char *instr) ;
boolean linsert( int n, unicode_t c) ;
boolean linsert_byte( int n, int c) ;
int lover( char *ostr) ;
boolean lover( char *ostr) ;
boolean lnewline( void) ;
boolean ldelete( long n, boolean kflag) ;
boolean ldelchar( long n, boolean kflag) ;
Expand Down
2 changes: 1 addition & 1 deletion random.c
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,7 @@ static int adjustmode( int kind, int global) {
}


static int iovstring( int f, int n, const char *prompt, int (*fun)( char *)) {
static int iovstring( int f, int n, const char *prompt, boolean (*fun)( char *)) {
char *tstring ; /* string to add */

/* ask for string to insert */
Expand Down

0 comments on commit a370d74

Please sign in to comment.