Commit e3bae98a authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

in mbstrchr(), don't count matches between valid and invalid multibyte

sequences anymore, for consistency


git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2894 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
parent 91d468d7
Showing with 8 additions and 1 deletion
+8 -1
...@@ -73,6 +73,10 @@ CVS code - ...@@ -73,6 +73,10 @@ CVS code -
- Make sure that the current position in the history list is - Make sure that the current position in the history list is
properly set to the bottom if we cancel out of the prompt. properly set to the bottom if we cancel out of the prompt.
New function history_reset(); changes to nanogetstr(). (DLR) New function history_reset(); changes to nanogetstr(). (DLR)
- chars.c:
mbstrchr()
- Don't count matches between valid and invalid multibyte
sequences anymore, for consistency. (DLR)
- files.c: - files.c:
open_file() open_file()
- Assert that filename isn't NULL, and don't do anything special - Assert that filename isn't NULL, and don't do anything special
......
...@@ -808,6 +808,7 @@ char *mbstrchr(const char *s, char *c) ...@@ -808,6 +808,7 @@ char *mbstrchr(const char *s, char *c)
#ifdef ENABLE_UTF8 #ifdef ENABLE_UTF8
if (ISSET(USE_UTF8)) { if (ISSET(USE_UTF8)) {
bool bad_c_mb = FALSE, bad_s_mb = FALSE;
char *s_mb = charalloc(MB_CUR_MAX); char *s_mb = charalloc(MB_CUR_MAX);
const char *q = s; const char *q = s;
wchar_t ws, wc; wchar_t ws, wc;
...@@ -816,6 +817,7 @@ char *mbstrchr(const char *s, char *c) ...@@ -816,6 +817,7 @@ char *mbstrchr(const char *s, char *c)
if (c_mb_len <= 0) { if (c_mb_len <= 0) {
mbtowc(NULL, NULL, 0); mbtowc(NULL, NULL, 0);
wc = (unsigned char)*c; wc = (unsigned char)*c;
bad_c_mb = TRUE;
} }
while (*s != '\0') { while (*s != '\0') {
...@@ -824,9 +826,10 @@ char *mbstrchr(const char *s, char *c) ...@@ -824,9 +826,10 @@ char *mbstrchr(const char *s, char *c)
if (mbtowc(&ws, s_mb, s_mb_len) <= 0) { if (mbtowc(&ws, s_mb, s_mb_len) <= 0) {
mbtowc(NULL, NULL, 0); mbtowc(NULL, NULL, 0);
ws = (unsigned char)*s; ws = (unsigned char)*s;
bad_s_mb = TRUE;
} }
if (ws == wc) if (bad_s_mb == bad_c_mb && ws == wc)
break; break;
s += s_mb_len; s += s_mb_len;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment