Changeset 1167 for 1.8.3/trunk/src/funlist.c
- Timestamp:
- 12/28/07 19:57:17 (1 year ago)
- Files:
-
- 1.8.3/trunk/src/funlist.c (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
1.8.3/trunk/src/funlist.c
r1117 r1167 18 18 #include "function.h" 19 19 #include "mymalloc.h" 20 #include " pcre.h"20 #include "mypcre.h" 21 21 #include "match.h" 22 22 #include "command.h" … … 139 139 */ 140 140 void 141 arr2list(char *r[], int max, char *list, char **lp, c har *sep)141 arr2list(char *r[], int max, char *list, char **lp, const char *sep) 142 142 { 143 143 int i; … … 2675 2675 { 2676 2676 pcre *re; 2677 pcre_extra * study = NULL;2677 pcre_extra *extra, *study = NULL; 2678 2678 const char *errptr; 2679 2679 int subpatterns; … … 2747 2747 study = pcre_study(re, 0, &errptr); 2748 2748 if (errptr != NULL) { 2749 mush_free( (Malloc_t)re, "pcre");2749 mush_free(re, "pcre"); 2750 2750 safe_str(T("#-1 REGEXP ERROR: "), buff, bp); 2751 2751 safe_str(errptr, buff, bp); … … 2759 2759 } 2760 2760 2761 if (study) { 2762 extra = study; 2763 set_match_limit(extra); 2764 } else 2765 extra = default_match_limit(); 2766 2761 2767 search = 0; 2762 2768 /* Do all the searches and replaces we can */ 2763 2769 2764 2770 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); 2766 2772 2767 2773 /* Match wasn't found... we're done */ 2768 2774 if (subpatterns < 0) { 2769 2775 safe_str(prebuf, postbuf, &postp); 2770 mush_free( (Malloc_t)re, "pcre");2776 mush_free(re, "pcre"); 2771 2777 free_ansi_string(orig); 2772 2778 if (study) 2773 mush_free( (Malloc_t)study, "pcre.extra");2779 mush_free(study, "pcre.extra"); 2774 2780 continue; 2775 2781 } … … 2805 2811 match_offset++; 2806 2812 } while (all && match_offset < prelen && 2807 (subpatterns = pcre_exec(re, study, prebuf, prelen,2813 (subpatterns = pcre_exec(re, extra, prebuf, prelen, 2808 2814 match_offset, 0, offsets, 99)) >= 0); 2809 2815 … … 2811 2817 *postp = '\0'; 2812 2818 2813 mush_free( (Malloc_t)re, "pcre");2819 mush_free(re, "pcre"); 2814 2820 if (study != NULL) 2815 mush_free( (Malloc_t)study, "pcre.extra");2821 mush_free(study, "pcre.extra"); 2816 2822 free_ansi_string(orig); 2817 2823 } … … 2849 2855 study = pcre_study(re, 0, &errptr); 2850 2856 if (errptr != NULL) { 2851 mush_free( (Malloc_t)re, "pcre");2857 mush_free(re, "pcre"); 2852 2858 safe_str(T("#-1 REGEXP ERROR: "), buff, bp); 2853 2859 safe_str(errptr, buff, bp); … … 2860 2866 add_check("pcre.extra"); 2861 2867 } 2868 if (study) { 2869 extra = study; 2870 set_match_limit(extra); 2871 } else 2872 extra = default_match_limit(); 2873 2862 2874 search = 0; 2863 2875 /* Do all the searches and replaces we can */ 2864 2876 do { 2865 2877 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); 2867 2879 if (subpatterns >= 0) { 2868 2880 /* We have a match */ … … 2901 2913 } 2902 2914 } while (subpatterns >= 0 && all); 2903 mush_free( (Malloc_t)re, "pcre");2915 mush_free(re, "pcre"); 2904 2916 if (study != NULL) 2905 mush_free( (Malloc_t)study, "pcre.extra");2917 mush_free(study, "pcre.extra"); 2906 2918 } 2907 2919 safe_ansi_string(orig, 0, orig->len, buff, bp); … … 2932 2944 char *qregs[NUMQ], *holder[NUMQ]; 2933 2945 pcre *re; 2946 pcre_extra *extra; 2934 2947 const char *errptr; 2935 2948 int erroffset; … … 2965 2978 } 2966 2979 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); 2968 2983 safe_integer(subpatterns >= 0, buff, bp); 2969 2984 … … 3050 3065 } 3051 3066 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"); 3055 3070 free_ansi_string(as); 3056 3071 } … … 3074 3089 int erroffset; 3075 3090 int flags = 0; 3076 3091 bool free_study; 3077 3092 dbref it = match_thing(executor, args[0]); 3093 3078 3094 reharg.first = 0; 3079 3095 if (it == NOTHING || it == AMBIGUOUS) { … … 3110 3126 return; 3111 3127 } 3112 if (reharg.study) 3128 if (reharg.study) { 3113 3129 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 } 3114 3136 3115 3137 reharg.buff = buff; … … 3118 3140 atr_iter_get(executor, it, args[1], 0, regrep_helper, (void *) &reharg); 3119 3141 mush_free(reharg.re, "pcre"); 3120 if ( reharg.study)3142 if (free_study) 3121 3143 mush_free(reharg.study, "pcre.extra"); 3122 3144 } … … 3154 3176 size_t rlen; 3155 3177 pcre *re; 3156 pcre_extra *study ;3178 pcre_extra *study, *extra; 3157 3179 const char *errptr; 3158 3180 int erroffset; … … 3195 3217 return; 3196 3218 } 3197 if (study) 3219 if (study) { 3198 3220 add_check("pcre.extra"); 3221 extra = study; 3222 set_match_limit(extra); 3223 } else 3224 extra = default_match_limit(); 3199 3225 3200 3226 do { 3201 3227 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) { 3203 3229 if (all && *bp != b) 3204 3230 safe_str(osep, buff, bp); … … 3209 3235 } while (s); 3210 3236 3211 mush_free( (Malloc_t)re, "pcre");3237 mush_free(re, "pcre"); 3212 3238 if (study) 3213 mush_free( (Malloc_t)study, "pcre.extra");3214 } 3239 mush_free(study, "pcre.extra"); 3240 }
