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 git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2784 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
3b2fdb00e4
commit
9905b6ae74
|
@ -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
|
||||
|
|
51
src/chars.c
51
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 */
|
||||
|
|
|
@ -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
|
||||
|
|
21
src/winio.c
21
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);
|
||||
|
|
Loading…
Reference in New Issue