| 7 |
and semantics are as close as possible to those of the Perl 5 language. |
and semantics are as close as possible to those of the Perl 5 language. |
| 8 |
|
|
| 9 |
Written by Philip Hazel |
Written by Philip Hazel |
| 10 |
Copyright (c) 1997-2006 University of Cambridge |
Copyright (c) 1997-2007 University of Cambridge |
| 11 |
|
|
| 12 |
----------------------------------------------------------------------------- |
----------------------------------------------------------------------------- |
| 13 |
Redistribution and use in source and binary forms, with or without |
Redistribution and use in source and binary forms, with or without |
| 189 |
option on the command line. */ |
option on the command line. */ |
| 190 |
|
|
| 191 |
#ifdef VPCOMPAT |
#ifdef VPCOMPAT |
| 192 |
|
#define strlen(s) _strlen(s) |
| 193 |
#define strncmp(s1,s2,m) _strncmp(s1,s2,m) |
#define strncmp(s1,s2,m) _strncmp(s1,s2,m) |
| 194 |
|
#define memcmp(s,c,n) _memcmp(s,c,n) |
| 195 |
#define memcpy(d,s,n) _memcpy(d,s,n) |
#define memcpy(d,s,n) _memcpy(d,s,n) |
| 196 |
#define memmove(d,s,n) _memmove(d,s,n) |
#define memmove(d,s,n) _memmove(d,s,n) |
| 197 |
#define memset(s,c,n) _memset(s,c,n) |
#define memset(s,c,n) _memset(s,c,n) |
| 200 |
/* To cope with SunOS4 and other systems that lack memmove() but have bcopy(), |
/* To cope with SunOS4 and other systems that lack memmove() but have bcopy(), |
| 201 |
define a macro for memmove() if HAVE_MEMMOVE is false, provided that HAVE_BCOPY |
define a macro for memmove() if HAVE_MEMMOVE is false, provided that HAVE_BCOPY |
| 202 |
is set. Otherwise, include an emulating function for those systems that have |
is set. Otherwise, include an emulating function for those systems that have |
| 203 |
neither (there some non-Unix environments where this is the case). This assumes |
neither (there some non-Unix environments where this is the case). */ |
|
that all calls to memmove are moving strings upwards in store, which is the |
|
|
case in PCRE. */ |
|
| 204 |
|
|
| 205 |
#if ! HAVE_MEMMOVE |
#if ! HAVE_MEMMOVE |
| 206 |
#undef memmove /* some systems may have a macro */ |
#undef memmove /* some systems may have a macro */ |
| 208 |
#define memmove(a, b, c) bcopy(b, a, c) |
#define memmove(a, b, c) bcopy(b, a, c) |
| 209 |
#else /* HAVE_BCOPY */ |
#else /* HAVE_BCOPY */ |
| 210 |
static void * |
static void * |
| 211 |
pcre_memmove(unsigned char *dest, const unsigned char *src, size_t n) |
pcre_memmove(void *d, const void *s, size_t n) |
| 212 |
{ |
{ |
| 213 |
size_t i; |
size_t i; |
| 214 |
dest += n; |
unsigned char *dest = (unsigned char *)d; |
| 215 |
src += n; |
const unsigned char *src = (const unsigned char *)s; |
| 216 |
for (i = 0; i < n; ++i) *(--dest) = *(--src); |
if (dest > src) |
| 217 |
return dest; |
{ |
| 218 |
|
dest += n; |
| 219 |
|
src += n; |
| 220 |
|
for (i = 0; i < n; ++i) *(--dest) = *(--src); |
| 221 |
|
return (void *)dest; |
| 222 |
|
} |
| 223 |
|
else |
| 224 |
|
{ |
| 225 |
|
for (i = 0; i < n; ++i) *dest++ = *src++; |
| 226 |
|
return (void *)(dest - n); |
| 227 |
|
} |
| 228 |
} |
} |
| 229 |
#define memmove(a, b, c) pcre_memmove(a, b, c) |
#define memmove(a, b, c) pcre_memmove(a, b, c) |
| 230 |
#endif /* not HAVE_BCOPY */ |
#endif /* not HAVE_BCOPY */ |