Transpose-characters valid with mixed UTF-8 and extended ASCII.

This commit is contained in:
Renaud 2016-05-21 07:52:19 +08:00
parent f11dea468f
commit 14e6240b9c
3 changed files with 19 additions and 11 deletions

7
line.c
View File

@ -277,8 +277,6 @@ int insspace(int f, int n)
return TRUE; return TRUE;
} }
static int linsert_byte( int n, int c) ;
/* /*
* linstr -- Insert a string at the current point * linstr -- Insert a string at the current point
*/ */
@ -291,7 +289,7 @@ int linstr( char *instr) {
while( (tmpc = *instr++ & 0xFF)) { while( (tmpc = *instr++ & 0xFF)) {
status = status =
(tmpc == '\n' ? lnewline() : linsert_byte( 1, tmpc)) ; (tmpc == '\n' ? lnewline() : (int) linsert_byte( 1, tmpc)) ;
/* Insertion error? */ /* Insertion error? */
if( status != TRUE) { if( status != TRUE) {
@ -314,8 +312,7 @@ int linstr( char *instr) {
* well, and FALSE on errors. * well, and FALSE on errors.
*/ */
static int linsert_byte(int n, int c) boolean linsert_byte( int n, int c) {
{
char *cp1; char *cp1;
char *cp2; char *cp2;
struct line *lp1; struct line *lp1;

1
line.h
View File

@ -38,6 +38,7 @@ void lchange( int flag) ;
int insspace( int f, int n) ; int insspace( int f, int n) ;
int linstr( char *instr) ; int linstr( char *instr) ;
int linsert( int n, unicode_t c) ; int linsert( int n, unicode_t c) ;
boolean linsert_byte( int n, int c) ;
int lover( char *ostr) ; int lover( char *ostr) ;
int lnewline( void) ; int lnewline( void) ;
boolean ldelete( long n, boolean kflag) ; boolean ldelete( long n, boolean kflag) ;

View File

@ -219,7 +219,7 @@ int setccol(int pos)
/* set us at the new position */ /* set us at the new position */
curwp->w_doto = i; curwp->w_doto = i;
/* and tell weather we made it */ /* and tell whether we made it */
return col >= pos; return col >= pos;
} }
@ -247,10 +247,14 @@ boolean twiddle( int f, int n) {
eof_f = TRUE ; eof_f = TRUE ;
} }
lgetchar( &c) ; len = lgetchar( &c) ; /* len => unicode or extended ASCII */
ldelchar( 1, FALSE) ; ldelchar( 1, FALSE) ;
backchar( FALSE, 1) ; backchar( FALSE, 1) ;
linsert( 1, c) ; if( len == 1)
linsert_byte( 1, c) ;
else
linsert( 1, c) ;
if( eof_f == TRUE) if( eof_f == TRUE)
forwchar( FALSE, 1) ; forwchar( FALSE, 1) ;
@ -346,7 +350,9 @@ int detab(int f, int n)
} }
/* advance/or back to the next line */ /* advance/or back to the next line */
forwline(TRUE, inc); if( forwline( TRUE, inc) == FALSE)
break ;
n -= inc; n -= inc;
} }
curwp->w_doto = 0; /* to the begining of the line */ curwp->w_doto = 0; /* to the begining of the line */
@ -419,7 +425,9 @@ int entab(int f, int n)
} }
/* advance/or back to the next line */ /* advance/or back to the next line */
forwline(TRUE, inc); if( forwline( TRUE, inc) == FALSE)
break ;
n -= inc; n -= inc;
} }
curwp->w_doto = 0; /* to the begining of the line */ curwp->w_doto = 0; /* to the begining of the line */
@ -463,7 +471,9 @@ int trim(int f, int n)
lp->l_used = length; lp->l_used = length;
/* advance/or back to the next line */ /* advance/or back to the next line */
forwline(TRUE, inc); if( forwline( TRUE, inc) == FALSE)
break ;
n -= inc; n -= inc;
} }
lchange(WFEDIT); lchange(WFEDIT);