diff options
author | delphij <delphij@FreeBSD.org> | 2007-10-08 16:17:42 +0000 |
---|---|---|
committer | delphij <delphij@FreeBSD.org> | 2007-10-08 16:17:42 +0000 |
commit | cee6fe7563d96f028c6e9343a81e24f9c7f70296 (patch) | |
tree | a5e1c28b8d2c6768b8b27fa4e866fa91cd86f8b9 /contrib/less/search.c | |
parent | de40ea14af9f01e8574114a8b793148ba1910638 (diff) | |
download | FreeBSD-src-cee6fe7563d96f028c6e9343a81e24f9c7f70296.zip FreeBSD-src-cee6fe7563d96f028c6e9343a81e24f9c7f70296.tar.gz |
Resolve conflicts to complete less v408 import.
Approved by: re (kensmith)
Diffstat (limited to 'contrib/less/search.c')
-rw-r--r-- | contrib/less/search.c | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/contrib/less/search.c b/contrib/less/search.c index e81bce5..c3a3e76 100644 --- a/contrib/less/search.c +++ b/contrib/less/search.c @@ -16,6 +16,7 @@ #include "less.h" #include "position.h" +#include "charset.h" #define MINPOS(a,b) (((a) < (b)) ? (a) : (b)) #define MAXPOS(a,b) (((a) > (b)) ? (a) : (b)) @@ -120,24 +121,31 @@ cvt_text(odst, osrc, lenp, ops) int *lenp; int ops; { - register char *dst; - register char *src; + char *dst; + char *src; register char *src_end; + LWCHAR ch; if (lenp != NULL) src_end = osrc + *lenp; else src_end = osrc + strlen(osrc); - for (src = osrc, dst = odst; src < src_end; src++) + for (src = osrc, dst = odst; src < src_end; ) { - if ((ops & CVT_TO_LC) && IS_UPPER(*src)) + ch = step_char(&src, +1, src_end); + if ((ops & CVT_TO_LC) && IS_UPPER(ch)) + { /* Convert uppercase to lowercase. */ - *dst++ = TO_LOWER(*src); - else if ((ops & CVT_BS) && *src == '\b' && dst > odst) + put_wchar(&dst, TO_LOWER(ch)); + } else if ((ops & CVT_BS) && ch == '\b' && dst > odst) + { /* Delete BS and preceding char. */ - dst--; - else if ((ops & CVT_ANSI) && *src == ESC) + do { + dst--; + } while (dst > odst && + !IS_ASCII_OCTET(*dst) && !IS_UTF8_LEAD(*dst)); + } else if ((ops & CVT_ANSI) && IS_CSI_START(ch)) { /* Skip to end of ANSI escape sequence. */ while (src + 1 != src_end) @@ -145,7 +153,7 @@ cvt_text(odst, osrc, lenp, ops) break; } else /* Just copy. */ - *dst++ = *src; + put_wchar(&dst, ch); } if ((ops & CVT_CRLF) && dst > odst && dst[-1] == '\r') dst--; @@ -182,14 +190,18 @@ get_cvt_ops() * Are there any uppercase letters in this string? */ static int -is_ucase(s) - char *s; +is_ucase(str) + char *str; { - register char *p; + char *str_end = str + strlen(str); + LWCHAR ch; - for (p = s; *p != '\0'; p++) - if (IS_UPPER(*p)) + while (str < str_end) + { + ch = step_char(&str, +1, str_end); + if (IS_UPPER(ch)) return (1); + } return (0); } @@ -679,7 +691,7 @@ adj_hilite_ansi(cvt_ops, line, line_len, npos) char *line_end = *line + line_len; if (cvt_ops & CVT_ANSI) - while (**line == ESC) + while (IS_CSI_START(**line)) { /* * Found an ESC. The file position moves |