diff --git a/display.c b/display.c index 8f007b8..69e0e13 100644 --- a/display.c +++ b/display.c @@ -87,7 +87,7 @@ static void modeline(struct window *wp); static void mlputi(int i, int r); static void mlputli(long l, int r); static void mlputf(int s); -static void mlputs( char *s) ; +static void mlputs( unsigned char *s) ; #if SIGWINCH static int newscreensize(int h, int w); #endif @@ -1154,7 +1154,7 @@ static void modeline(struct window *wp) vtputc( ' ') ; n = 3 ; - cp = &PROGRAM_NAME_LONG " " VERSION ": " [ 1] ; /* Start past utf8 mark */ + cp = PROGRAM_NAME_LONG " " VERSION ": " ; while ((c = *cp++) != 0) { vtputc(c); ++n; @@ -1394,7 +1394,7 @@ void mlwrite(const char *fmt, ...) break; case 's': - mlputs(va_arg(ap, char *)); + mlputs( (unsigned char *) va_arg( ap, char *)) ; break; case 'f': @@ -1441,10 +1441,28 @@ void mlforce( char *s) { * the characters in the string all have width "1"; if this is not the case * things will get screwed up a little. */ -static void mlputs( char *s) { - int c ; +static void mlputs( unsigned char *s) { + unicode_t c ; while( ((c = *s++) != 0) && (ttcol < term.t_ncol)) { + /* Accept UTF-8 sequence */ + if( c > 0xC1 && c <= 0xF4) { + char utf[ 4] ; + char cc ; + int bytes ; + + utf[ 0] = c ; + utf[ 1] = cc = *s ; + if( (c & 0x20) && ((cc & 0xC0) == 0x80)) { /* at least 3 bytes and a valid encoded char */ + utf[ 2] = cc = s[ 1] ; + if( (c & 0x10) && ((cc & 0xC0) == 0x80)) /* at least 4 bytes and a valid encoded char */ + utf[ 3] = s[ 2] ; + } + + bytes = utf8_to_unicode( utf, 0, sizeof utf, (unicode_t *) &c) ; + s += bytes - 1 ; + } + TTputc( c) ; ++ttcol ; } diff --git a/eval.c b/eval.c index 99a6545..c50c88a 100644 --- a/eval.c +++ b/eval.c @@ -694,7 +694,7 @@ static char *gtenv( char *vname) { case EVVERSION: return VERSION; case EVPROGNAME: - return PROGRAM_NAME_LONG; + return PROGRAM_NAME_PFX PROGRAM_NAME_LONG ; case EVSEED: return i_to_a(seed); case EVDISINP: diff --git a/main.c b/main.c index f2bb3e0..17e945c 100644 --- a/main.c +++ b/main.c @@ -4,7 +4,11 @@ /* * main.c - + * + * µEMACS 4.2 + * + * Based on: + * * uEmacs/PK 4.0 * * Based on: @@ -53,10 +57,14 @@ * * 4.0 Petri Kutvonen, 1-Sep-91 * - * This modified version is now called uEmacs/rf. + * This modified version is now called uEMACS. * * 4.1 Renaud Fivet, 1-May-13 * + * Renamed as µEMACS to emphasize UTF-8 support. + * + * 4.2 Renaud Fivet, 2015-02-12 + * */ #include @@ -106,7 +114,7 @@ static void emergencyexit(int signr) static void edinit( char *bname) ; static void version( void) { - fputs( PROGRAM_NAME_LONG " version " VERSION "\n", stdout) ; + fputs( PROGRAM_NAME_PFX PROGRAM_NAME_LONG " version " VERSION "\n", stdout) ; } diff --git a/utf8.c b/utf8.c index 29a0b18..6536d13 100644 --- a/utf8.c +++ b/utf8.c @@ -88,6 +88,12 @@ unsigned unicode_to_utf8( unicode_t c, char *utf8) { int bytes = 1 ; assert( c <= 0x10FFFF) ; + +#ifdef NDEBUG + if( c > 0x10FFFF) /* Let's assume this is due to sign extension */ + c &= 0xFF ; +#endif + *utf8 = c ; if (c > 0x7f) { int prefix = 0x40; diff --git a/version.h b/version.h index e76b0ed..f527976 100644 --- a/version.h +++ b/version.h @@ -9,8 +9,9 @@ # define PROGRAM_NAME "em" #endif -#define PROGRAM_NAME_LONG "\xC2\xB5""EMACS" /* utf8 µEMACS */ +# define PROGRAM_NAME_PFX "\xC2" +# define PROGRAM_NAME_LONG "\xB5""EMACS" /* UTF-8 µEMACS */ -#define VERSION "4.1.1" +# define VERSION "4.2.0" #endif /* VERSION_H_ */