Skip to content

Commit 36f5184

Browse files
authored
Remove memmove, bcopy, strerror and VPCOMPAT macros (#805)
1 parent a00b602 commit 36f5184

File tree

12 files changed

+4
-234
lines changed

12 files changed

+4
-234
lines changed

BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ copy_file(
2222

2323
LOCAL_DEFINES = [
2424
"HAVE_CONFIG_H",
25-
"HAVE_MEMMOVE",
26-
"HAVE_STRERROR",
2725
"PCRE2_STATIC",
2826
"SUPPORT_PCRE2_8",
2927
"SUPPORT_UNICODE",

CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,8 @@ check_include_file(sys/types.h HAVE_SYS_TYPES_H)
172172
check_include_file(unistd.h HAVE_UNISTD_H)
173173
check_include_file(windows.h HAVE_WINDOWS_H)
174174

175-
check_symbol_exists(bcopy "strings.h" HAVE_BCOPY)
176175
check_symbol_exists(memfd_create "sys/mman.h" HAVE_MEMFD_CREATE)
177-
check_symbol_exists(memmove "string.h" HAVE_MEMMOVE)
178176
check_symbol_exists(secure_getenv "stdlib.h" HAVE_SECURE_GETENV)
179-
check_symbol_exists(strerror "string.h" HAVE_STRERROR)
180177

181178
check_c_source_compiles(
182179
[=[

build.zig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ pub fn build(b: *std.Build) !void {
3131
.HAVE_BUILTIN_UNREACHABLE = true,
3232
.HAVE_VISIBILITY = true,
3333

34-
.HAVE_MEMMOVE = true,
35-
.HAVE_STRERROR = true,
36-
3734
.SUPPORT_PCRE2_8 = codeUnitWidth == CodeUnitWidth.@"8",
3835
.SUPPORT_PCRE2_16 = codeUnitWidth == CodeUnitWidth.@"16",
3936
.SUPPORT_PCRE2_32 = codeUnitWidth == CodeUnitWidth.@"32",

configure.ac

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -578,11 +578,7 @@ Boolean macros such as HAVE_STDLIB_H and SUPPORT_PCRE2_8 should either be
578578
defined (conventionally to 1) for TRUE, and not defined at all for FALSE. All
579579
such macros are listed as a commented #undef in config.h.generic. Macros such
580580
as MATCH_LIMIT, whose actual value is relevant, have defaults defined, but are
581-
surrounded by #ifndef/#endif lines so that the value can be overridden by -D.
582-
583-
PCRE2 uses memmove() if HAVE_MEMMOVE is defined; otherwise it uses bcopy() if
584-
HAVE_BCOPY is defined. If your system has neither bcopy() nor memmove(), make
585-
sure both macros are undefined; an emulation function will then be used. */])
581+
surrounded by #ifndef/#endif lines so that the value can be overridden by -D. */])
586582

587583
# Checks for header files.
588584
AC_CHECK_HEADERS(assert.h limits.h sys/types.h sys/stat.h dirent.h)
@@ -627,7 +623,7 @@ AC_TYPE_SIZE_T
627623

628624
# Checks for library functions.
629625

630-
AC_CHECK_FUNCS(bcopy memfd_create memmove mkostemp secure_getenv strerror)
626+
AC_CHECK_FUNCS(memfd_create mkostemp secure_getenv)
631627
AC_MSG_CHECKING([for realpath])
632628
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
633629
#include <stdlib.h>

maint/README

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,6 @@ new release.
226226
maint/RunPerlTest shell script can be used to do this testing in Unix-like
227227
environment.
228228

229-
- It is possible to test with the emulated memmove() function by undefining
230-
HAVE_MEMMOVE and HAVE_BCOPY in config.h, though I do not do this often.
231-
232229
- Check the external testing tools. CodeQL & Clang Static Analyzer report
233230
their results to the GitHub "Security" dashboard. Coverity has its own
234231
external dashboard, as does OSS-Fuzz. Since we have these tools, we should

src/config-cmake.h.in

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@
1111
#cmakedefine HAVE_UNISTD_H 1
1212
#cmakedefine HAVE_WINDOWS_H 1
1313

14-
#cmakedefine HAVE_BCOPY 1
1514
#cmakedefine HAVE_MEMFD_CREATE 1
16-
#cmakedefine HAVE_MEMMOVE 1
1715
#cmakedefine HAVE_SECURE_GETENV 1
18-
#cmakedefine HAVE_STRERROR 1
1916

2017
#cmakedefine SUPPORT_PCRE2_8 1
2118
#cmakedefine SUPPORT_PCRE2_16 1

src/config.h.generic

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,7 @@ Boolean macros such as HAVE_STDLIB_H and SUPPORT_PCRE2_8 should either be
2222
defined (conventionally to 1) for TRUE, and not defined at all for FALSE. All
2323
such macros are listed as a commented #undef in config.h.generic. Macros such
2424
as MATCH_LIMIT, whose actual value is relevant, have defaults defined, but are
25-
surrounded by #ifndef/#endif lines so that the value can be overridden by -D.
26-
27-
PCRE2 uses memmove() if HAVE_MEMMOVE is defined; otherwise it uses bcopy() if
28-
HAVE_BCOPY is defined. If your system has neither bcopy() nor memmove(), make
29-
sure both macros are undefined; an emulation function will then be used. */
25+
surrounded by #ifndef/#endif lines so that the value can be overridden by -D. */
3026

3127
/* By default, the \R escape sequence matches any Unicode line ending
3228
character or sequence of characters. If BSR_ANYCRLF is defined (to any
@@ -63,9 +59,6 @@ sure both macros are undefined; an emulation function will then be used. */
6359
/* Define this if your compiler supports __attribute__((uninitialized)) */
6460
/* #undef HAVE_ATTRIBUTE_UNINITIALIZED */
6561

66-
/* Define to 1 if you have the `bcopy' function. */
67-
/* #undef HAVE_BCOPY */
68-
6962
/* Define this if your compiler provides __assume() */
7063
/* #undef HAVE_BUILTIN_ASSUME */
7164

@@ -99,9 +92,6 @@ sure both macros are undefined; an emulation function will then be used. */
9992
/* Define to 1 if you have the `memfd_create' function. */
10093
/* #undef HAVE_MEMFD_CREATE */
10194

102-
/* Define to 1 if you have the `memmove' function. */
103-
/* #undef HAVE_MEMMOVE */
104-
10595
/* Define to 1 if you have the <minix/config.h> header file. */
10696
/* #undef HAVE_MINIX_CONFIG_H */
10797

@@ -138,9 +128,6 @@ sure both macros are undefined; an emulation function will then be used. */
138128
/* Define to 1 if you have the <stdlib.h> header file. */
139129
/* #undef HAVE_STDLIB_H */
140130

141-
/* Define to 1 if you have the `strerror' function. */
142-
/* #undef HAVE_STRERROR */
143-
144131
/* Define to 1 if you have the <strings.h> header file. */
145132
/* #undef HAVE_STRINGS_H */
146133

src/pcre2_internal.h

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -209,28 +209,6 @@ code that a non-static object is being referenced. */
209209
#define PRIV(name) _pcre2_##name
210210
#endif
211211

212-
/* When compiling for use with the Virtual Pascal compiler, these functions
213-
need to have their names changed. PCRE2 must be compiled with the -DVPCOMPAT
214-
option on the command line. */
215-
216-
#ifdef VPCOMPAT
217-
#define strlen(s) _strlen(s)
218-
#define strncmp(s1,s2,m) _strncmp(s1,s2,m)
219-
#define memcmp(s,c,n) _memcmp(s,c,n)
220-
#define memcpy(d,s,n) _memcpy(d,s,n)
221-
#define memmove(d,s,n) _memmove(d,s,n)
222-
#define memset(s,c,n) _memset(s,c,n)
223-
#else /* VPCOMPAT */
224-
225-
/* Otherwise, to cope with SunOS4 and other systems that lack memmove(), define
226-
a macro that calls an emulating function. */
227-
228-
#ifndef HAVE_MEMMOVE
229-
#undef memmove /* Some systems may have a macro */
230-
#define memmove(a, b, c) PRIV(memmove)(a, b, c)
231-
#endif /* not HAVE_MEMMOVE */
232-
#endif /* not VPCOMPAT */
233-
234212
/* This is an unsigned int value that no UTF character can ever have, as
235213
Unicode doesn't go beyond 0x0010ffff. */
236214

@@ -2380,13 +2358,6 @@ extern BOOL _pcre2_xclass(uint32_t, PCRE2_SPTR, const uint8_t *, BOOL);
23802358
extern BOOL _pcre2_eclass(uint32_t, PCRE2_SPTR, PCRE2_SPTR,
23812359
const uint8_t *, BOOL);
23822360

2383-
/* This function is needed only when memmove() is not available. */
2384-
2385-
#if !defined(VPCOMPAT) && !defined(HAVE_MEMMOVE)
2386-
#define _pcre2_memmove PCRE2_SUFFIX(_pcre2_memmove)
2387-
extern void * _pcre2_memmove(void *, const void *, size_t);
2388-
#endif
2389-
23902361
#endif /* PCRE2_CODE_UNIT_WIDTH */
23912362

23922363
#include "pcre2_util.h"

src/pcre2_string_utils.c

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -48,42 +48,6 @@ functions work only on 8-bit data. */
4848

4949

5050

51-
/*************************************************
52-
* Emulated memmove() for systems without it *
53-
*************************************************/
54-
55-
/* This function can make use of bcopy() if it is available. Otherwise do it by
56-
steam, as there some non-Unix environments that lack both memmove() and
57-
bcopy(). */
58-
59-
#if !defined(VPCOMPAT) && !defined(HAVE_MEMMOVE)
60-
void *
61-
PRIV(memmove)(void *d, const void *s, size_t n)
62-
{
63-
#ifdef HAVE_BCOPY
64-
bcopy(s, d, n);
65-
return d;
66-
#else
67-
size_t i;
68-
unsigned char *dest = (unsigned char *)d;
69-
const unsigned char *src = (const unsigned char *)s;
70-
if (dest > src)
71-
{
72-
dest += n;
73-
src += n;
74-
for (i = 0; i < n; ++i) *(--dest) = *(--src);
75-
return (void *)dest;
76-
}
77-
else
78-
{
79-
for (i = 0; i < n; ++i) *dest++ = *src++;
80-
return (void *)(dest - n);
81-
}
82-
#endif /* not HAVE_BCOPY */
83-
}
84-
#endif /* not VPCOMPAT && not HAVE_MEMMOVE */
85-
86-
8751
/*************************************************
8852
* Compare two zero-terminated PCRE2 strings *
8953
*************************************************/

src/pcre2grep.c

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -535,44 +535,6 @@ const char utf8_table4[] = {
535535
3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5 };
536536

537537

538-
#if !defined(VPCOMPAT) && !defined(HAVE_MEMMOVE)
539-
/*************************************************
540-
* Emulated memmove() for systems without it *
541-
*************************************************/
542-
543-
/* This function can make use of bcopy() if it is available. Otherwise do it by
544-
steam, as there are some non-Unix environments that lack both memmove() and
545-
bcopy(). */
546-
547-
static void *
548-
emulated_memmove(void *d, const void *s, size_t n)
549-
{
550-
#ifdef HAVE_BCOPY
551-
bcopy(s, d, n);
552-
return d;
553-
#else
554-
size_t i;
555-
unsigned char *dest = (unsigned char *)d;
556-
const unsigned char *src = (const unsigned char *)s;
557-
if (dest > src)
558-
{
559-
dest += n;
560-
src += n;
561-
for (i = 0; i < n; ++i) *(--dest) = *(--src);
562-
return (void *)dest;
563-
}
564-
else
565-
{
566-
for (i = 0; i < n; ++i) *dest++ = *src++;
567-
return (void *)(dest - n);
568-
}
569-
#endif /* not HAVE_BCOPY */
570-
}
571-
#undef memmove
572-
#define memmove(d,s,n) emulated_memmove(d,s,n)
573-
#endif /* not VPCOMPAT && not HAVE_MEMMOVE */
574-
575-
576538

577539
/*************************************************
578540
* Convert code point to UTF-8 *
@@ -1175,28 +1137,6 @@ FWRITE_IGNORE(buf, 1, length, stdout);
11751137

11761138

11771139

1178-
#ifndef HAVE_STRERROR
1179-
/*************************************************
1180-
* Provide strerror() for non-ANSI libraries *
1181-
*************************************************/
1182-
1183-
/* Some old-fashioned systems still around (e.g. SunOS4) don't have strerror()
1184-
in their libraries, but can provide the same facility by this simple
1185-
alternative function. */
1186-
1187-
extern int sys_nerr;
1188-
extern char *sys_errlist[];
1189-
1190-
char *
1191-
strerror(int n)
1192-
{
1193-
if (n < 0 || n >= sys_nerr) return "unknown error number";
1194-
return sys_errlist[n];
1195-
}
1196-
#endif /* HAVE_STRERROR */
1197-
1198-
1199-
12001140
/*************************************************
12011141
* Usage function *
12021142
*************************************************/

0 commit comments

Comments
 (0)