diff --git a/random.c b/random.c index 4bbc50d..71fe0a7 100644 --- a/random.c +++ b/random.c @@ -73,7 +73,7 @@ int showcpos(int f, int n) int numlines; /* # of lines in file */ long predchars; /* # chars preceding point */ int predlines; /* # lines preceding point */ - int curchar; /* character under cursor */ + unicode_t curchar ; /* character under cursor */ int ratio; int col; int savepos; /* temp save for current offset */ @@ -91,12 +91,15 @@ int showcpos(int f, int n) while (lp != curbp->b_linep) { /* if we are on the current line, record it */ if (lp == curwp->w_dotp) { + int len ; + predlines = numlines; predchars = numchars + curwp->w_doto; - if ((curwp->w_doto) == llength(lp)) + len = llength( lp) ; + if( (curwp->w_doto) == len) curchar = '\n'; else - curchar = lgetc(lp, curwp->w_doto); + (void) utf8_to_unicode( lp->l_text, curwp->w_doto, len, &curchar) ; } /* on to the next line */ ++numlines; diff --git a/utf8.c b/utf8.c index 07ea48f..4ee423f 100644 --- a/utf8.c +++ b/utf8.c @@ -97,7 +97,7 @@ unsigned unicode_to_utf8(unsigned int c, char *utf8) bytes++; prefix >>= 1; c >>= 6; - } while (c > prefix); + } while( c >= prefix) ; *p = c - 2*prefix; reverse_string(utf8, p); }