1 |
|
/* |
2 |
< |
* Copyright (C) 1984-2009 Mark Nudelman |
2 |
> |
* Copyright (C) 1984-2012 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. |
7 |
> |
* For more information, see the README file. |
8 |
|
*/ |
9 |
|
|
10 |
|
/* |
63 |
|
int ops; |
64 |
|
{ |
65 |
|
char *dst; |
66 |
+ |
char *edst = odst; |
67 |
|
char *src; |
68 |
|
register char *src_end; |
69 |
|
LWCHAR ch; |
98 |
|
if ((ops & CVT_TO_LC) && IS_UPPER(ch)) |
99 |
|
ch = TO_LOWER(ch); |
100 |
|
put_wchar(&dst, ch); |
101 |
< |
/* |
102 |
< |
* Record the original position of the char. |
103 |
< |
* But if we've already recorded a position |
104 |
< |
* for this char (due to a backspace), leave |
105 |
< |
* it alone; if multiple source chars map to |
106 |
< |
* one destination char, we want the position |
107 |
< |
* of the first one. |
108 |
< |
*/ |
109 |
< |
if (chpos != NULL && chpos[dst_pos] < 0) |
101 |
> |
/* Record the original position of the char. */ |
102 |
> |
if (chpos != NULL) |
103 |
|
chpos[dst_pos] = src_pos; |
104 |
|
} |
105 |
+ |
if (dst > edst) |
106 |
+ |
edst = dst; |
107 |
|
} |
108 |
< |
if ((ops & CVT_CRLF) && dst > odst && dst[-1] == '\r') |
109 |
< |
dst--; |
110 |
< |
*dst = '\0'; |
108 |
> |
if ((ops & CVT_CRLF) && edst > odst && edst[-1] == '\r') |
109 |
> |
edst--; |
110 |
> |
*edst = '\0'; |
111 |
|
if (lenp != NULL) |
112 |
< |
*lenp = dst - odst; |
113 |
< |
if (chpos != NULL) |
119 |
< |
chpos[dst - odst] = src - osrc; |
112 |
> |
*lenp = edst - odst; |
113 |
> |
/* FIXME: why was this here? if (chpos != NULL) chpos[dst - odst] = src - osrc; */ |
114 |
|
} |