mirror of
https://github.com/rfivet/uemacs.git
synced 2024-12-18 23:36:23 -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
|
cat lintout
|
||||||
|
|
||||||
splint:
|
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:
|
errs:
|
||||||
@rm -f makeout
|
@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.
|
* column, return the best choice for the offset. The offset is returned.
|
||||||
* Used by "C-N" and "C-P".
|
* Used by "C-N" and "C-P".
|
||||||
*/
|
*/
|
||||||
static int getgoal(struct line *dlp)
|
static unsigned getgoal( struct line *dlp) {
|
||||||
{
|
int col ;
|
||||||
int col;
|
unsigned idx ;
|
||||||
int newcol;
|
const unsigned len = llength( dlp) ;
|
||||||
int dbo;
|
|
||||||
int len = llength(dlp);
|
|
||||||
|
|
||||||
col = 0;
|
col = 0 ;
|
||||||
dbo = 0;
|
idx = 0 ;
|
||||||
while (dbo != len) {
|
while( idx < len) {
|
||||||
unicode_t c;
|
unicode_t c ;
|
||||||
int width = utf8_to_unicode(dlp->l_text, dbo, len, &c);
|
unsigned width = utf8_to_unicode( dlp->l_text, idx, len, &c) ;
|
||||||
newcol = col;
|
|
||||||
|
|
||||||
/* Take tabs, ^X and \xx hex characters into account */
|
/* Take tabs, ^X and \xx hex characters into account */
|
||||||
if (c == '\t')
|
if( c == '\t')
|
||||||
newcol |= tabmask;
|
col |= tabmask ;
|
||||||
else if (c < 0x20 || c == 0x7F)
|
else if( c < 0x20 || c == 0x7F)
|
||||||
++newcol;
|
col += 1 ;
|
||||||
else if (c >= 0x80 && c <= 0xa0)
|
else if( c >= 0x80 && c <= 0xA0)
|
||||||
newcol += 2;
|
col += 2 ;
|
||||||
|
|
||||||
++newcol;
|
col += 1 ;
|
||||||
if (newcol > curgoal)
|
if( col > curgoal)
|
||||||
break;
|
break ;
|
||||||
col = newcol;
|
|
||||||
dbo += width;
|
idx += width ;
|
||||||
}
|
}
|
||||||
return dbo;
|
|
||||||
|
return idx ;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user