From de04424e510d24898d49319ffb580d959fa061e3 Mon Sep 17 00:00:00 2001 From: Renaud Fivet Date: Mon, 2 Feb 2015 19:44:35 +0800 Subject: [PATCH] Align scope and parameter type for linsert and is_beginning_utf8. --- line.c | 13 ++++++++----- line.h | 2 +- utf8.h | 5 ----- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/line.c b/line.c index 9c4afb7..e6409df 100644 --- a/line.c +++ b/line.c @@ -32,6 +32,10 @@ int tabmask = 0x07 ; /* tabulator mask */ static int ldelnewline( void) ; +static inline int is_beginning_utf8( unsigned char c) { + return (c & 0xc0) != 0x80; +} + /* The editor holds deleted text chunks in the struct kill buffer. The * kill buffer is logically a stream of ascii characters, however * due to its unpredicatable size, it gets implemented as a linked @@ -261,11 +265,11 @@ int linstr( char *instr) { int status = TRUE ; if( instr != NULL) { - char tmpc ; + unicode_t tmpc ; - while( (tmpc = *instr++)) { + while( (tmpc = *instr++ & 0xFF)) { status = - (tmpc == '\n' ? lnewline() : linsert( 1, tmpc & 0xFF)) ; + (tmpc == '\n' ? lnewline() : linsert( 1, tmpc)) ; /* Insertion error? */ if( status != TRUE) { @@ -369,8 +373,7 @@ static int linsert_byte(int n, int c) return TRUE; } -int linsert(int n, int c) -{ +int linsert( int n, unicode_t c) { char utf8[6]; int bytes, i ; diff --git a/line.h b/line.h index a01730b..aa2c566 100644 --- a/line.h +++ b/line.h @@ -38,7 +38,7 @@ void lfree( struct line *lp) ; void lchange( int flag) ; int insspace( int f, int n) ; int linstr( char *instr) ; -int linsert( int n, int c) ; +int linsert( int n, unicode_t c) ; int lover( char *ostr) ; int lnewline( void) ; int ldelete( long n, int kflag) ; diff --git a/utf8.h b/utf8.h index 1a6f274..6ac547e 100644 --- a/utf8.h +++ b/utf8.h @@ -7,9 +7,4 @@ unsigned utf8_to_unicode( char *line, unsigned index, unsigned len, unicode_t *res) ; unsigned unicode_to_utf8( unsigned int c, char *utf8) ; -static inline int is_beginning_utf8( unsigned char c) -{ - return (c & 0xc0) != 0x80; -} - #endif