pattern.c (6f26c71d76bb795b30684affb3b57870a7926b26) | pattern.c (2235c7feac959bcc9ddfd6a2bc6be32102b1f84c) |
---|---|
1/* | 1/* |
2 * Copyright (C) 1984-2020 Mark Nudelman | 2 * Copyright (C) 1984-2021 Mark Nudelman |
3 * 4 * You may distribute under the terms of either the GNU General Public 5 * License or the Less License, as specified in the README file. 6 * 7 * For more information, see the README file. 8 */ 9 10/* --- 129 unchanged lines hidden (view full) --- 140 } 141 return (0); 142} 143 144/* 145 * Like compile_pattern2, but convert the pattern to lowercase if necessary. 146 */ 147 public int | 3 * 4 * You may distribute under the terms of either the GNU General Public 5 * License or the Less License, as specified in the README file. 6 * 7 * For more information, see the README file. 8 */ 9 10/* --- 129 unchanged lines hidden (view full) --- 140 } 141 return (0); 142} 143 144/* 145 * Like compile_pattern2, but convert the pattern to lowercase if necessary. 146 */ 147 public int |
148compile_pattern(pattern, search_type, comp_pattern) | 148compile_pattern(pattern, search_type, show_error, comp_pattern) |
149 char *pattern; 150 int search_type; | 149 char *pattern; 150 int search_type; |
151 int show_error; |
|
151 PATTERN_TYPE *comp_pattern; 152{ 153 char *cvt_pattern; 154 int result; 155 156 if (caseless != OPT_ONPLUS) 157 cvt_pattern = pattern; 158 else 159 { 160 cvt_pattern = (char*) ecalloc(1, cvt_length(strlen(pattern), CVT_TO_LC)); 161 cvt_text(cvt_pattern, pattern, (int *)NULL, (int *)NULL, CVT_TO_LC); 162 } | 152 PATTERN_TYPE *comp_pattern; 153{ 154 char *cvt_pattern; 155 int result; 156 157 if (caseless != OPT_ONPLUS) 158 cvt_pattern = pattern; 159 else 160 { 161 cvt_pattern = (char*) ecalloc(1, cvt_length(strlen(pattern), CVT_TO_LC)); 162 cvt_text(cvt_pattern, pattern, (int *)NULL, (int *)NULL, CVT_TO_LC); 163 } |
163 result = compile_pattern2(cvt_pattern, search_type, comp_pattern, 1); | 164 result = compile_pattern2(cvt_pattern, search_type, comp_pattern, show_error); |
164 if (cvt_pattern != pattern) 165 free(cvt_pattern); 166 return (result); 167} 168 169/* 170 * Forget that we have a compiled pattern. 171 */ --- 37 unchanged lines hidden (view full) --- 209#endif 210#if HAVE_V8_REGCOMP 211 if (*pattern != NULL) 212 free(*pattern); 213 *pattern = NULL; 214#endif 215} 216 | 165 if (cvt_pattern != pattern) 166 free(cvt_pattern); 167 return (result); 168} 169 170/* 171 * Forget that we have a compiled pattern. 172 */ --- 37 unchanged lines hidden (view full) --- 210#endif 211#if HAVE_V8_REGCOMP 212 if (*pattern != NULL) 213 free(*pattern); 214 *pattern = NULL; 215#endif 216} 217 |
218#if 0 |
|
217/* 218 * Can a pattern be successfully compiled? 219 */ 220 public int 221valid_pattern(pattern) 222 char *pattern; 223{ 224 PATTERN_TYPE comp_pattern; 225 int result; 226 | 219/* 220 * Can a pattern be successfully compiled? 221 */ 222 public int 223valid_pattern(pattern) 224 char *pattern; 225{ 226 PATTERN_TYPE comp_pattern; 227 int result; 228 |
227 CLEAR_PATTERN(comp_pattern); | 229 SET_NULL_PATTERN(comp_pattern); |
228 result = compile_pattern2(pattern, 0, &comp_pattern, 0); 229 if (result != 0) 230 return (0); 231 uncompile_pattern(&comp_pattern); 232 return (1); 233} | 230 result = compile_pattern2(pattern, 0, &comp_pattern, 0); 231 if (result != 0) 232 return (0); 233 uncompile_pattern(&comp_pattern); 234 return (1); 235} |
236#endif |
|
234 235/* 236 * Is a compiled pattern null? 237 */ 238 public int 239is_null_pattern(pattern) 240 PATTERN_TYPE pattern; 241{ --- 222 unchanged lines hidden --- | 237 238/* 239 * Is a compiled pattern null? 240 */ 241 public int 242is_null_pattern(pattern) 243 PATTERN_TYPE pattern; 244{ --- 222 unchanged lines hidden --- |