chared.c (1.60) | chared.c (1.61) |
---|---|
1/* $NetBSD: chared.c,v 1.60 2022/01/11 18:30:15 christos Exp $ */ | 1/* $NetBSD: chared.c,v 1.61 2022/02/08 15:05:10 christos Exp $ */ |
2 3/*- 4 * Copyright (c) 1992, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * Christos Zoulas of Cornell University. 9 * --- 22 unchanged lines hidden (view full) --- 32 * SUCH DAMAGE. 33 */ 34 35#include "config.h" 36#if !defined(lint) && !defined(SCCSID) 37#if 0 38static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93"; 39#else | 2 3/*- 4 * Copyright (c) 1992, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * Christos Zoulas of Cornell University. 9 * --- 22 unchanged lines hidden (view full) --- 32 * SUCH DAMAGE. 33 */ 34 35#include "config.h" 36#if !defined(lint) && !defined(SCCSID) 37#if 0 38static char sccsid[] = "@(#)chared.c 8.1 (Berkeley) 6/4/93"; 39#else |
40__RCSID("$NetBSD: chared.c,v 1.60 2022/01/11 18:30:15 christos Exp $"); | 40__RCSID("$NetBSD: chared.c,v 1.61 2022/02/08 15:05:10 christos Exp $"); |
41#endif 42#endif /* not lint && not SCCSID */ 43 44/* 45 * chared.c: Character editor utilities 46 */ 47#include <ctype.h> 48#include <stdlib.h> --- 570 unchanged lines hidden (view full) --- 619 return; 620 621 c_delbefore(el, n); /* delete before dot */ 622 el->el_line.cursor -= n; 623 if (el->el_line.cursor < el->el_line.buffer) 624 el->el_line.cursor = el->el_line.buffer; 625} 626 | 41#endif 42#endif /* not lint && not SCCSID */ 43 44/* 45 * chared.c: Character editor utilities 46 */ 47#include <ctype.h> 48#include <stdlib.h> --- 570 unchanged lines hidden (view full) --- 619 return; 620 621 c_delbefore(el, n); /* delete before dot */ 622 el->el_line.cursor -= n; 623 if (el->el_line.cursor < el->el_line.buffer) 624 el->el_line.cursor = el->el_line.buffer; 625} 626 |
627/* el_deletestr1(): 628 * Delete characters between starn and end 629 */ 630int 631el_deletestr1(EditLine *el, int start, int end) 632{ 633 size_t line_lenght, len; 634 wchar_t * p1, * p2; 635 636 if (end <= start) 637 return 0; 638 639 line_lenght = (size_t) (el->el_line.lastchar - el->el_line.buffer); 640 641 if (start >= (int) line_lenght || end >= (int) line_lenght) 642 return 0; 643 644 len = (size_t) (end - start); 645 if (len > line_lenght - (size_t) end) 646 len = line_lenght - (size_t) end; 647 648 p1 = el->el_line.buffer + start; 649 p2 = el->el_line.buffer + end; 650 for (size_t i = 0; i < len; i++){ 651 *p1++ = *p2++; 652 el->el_line.lastchar--; 653 } 654 655 if (el->el_line.cursor < el->el_line.buffer) 656 el->el_line.cursor = el->el_line.buffer; 657 658 return end - start; 659} 660 |
|
627/* el_wreplacestr(): 628 * Replace the contents of the line with the provided string 629 */ 630int 631el_wreplacestr(EditLine *el, const wchar_t *s) 632{ 633 size_t len; 634 wchar_t * p; --- 142 unchanged lines hidden --- | 661/* el_wreplacestr(): 662 * Replace the contents of the line with the provided string 663 */ 664int 665el_wreplacestr(EditLine *el, const wchar_t *s) 666{ 667 size_t len; 668 wchar_t * p; --- 142 unchanged lines hidden --- |