mirror of
https://github.com/rfivet/uemacs.git
synced 2024-11-14 00:26:01 -05:00
Review getgoal code.
This commit is contained in:
parent
80cbd37f5c
commit
87350f4c16
2
Makefile
2
Makefile
@ -87,7 +87,7 @@ lint: ${SRC}
|
||||
cat lintout
|
||||
|
||||
splint:
|
||||
splint -weak $(DEFINES) $(SRC) -booltype boolean -booltrue TRUE -boolfalse FALSE +posixlib
|
||||
splint -weak $(DEFINES) $(SRC) -booltype boolean -booltrue TRUE -boolfalse FALSE +posixlib +matchanyintegral
|
||||
|
||||
errs:
|
||||
@rm -f makeout
|
||||
|
46
basic.c
46
basic.c
@ -38,35 +38,33 @@ int curgoal ; /* Goal for C-P, C-N */
|
||||
* column, return the best choice for the offset. The offset is returned.
|
||||
* Used by "C-N" and "C-P".
|
||||
*/
|
||||
static int getgoal(struct line *dlp)
|
||||
{
|
||||
int col;
|
||||
int newcol;
|
||||
int dbo;
|
||||
int len = llength(dlp);
|
||||
static unsigned getgoal( struct line *dlp) {
|
||||
int col ;
|
||||
unsigned idx ;
|
||||
const unsigned len = llength( dlp) ;
|
||||
|
||||
col = 0;
|
||||
dbo = 0;
|
||||
while (dbo != len) {
|
||||
unicode_t c;
|
||||
int width = utf8_to_unicode(dlp->l_text, dbo, len, &c);
|
||||
newcol = col;
|
||||
col = 0 ;
|
||||
idx = 0 ;
|
||||
while( idx < len) {
|
||||
unicode_t c ;
|
||||
unsigned width = utf8_to_unicode( dlp->l_text, idx, len, &c) ;
|
||||
|
||||
/* Take tabs, ^X and \xx hex characters into account */
|
||||
if (c == '\t')
|
||||
newcol |= tabmask;
|
||||
else if (c < 0x20 || c == 0x7F)
|
||||
++newcol;
|
||||
else if (c >= 0x80 && c <= 0xa0)
|
||||
newcol += 2;
|
||||
if( c == '\t')
|
||||
col |= tabmask ;
|
||||
else if( c < 0x20 || c == 0x7F)
|
||||
col += 1 ;
|
||||
else if( c >= 0x80 && c <= 0xA0)
|
||||
col += 2 ;
|
||||
|
||||
++newcol;
|
||||
if (newcol > curgoal)
|
||||
break;
|
||||
col = newcol;
|
||||
dbo += width;
|
||||
col += 1 ;
|
||||
if( col > curgoal)
|
||||
break ;
|
||||
|
||||
idx += width ;
|
||||
}
|
||||
return dbo;
|
||||
|
||||
return idx ;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user