-
-
- /* Duping the pattern for our internal work */
- new_str = strdup(pattern);
- if(!new_str)
- {
- reg->error = OS_REGEX_OUTOFMEMORY;
- goto compile_error;
- }
- new_str_free = new_str;
- pt = new_str;
-
-
- /* Getting the number of sub patterns */
- while(*pt != '\0')
- {
- /* The pattern must be always lower case if
- * case sensitive is set
- */
- if(!(flags & OS_CASE_SENSITIVE))
- {
- *pt = charmap[(uchar)*pt];
- }
-
- /* Number of sub patterns */
- if(*pt == OR)
- {
- count++;
- }
- pt++;
- }
-
-
- /* For the last pattern */
- count++;
- reg->patterns = calloc(count +1, sizeof(char *));
- reg->size = calloc(count +1, sizeof(int));
- reg->match_fp = calloc(count +1, sizeof(void *));
-
-
- /* Memory allocation error check */
- if(!reg->patterns || !reg->size || !reg->match_fp)
- {
- reg->error = OS_REGEX_OUTOFMEMORY;
- goto compile_error;
- }
-