cvt.c (221715) | cvt.c (237613) |
---|---|
1/* | 1/* |
2 * Copyright (C) 1984-2011 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 * | 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. |
9 */ 10 11/* 12 * Routines to convert text in various ways. Used by search. 13 */ 14 15#include "less.h" 16#include "charset.h" --- 42 unchanged lines hidden (view full) --- 59cvt_text(odst, osrc, chpos, lenp, ops) 60 char *odst; 61 char *osrc; 62 int *chpos; 63 int *lenp; 64 int ops; 65{ 66 char *dst; | 8 */ 9 10/* 11 * Routines to convert text in various ways. Used by search. 12 */ 13 14#include "less.h" 15#include "charset.h" --- 42 unchanged lines hidden (view full) --- 58cvt_text(odst, osrc, chpos, lenp, ops) 59 char *odst; 60 char *osrc; 61 int *chpos; 62 int *lenp; 63 int ops; 64{ 65 char *dst; |
66 char *edst = odst; |
|
67 char *src; 68 register char *src_end; 69 LWCHAR ch; 70 71 if (lenp != NULL) 72 src_end = osrc + *lenp; 73 else 74 src_end = osrc + strlen(osrc); --- 18 unchanged lines hidden (view full) --- 93 if (!is_ansi_middle(*src++)) 94 break; 95 } else 96 { 97 /* Just copy the char to the destination buffer. */ 98 if ((ops & CVT_TO_LC) && IS_UPPER(ch)) 99 ch = TO_LOWER(ch); 100 put_wchar(&dst, ch); | 67 char *src; 68 register char *src_end; 69 LWCHAR ch; 70 71 if (lenp != NULL) 72 src_end = osrc + *lenp; 73 else 74 src_end = osrc + strlen(osrc); --- 18 unchanged lines hidden (view full) --- 93 if (!is_ansi_middle(*src++)) 94 break; 95 } else 96 { 97 /* Just copy the char to the destination buffer. */ 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) |
110 chpos[dst_pos] = src_pos; 111 } | 103 chpos[dst_pos] = src_pos; 104 } |
105 if (dst > edst) 106 edst = dst; |
|
112 } | 107 } |
113 if ((ops & CVT_CRLF) && dst > odst && dst[-1] == '\r') 114 dst--; 115 *dst = '\0'; | 108 if ((ops & CVT_CRLF) && edst > odst && edst[-1] == '\r') 109 edst--; 110 *edst = '\0'; |
116 if (lenp != NULL) | 111 if (lenp != NULL) |
117 *lenp = dst - odst; 118 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; */ |
120} | 114} |