version 1.1.1.1, 2011/09/16 17:47:04 |
version 1.1.1.2, 2014/04/25 13:33:45 |
|
|
/* |
/* |
* Copyright (C) 1984-2011 Mark Nudelman |
* Copyright (C) 1984-2012 Mark Nudelman |
* |
* |
* You may distribute under the terms of either the GNU General Public |
* You may distribute under the terms of either the GNU General Public |
* License or the Less License, as specified in the README file. |
* License or the Less License, as specified in the README file. |
* |
* |
* For more information about less, or for information on how to |
* For more information, see the README file. |
* contact the author, see the README file. |
|
*/ |
*/ |
|
|
/* |
/* |
|
|
int ops; |
int ops; |
{ |
{ |
char *dst; |
char *dst; |
|
char *edst = odst; |
char *src; |
char *src; |
register char *src_end; |
register char *src_end; |
LWCHAR ch; |
LWCHAR ch; |
|
|
/* Just copy the char to the destination buffer. */ |
/* Just copy the char to the destination buffer. */ |
if ((ops & CVT_TO_LC) && IS_UPPER(ch)) |
if ((ops & CVT_TO_LC) && IS_UPPER(ch)) |
ch = TO_LOWER(ch); |
ch = TO_LOWER(ch); |
|
#if !SMALL |
put_wchar(&dst, ch); |
put_wchar(&dst, ch); |
/* |
#else |
* Record the original position of the char. |
*dst++ = (char)ch; |
* But if we've already recorded a position |
#endif /* !SMALL */ |
* for this char (due to a backspace), leave |
/* Record the original position of the char. */ |
* it alone; if multiple source chars map to |
if (chpos != NULL) |
* one destination char, we want the position |
|
* of the first one. |
|
*/ |
|
if (chpos != NULL && chpos[dst_pos] < 0) |
|
chpos[dst_pos] = src_pos; |
chpos[dst_pos] = src_pos; |
} |
} |
|
if (dst > edst) |
|
edst = dst; |
} |
} |
if ((ops & CVT_CRLF) && dst > odst && dst[-1] == '\r') |
if ((ops & CVT_CRLF) && edst > odst && edst[-1] == '\r') |
dst--; |
edst--; |
*dst = '\0'; |
*edst = '\0'; |
if (lenp != NULL) |
if (lenp != NULL) |
*lenp = dst - odst; |
*lenp = edst - odst; |
if (chpos != NULL) |
/* FIXME: why was this here? if (chpos != NULL) chpos[dst - odst] = src - osrc; */ |
chpos[dst - odst] = src - osrc; |
|
} |
} |