Skip to content

Commit

Permalink
Use memmove instead of memcpy for overlapping memory area. (reproduci…
Browse files Browse the repository at this point in the history
…ble on OpenBSD).
  • Loading branch information
rfivet committed Aug 26, 2022
1 parent 737fee5 commit 041210b
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 15 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# README #

µEMACS (ue) on Cygwin/Linux/NetBSD, based on uEmacs/PK (em) from [kernel.org](
https://git.kernel.org/pub/scm/editors/uemacs/uemacs.git/).
µEMACS (ue) on Cygwin/MSYS2/Linux/NetBSD/OpenBSD, based on uEmacs/PK (em)
from [kernel.org](https://git.kernel.org/pub/scm/editors/uemacs/uemacs.git/).

### Changes compare to uEmacs/PK ###

Expand All @@ -26,6 +26,6 @@ https://git.kernel.org/pub/scm/editors/uemacs/uemacs.git/).

### How to build ###

* dependencies: gcc, gmake, ncurses-devel.
* dependencies: (gcc || clang) && gmake && ncurses-devel.

* make
2 changes: 1 addition & 1 deletion defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#if __unix__ || (defined(__APPLE__) && defined(__MACH__))
# define UNIX 1
# if __NetBSD__ || (defined(__APPLE__) && defined(__MACH__))
# if __NetBSD__ || __OpenBSD__ || (defined(__APPLE__) && defined(__MACH__))
# define BSD 1
# define POSIX 1
# elif __linux__
Expand Down
6 changes: 2 additions & 4 deletions exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,9 +557,7 @@ static int dobuf( buffer_p bp) {
/* remove leading spaces */
if( eline != lp->l_text) {
int size = lp->l_used = eol - eline ;
if( size)
memcpy( lp->l_text, eline, size) ;

memmove( lp->l_text, eline, size) ;
eline = lp->l_text ;
eol = &lp->l_text[ size] ;
}
Expand Down Expand Up @@ -595,7 +593,7 @@ static int dobuf( buffer_p bp) {
/* turn line into a string */
int size = lp->l_used - 6 ;
if( size)
memcpy( lp->l_text, &eline[ 6], size) ;
memmove( lp->l_text, &eline[ 6], size) ;

eline = lp->l_text ;
eline[ size] = 0 ;
Expand Down
2 changes: 1 addition & 1 deletion line.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ boolean lnewline( void) {

memcpy( lp2->l_text, lp1->l_text, doto) ;
lp1->l_used -= doto ;
memcpy( lp1->l_text, &lp1->l_text[ doto], lp1->l_used) ;
memmove( lp1->l_text, &lp1->l_text[ doto], lp1->l_used) ;
lp2->l_fp = lp1 ;
lp2->l_bp = lp1->l_bp ;
lp1->l_bp = lp2 ;
Expand Down
4 changes: 0 additions & 4 deletions pklock.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#ifdef SVR4
#include <string.h>
#else
#include <strings.h>
#endif
#include <errno.h>

#include "util.h"
Expand Down
8 changes: 6 additions & 2 deletions posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ int ttcol = -1 ; /* Column location of HW cursor */

/* Define missing macroes for BSD and CYGWIN environment */
#if BSD
#define OLCUC 0000002
#define XCASE 0000004
# ifndef OLCUC
# define OLCUC 0000002
# endif
# ifndef XCASE
# define XCASE 0000004
# endif
#endif

#ifdef __CYGWIN__ /* gcc predefined (see cpp -dM) */
Expand Down

0 comments on commit 041210b

Please sign in to comment.