From 9905b6ae743940693560aeed8cdb95df4bdd3b6b Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Tue, 28 Jun 2005 07:26:11 +0000 Subject: [PATCH] =?UTF-8?q?rework=20the=20credits=20handling=20to=20displa?= =?UTF-8?q?y=20Florian=20K=C3=B6nig's=20name=20properly=20whether=20we're?= =?UTF-8?q?=20in=20a=20UTF-8=20locale=20or=20not.=20=20This=20requires=20a?= =?UTF-8?q?=20minor=20hack,=20but=20it's=20better=20than=20requiring=20a?= =?UTF-8?q?=20massive=20function=20that=20we=20only=20use=20once?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2784 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 5 +++++ src/chars.c | 51 --------------------------------------------------- src/proto.h | 3 --- src/winio.c | 21 ++++++++++++--------- 4 files changed, 17 insertions(+), 63 deletions(-) diff --git a/ChangeLog b/ChangeLog index 894b22ec..dddcfe69 100644 --- a/ChangeLog +++ b/ChangeLog @@ -127,6 +127,11 @@ CVS code - totlines a size_t, and change related variables to match. (DLR, initial problem with parse_line_column() found by Mike Frysinger) + - Rework the credits handling to display Florian König's name + properly whether we're in a UTF-8 locale or not. This + requires a minor hack, but it's better than requiring a + massive function that we only use once. Changes to + do_credits(); removal of make_valid_mbstring(). (DLR) - chars.c: make_mbstring() - Change erroneous ENABLE_EXTRA #ifdef to NANO_EXTRA to fix a diff --git a/src/chars.c b/src/chars.c index b09ba9e1..c9f82c89 100644 --- a/src/chars.c +++ b/src/chars.c @@ -861,54 +861,3 @@ bool is_valid_mbstring(const char *s) TRUE; } #endif /* ENABLE_NANORC */ - -#ifdef NANO_EXTRA -/* Convert the string s to a valid multibyte string with the same wide - * character values as s. Return the (dynamically allocated) multibyte - * string. */ -char *make_valid_mbstring(const char *s) -{ - assert(s != NULL); - -#ifdef NANO_WIDE - if (ISSET(USE_UTF8)) { - char *chr_mb = charalloc(MB_CUR_MAX); - char *s_mb = charalloc((MB_CUR_MAX * strlen(s)) + 1); - size_t s_mb_len = 0; - - while (*s != '\0') { - int chr_mb_len, i; - bool bad_chr; - - chr_mb_len = parse_mbchar(s, chr_mb, &bad_chr, NULL); - - if (bad_chr) { - char *bad_chr_mb; - int bad_chr_mb_len; - - bad_chr_mb = make_mbchar((unsigned char)*chr_mb, - &bad_chr_mb_len); - - for (i = 0; i < bad_chr_mb_len; i++) - s_mb[s_mb_len + i] = bad_chr_mb[i]; - s_mb_len += bad_chr_mb_len; - - free(bad_chr_mb); - } else { - for (i = 0; i < chr_mb_len; i++) - s_mb[s_mb_len + i] = chr_mb[i]; - s_mb_len += chr_mb_len; - } - - s += chr_mb_len; - } - - free(chr_mb); - null_at(&s_mb, s_mb_len); - - return s_mb; - } else -#endif - return mallocstrcpy(NULL, s); -} -#endif /* NANO_EXTRA */ diff --git a/src/proto.h b/src/proto.h index a82b7308..961e95c8 100644 --- a/src/proto.h +++ b/src/proto.h @@ -224,9 +224,6 @@ char *mbstrchr(const char *s, char *c); #ifdef ENABLE_NANORC bool is_valid_mbstring(const char *s); #endif -#ifdef NANO_EXTRA -char *make_valid_mbstring(const char *s); -#endif /* Public functions in color.c. */ #ifdef ENABLE_COLOR diff --git a/src/winio.c b/src/winio.c index 8fce798b..336f5792 100644 --- a/src/winio.c +++ b/src/winio.c @@ -4094,7 +4094,7 @@ void do_credits(void) "David Benbennick", "Ken Tyler", "Sven Guckes", - "Florian K\xF6nig", + NULL, /* credits[14], handled below. */ "Pauli Virtanen", "Daniele Medri", "Clement Laforet", @@ -4146,6 +4146,14 @@ void do_credits(void) N_("Thank you for using nano!") }; + /* credits[14]: Use a minor hack to make sure this name is displayed + * properly, since we can't dynamically assign it above. */ + credits[14] = +#ifdef NANO_WIDE + ISSET(USE_UTF8) ? "Florian K\xC3\xB6nig" : +#endif + "Florian K\xF6nig"; + curs_set(0); nodelay(edit, TRUE); scrollok(edit, TRUE); @@ -4163,25 +4171,20 @@ void do_credits(void) break; if (crpos < CREDIT_LEN) { - char *what; + const char *what; size_t start_x; - /* Make sure every credit is a valid multibyte string, since - * we can't dynamically set the credits to their multibyte - * equivalents when we need to. Sigh... */ if (credits[crpos] == NULL) { assert(0 <= xlpos && xlpos < XLCREDIT_LEN); - what = mallocstrcpy(NULL, _(xlcredits[xlpos])); + what = _(xlcredits[xlpos]); xlpos++; } else - what = make_valid_mbstring(credits[crpos]); + what = credits[crpos]; start_x = COLS / 2 - strlenpt(what) / 2 - 1; mvwaddstr(edit, editwinrows - 1 - (editwinrows % 2), start_x, what); - - free(what); } napms(700);