patch 9.1.1395: search_stat not reset when pattern differs in case

Problem:  search_stat not reset when pattern differs in case
          (tahzibijafar)
Solution: use STRNCMP instead of MB_STRNICMP macro

There was a long standing todo comment, that using MB_STRNICMP is wrong.
So let's change it to STRNCMP() instead. Even if it not handle
multi-byte characters correctly, then Vim will rather recompute the
search stat, instead of re-using the old (and possibly wrong) value.

fixes: #17312
closes: #17314

Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/testdir/test_search_stat.vim b/src/testdir/test_search_stat.vim
index b57b7ba..c8e055d 100644
--- a/src/testdir/test_search_stat.vim
+++ b/src/testdir/test_search_stat.vim
@@ -459,4 +459,23 @@
   call StopVimInTerminal(buf)
 endfunc
 
+func Test_search_stat_smartcase_ignorecase()
+  CheckRunVimInTerminal
+
+  let lines =<< trim END
+    set shm-=S ignorecase smartcase
+    call setline(1, [' MainmainmainmmmainmAin', ''])
+  END
+  call writefile(lines, 'Xsearchstat_ignorecase', '5')
+
+  let buf = RunVimInTerminal('-S Xsearchstat_ignorecase', #{rows: 10})
+  call term_sendkeys(buf, "/main\<cr>nnnn")
+  call WaitForAssert({-> assert_match('\[5\/5\]', term_getline(buf, 10))}, 1000)
+
+  call term_sendkeys(buf, "/mAin\<cr>")
+  call WaitForAssert({-> assert_match('\[1\/1\]', term_getline(buf, 10))}, 1000)
+
+  call StopVimInTerminal(buf)
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab