Loading ...
Sorry, an error occurred while loading the content.

Re: over the maxfuncdepth (patch)

Expand Messages
  • Bram Moolenaar
    ... Aha, the mb_strnicmp() function didn t return -1, thus couldn t be used for sorting. Thanks for figuring this out! I think the handling of strings that
    Message 1 of 3 , Jun 19, 2001
    • 0 Attachment
      Yasuhiro Matsumoto wrote:

      > Hi vim-multibyte and bram.
      >
      > a function of mb_strnicmp is not one of mbsnicmp.
      > "eval.c" use negative value of STRICMP.
      > -----------
      > explore.vim
      > s:SortR
      > s:StrCmp
      > a:line1 < a:line2
      > a:line1 > a:line2
      > eval.c (line 1554)
      > -----------
      >
      > this is a patch.

      Aha, the mb_strnicmp() function didn't return -1, thus couldn't be used for
      sorting. Thanks for figuring this out!

      I think the handling of strings that differ in length isn't done right. See
      the code below for what I made out of it.

      > to bram -
      > I may that you return "vim.h" to original.
      > (no problem and no slowdown)

      Well, I suppose it doesn't hurt to keep it in.


      int
      mb_strnicmp(s1, s2, n)
      char_u *s1, *s2;
      int n;
      {
      int i, l;
      int cdiff;

      for (i = 0; i < n; i += l)
      {
      l = (*mb_ptr2len_check)(s1 + i);
      if (l <= 1)
      {
      /* Single byte: first check normally, then with ignore case. */
      if (s1[i] != s2[i])
      {
      cdiff = TO_LOWER(s1[i]) - TO_LOWER(s2[i]);
      if (cdiff != 0)
      return cdiff;
      }
      else if (s1[i] == NUL)
      return 0;
      }
      else
      {
      /* For multi-byte only ignore case for Unicode. */
      if (l > n - i)
      l = n - i;
      if (enc_utf8)
      cdiff = utf_fold(utf_ptr2char(s1 + i))
      - utf_fold(utf_ptr2char(s2 + i));
      else
      cdiff = STRNCMP(s1 + i, s2 + i, l);
      if (cdiff != 0)
      return cdiff;
      }
      }
      return 0;
      }
      --
      TIM: Too late.
      ARTHUR: What?
      TIM: There he is!
      [They all turn,, and see a large white RABBIT lollop a few yards out of the
      cave. Accompanied by terrifying chord and jarring metallic monster noise.]
      "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

      /// Bram Moolenaar -- Bram@... -- http://www.moolenaar.net \\\
      ((( Creator of Vim -- http://vim.sf.net -- ftp://ftp.vim.org/pub/vim )))
      \\\ Help me helping AIDS orphans in Uganda - http://iccf-holland.org ///
    Your message has been successfully submitted and would be delivered to recipients shortly.