Version 4.2

Consistent display of µEMACS as program name among
- ue --version
- on status bar
- insert-string $progname
- write-message $progname (FIX).
This commit is contained in:
Renaud 2015-02-12 13:15:45 +08:00
parent b2306e379d
commit e13bc9ca7e
5 changed files with 44 additions and 11 deletions

View File

@ -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 ;
}

2
eval.c
View File

@ -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:

14
main.c
View File

@ -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 <stdio.h>
@ -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) ;
}

6
utf8.c
View File

@ -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;

View File

@ -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_ */