[erlang-bugs] R12B-5 hide private libpcre patch

Paul Fisher pfisher@REDACTED
Wed Dec 31 22:14:16 CET 2008


A while ago I had reported that the libpcre code compiled into 
beam(.smp) interfered with linked-in drivers because of incompatible 
changes to the code.  The solution is to hide the entry points so that 
they are not resolved from linked-in driver code that expects to 
dynamically resolve to libpcre.so.3.

The following patch renames the public entry points to be prefixed with 
erts_pcre_ and has worked in our environment:

diff -ur otp_src_R12B-5.orig/erts/emulator/beam/erl_bif_re.c 
otp_src_R12B-5/erts/emulator/beam/erl_bif_re.c
--- otp_src_R12B-5.orig/erts/emulator/beam/erl_bif_re.c	2008-11-24 
08:48:37.920967010 -0600
+++ otp_src_R12B-5/erts/emulator/beam/erl_bif_re.c	2008-11-24 
09:22:54.770789631 -0600
@@ -61,10 +61,10 @@

  void erts_init_bif_re(void)
  {
-    pcre_malloc = &erts_pcre_malloc;
-    pcre_free = &erts_pcre_free;
-    pcre_stack_malloc = &erts_pcre_stack_malloc;
-    pcre_stack_free = &erts_pcre_stack_free;
+    erts_pcre_malloc_f = &erts_pcre_malloc;
+    erts_pcre_free_f = &erts_pcre_free;
+    erts_pcre_stack_malloc_f = &erts_pcre_stack_malloc;
+    erts_pcre_stack_free_f = &erts_pcre_stack_free;
      default_table = NULL; /* ISO8859-1 default, forced into pcre */
      max_loop_limit = CONTEXT_REDS * LOOP_FACTOR;

@@ -389,12 +389,12 @@
  	hp += 3;
  	ret = TUPLE2(hp, error_tag, ret);
      } else {
-	pcre_fullinfo(result, NULL, PCRE_INFO_SIZE, &pattern_size);
-	pcre_fullinfo(result, NULL, PCRE_INFO_CAPTURECOUNT, &capture_count);
+	erts_pcre_fullinfo(result, NULL, PCRE_INFO_SIZE, &pattern_size);
+	erts_pcre_fullinfo(result, NULL, PCRE_INFO_CAPTURECOUNT, &capture_count);
  	/* XXX: Optimize - keep in offheap binary to allow this to
  	   be kept across traps w/o need of copying */
  	ret = new_binary(p, (byte *) result, pattern_size);
-	pcre_free(result);
+	erts_pcre_free(result);
  	hp = HAlloc(p, (with_ok) ? (3+5) : 5);
  	ret = TUPLE4(hp,am_re_pattern, make_small(capture_count), 
make_small(unicode),ret);
  	if (with_ok) {
@@ -448,8 +448,8 @@
  	BIF_ERROR(BIF_P,BADARG);
      }
      expr[slen]='\0';
-    result = pcre_compile2(expr, options, &errcode,
-			   &errstr, &errofset, default_table);
+    result = erts_pcre_compile2(expr, options, &errcode,
+                                &errstr, &errofset, default_table);

      ret = build_compile_result(BIF_P, am_error, result, errcode,
  			       errstr, errofset, unicode, 1);
@@ -495,7 +495,7 @@
  static void cleanup_restart_context(RestartContext *rc)
  {
      if (rc->restart_data != NULL) {
-	pcre_free_restart_data(rc->restart_data);
+	erts_pcre_free_restart_data(rc->restart_data);
  	rc->restart_data = NULL;
      }
      if (rc->ovector != NULL) {
@@ -767,7 +767,7 @@
  			}
  			tmpb[slen] = '\0';
  		    }
-		    if ((ri->v[ri->num_spec - 1] = pcre_get_stringnumber(code,tmpb)) ==
+		    if ((ri->v[ri->num_spec - 1] = 
erts_pcre_get_stringnumber(code,tmpb)) ==
  			PCRE_ERROR_NOSUBSTRING) {
  			ri->v[ri->num_spec - 1] = -1;
  		    }
@@ -849,8 +849,8 @@
  		BIF_ERROR(BIF_P,BADARG);
  	    }
  	    expr[slen]='\0';
-	    result = pcre_compile2(expr, comp_options, &errcode,
-				   &errstr, &errofset, default_table);
+	    result = erts_pcre_compile2(expr, comp_options, &errcode,
+                                        &errstr, &errofset, default_table);
  	    if (!result) {
  		erts_free(ERTS_ALC_T_RE_TMP_BUF, expr);
  		/* Compilation error gives badarg except in the compile
@@ -876,12 +876,12 @@
  		BIF_TRAP3(grun_trap_exportp, BIF_P, BIF_ARG_1, precompiled, r);
  	    }

-	    pcre_fullinfo(result, NULL, PCRE_INFO_SIZE, &code_size);
-	    pcre_fullinfo(result, NULL, PCRE_INFO_CAPTURECOUNT, &capture_count);
+	    erts_pcre_fullinfo(result, NULL, PCRE_INFO_SIZE, &code_size);
+	    erts_pcre_fullinfo(result, NULL, PCRE_INFO_CAPTURECOUNT, 
&capture_count);
  	    ovsize = 3*(capture_count+1);
  	    restart.code = erts_alloc(ERTS_ALC_T_RE_SUBJECT, code_size);
  	    memcpy(restart.code, result, code_size);
-	    pcre_free(result);
+	    erts_pcre_free(result);
  	    erts_free(ERTS_ALC_T_RE_TMP_BUF, expr);
  	    /*unicode = (pflags & PARSE_FLAG_UNICODE) ? 1 : 0;*/
  	} else {
@@ -967,7 +967,7 @@
      loop_count = 0xFFFFFFFF;
  #endif

-    rc = pcre_exec(restart.code, &(restart.extra), restart.subject, 
slength, startoffset,
+    rc = erts_pcre_exec(restart.code, &(restart.extra), 
restart.subject, slength, startoffset,
  		   options, restart.ovector, ovsize);
      ASSERT(loop_count != 0xFFFFFFFF);
      BUMP_REDS(BIF_P, loop_count / LOOP_FACTOR);
@@ -1035,7 +1035,7 @@
  #ifdef DEBUG
      loop_count = 0xFFFFFFFF;
  #endif
-    rc = pcre_exec(NULL, &(restartp->extra), NULL, 0, 0, 0, NULL, 0);
+    rc = erts_pcre_exec(NULL, &(restartp->extra), NULL, 0, 0, 0, NULL, 0);
      ASSERT(loop_count != 0xFFFFFFFF);
      BUMP_REDS(BIF_P, loop_count / LOOP_FACTOR);
      if (rc == PCRE_ERROR_LOOP_LIMIT) {
diff -ur otp_src_R12B-5.orig/erts/emulator/pcre/pcre_compile.c 
otp_src_R12B-5/erts/emulator/pcre/pcre_compile.c
--- otp_src_R12B-5.orig/erts/emulator/pcre/pcre_compile.c	2008-11-24 
08:48:37.874132417 -0600
+++ otp_src_R12B-5/erts/emulator/pcre/pcre_compile.c	2008-11-24 
09:22:26.143832254 -0600
@@ -5786,15 +5786,15 @@
  */

  PCRE_EXP_DEFN pcre *
-pcre_compile(const char *pattern, int options, const char **errorptr,
+erts_pcre_compile(const char *pattern, int options, const char **errorptr,
    int *erroroffset, const unsigned char *tables)
  {
-return pcre_compile2(pattern, options, NULL, errorptr, erroroffset, 
tables);
+return erts_pcre_compile2(pattern, options, NULL, errorptr, 
erroroffset, tables);
  }


  PCRE_EXP_DEFN pcre *
-pcre_compile2(const char *pattern, int options, int *errorcodeptr,
+erts_pcre_compile2(const char *pattern, int options, int *errorcodeptr,
    const char **errorptr, int *erroroffset, const unsigned char *tables)
  {
  real_pcre *re;
@@ -6022,7 +6022,7 @@
  cd->name_entry_size. */

  size = length + sizeof(real_pcre) + cd->names_found * 
(cd->name_entry_size + 3);
-re = (real_pcre *)(pcre_malloc)(size);
+re = (real_pcre *)(erts_pcre_malloc_f)(size);

  if (re == NULL)
    {
@@ -6118,7 +6118,7 @@

  if (errorcode != 0)
    {
-  (pcre_free)(re);
+  (erts_pcre_free_f)(re);
    PCRE_EARLY_ERROR_RETURN:
    *erroroffset = ptr - (const uschar *)pattern;
    PCRE_EARLY_ERROR_RETURN2:
@@ -6206,7 +6206,7 @@

  if (code - codestart > length)
    {
-  (pcre_free)(re);
+  (erts_pcre_free_f)(re);
    *errorptr = find_error_text(ERR23);
    *erroroffset = ptr - (uschar *)pattern;
    if (errorcodeptr != NULL) *errorcodeptr = ERR23;
diff -ur otp_src_R12B-5.orig/erts/emulator/pcre/pcre_config.c 
otp_src_R12B-5/erts/emulator/pcre/pcre_config.c
--- otp_src_R12B-5.orig/erts/emulator/pcre/pcre_config.c	2008-11-24 
08:48:37.896839943 -0600
+++ otp_src_R12B-5/erts/emulator/pcre/pcre_config.c	2008-11-24 
09:11:51.900473970 -0600
@@ -63,7 +63,7 @@
  */

  PCRE_EXP_DEFN int
-pcre_config(int what, void *where)
+erts_pcre_config(int what, void *where)
  {
  switch (what)
    {
diff -ur otp_src_R12B-5.orig/erts/emulator/pcre/pcre_dfa_exec.c 
otp_src_R12B-5/erts/emulator/pcre/pcre_dfa_exec.c
--- otp_src_R12B-5.orig/erts/emulator/pcre/pcre_dfa_exec.c	2008-11-24 
08:48:37.875955067 -0600
+++ otp_src_R12B-5/erts/emulator/pcre/pcre_dfa_exec.c	2008-11-24 
09:22:12.611173554 -0600
@@ -2404,7 +2404,7 @@
        /* Handle callouts */

        case OP_CALLOUT:
-      if (pcre_callout != NULL)
+      if (erts_pcre_callout_f != NULL)
          {
          int rrc;
          pcre_callout_block cb;
@@ -2420,7 +2420,7 @@
          cb.capture_top      = 1;
          cb.capture_last     = -1;
          cb.callout_data     = md->callout_data;
-        if ((rrc = (*pcre_callout)(&cb)) < 0) return rrc;   /* Abandon */
+        if ((rrc = (*erts_pcre_callout_f)(&cb)) < 0) return rrc;   /* 
Abandon */
          if (rrc == 0) { ADD_ACTIVE(state_offset + 2 + 2*LINK_SIZE, 0); }
          }
        break;
@@ -2506,7 +2506,7 @@
  */

  PCRE_EXP_DEFN int
-pcre_dfa_exec(const pcre *argument_re, const pcre_extra *extra_data,
+erts_pcre_dfa_exec(const pcre *argument_re, const pcre_extra *extra_data,
    const char *subject, int length, int start_offset, int options, int 
*offsets,
    int offsetcount, int *workspace, int wscount)
  {
diff -ur otp_src_R12B-5.orig/erts/emulator/pcre/pcre_exec.c 
otp_src_R12B-5/erts/emulator/pcre/pcre_exec.c
--- otp_src_R12B-5.orig/erts/emulator/pcre/pcre_exec.c	2008-11-24 
08:48:37.876553392 -0600
+++ otp_src_R12B-5/erts/emulator/pcre/pcre_exec.c	2008-11-24 
09:22:23.386491532 -0600
@@ -275,7 +275,7 @@

  #define RMATCH(ra,rb,rc,rd,re,rf,rg,rw)\
    {\
-  heapframe *newframe = (pcre_stack_malloc)(sizeof(heapframe));\
+  heapframe *newframe = (erts_pcre_stack_malloc_f)(sizeof(heapframe));\
    frame->Xwhere = rw; \
    newframe->Xeptr = ra;\
    newframe->Xecode = rb;\
@@ -298,7 +298,7 @@
    {\
    heapframe *newframe = frame;\
    frame = newframe->Xprevframe;\
-  (pcre_stack_free)(newframe);\
+  (erts_pcre_stack_free_f)(newframe);\
    if (frame != NULL)\
      {\
      rrc = ra;\
@@ -315,7 +315,7 @@
    {\
    heapframe *newframe = frame;\
    frame = newframe->Xprevframe;\
-  (pcre_stack_free)(newframe);\
+  (erts_pcre_stack_free_f)(newframe);\
    if (frame != NULL)\
      {\
      rrc = ra;\
@@ -491,11 +491,11 @@
    EDEBUGF(("Break restore!"));
    goto LOOP_COUNT_RETURN;
  }
-frame = (pcre_stack_malloc)(sizeof(heapframe));
+frame = (erts_pcre_stack_malloc_f)(sizeof(heapframe));
  #else
  #define COST(N)
  #define COST_CHK(N)
-heapframe *frame = (pcre_stack_malloc)(sizeof(heapframe));
+heapframe *frame = (erts_pcre_stack_malloc_f)(sizeof(heapframe));
  #endif

  frame->Xprevframe = NULL;            /* Marks the top level */
@@ -1038,7 +1038,7 @@
      function is able to force a failure. */

      case OP_CALLOUT:
-    if (pcre_callout != NULL)
+    if (erts_pcre_callout_f != NULL)
        {
        pcre_callout_block cb;
        cb.version          = 1;   /* Version 1 of the callout block */
@@ -1053,7 +1053,7 @@
        cb.capture_top      = offset_top/2;
        cb.capture_last     = md->capture_last;
        cb.callout_data     = md->callout_data;
-      if ((rrc = (*pcre_callout)(&cb)) > 0) RRETURN(MATCH_NOMATCH);
+      if ((rrc = (*erts_pcre_callout_f)(&cb)) > 0) RRETURN(MATCH_NOMATCH);
        if (rrc < 0) RRETURN(rrc);
        }
      ecode += 2 + 2*LINK_SIZE;
@@ -1102,7 +1102,7 @@
        else
          {
          new_recursive.offset_save =
-          (int *)(pcre_malloc)(new_recursive.saved_max * sizeof(int));
+          (int *)(erts_pcre_malloc_f)(new_recursive.saved_max * 
sizeof(int));
          if (new_recursive.offset_save == NULL) 
RRETURN(PCRE_ERROR_NOMEMORY);
          }

@@ -1125,7 +1125,7 @@
            DPRINTF(("Recursion matched\n"));
            md->recursive = new_recursive.prevrec;
            if (new_recursive.offset_save != stacksave)
-            (pcre_free)(new_recursive.offset_save);
+            (erts_pcre_free_f)(new_recursive.offset_save);
            RRETURN(MATCH_MATCH);
            }
          else if (rrc != MATCH_NOMATCH && rrc != MATCH_THEN)
@@ -1144,7 +1144,7 @@
        DPRINTF(("Recursion didn't match\n"));
        md->recursive = new_recursive.prevrec;
        if (new_recursive.offset_save != stacksave)
-        (pcre_free)(new_recursive.offset_save);
+        (erts_pcre_free_f)(new_recursive.offset_save);
        RRETURN(MATCH_NOMATCH);
        }
      /* Control never reaches here */
@@ -4442,7 +4442,7 @@
     utf8 = newframe->Xcur_is_word;
     minimize = newframe->Xcondition;
     possessive = newframe->Xprev_is_word;
-   (pcre_stack_free)(newframe);
+   (erts_pcre_stack_free_f)(newframe);
     EDEBUGF(("LOOP_COUNT_RETURN: %d",frame->Xwhere));
     switch (frame->Xwhere)
       {
@@ -4467,7 +4467,7 @@
     * possessive                     Xprev_is_word
     */
    {
-    heapframe *newframe = (pcre_stack_malloc)(sizeof(heapframe));
+    heapframe *newframe = (erts_pcre_stack_malloc_f)(sizeof(heapframe));
      newframe->Xprevframe = frame;
      newframe->Xop = rrc;
      newframe->Xfi = i;
@@ -4489,7 +4489,7 @@
  static void free_saved_match_state(heapframe *top) {
    while (top != NULL) {
      heapframe *nxt = top->Xprevframe;
-     (pcre_stack_free)(top);
+     (erts_pcre_stack_free_f)(top);
       top = nxt;
    }
  }
@@ -4617,7 +4617,7 @@
  #endif

  PCRE_EXP_DEFN int
-pcre_exec(const pcre *argument_re, const pcre_extra *extra_data,
+erts_pcre_exec(const pcre *argument_re, const pcre_extra *extra_data,
    PCRE_SPTR subject, int length, int start_offset, int options, int 
*offsets,
    int offsetcount)
  {
@@ -4721,7 +4721,7 @@
   } else {
     if (extra_data != NULL &&
         (extra_data->flags & PCRE_EXTRA_LOOP_LIMIT)) {
-     exec_context = (PcreExecContext *) 
(pcre_malloc)(sizeof(PcreExecContext));
+     exec_context = (PcreExecContext *) 
(erts_pcre_malloc_f)(sizeof(PcreExecContext));
       *(extra_data->restart_data) = (void *) exec_context;
       /* need freeing by special routine from client */
     } else {
@@ -4944,7 +4944,7 @@
  if (re->top_backref > 0 && re->top_backref >= ocount/3)
    {
    ocount = re->top_backref * 3 + 3;
-  md->offset_vector = (int *)(pcre_malloc)(ocount * sizeof(int));
+  md->offset_vector = (int *)(erts_pcre_malloc_f)(ocount * sizeof(int));
    if (md->offset_vector == NULL) return PCRE_ERROR_NOMEMORY;
    using_temporary_offsets = TRUE;
    DPRINTF(("Got memory to hold back references\n"));
@@ -5304,10 +5304,10 @@
  #ifdef ERLANG_INTEGRATION
      if (extra_data == NULL ||
  	!(extra_data->flags & PCRE_EXTRA_LOOP_LIMIT)) {
-	(pcre_free)(md->offset_vector);
+	(erts_pcre_free_f)(md->offset_vector);
      }
  #else
-	(pcre_free)(md->offset_vector);
+	(erts_pcre_free_f)(md->offset_vector);
  #endif
      }

@@ -5336,7 +5336,7 @@
  if (using_temporary_offsets)
    {
    DPRINTF(("Freeing temporary memory\n"));
-  (pcre_free)(md->offset_vector);
+  (erts_pcre_free_f)(md->offset_vector);
    }

  if (rc != MATCH_NOMATCH)
@@ -5375,16 +5375,16 @@
  #undef re
  #undef ims

-void pcre_free_restart_data(void *restart_data) {
+void erts_pcre_free_restart_data(void *restart_data) {
    PcreExecContext *top = (PcreExecContext *) restart_data;
    /* We might be done, or we might not, so there might be some saved 
match_states here */
    if (top != NULL) {
      match_data *md = top->Xmd;
      if (top->Xusing_temporary_offsets && md->offset_vector != NULL) {
-	(pcre_free)(md->offset_vector);
+	(erts_pcre_free_f)(md->offset_vector);
      }
      free_saved_match_state(top->Xmd->state_save);
-    (pcre_free)(top);
+    (erts_pcre_free_f)(top);
    }
  }
  #endif
diff -ur otp_src_R12B-5.orig/erts/emulator/pcre/pcre_fullinfo.c 
otp_src_R12B-5/erts/emulator/pcre/pcre_fullinfo.c
--- otp_src_R12B-5.orig/erts/emulator/pcre/pcre_fullinfo.c	2008-11-24 
08:48:37.874225285 -0600
+++ otp_src_R12B-5/erts/emulator/pcre/pcre_fullinfo.c	2008-11-24 
09:11:46.425871337 -0600
@@ -66,8 +66,8 @@
  */

  PCRE_EXP_DEFN int
-pcre_fullinfo(const pcre *argument_re, const pcre_extra *extra_data, 
int what,
-  void *where)
+erts_pcre_fullinfo(const pcre *argument_re, const pcre_extra *extra_data,
+                 int what, void *where)
  {
  real_pcre internal_re;
  pcre_study_data internal_study;
diff -ur otp_src_R12B-5.orig/erts/emulator/pcre/pcre_get.c 
otp_src_R12B-5/erts/emulator/pcre/pcre_get.c
--- otp_src_R12B-5.orig/erts/emulator/pcre/pcre_get.c	2008-11-24 
08:48:37.896368417 -0600
+++ otp_src_R12B-5/erts/emulator/pcre/pcre_get.c	2008-11-24 
12:42:06.283498362 -0600
@@ -65,21 +65,22 @@
                  (PCRE_ERROR_NOSUBSTRING) if not found
  */

+PCRE_EXP_DEFN
  int
-pcre_get_stringnumber(const pcre *code, const char *stringname)
+erts_pcre_get_stringnumber(const pcre *code, const char *stringname)
  {
  int rc;
  int entrysize;
  int top, bot;
  uschar *nametable;

-if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)
+if ((rc = erts_pcre_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)
    return rc;
  if (top <= 0) return PCRE_ERROR_NOSUBSTRING;

-if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMEENTRYSIZE, 
&entrysize)) != 0)
+if ((rc = erts_pcre_fullinfo(code, NULL, PCRE_INFO_NAMEENTRYSIZE, 
&entrysize)) != 0)
    return rc;
-if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)
+if ((rc = erts_pcre_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, 
&nametable)) != 0)
    return rc;

  bot = 0;
@@ -114,8 +115,9 @@
                  (PCRE_ERROR_NOSUBSTRING) if not found
  */

+PCRE_EXP_DEFN
  int
-pcre_get_stringtable_entries(const pcre *code, const char *stringname,
+erts_pcre_get_stringtable_entries(const pcre *code, const char *stringname,
    char **firstptr, char **lastptr)
  {
  int rc;
@@ -123,13 +125,13 @@
  int top, bot;
  uschar *nametable, *lastentry;

-if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)
+if ((rc = erts_pcre_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)
    return rc;
  if (top <= 0) return PCRE_ERROR_NOSUBSTRING;

-if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMEENTRYSIZE, 
&entrysize)) != 0)
+if ((rc = erts_pcre_fullinfo(code, NULL, PCRE_INFO_NAMEENTRYSIZE, 
&entrysize)) != 0)
    return rc;
-if ((rc = pcre_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)
+if ((rc = erts_pcre_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, 
&nametable)) != 0)
    return rc;

  lastentry = nametable + entrysize * (top - 1);
@@ -190,8 +192,8 @@
  char *first, *last;
  uschar *entry;
  if ((re->options & PCRE_DUPNAMES) == 0 && (re->flags & PCRE_JCHANGED) 
== 0)
-  return pcre_get_stringnumber(code, stringname);
-entrysize = pcre_get_stringtable_entries(code, stringname, &first, &last);
+  return erts_pcre_get_stringnumber(code, stringname);
+entrysize = erts_pcre_get_stringtable_entries(code, stringname, &first, 
&last);
  if (entrysize <= 0) return entrysize;
  for (entry = (uschar *)first; entry <= (uschar *)last; entry += entrysize)
    {
@@ -231,8 +233,9 @@
                     PCRE_ERROR_NOSUBSTRING (-7) no such captured substring
  */

+PCRE_EXP_DEFN
  int
-pcre_copy_substring(const char *subject, int *ovector, int stringcount,
+erts_pcre_copy_substring(const char *subject, int *ovector, int 
stringcount,
    int stringnumber, char *buffer, int size)
  {
  int yield;
@@ -276,13 +279,14 @@
                     PCRE_ERROR_NOSUBSTRING (-7) no such captured substring
  */

+PCRE_EXP_DEFN
  int
-pcre_copy_named_substring(const pcre *code, const char *subject, int 
*ovector,
+erts_pcre_copy_named_substring(const pcre *code, const char *subject, 
int *ovector,
    int stringcount, const char *stringname, char *buffer, int size)
  {
  int n = get_first_set(code, stringname, ovector);
  if (n <= 0) return n;
-return pcre_copy_substring(subject, ovector, stringcount, n, buffer, size);
+return erts_pcre_copy_substring(subject, ovector, stringcount, n, 
buffer, size);
  }


@@ -308,8 +312,9 @@
                     PCRE_ERROR_NOMEMORY (-6) failed to get store
  */

+PCRE_EXP_DEFN
  int
-pcre_get_substring_list(const char *subject, int *ovector, int stringcount,
+erts_pcre_get_substring_list(const char *subject, int *ovector, int 
stringcount,
    const char ***listptr)
  {
  int i;
@@ -321,7 +326,7 @@
  for (i = 0; i < double_count; i += 2)
    size += sizeof(char *) + ovector[i+1] - ovector[i] + 1;

-stringlist = (char **)(pcre_malloc)(size);
+stringlist = (char **)(erts_pcre_malloc_f)(size);
  if (stringlist == NULL) return PCRE_ERROR_NOMEMORY;

  *listptr = (const char **)stringlist;
@@ -353,10 +358,11 @@
  Returns:    nothing
  */

+PCRE_EXP_DEFN
  void
-pcre_free_substring_list(const char **pointer)
+erts_pcre_free_substring_list(const char **pointer)
  {
-(pcre_free)((void *)pointer);
+(erts_pcre_free_f)((void *)pointer);
  }


@@ -386,8 +392,9 @@
                     PCRE_ERROR_NOSUBSTRING (-7) substring not present
  */

+PCRE_EXP_DEFN
  int
-pcre_get_substring(const char *subject, int *ovector, int stringcount,
+erts_pcre_get_substring(const char *subject, int *ovector, int stringcount,
    int stringnumber, const char **stringptr)
  {
  int yield;
@@ -396,7 +403,7 @@
    return PCRE_ERROR_NOSUBSTRING;
  stringnumber *= 2;
  yield = ovector[stringnumber+1] - ovector[stringnumber];
-substring = (char *)(pcre_malloc)(yield + 1);
+substring = (char *)(erts_pcre_malloc_f)(yield + 1);
  if (substring == NULL) return PCRE_ERROR_NOMEMORY;
  memcpy(substring, subject + ovector[stringnumber], yield);
  substring[yield] = 0;
@@ -433,13 +440,14 @@
                     PCRE_ERROR_NOSUBSTRING (-7) no such captured substring
  */

+PCRE_EXP_DEFN
  int
-pcre_get_named_substring(const pcre *code, const char *subject, int 
*ovector,
+erts_pcre_get_named_substring(const pcre *code, const char *subject, 
int *ovector,
    int stringcount, const char *stringname, const char **stringptr)
  {
  int n = get_first_set(code, stringname, ovector);
  if (n <= 0) return n;
-return pcre_get_substring(subject, ovector, stringcount, n, stringptr);
+return erts_pcre_get_substring(subject, ovector, stringcount, n, 
stringptr);
  }


@@ -456,10 +464,11 @@
  Returns:    nothing
  */

+PCRE_EXP_DEFN
  void
-pcre_free_substring(const char *pointer)
+erts_pcre_free_substring(const char *pointer)
  {
-(pcre_free)((void *)pointer);
+(erts_pcre_free_f)((void *)pointer);
  }

  /* End of pcre_get.c */
Only in otp_src_R12B-5/erts/emulator/pcre: pcre_get.c~
diff -ur otp_src_R12B-5.orig/erts/emulator/pcre/pcre_globals.c 
otp_src_R12B-5/erts/emulator/pcre/pcre_globals.c
--- otp_src_R12B-5.orig/erts/emulator/pcre/pcre_globals.c	2008-11-24 
08:48:37.876134005 -0600
+++ otp_src_R12B-5/erts/emulator/pcre/pcre_globals.c	2008-11-24 
09:22:21.490581180 -0600
@@ -53,11 +53,11 @@
  #include "pcre_internal.h"

  #ifndef VPCOMPAT
-PCRE_EXP_DATA_DEFN void *(*pcre_malloc)(size_t) = malloc;
-PCRE_EXP_DATA_DEFN void  (*pcre_free)(void *) = free;
-PCRE_EXP_DATA_DEFN void *(*pcre_stack_malloc)(size_t) = malloc;
-PCRE_EXP_DATA_DEFN void  (*pcre_stack_free)(void *) = free;
-PCRE_EXP_DATA_DEFN int   (*pcre_callout)(pcre_callout_block *) = NULL;
+PCRE_EXP_DATA_DEFN void *(*erts_pcre_malloc_f)(size_t) = malloc;
+PCRE_EXP_DATA_DEFN void  (*erts_pcre_free_f)(void *) = free;
+PCRE_EXP_DATA_DEFN void *(*erts_pcre_stack_malloc_f)(size_t) = malloc;
+PCRE_EXP_DATA_DEFN void  (*erts_pcre_stack_free_f)(void *) = free;
+PCRE_EXP_DATA_DEFN int   (*erts_pcre_callout_f)(pcre_callout_block *) = 
NULL;
  #endif

  /* End of pcre_globals.c */
diff -ur otp_src_R12B-5.orig/erts/emulator/pcre/pcre.h 
otp_src_R12B-5/erts/emulator/pcre/pcre.h
--- otp_src_R12B-5.orig/erts/emulator/pcre/pcre.h	2008-11-24 
08:48:37.895104421 -0600
+++ otp_src_R12B-5/erts/emulator/pcre/pcre.h	2008-11-24 
09:17:42.955780881 -0600
@@ -261,55 +261,55 @@
  have to take another form. */

  #ifndef VPCOMPAT
-PCRE_EXP_DECL void *(*pcre_malloc)(size_t);
-PCRE_EXP_DECL void  (*pcre_free)(void *);
-PCRE_EXP_DECL void *(*pcre_stack_malloc)(size_t);
-PCRE_EXP_DECL void  (*pcre_stack_free)(void *);
-PCRE_EXP_DECL int   (*pcre_callout)(pcre_callout_block *);
+PCRE_EXP_DECL void *(*erts_pcre_malloc_f)(size_t);
+PCRE_EXP_DECL void  (*erts_pcre_free_f)(void *);
+PCRE_EXP_DECL void *(*erts_pcre_stack_malloc_f)(size_t);
+PCRE_EXP_DECL void  (*erts_pcre_stack_free_f)(void *);
+PCRE_EXP_DECL int   (*erts_pcre_callout_f)(pcre_callout_block *);
  #else   /* VPCOMPAT */
-PCRE_EXP_DECL void *pcre_malloc(size_t);
-PCRE_EXP_DECL void  pcre_free(void *);
-PCRE_EXP_DECL void *pcre_stack_malloc(size_t);
-PCRE_EXP_DECL void  pcre_stack_free(void *);
-PCRE_EXP_DECL int   pcre_callout(pcre_callout_block *);
+PCRE_EXP_DECL void *erts_pcre_malloc_f(size_t);
+PCRE_EXP_DECL void  erts_pcre_free_f(void *);
+PCRE_EXP_DECL void *erts_pcre_stack_malloc_f(size_t);
+PCRE_EXP_DECL void  erts_pcre_stack_free_f(void *);
+PCRE_EXP_DECL int   erts_pcre_callout_f(pcre_callout_block *);
  #endif  /* VPCOMPAT */

  /* Exported PCRE functions */

-PCRE_EXP_DECL pcre *pcre_compile(const char *, int, const char **, int *,
+PCRE_EXP_DECL pcre *erts_pcre_compile(const char *, int, const char **, 
int *,
                    const unsigned char *);
-PCRE_EXP_DECL pcre *pcre_compile2(const char *, int, int *, const char **,
+PCRE_EXP_DECL pcre *erts_pcre_compile2(const char *, int, int *, const 
char **,
                    int *, const unsigned char *);
-PCRE_EXP_DECL int  pcre_config(int, void *);
-PCRE_EXP_DECL int  pcre_copy_named_substring(const pcre *, const char *,
+PCRE_EXP_DECL int  erts_pcre_config(int, void *);
+PCRE_EXP_DECL int  erts_pcre_copy_named_substring(const pcre *, const 
char *,
                    int *, int, const char *, char *, int);
-PCRE_EXP_DECL int  pcre_copy_substring(const char *, int *, int, int, 
char *,
+PCRE_EXP_DECL int  erts_pcre_copy_substring(const char *, int *, int, 
int, char *,
                    int);
-PCRE_EXP_DECL int  pcre_dfa_exec(const pcre *, const pcre_extra *,
+PCRE_EXP_DECL int  erts_pcre_dfa_exec(const pcre *, const pcre_extra *,
                    const char *, int, int, int, int *, int , int *, int);
-PCRE_EXP_DECL int  pcre_exec(const pcre *, const pcre_extra *, PCRE_SPTR,
+PCRE_EXP_DECL int  erts_pcre_exec(const pcre *, const pcre_extra *, 
PCRE_SPTR,
                     int, int, int, int *, int);
-PCRE_EXP_DECL void pcre_free_substring(const char *);
-PCRE_EXP_DECL void pcre_free_substring_list(const char **);
-PCRE_EXP_DECL int  pcre_fullinfo(const pcre *, const pcre_extra *, int,
+PCRE_EXP_DECL void erts_pcre_free_substring(const char *);
+PCRE_EXP_DECL void erts_pcre_free_substring_list(const char **);
+PCRE_EXP_DECL int  erts_pcre_fullinfo(const pcre *, const pcre_extra *, 
int,
                    void *);
-PCRE_EXP_DECL int  pcre_get_named_substring(const pcre *, const char *,
+PCRE_EXP_DECL int  erts_pcre_get_named_substring(const pcre *, const 
char *,
                    int *, int, const char *, const char **);
-PCRE_EXP_DECL int  pcre_get_stringnumber(const pcre *, const char *);
-PCRE_EXP_DECL int  pcre_get_stringtable_entries(const pcre *, const char *,
+PCRE_EXP_DECL int  erts_pcre_get_stringnumber(const pcre *, const char *);
+PCRE_EXP_DECL int  erts_pcre_get_stringtable_entries(const pcre *, 
const char *,
                    char **, char **);
-PCRE_EXP_DECL int  pcre_get_substring(const char *, int *, int, int,
+PCRE_EXP_DECL int  erts_pcre_get_substring(const char *, int *, int, int,
                    const char **);
-PCRE_EXP_DECL int  pcre_get_substring_list(const char *, int *, int,
+PCRE_EXP_DECL int  erts_pcre_get_substring_list(const char *, int *, int,
                    const char ***);
-PCRE_EXP_DECL int  pcre_info(const pcre *, int *, int *);
-PCRE_EXP_DECL const unsigned char *pcre_maketables(void);
-PCRE_EXP_DECL int  pcre_refcount(pcre *, int);
-PCRE_EXP_DECL pcre_extra *pcre_study(const pcre *, int, const char **);
-PCRE_EXP_DECL const char *pcre_version(void);
+PCRE_EXP_DECL int  erts_pcre_info(const pcre *, int *, int *);
+PCRE_EXP_DECL const unsigned char *erts_pcre_maketables(void);
+PCRE_EXP_DECL int  erts_pcre_refcount(pcre *, int);
+PCRE_EXP_DECL pcre_extra *erts_pcre_study(const pcre *, int, const char 
**);
+PCRE_EXP_DECL const char *erts_pcre_version(void);

  #ifdef ERLANG_INTEGRATION
-PCRE_EXP_DECL void  pcre_free_restart_data(void *restart_data);
+PCRE_EXP_DECL void  erts_pcre_free_restart_data(void *restart_data);
  #endif
  #ifdef __cplusplus
  }  /* extern "C" */
diff -ur otp_src_R12B-5.orig/erts/emulator/pcre/pcre_info.c 
otp_src_R12B-5/erts/emulator/pcre/pcre_info.c
--- otp_src_R12B-5.orig/erts/emulator/pcre/pcre_info.c	2008-11-24 
08:48:37.876051985 -0600
+++ otp_src_R12B-5/erts/emulator/pcre/pcre_info.c	2008-11-24 
09:11:44.595525247 -0600
@@ -73,7 +73,7 @@
  */

  PCRE_EXP_DEFN int
-pcre_info(const pcre *argument_re, int *optptr, int *first_byte)
+erts_pcre_info(const pcre *argument_re, int *optptr, int *first_byte)
  {
  real_pcre internal_re;
  const real_pcre *re = (const real_pcre *)argument_re;
diff -ur otp_src_R12B-5.orig/erts/emulator/pcre/pcre_maketables.c 
otp_src_R12B-5/erts/emulator/pcre/pcre_maketables.c
--- otp_src_R12B-5.orig/erts/emulator/pcre/pcre_maketables.c	2008-11-24 
08:48:37.897015923 -0600
+++ otp_src_R12B-5/erts/emulator/pcre/pcre_maketables.c	2008-11-24 
09:22:27.483868368 -0600
@@ -73,7 +73,7 @@
  int i;

  #ifndef DFTABLES
-yield = (unsigned char*)(pcre_malloc)(tables_length);
+yield = (unsigned char*)(erts_pcre_malloc_f)(tables_length);
  #else
  yield = (unsigned char*)malloc(tables_length);
  #endif
diff -ur otp_src_R12B-5.orig/erts/emulator/pcre/pcre_refcount.c 
otp_src_R12B-5/erts/emulator/pcre/pcre_refcount.c
--- otp_src_R12B-5.orig/erts/emulator/pcre/pcre_refcount.c	2008-11-24 
08:48:37.896195159 -0600
+++ otp_src_R12B-5/erts/emulator/pcre/pcre_refcount.c	2008-11-24 
09:11:42.645337836 -0600
@@ -69,7 +69,7 @@
  */

  PCRE_EXP_DEFN int
-pcre_refcount(pcre *argument_re, int adjust)
+erts_pcre_refcount(pcre *argument_re, int adjust)
  {
  real_pcre *re = (real_pcre *)argument_re;
  if (re == NULL) return PCRE_ERROR_NULL;
diff -ur otp_src_R12B-5.orig/erts/emulator/pcre/pcre_study.c 
otp_src_R12B-5/erts/emulator/pcre/pcre_study.c
--- otp_src_R12B-5.orig/erts/emulator/pcre/pcre_study.c	2008-11-24 
08:48:37.896931557 -0600
+++ otp_src_R12B-5/erts/emulator/pcre/pcre_study.c	2008-11-24 
09:19:15.702477776 -0600
@@ -496,7 +496,7 @@
  */

  PCRE_EXP_DEFN pcre_extra *
-pcre_study(const pcre *external_re, int options, const char **errorptr)
+erts_pcre_study(const pcre *external_re, int options, const char 
**errorptr)
  {
  uschar start_bits[32];
  pcre_extra *extra;
@@ -556,7 +556,7 @@
  the pcre_fullinfo() function so that if it becomes variable in the 
future, we
  don't have to change that code. */

-extra = (pcre_extra *)(pcre_malloc)
+extra = (pcre_extra *)(erts_pcre_malloc_f)
    (sizeof(pcre_extra) + sizeof(pcre_study_data));

  if (extra == NULL)
diff -ur otp_src_R12B-5.orig/erts/emulator/pcre/pcre_version.c 
otp_src_R12B-5/erts/emulator/pcre/pcre_version.c
--- otp_src_R12B-5.orig/erts/emulator/pcre/pcre_version.c	2008-11-24 
08:48:37.896282894 -0600
+++ otp_src_R12B-5/erts/emulator/pcre/pcre_version.c	2008-11-24 
09:11:38.519598556 -0600
@@ -80,7 +80,7 @@
  the STRING macro with an empty argument when doing the test. */

  PCRE_EXP_DEFN const char *
-pcre_version(void)
+erts_pcre_version(void)
  {
  return (XSTRING(Z PCRE_PRERELEASE)[1] == 0)?
    XSTRING(PCRE_MAJOR.PCRE_MINOR PCRE_DATE) :


--
paul



More information about the erlang-bugs mailing list