don't work around invalid multibyte sequences in rcfile options anymore,
but generate errors git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2650 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
6a0d5b8fec
commit
30d0a81656
17
ChangeLog
17
ChangeLog
|
@ -58,12 +58,14 @@ CVS code -
|
||||||
wrappers; change other ctype wrappers to take wint_t instead
|
wrappers; change other ctype wrappers to take wint_t instead
|
||||||
of wchar_t; rename some functions for consistency; and don't
|
of wchar_t; rename some functions for consistency; and don't
|
||||||
count matches between valid and invalid multibyte sequences
|
count matches between valid and invalid multibyte sequences
|
||||||
anymore, as it causes problems when doing a replace. Changes
|
anymore, as it causes problems when doing a replace. New
|
||||||
to is_alnum_mbchar(), is_blank_char() (renamed nisblank()),
|
function is_valid_mbstring(); changes to is_alnum_mbchar(),
|
||||||
is_blank_mbchar(), is_blank_wchar() (renamed niswblank()),
|
is_blank_char() (renamed nisblank()), is_blank_mbchar(),
|
||||||
is_cntrl_wchar(), control_rep(), control_mbrep(),
|
is_blank_wchar() (renamed niswblank()), is_cntrl_wchar(),
|
||||||
mbstrncasecmp(), mbstrcasestr(), mbrevstrcasestr(), etc.;
|
control_rep(), control_mbrep(), make_mbstring() (renamed
|
||||||
removal of is_alnum_char() and is_alnum_wchar(). (DLR)
|
make_valid_mbstring()), mbstrncasecmp(), mbstrcasestr(),
|
||||||
|
mbrevstrcasestr(), etc.; removal of is_alnum_char() and
|
||||||
|
is_alnum_wchar(). (DLR)
|
||||||
- Implement word count via Meta-D at the main window. Note that
|
- Implement word count via Meta-D at the main window. Note that
|
||||||
this is disabled when NANO_SMALL is defined. New functions
|
this is disabled when NANO_SMALL is defined. New functions
|
||||||
do_word_count() and do_next_word_void(); changes to
|
do_word_count() and do_next_word_void(); changes to
|
||||||
|
@ -177,6 +179,9 @@ CVS code -
|
||||||
(DLR)
|
(DLR)
|
||||||
- Properly generate an error if we get a color directive without
|
- Properly generate an error if we get a color directive without
|
||||||
a regex string. (DLR)
|
a regex string. (DLR)
|
||||||
|
parse_rcfile()
|
||||||
|
- Properly generate an error if we get an invalid multibyte
|
||||||
|
string for an option, instead of working around it. (DLR)
|
||||||
- search.c:
|
- search.c:
|
||||||
do_gotoline()
|
do_gotoline()
|
||||||
- Properly show an error message if we try to go to line 0,
|
- Properly show an error message if we try to go to line 0,
|
||||||
|
|
36
src/chars.c
36
src/chars.c
|
@ -278,24 +278,50 @@ char *make_mbchar(int chr, int *chr_mb_len)
|
||||||
return chr_mb;
|
return chr_mb;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(ENABLE_NANORC) || defined(NANO_EXTRA)
|
#ifdef ENABLE_NANORC
|
||||||
|
/* Check if the string str is a valid multibyte string. Return TRUE if
|
||||||
|
* it is, and FALSE otherwise. */
|
||||||
|
bool is_valid_mbstring(const char *str)
|
||||||
|
{
|
||||||
|
assert(str != NULL);
|
||||||
|
|
||||||
|
#ifdef NANO_WIDE
|
||||||
|
if (!ISSET(NO_UTF8)) {
|
||||||
|
while (*str != '\0') {
|
||||||
|
int chr_mb_len;
|
||||||
|
bool bad_chr;
|
||||||
|
|
||||||
|
chr_mb_len = parse_mbchar(str, NULL, &bad_chr, NULL);
|
||||||
|
|
||||||
|
if (bad_chr)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
str += chr_mb_len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
#endif /* ENABLE_NANORC */
|
||||||
|
|
||||||
|
#ifdef NANO_EXTRA
|
||||||
/* Convert the string str to a valid multibyte string with the same wide
|
/* Convert the string str to a valid multibyte string with the same wide
|
||||||
* character values as str. Return the (dynamically allocated)
|
* character values as str. Return the (dynamically allocated)
|
||||||
* multibyte string. */
|
* multibyte string. */
|
||||||
char *make_mbstring(const char *str)
|
char *make_valid_mbstring(const char *str)
|
||||||
{
|
{
|
||||||
assert(str != NULL);
|
assert(str != NULL);
|
||||||
|
|
||||||
#ifdef NANO_WIDE
|
#ifdef NANO_WIDE
|
||||||
if (!ISSET(NO_UTF8)) {
|
if (!ISSET(NO_UTF8)) {
|
||||||
char *chr_mb = charalloc(MB_CUR_MAX);
|
char *chr_mb = charalloc(MB_CUR_MAX);
|
||||||
int chr_mb_len;
|
|
||||||
char *str_mb = charalloc((MB_CUR_MAX * strlen(str)) + 1);
|
char *str_mb = charalloc((MB_CUR_MAX * strlen(str)) + 1);
|
||||||
size_t str_mb_len = 0;
|
size_t str_mb_len = 0;
|
||||||
|
|
||||||
while (*str != '\0') {
|
while (*str != '\0') {
|
||||||
|
int chr_mb_len, i;
|
||||||
bool bad_chr;
|
bool bad_chr;
|
||||||
int i;
|
|
||||||
|
|
||||||
chr_mb_len = parse_mbchar(str, chr_mb, &bad_chr, NULL);
|
chr_mb_len = parse_mbchar(str, chr_mb, &bad_chr, NULL);
|
||||||
|
|
||||||
|
@ -328,7 +354,7 @@ char *make_mbstring(const char *str)
|
||||||
#endif
|
#endif
|
||||||
return mallocstrcpy(NULL, str);
|
return mallocstrcpy(NULL, str);
|
||||||
}
|
}
|
||||||
#endif /* ENABLE_NANORC || NANO_EXTRA */
|
#endif /* NANO_EXTRA */
|
||||||
|
|
||||||
/* Parse a multibyte character from buf. Return the number of bytes
|
/* Parse a multibyte character from buf. Return the number of bytes
|
||||||
* used. If chr isn't NULL, store the multibyte character in it. If
|
* used. If chr isn't NULL, store the multibyte character in it. If
|
||||||
|
|
|
@ -181,8 +181,11 @@ char *control_mbrep(const char *c, char *crep, int *crep_len);
|
||||||
int mbwidth(const char *c);
|
int mbwidth(const char *c);
|
||||||
int mb_cur_max(void);
|
int mb_cur_max(void);
|
||||||
char *make_mbchar(int chr, int *chr_mb_len);
|
char *make_mbchar(int chr, int *chr_mb_len);
|
||||||
#if defined(ENABLE_NANORC) || defined(NANO_EXTRA)
|
#ifdef ENABLE_NANORC
|
||||||
char *make_mbstring(const char *str);
|
bool is_valid_mbstring(const char *str);
|
||||||
|
#endif
|
||||||
|
#ifdef NANO_EXTRA
|
||||||
|
char *make_valid_mbstring(const char *str);
|
||||||
#endif
|
#endif
|
||||||
int parse_mbchar(const char *buf, char *chr, bool *bad_chr, size_t
|
int parse_mbchar(const char *buf, char *chr, bool *bad_chr, size_t
|
||||||
*col);
|
*col);
|
||||||
|
|
16
src/rcfile.c
16
src/rcfile.c
|
@ -568,12 +568,19 @@ void parse_rcfile(FILE *rcstream)
|
||||||
option++;
|
option++;
|
||||||
ptr = parse_argument(ptr);
|
ptr = parse_argument(ptr);
|
||||||
|
|
||||||
/* Make sure option is a valid multibyte
|
option = mallocstrcpy(NULL, option);
|
||||||
* string. */
|
|
||||||
option = make_mbstring(option);
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "option = \"%s\"\n", option);
|
fprintf(stderr, "option = \"%s\"\n", option);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Make sure option is a valid multibyte
|
||||||
|
* string. */
|
||||||
|
if (!is_valid_mbstring(option)) {
|
||||||
|
rcfile_error(
|
||||||
|
N_("Option is not a valid multibyte string"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef DISABLE_OPERATINGDIR
|
#ifndef DISABLE_OPERATINGDIR
|
||||||
if (strcasecmp(rcopts[i].name, "operatingdir") == 0)
|
if (strcasecmp(rcopts[i].name, "operatingdir") == 0)
|
||||||
operating_dir = option;
|
operating_dir = option;
|
||||||
|
@ -593,7 +600,8 @@ void parse_rcfile(FILE *rcstream)
|
||||||
#ifndef NANO_SMALL
|
#ifndef NANO_SMALL
|
||||||
if (strcasecmp(rcopts[i].name, "whitespace") == 0) {
|
if (strcasecmp(rcopts[i].name, "whitespace") == 0) {
|
||||||
whitespace = option;
|
whitespace = option;
|
||||||
if (mbstrlen(whitespace) != 2 || strlenpt(whitespace) != 2) {
|
if (mbstrlen(whitespace) != 2 ||
|
||||||
|
strlenpt(whitespace) != 2) {
|
||||||
rcfile_error(
|
rcfile_error(
|
||||||
N_("Two single-column characters required"));
|
N_("Two single-column characters required"));
|
||||||
free(whitespace);
|
free(whitespace);
|
||||||
|
|
|
@ -4119,7 +4119,7 @@ void do_credits(void)
|
||||||
what = mallocstrcpy(NULL, _(xlcredits[xlpos]));
|
what = mallocstrcpy(NULL, _(xlcredits[xlpos]));
|
||||||
xlpos++;
|
xlpos++;
|
||||||
} else
|
} else
|
||||||
what = make_mbstring(credits[crpos]);
|
what = make_valid_mbstring(credits[crpos]);
|
||||||
|
|
||||||
start_x = COLS / 2 - strlenpt(what) / 2 - 1;
|
start_x = COLS / 2 - strlenpt(what) / 2 - 1;
|
||||||
mvwaddstr(edit, editwinrows - 1 - (editwinrows % 2),
|
mvwaddstr(edit, editwinrows - 1 - (editwinrows % 2),
|
||||||
|
|
Loading…
Reference in New Issue