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 int len;
672 char *p = *pp;
673
674 if (!utf_mode)
675 {
676 /* It's easy if chars are one byte. */
677 if (dir > 0)
678 ch = (LWCHAR) ((p < limit) ? *p++ : 0);
679 else
680 ch = (LWCHAR) ((p > limit) ? *--p : 0);
681 } else if (dir > 0)
682 {
683 len = utf_len(*p);
684 if (p + len > limit)
685 {
686 ch = 0;
687 p = limit;
688 } else
689 {
690 ch = get_wchar(p);
691 p += len;
692 }
693 } else
694 {
695 while (p > limit && IS_UTF8_TRAIL(p[-1]))
696 p--;
697 if (p > limit)
698 ch = get_wchar(--p);
699 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 int len;
672 char *p = *pp;
673
674 if (!utf_mode)
675 {
676 /* It's easy if chars are one byte. */
677 if (dir > 0)
678 ch = (LWCHAR) ((p < limit) ? *p++ : 0);
679 else
680 ch = (LWCHAR) ((p > limit) ? *--p : 0);
681 } else if (dir > 0)
682 {
683 len = utf_len(*p);
684 if (p + len > limit)
685 {
686 ch = 0;
687 p = limit;
688 } else
689 {
690 ch = get_wchar(p);
691 p += len;
692 }
693 } else
694 {
695 while (p > limit && IS_UTF8_TRAIL(p[-1]))
696 p--;
697 if (p > limit)
698 ch = get_wchar(--p);
699 else
--- 468 unchanged lines hidden ---