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