1/*
2 * Copyright (C) 1984-2007 Mark Nudelman
3 *
4 * You may distribute under the terms of either the GNU General Public
5 * License or the Less License, as specified in the README file.
6 *
7 * For more information about less, or for information on how to
8 * contact the author, see the README file.
--- 654 unchanged lines hidden (view full) ---
663 */
664 public LWCHAR
665step_char(pp, dir, limit)
666 char **pp;
667 signed int dir;
668 char *limit;
669{
670 LWCHAR ch;
671 char *p = *pp;
672
673 if (!utf_mode)
674 {
675 /* It's easy if chars are one byte. */
676 if (dir > 0)
677 ch = (LWCHAR) ((p < limit) ? *p++ : 0);
678 else
679 ch = (LWCHAR) ((p > limit) ? *--p : 0);
680 } else if (dir > 0)
681 {
682 if (p + utf_len(*p) > limit)
683 ch = 0;
684 else
685 {
686 ch = get_wchar(p);
687 p++;
688 while (IS_UTF8_TRAIL(*p))
689 p++;
690 }
691 } else
692 {
693 while (p > limit && IS_UTF8_TRAIL(p[-1]))
694 p--;
695 if (p > limit)
696 ch = get_wchar(--p);
697 else
--- 468 unchanged lines hidden ---
2 * Copyright (C) 1984-2007 Mark Nudelman
3 *
4 * You may distribute under the terms of either the GNU General Public
5 * License or the Less License, as specified in the README file.
6 *
7 * For more information about less, or for information on how to
8 * contact the author, see the README file.
--- 654 unchanged lines hidden (view full) ---
663 */
664 public LWCHAR
665step_char(pp, dir, limit)
666 char **pp;
667 signed int dir;
668 char *limit;
669{
670 LWCHAR ch;
671 char *p = *pp;
672
673 if (!utf_mode)
674 {
675 /* It's easy if chars are one byte. */
676 if (dir > 0)
677 ch = (LWCHAR) ((p < limit) ? *p++ : 0);
678 else
679 ch = (LWCHAR) ((p > limit) ? *--p : 0);
680 } else if (dir > 0)
681 {
682 if (p + utf_len(*p) > limit)
683 ch = 0;
684 else
685 {
686 ch = get_wchar(p);
687 p++;
688 while (IS_UTF8_TRAIL(*p))
689 p++;
690 }
691 } else
692 {
693 while (p > limit && IS_UTF8_TRAIL(p[-1]))
694 p--;
695 if (p > limit)
696 ch = get_wchar(--p);
697 else
--- 468 unchanged lines hidden ---