Skip to content

Commit 52c0de1

Browse files
committed
patch 8.0.0241: fallback implementation of mch_memmove is unused
Problem: Vim defines a mch_memmove() function but it doesn't work, thus is always unused. Solution: Remove the mch_memmove implementation. (suggested by Dominique Pelle)
1 parent 4f7090b commit 52c0de1

4 files changed

Lines changed: 8 additions & 45 deletions

File tree

src/misc2.c

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,34 +1740,6 @@ vim_memset(void *ptr, int c, size_t size)
17401740
}
17411741
#endif
17421742

1743-
/* skipped when generating prototypes, the prototype is in vim.h */
1744-
#ifdef VIM_MEMMOVE
1745-
/*
1746-
* Version of memmove() that handles overlapping source and destination.
1747-
* For systems that don't have a function that is guaranteed to do that (SYSV).
1748-
*/
1749-
void
1750-
mch_memmove(void *src_arg, void *dst_arg, size_t len)
1751-
{
1752-
/*
1753-
* A void doesn't have a size, we use char pointers.
1754-
*/
1755-
char *dst = dst_arg, *src = src_arg;
1756-
1757-
/* overlap, copy backwards */
1758-
if (dst > src && dst < src + len)
1759-
{
1760-
src += len;
1761-
dst += len;
1762-
while (len-- > 0)
1763-
*--dst = *--src;
1764-
}
1765-
else /* copy forwards */
1766-
while (len-- > 0)
1767-
*dst++ = *src++;
1768-
}
1769-
#endif
1770-
17711743
#if (!defined(HAVE_STRCASECMP) && !defined(HAVE_STRICMP)) || defined(PROTO)
17721744
/*
17731745
* Compare two strings, ignoring case, using current locale.

src/os_unix.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -423,21 +423,17 @@ typedef struct dsc$descriptor DESC;
423423
# endif
424424
#endif
425425

426-
/* memmove is not present on all systems, use memmove, bcopy, memcpy or our
427-
* own version */
428-
/* Some systems have (void *) arguments, some (char *). If we use (char *) it
426+
/* memmove() is not present on all systems, use memmove, bcopy or memcpy.
427+
* Some systems have (void *) arguments, some (char *). If we use (char *) it
429428
* works for all */
430-
#ifdef USEMEMMOVE
429+
#if defined(USEMEMMOVE) || (!defined(USEBCOPY) && !defined(USEMEMCPY))
431430
# define mch_memmove(to, from, len) memmove((char *)(to), (char *)(from), len)
432431
#else
433432
# ifdef USEBCOPY
434433
# define mch_memmove(to, from, len) bcopy((char *)(from), (char *)(to), len)
435434
# else
436-
# ifdef USEMEMCPY
435+
/* ifdef USEMEMCPY */
437436
# define mch_memmove(to, from, len) memcpy((char *)(to), (char *)(from), len)
438-
# else
439-
# define VIM_MEMMOVE /* found in misc2.c */
440-
# endif
441437
# endif
442438
#endif
443439

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,8 @@ static char *(features[]) =
764764

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
241,
767769
/**/
768770
240,
769771
/**/

src/vim.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,15 +1714,8 @@ typedef unsigned short disptick_T; /* display tick type */
17141714

17151715
typedef void *vim_acl_T; /* dummy to pass an ACL to a function */
17161716

1717-
/*
1718-
* Include a prototype for mch_memmove(), it may not be in alloc.pro.
1719-
*/
1720-
#ifdef VIM_MEMMOVE
1721-
void mch_memmove(void *, void *, size_t);
1722-
#else
1723-
# ifndef mch_memmove
1724-
# define mch_memmove(to, from, len) memmove(to, from, len)
1725-
# endif
1717+
#ifndef mch_memmove
1718+
# define mch_memmove(to, from, len) memmove((char*)(to), (char*)(from), (char*)(len))
17261719
#endif
17271720

17281721
/*

0 commit comments

Comments
 (0)