=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/less/cvt.c,v retrieving revision 1.2 retrieving revision 1.3 diff -c -r1.2 -r1.3 *** src/usr.bin/less/cvt.c 2011/09/16 18:12:09 1.2 --- src/usr.bin/less/cvt.c 2014/04/25 13:38:21 1.3 *************** *** 1,11 **** /* ! * Copyright (C) 1984-2011 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. */ /* --- 1,10 ---- /* ! * 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, see the README file. */ /* *************** *** 64,69 **** --- 63,69 ---- int ops; { char *dst; + char *edst = odst; char *src; register char *src_end; LWCHAR ch; *************** *** 102,124 **** #else *dst++ = (char)ch; #endif /* !SMALL */ ! /* ! * 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) chpos[dst_pos] = src_pos; } } ! if ((ops & CVT_CRLF) && dst > odst && dst[-1] == '\r') ! dst--; ! *dst = '\0'; if (lenp != NULL) ! *lenp = dst - odst; ! if (chpos != NULL) ! chpos[dst - odst] = src - osrc; } --- 102,118 ---- #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) && edst > odst && edst[-1] == '\r') ! edst--; ! *edst = '\0'; if (lenp != NULL) ! *lenp = edst - odst; ! /* FIXME: why was this here? if (chpos != NULL) chpos[dst - odst] = src - osrc; */ }