/[pcre]/code/trunk/pcre_internal.h
ViewVC logotype

Diff of /code/trunk/pcre_internal.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 96 by nigel, Fri Mar 2 13:10:43 2007 UTC revision 145 by ph10, Wed Apr 4 14:06:52 2007 UTC
# Line 7  Line 7 
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
# Line 83  setjmp and stdarg are used is when NO_RE Line 83  setjmp and stdarg are used is when NO_RE
83  #include <stdlib.h>  #include <stdlib.h>
84  #include <string.h>  #include <string.h>
85    
86  #ifndef PCRE_SPY  /* When compiling a DLL for Windows, the exported symbols have to be declared
87  #define PCRE_DEFINITION       /* Win32 __declspec(export) trigger for .dll */  using some MS magic. I found some useful information on this web page:
88    http://msdn2.microsoft.com/en-us/library/y4h7bcy6(VS.80).aspx. According to the
89    information there, using __declspec(dllesport) without "extern" we have a
90    definition; with "extern" we have a declaration. The settings here override the
91    setting in pcre.h (which is included below); it defines only PCRE_EXP_DECL,
92    which is all that is needed for applications, which import the symbols. We use:
93    
94      PCRE_EXP_DECL       for declarations
95      PCRE_EXP_DEFN       for definitions of exported functions
96      PCRE_EXP_DATA_DEFN  for definitions of exported variables
97    
98    The reason for the two DEFN macros is that in non-Windows environments, one
99    does not want to have "extern" before variable definitions because it leads to
100    compiler warnings. So we distinguish between functions and variables. In
101    Windows, the two should always be the same.
102    
103    The reason for wrapping this in #ifndef PCRE_EXP_DECL is so that pcretest,
104    which is an application, but needs to import this file in order to "peek" at
105    internals, can #include pcre.h first, can get an application's-eye view.
106    
107    In principle, people compiling for non-Windows, non-Unix-like (i.e. uncommon,
108    special-purpose environments) might want to stick other stuff in front of
109    exported symbols. That's why, in the non-Windows case, we set PCRE_EXP_DEFN and
110    PCRE_EXP_DATA_DEFN only if they are not already set. */
111    
112    #ifndef PCRE_EXP_DECL
113    #  ifdef _WIN32
114    #    ifdef DLL_EXPORT
115    #      define PCRE_EXP_DECL       extern __declspec(dllexport)
116    #      define PCRE_EXP_DEFN       __declspec(dllexport)
117    #      define PCRE_EXP_DATA_DEFN  __declspec(dllexport)
118    #    else
119    #      define PCRE_EXP_DECL       extern
120    #      define PCRE_EXP_DEFN
121    #      define PCRE_EXP_DATA_DEFN
122    #    endif
123    #
124    #  else
125    #    ifdef __cplusplus
126    #      define PCRE_EXP_DECL       extern "C"
127    #    else
128    #      define PCRE_EXP_DECL       extern
129    #    endif
130    #    ifndef PCRE_EXP_DEFN
131    #      define PCRE_EXP_DEFN       PCRE_EXP_DECL
132    #    endif
133    #    ifndef PCRE_EXP_DATA_DEFN
134    #      define PCRE_EXP_DATA_DEFN
135    #    endif
136    #  endif
137  #endif  #endif
138    
139  /* We need to have types that specify unsigned 16-bit and 32-bit integers. We  /* We need to have types that specify unsigned 16-bit and 32-bit integers. We
# Line 178  must begin with PCRE_. */ Line 227  must begin with PCRE_. */
227  #define USPTR const unsigned char *  #define USPTR const unsigned char *
228  #endif  #endif
229    
230    
231    
232  /* Include the public PCRE header and the definitions of UCP character property  /* Include the public PCRE header and the definitions of UCP character property
233  values. */  values. */
234    
235  #include "pcre.h"  #include <pcre.h>
236  #include "ucp.h"  #include "ucp.h"
237    
238  /* When compiling for use with the Virtual Pascal compiler, these functions  /* When compiling for use with the Virtual Pascal compiler, these functions
# Line 189  need to have their names changed. PCRE m Line 240  need to have their names changed. PCRE m
240  option on the command line. */  option on the command line. */
241    
242  #ifdef VPCOMPAT  #ifdef VPCOMPAT
243    #define strlen(s)        _strlen(s)
244  #define strncmp(s1,s2,m) _strncmp(s1,s2,m)  #define strncmp(s1,s2,m) _strncmp(s1,s2,m)
245    #define memcmp(s,c,n)    _memcmp(s,c,n)
246  #define memcpy(d,s,n)    _memcpy(d,s,n)  #define memcpy(d,s,n)    _memcpy(d,s,n)
247  #define memmove(d,s,n)   _memmove(d,s,n)  #define memmove(d,s,n)   _memmove(d,s,n)
248  #define memset(s,c,n)    _memset(s,c,n)  #define memset(s,c,n)    _memset(s,c,n)
# Line 198  option on the command line. */ Line 251  option on the command line. */
251  /* 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(),
252  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
253  is set. Otherwise, include an emulating function for those systems that have  is set. Otherwise, include an emulating function for those systems that have
254  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. */  
255    
256  #if ! HAVE_MEMMOVE  #ifndef HAVE_MEMMOVE
257  #undef  memmove        /* some systems may have a macro */  #undef  memmove        /* some systems may have a macro */
258  #if HAVE_BCOPY  #ifdef HAVE_BCOPY
259  #define memmove(a, b, c) bcopy(b, a, c)  #define memmove(a, b, c) bcopy(b, a, c)
260  #else  /* HAVE_BCOPY */  #else  /* HAVE_BCOPY */
261  static void *  static void *
262  pcre_memmove(unsigned char *dest, const unsigned char *src, size_t n)  pcre_memmove(void *d, const void *s, size_t n)
263  {  {
264  size_t i;  size_t i;
265  dest += n;  unsigned char *dest = (unsigned char *)d;
266  src += n;  const unsigned char *src = (const unsigned char *)s;
267  for (i = 0; i < n; ++i) *(--dest) =  *(--src);  if (dest > src)
268  return dest;    {
269      dest += n;
270      src += n;
271      for (i = 0; i < n; ++i) *(--dest) = *(--src);
272      return (void *)dest;
273      }
274    else
275      {
276      for (i = 0; i < n; ++i) *dest++ = *src++;
277      return (void *)(dest - n);
278      }
279  }  }
280  #define memmove(a, b, c) pcre_memmove(a, b, c)  #define memmove(a, b, c) pcre_memmove(a, b, c)
281  #endif   /* not HAVE_BCOPY */  #endif   /* not HAVE_BCOPY */

Legend:
Removed from v.96  
changed lines
  Added in v.145

  ViewVC Help
Powered by ViewVC 1.1.5