PennMUSH Community
Show
Ignore:
Timestamp:
12/28/07 19:57:17 (1 year ago)
Author:
shawnw
Message:

Merge devel into trunk for p6 release

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • 1.8.3/trunk/src/funlist.c

    r1117 r1167  
    1818#include "function.h" 
    1919#include "mymalloc.h" 
    20 #include "pcre.h" 
     20#include "mypcre.h" 
    2121#include "match.h" 
    2222#include "command.h" 
     
    139139 */ 
    140140void 
    141 arr2list(char *r[], int max, char *list, char **lp, char *sep) 
     141arr2list(char *r[], int max, char *list, char **lp, const char *sep) 
    142142{ 
    143143  int i; 
     
    26752675{ 
    26762676  pcre *re; 
    2677   pcre_extra *study = NULL; 
     2677  pcre_extra *extra, *study = NULL; 
    26782678  const char *errptr; 
    26792679  int subpatterns; 
     
    27472747      study = pcre_study(re, 0, &errptr); 
    27482748      if (errptr != NULL) { 
    2749         mush_free((Malloc_t) re, "pcre"); 
     2749        mush_free(re, "pcre"); 
    27502750        safe_str(T("#-1 REGEXP ERROR: "), buff, bp); 
    27512751        safe_str(errptr, buff, bp); 
     
    27592759    } 
    27602760 
     2761    if (study) { 
     2762      extra = study; 
     2763      set_match_limit(extra); 
     2764    } else 
     2765      extra = default_match_limit(); 
     2766 
    27612767    search = 0; 
    27622768    /* Do all the searches and replaces we can */ 
    27632769 
    27642770    start = prebuf; 
    2765     subpatterns = pcre_exec(re, study, prebuf, prelen, 0, 0, offsets, 99); 
     2771    subpatterns = pcre_exec(re, extra, prebuf, prelen, 0, 0, offsets, 99); 
    27662772 
    27672773    /* Match wasn't found... we're done */ 
    27682774    if (subpatterns < 0) { 
    27692775      safe_str(prebuf, postbuf, &postp); 
    2770       mush_free((Malloc_t) re, "pcre"); 
     2776      mush_free(re, "pcre"); 
    27712777      free_ansi_string(orig); 
    27722778      if (study) 
    2773         mush_free((Malloc_t) study, "pcre.extra"); 
     2779        mush_free(study, "pcre.extra"); 
    27742780      continue; 
    27752781    } 
     
    28052811        match_offset++; 
    28062812    } while (all && match_offset < prelen && 
    2807              (subpatterns = pcre_exec(re, study, prebuf, prelen, 
     2813             (subpatterns = pcre_exec(re, extra, prebuf, prelen, 
    28082814                                      match_offset, 0, offsets, 99)) >= 0); 
    28092815 
     
    28112817    *postp = '\0'; 
    28122818 
    2813     mush_free((Malloc_t) re, "pcre"); 
     2819    mush_free(re, "pcre"); 
    28142820    if (study != NULL) 
    2815       mush_free((Malloc_t) study, "pcre.extra"); 
     2821      mush_free(study, "pcre.extra"); 
    28162822    free_ansi_string(orig); 
    28172823  } 
     
    28492855        study = pcre_study(re, 0, &errptr); 
    28502856        if (errptr != NULL) { 
    2851           mush_free((Malloc_t) re, "pcre"); 
     2857          mush_free(re, "pcre"); 
    28522858          safe_str(T("#-1 REGEXP ERROR: "), buff, bp); 
    28532859          safe_str(errptr, buff, bp); 
     
    28602866          add_check("pcre.extra"); 
    28612867      } 
     2868      if (study) { 
     2869        extra = study; 
     2870        set_match_limit(extra); 
     2871      } else 
     2872        extra = default_match_limit(); 
     2873 
    28622874      search = 0; 
    28632875      /* Do all the searches and replaces we can */ 
    28642876      do { 
    28652877        subpatterns = 
    2866           pcre_exec(re, study, orig->text, orig->len, search, 0, offsets, 99); 
     2878          pcre_exec(re, extra, orig->text, orig->len, search, 0, offsets, 99); 
    28672879        if (subpatterns >= 0) { 
    28682880          /* We have a match */ 
     
    29012913        } 
    29022914      } while (subpatterns >= 0 && all); 
    2903       mush_free((Malloc_t) re, "pcre"); 
     2915      mush_free(re, "pcre"); 
    29042916      if (study != NULL) 
    2905         mush_free((Malloc_t) study, "pcre.extra"); 
     2917        mush_free(study, "pcre.extra"); 
    29062918    } 
    29072919    safe_ansi_string(orig, 0, orig->len, buff, bp); 
     
    29322944  char *qregs[NUMQ], *holder[NUMQ]; 
    29332945  pcre *re; 
     2946  pcre_extra *extra; 
    29342947  const char *errptr; 
    29352948  int erroffset; 
     
    29652978  } 
    29662979  add_check("pcre"); 
    2967   subpatterns = pcre_exec(re, NULL, txt, arglens[0], 0, 0, offsets, 99); 
     2980  extra = default_match_limit(); 
     2981 
     2982  subpatterns = pcre_exec(re, extra, txt, arglens[0], 0, 0, offsets, 99); 
    29682983  safe_integer(subpatterns >= 0, buff, bp); 
    29692984 
     
    30503065  } 
    30513066  for (i = 0; i < nqregs; i++) { 
    3052     mush_free((Malloc_t) holder[i], "regmatch"); 
    3053   } 
    3054   mush_free((Malloc_t) re, "pcre"); 
     3067    mush_free(holder[i], "regmatch"); 
     3068  } 
     3069  mush_free(re, "pcre"); 
    30553070  free_ansi_string(as); 
    30563071} 
     
    30743089  int erroffset; 
    30753090  int flags = 0; 
    3076  
     3091  bool free_study; 
    30773092  dbref it = match_thing(executor, args[0]); 
     3093 
    30783094  reharg.first = 0; 
    30793095  if (it == NOTHING || it == AMBIGUOUS) { 
     
    31103126    return; 
    31113127  } 
    3112   if (reharg.study) 
     3128  if (reharg.study) { 
    31133129    add_check("pcre.extra"); 
     3130    free_study = true; 
     3131    set_match_limit(reharg.study); 
     3132  } else { 
     3133    free_study = false; 
     3134    reharg.study = default_match_limit(); 
     3135  } 
    31143136 
    31153137  reharg.buff = buff; 
     
    31183140  atr_iter_get(executor, it, args[1], 0, regrep_helper, (void *) &reharg); 
    31193141  mush_free(reharg.re, "pcre"); 
    3120   if (reharg.study) 
     3142  if (free_study) 
    31213143    mush_free(reharg.study, "pcre.extra"); 
    31223144} 
     
    31543176  size_t rlen; 
    31553177  pcre *re; 
    3156   pcre_extra *study
     3178  pcre_extra *study, *extra
    31573179  const char *errptr; 
    31583180  int erroffset; 
     
    31953217    return; 
    31963218  } 
    3197   if (study) 
     3219  if (study) { 
    31983220    add_check("pcre.extra"); 
     3221    extra = study; 
     3222    set_match_limit(extra); 
     3223  } else 
     3224    extra = default_match_limit(); 
    31993225 
    32003226  do { 
    32013227    r = remove_markup(split_token(&s, sep), &rlen); 
    3202     if (pcre_exec(re, study, r, rlen - 1, 0, 0, offsets, 99) >= 0) { 
     3228    if (pcre_exec(re, extra, r, rlen - 1, 0, 0, offsets, 99) >= 0) { 
    32033229      if (all && *bp != b) 
    32043230        safe_str(osep, buff, bp); 
     
    32093235  } while (s); 
    32103236 
    3211   mush_free((Malloc_t) re, "pcre"); 
     3237  mush_free(re, "pcre"); 
    32123238  if (study) 
    3213     mush_free((Malloc_t) study, "pcre.extra"); 
    3214 } 
     3239    mush_free(study, "pcre.extra"); 
     3240}