~ubuntu-branches/ubuntu/edgy/agrep/edgy

« back to all changes in this revision

Viewing changes to preprocess.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2005-12-27 17:01:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20051227170100-nk2hnq0bnlkbk3q3
Tags: 4.17-2
Added patch to fix FTBS on amd64 (Closes: #344909).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (c) 1991 Sun Wu and Udi Manber.  All Rights Reserved. */
 
1
/* Copyright (c) 1994 Sun Wu, Udi Manber, Burra Gopal.  All Rights Reserved. */
2
2
/* substitute metachar with special symbol                               */
3
3
/* if regularr expression, then set flag REGEX                           */
4
4
/* if REGEX and MULTIPAT then report error message,                      */
6
6
/* process start of line, endof line symbol,                             */
7
7
/* process -w WORDBOUND option, append special symbol at begin&end of    */
8
8
/* process -d option before this routine                                 */
9
 
/* the delimiter pattern is in D_pattern (need to end with '; ')          */
 
9
/* the delimiter pattern is in D_pattern (need to end with '; ')         */
10
10
/* if '-t' (suggestion: how about -B) the pattern is passed to sgrep     */
11
11
/* and doesn't go here                                                   */
12
12
/* in that case, -d is ignored? or not necessary                         */
13
13
/* upon return, Pattern contains the pattern to be processed by maskgen  */
14
14
/* D_pattern contains transformed D_pattern                              */
15
 
   
 
15
 
16
16
#include "agrep.h"
17
 
  
18
 
extern int SIMPLEPATTERN, WHOLELINE, REGEX, RE_ERR, DELIMITER, TAIL, WORDBOUND;
 
17
#include <errno.h>
 
18
 
 
19
extern int PAT_FILE, PAT_BUFFER;
 
20
extern ParseTree *AParse;
 
21
extern int WHOLELINE, REGEX, FASTREGEX, RE_ERR, DELIMITER, TAIL, WORDBOUND;
19
22
extern int HEAD;
20
23
extern CHAR Progname[];
21
 
extern int D_length;
 
24
extern int D_length, tc_D_length;
 
25
extern CHAR tc_D_pattern[MaxDelimit * 2];
22
26
extern int table[WORD][WORD];
23
 
  
 
27
extern int agrep_initialfd;
 
28
extern int EXITONERROR;
 
29
extern int errno;
 
30
 
 
31
extern int  multifd;
 
32
extern char *multibuf;
 
33
extern int  multilen;
 
34
extern int anum_terminals;
 
35
extern ParseTree aterminals[MAXNUM_PAT];
 
36
extern char FREQ_FILE[MAX_LINE_LEN], HASH_FILE[MAX_LINE_LEN], STRING_FILE[MAX_LINE_LEN];        /* interfacing with tcompress */
 
37
extern int AComplexBoolean;
 
38
 
 
39
int
24
40
preprocess(D_pattern, Pattern)   /* need two parameters  */
25
 
CHAR *D_pattern, *Pattern;
 
41
CHAR D_pattern[], Pattern[];
26
42
{
27
 
  CHAR temp[Maxline], *r_pat, *old_pat;  /* r_pat for r.e. */
28
 
  CHAR old_D_pat[MaxDelimit];
29
 
  int i, j=0, rp=0, m, t=0, partitions, num_pos, ANDON = 0;
30
 
  int d_end ;  
31
 
  int IN_RANGE=0, EVEN=0, OR_AND=0;
32
 
  old_pat = Pattern; /* to remember the starting position */
33
 
  m = strlen(Pattern);
34
 
  for(i=0; i< m; i++) {
35
 
      if(Pattern[i] == '\\') i++;
36
 
      else if(Pattern[i] == '|' || Pattern[i] == '*' ) REGEX = ON;   
37
 
  }
38
 
  r_pat = (CHAR *) malloc(strlen(Pattern)+2*strlen(D_pattern));
39
 
  strcpy(temp, D_pattern);
40
 
  d_end = t = strlen(temp);  /* size of D_pattern, including '; ' */
41
 
  if (WHOLELINE) { temp[t++] = LANGLE; 
42
 
                   temp[t++] = NNLINE; 
43
 
                   temp[t++] = RANGLE;
44
 
                   temp[t] = '\0';
45
 
                   strcat(temp, Pattern);
46
 
                   m = strlen(temp);
47
 
                   temp[m++] = LANGLE; 
48
 
                   temp[m++] = '\n'; 
49
 
                   temp[m++] = RANGLE; 
50
 
                   temp[m] = '\0';  }
51
 
  else {
52
 
     if (WORDBOUND) { temp[t++] = LANGLE; 
53
 
                      temp[t++] = WORDB; 
54
 
                      temp[t++] = RANGLE;
55
 
                      temp[t] = '\0'; }
56
 
     strcat(temp, Pattern);
57
 
     m = strlen(temp);
58
 
     if (WORDBOUND) { temp[m++] = LANGLE; 
59
 
                      temp[m++] = WORDB; 
60
 
                      temp[m++] = RANGLE; }
61
 
     temp[m] = '\0';
62
 
  }
63
 
        /* now temp contains augmented pattern , m it's size */
64
 
 
65
 
  D_length = 0;
66
 
  for (i=0, j=0; i< d_end-2; i++) {
67
 
      switch(temp[i]) 
68
 
      {
69
 
         case '\\' : i++; 
70
 
                     Pattern[j++] = temp[i];
71
 
                     old_D_pat[D_length++] = temp[i];
72
 
                     break;
73
 
         case '<'  : Pattern[j++] = LANGLE;
74
 
                     break;
75
 
         case '>'  : Pattern[j++] = RANGLE;
76
 
                     break;
77
 
         case '^'  : Pattern[j++] = '\n';
78
 
                     old_D_pat[D_length++] = temp[i];
79
 
                     break;
80
 
         case '$'  : Pattern[j++] = '\n';
81
 
                     old_D_pat[D_length++] = temp[i];
82
 
                     break;
83
 
         default  :  Pattern[j++] = temp[i];
84
 
                     old_D_pat[D_length++] = temp[i];
85
 
                     break;
86
 
     }
87
 
  }
88
 
  if(D_length > MAXDELIM) {
89
 
     fprintf(stderr, "%s: delimiter pattern too long\n", Progname);
90
 
     exit(2);
91
 
  }
92
 
  Pattern[j++] = ANDPAT;
93
 
  old_D_pat[D_length] = '\0';
94
 
  strcpy(D_pattern, old_D_pat);
95
 
  D_length++;
96
 
/*
97
 
  Pattern[j++] = ' ';
98
 
*/
99
 
  Pattern[j] = '\0';
100
 
  rp = 0; 
101
 
  if(REGEX) {
102
 
      r_pat[rp++] = '.';    /* if REGEX: always append '.' in front */
103
 
      r_pat[rp++] = '(';
104
 
      Pattern[j++] = NOCARE;
105
 
      HEAD = ON;
106
 
  }
107
 
  for (i=d_end; i < m ; i++)
108
 
  {
109
 
       switch(temp[i]) 
110
 
       {
111
 
           case '\\': i++;  Pattern[j++] = temp[i]; 
112
 
                      r_pat[rp++] = 'o';   /* the symbol doesn't matter */
113
 
                      break;
114
 
           case '#':  if(REGEX) {
115
 
                         Pattern[j++] = NOCARE;
116
 
                         r_pat[rp++] = '.';
117
 
                         r_pat[rp++] = '*';
118
 
                         break; }
119
 
                      Pattern[j++] = WILDCD;
120
 
                      break; 
121
 
           case '(':  Pattern[j++] = LPARENT; 
122
 
                      r_pat[rp++] = '(';     
123
 
                      break;
124
 
           case ')':  Pattern[j++] = RPARENT; 
125
 
                      r_pat[rp++] = ')'; 
126
 
                      break;
127
 
           case '[':  Pattern[j++] = LRANGE;  
128
 
                      r_pat[rp++] = '[';
129
 
                      IN_RANGE = ON;
130
 
                      break;
131
 
           case ']':  Pattern[j++] = RRANGE;  
132
 
                      r_pat[rp++] = ']'; 
133
 
                      IN_RANGE = OFF;
134
 
                      break;
135
 
           case '<':  Pattern[j++] = LANGLE;  
136
 
                      break;
137
 
           case '>':  Pattern[j++] = RANGLE;  
138
 
                      break;
139
 
           case '^':  if (temp[i-1] == '[') Pattern[j++] = NOTSYM;
140
 
                      else Pattern[j++] = '\n';
141
 
                      r_pat[rp++] = '^';
142
 
                      break;
143
 
           case '$':  Pattern[j++] = '\n'; 
144
 
                      r_pat[rp++] = '$';
145
 
                      break;
146
 
           case '.':  Pattern[j++] = NOCARE;
147
 
                      r_pat[rp++] = '.';
148
 
                      break;
149
 
           case '*':  Pattern[j++] = STAR; 
150
 
                      r_pat[rp++] = '*';
151
 
                      break;
152
 
           case '|':  Pattern[j++] = ORSYM; 
153
 
                      r_pat[rp++] = '|';
154
 
                      break;
155
 
           case ',':  Pattern[j++] = ORPAT;  
156
 
                      RE_ERR = ON; 
157
 
                      break;
158
 
           case ';':  if(ANDON) RE_ERR = ON; 
159
 
                      Pattern[j++] = ANDPAT;
160
 
                      ANDON = ON;
161
 
                      break;
162
 
           case '-':  if(IN_RANGE) {
163
 
                          Pattern[j++] = HYPHEN; 
164
 
                          r_pat[rp++] = '-';
165
 
                      }
166
 
                      else { 
167
 
                          Pattern[j++] = temp[i];
168
 
                          r_pat[rp++] = temp[i];
169
 
                      }  
170
 
                      break;
171
 
           case NNLINE :
172
 
                      Pattern[j++] = temp[i];
173
 
                      r_pat[rp++] = 'N';
174
 
                      break;
175
 
           default:   Pattern[j++] = temp[i]; 
176
 
                      r_pat[rp++] = temp[i];
177
 
                      break;
178
 
      }
179
 
  }
180
 
  if(REGEX) {           /* append ').' at end of regular expression */
181
 
      r_pat[rp++] = ')';
182
 
      r_pat[rp++] = '.';
183
 
      Pattern[j++] = NOCARE;
184
 
      TAIL = ON;
185
 
  }
186
 
  Pattern[j] = '\0'; 
187
 
  m = j;
188
 
  r_pat[rp] = '\0'; 
189
 
  if(REGEX)
190
 
  {  
191
 
     if(DELIMITER || WORDBOUND)  {
192
 
          fprintf(stderr, "%s: -d or -w option is not supported for this pattern\n", Progname);
193
 
          exit(2);
194
 
     }
195
 
     if(RE_ERR) {
196
 
        fprintf(stderr, "%s: illegal regular expression\n", Progname);
197
 
        exit(2);
198
 
     }
199
 
     while(*Pattern != NOCARE && m-- > 0) Pattern++;  /* poit to . */
200
 
     num_pos = init(r_pat, table);
201
 
     if(num_pos <= 0) {
202
 
         fprintf(stderr, "%s: illegal regular expression\n", Progname);
203
 
         exit(2);
204
 
     }
205
 
     if(num_pos > 30) {
206
 
        fprintf(stderr, "%s: regular expression too long\n", Progname);
207
 
        exit(2);
208
 
     }
209
 
  strcpy(old_pat, Pattern); /* do real change to the Pattern to be returned */
210
 
  return;
211
 
  } /* if regex */
212
 
 
213
 
  return;
 
43
        CHAR temp[Maxline], *r_pat, *old_pat;  /* r_pat for r.e. */
 
44
        CHAR old_D_pat[MaxDelimit*2];
 
45
        int i, j=0, rp=0, m, t=0, num_pos, ANDON = 0;
 
46
        int d_end ;  
 
47
        int IN_RANGE=0;
 
48
        int ret1, ret2;
 
49
 
 
50
#if     DEBUG
 
51
        fprintf(stderr, "preprocess: m=%d, pat=%s, PAT_FILE=%d, PAT_BUFFER=%d\n", strlen(Pattern), Pattern, PAT_FILE, PAT_BUFFER);
 
52
#endif
 
53
        if ((m = strlen(Pattern)) <= 0) return 0;
 
54
        if (PAT_FILE || PAT_BUFFER) return 0;
 
55
        REGEX = OFF;
 
56
        FASTREGEX = OFF;
 
57
        old_pat = Pattern; /* to remember the starting position */
 
58
 
 
59
        /* Check if pattern is a concatenation of ands OR ors of simple patterns */
 
60
        multibuf = (char *)malloc(m * 2 + 2);   /* worst case: a,a,a,a,a,a */
 
61
        if (multibuf == NULL) goto normal_processing;
 
62
        /* if (WORDBOUND) goto normal_processing; */
 
63
 
 
64
        multilen = 0;
 
65
        AParse = 0;
 
66
        ret1 = ret2 = 0;
 
67
        if (((ret1 = asplit_pattern(Pattern, m, aterminals, &anum_terminals, &AParse)) <= 0) || /* can change the pattern if simple boolean with {} */
 
68
            ((ret2 = asplit_terminal(0, anum_terminals, multibuf, &multilen)) <= 0) ||
 
69
            ((ret2 == 1) && !(aterminals[0].op & NOTPAT))) {    /* must do normal processing */
 
70
                if (AComplexBoolean && (AParse != NULL)) destroy_tree(AParse);  /* so that direct exec invocations don't use AParse by mistake! */
 
71
#if     DEBUG
 
72
                fprintf(stderr, "preprocess: split_pat = %d, split_term = %d, #terms = %d\n", ret1, ret2, anum_terminals);
 
73
#endif  /*DEBUG*/
 
74
                /*
 
75
                if (ret2 == 1) {
 
76
                        strcpy(Pattern, aterminals[0].data.leaf.value);
 
77
                        m = strlen(Pattern);
 
78
                }
 
79
                */
 
80
                m = strlen(Pattern);
 
81
                AParse = 0;
 
82
                free(multibuf);
 
83
                multibuf = NULL;
 
84
                multilen = 0;
 
85
                goto normal_processing;
 
86
        }
 
87
 
 
88
        /* This is quick processing */
 
89
        if (AParse != 0) {      /* successfully converted to ANDPAT/ORPAT */
 
90
                PAT_BUFFER = 1;
 
91
                /* printf("preprocess(): converted= %d, patterns= %s", AParse, multibuf); */
 
92
                /* Now I have to process the delimiter if any */
 
93
                if (DELIMITER) {
 
94
                        /* D_pattern is "<PAT>; ", D_length is 1 + length of string PAT: see agrep.c/'d' */
 
95
                        preprocess_delimiter(D_pattern+1, D_length - 1, D_pattern, &D_length);
 
96
                        /* D_pattern is the exact stuff we want to match, D_length is its strlen */
 
97
                        if ((tc_D_length = quick_tcompress(FREQ_FILE, HASH_FILE, D_pattern, D_length, tc_D_pattern, MaxDelimit*2, TC_EASYSEARCH)) <= 0) {
 
98
                                strcpy(tc_D_pattern, D_pattern);
 
99
                                tc_D_length = D_length;
 
100
                        }
 
101
                        /* printf("mgrep's delim=%s,%d tc_delim=%s,%d\n", D_pattern, D_length, tc_D_pattern, tc_D_length); */
 
102
                }
 
103
                return 0;
 
104
        }
 
105
        /* else either unknown character, one simple pattern or none at all */
 
106
 
 
107
normal_processing:
 
108
        for(i=0; i< m; i++) {
 
109
                if(Pattern[i] == '\\') i++;
 
110
                else if(Pattern[i] == '|' || Pattern[i] == '*') REGEX = ON;
 
111
        }
 
112
 
 
113
        r_pat = (CHAR *) malloc(strlen(Pattern)+2*strlen(D_pattern) + 8);       /* bug-report, From: Chris Dalton <crd@hplb.hpl.hp.com> */
 
114
        strcpy(temp, D_pattern);
 
115
        d_end = t = strlen(temp);  /* size of D_pattern, including '; ' */
 
116
        if (WHOLELINE) { 
 
117
                temp[t++] = LANGLE; 
 
118
                temp[t++] = NNLINE; 
 
119
                temp[t++] = RANGLE;
 
120
                temp[t] = '\0';
 
121
                strcat(temp, Pattern);
 
122
                m = strlen(temp);
 
123
                temp[m++] = LANGLE; 
 
124
                temp[m++] = '\n'; 
 
125
                temp[m++] = RANGLE; 
 
126
                temp[m] = '\0';  
 
127
        }
 
128
        else {
 
129
                if (WORDBOUND) { 
 
130
                        temp[t++] = LANGLE; 
 
131
                        temp[t++] = WORDB; 
 
132
                        temp[t++] = RANGLE;
 
133
                        temp[t] = '\0'; 
 
134
                }
 
135
                strcat(temp, Pattern);
 
136
                m = strlen(temp);
 
137
                if (WORDBOUND) { 
 
138
                        temp[m++] = LANGLE; 
 
139
                        temp[m++] = WORDB; 
 
140
                        temp[m++] = RANGLE; 
 
141
                }
 
142
                temp[m] = '\0';
 
143
        }
 
144
        /* now temp contains augmented pattern , m it's size */
 
145
        D_length = 0;
 
146
        for (i=0, j=0; i< d_end-2; i++) {
 
147
                switch(temp[i]) 
 
148
                {
 
149
                case '\\' : 
 
150
                        i++; 
 
151
                        Pattern[j++] = temp[i];
 
152
                        old_D_pat[D_length++] = temp[i];
 
153
                        break;
 
154
                case '<'  : 
 
155
                        Pattern[j++] = LANGLE;
 
156
                        break;
 
157
                case '>'  : 
 
158
                        Pattern[j++] = RANGLE;
 
159
                        break;
 
160
                case '^'  : 
 
161
                        Pattern[j++] = '\n';
 
162
                        old_D_pat[D_length++] = temp[i];
 
163
                        break;
 
164
                case '$'  : 
 
165
                        Pattern[j++] = '\n';
 
166
                        old_D_pat[D_length++] = temp[i];
 
167
                        break;
 
168
                default  :  
 
169
                        Pattern[j++] = temp[i];
 
170
                        old_D_pat[D_length++] = temp[i];
 
171
                        break;
 
172
                }
 
173
        }
 
174
        if(D_length > MAXDELIM) {
 
175
                fprintf(stderr, "%s: delimiter pattern too long (has > %d chars)\n", Progname, MAXDELIM);
 
176
                free(r_pat);
 
177
                if (!EXITONERROR) {
 
178
                        errno = AGREP_ERROR;
 
179
                        return -1;
 
180
                }
 
181
                else exit(2);
 
182
        }
 
183
 
 
184
        Pattern[j++] = ANDPAT;
 
185
        old_D_pat[D_length] = '\0';
 
186
        strcpy(D_pattern, old_D_pat);
 
187
        D_length++;
 
188
        /*
 
189
          Pattern[j++] = ' ';
 
190
        */
 
191
        Pattern[j] = '\0';
 
192
        rp = 0; 
 
193
        if(REGEX) {
 
194
                r_pat[rp++] = '.';    /* if REGEX: always append '.' in front */
 
195
                r_pat[rp++] = '(';
 
196
                Pattern[j++] = NOCARE;
 
197
                HEAD = ON;
 
198
        }
 
199
        for (i=d_end; i < m ; i++)
 
200
        {
 
201
                switch(temp[i]) 
 
202
                {
 
203
                case '\\': 
 
204
                        i++;  
 
205
                        Pattern[j++] = temp[i]; 
 
206
                        r_pat[rp++] = 'o';   /* the symbol doesn't matter */
 
207
                        break;
 
208
                case '#':  
 
209
                        FASTREGEX = ON;
 
210
                        if(REGEX) {
 
211
                                Pattern[j++] = NOCARE;
 
212
                                r_pat[rp++] = '.';
 
213
                                r_pat[rp++] = '*';
 
214
                                break; 
 
215
                        }
 
216
                        Pattern[j++] = WILDCD;
 
217
                        break; 
 
218
                case '(':  
 
219
                        Pattern[j++] = LPARENT; 
 
220
                        r_pat[rp++] = '(';     
 
221
                        break;
 
222
                case ')':  
 
223
                        Pattern[j++] = RPARENT; 
 
224
                        r_pat[rp++] = ')'; 
 
225
                        break;
 
226
                case '[':  
 
227
                        Pattern[j++] = LRANGE;  
 
228
                        r_pat[rp++] = '[';
 
229
                        IN_RANGE = ON;
 
230
                        break;
 
231
                case ']':  
 
232
                        Pattern[j++] = RRANGE;  
 
233
                        r_pat[rp++] = ']'; 
 
234
                        IN_RANGE = OFF;
 
235
                        break;
 
236
                case '<':  
 
237
                        Pattern[j++] = LANGLE;  
 
238
                        break;
 
239
                case '>':  
 
240
                        Pattern[j++] = RANGLE;  
 
241
                        break;
 
242
                case '^':  
 
243
                        if (temp[i-1] == '[') Pattern[j++] = NOTSYM;
 
244
                        else Pattern[j++] = '\n';
 
245
                        r_pat[rp++] = '^';
 
246
                        break;
 
247
                case '$':  
 
248
                        Pattern[j++] = '\n'; 
 
249
                        r_pat[rp++] = '$';
 
250
                        break;
 
251
                case '.':  
 
252
                        Pattern[j++] = NOCARE;
 
253
                        r_pat[rp++] = '.';
 
254
                        break;
 
255
                case '*':  
 
256
                        Pattern[j++] = STAR; 
 
257
                        r_pat[rp++] = '*';
 
258
                        break;
 
259
                case '|':  
 
260
                        Pattern[j++] = ORSYM; 
 
261
                        r_pat[rp++] = '|';
 
262
                        break;
 
263
                case ',':  
 
264
                        Pattern[j++] = ORPAT;  
 
265
                        RE_ERR = ON; 
 
266
                        break;
 
267
                case ';':  
 
268
                        if(ANDON) RE_ERR = ON; 
 
269
                        Pattern[j++] = ANDPAT;
 
270
                        ANDON = ON;
 
271
                        break;
 
272
                case '-':  
 
273
                        if(IN_RANGE) {
 
274
                                Pattern[j++] = HYPHEN; 
 
275
                                r_pat[rp++] = '-';
 
276
                        }
 
277
                        else { 
 
278
                                Pattern[j++] = temp[i];
 
279
                                r_pat[rp++] = temp[i];
 
280
                        }  
 
281
                        break;
 
282
                case NNLINE :
 
283
                        Pattern[j++] = temp[i];
 
284
                        r_pat[rp++] = 'N';
 
285
                        break;
 
286
                default:   
 
287
                        Pattern[j++] = temp[i]; 
 
288
                        r_pat[rp++] = temp[i];
 
289
                        break;
 
290
                }
 
291
        }
 
292
        if(REGEX) {           /* append ').' at end of regular expression */
 
293
                r_pat[rp++] = ')';
 
294
                r_pat[rp++] = '.';
 
295
                Pattern[j++] = NOCARE;
 
296
                TAIL = ON;
 
297
        }
 
298
        Pattern[j] = '\0'; 
 
299
        m = j;
 
300
        r_pat[rp] = '\0'; 
 
301
        if(REGEX)
 
302
        {  
 
303
                if(DELIMITER || WORDBOUND)  {
 
304
                        fprintf(stderr, "%s: -d or -w option is not supported for this pattern\n", Progname);
 
305
                        free(r_pat);
 
306
                        if (!EXITONERROR) {
 
307
                                errno = AGREP_ERROR;
 
308
                                return -1;
 
309
                        }
 
310
                        else exit(2);
 
311
                }
 
312
                if(RE_ERR) {
 
313
                        fprintf(stderr, "%s: illegal regular expression\n", Progname);
 
314
                        free(r_pat);
 
315
                        if (!EXITONERROR) {
 
316
                                errno = AGREP_ERROR;
 
317
                                return -1;
 
318
                        }
 
319
                        else exit(2);
 
320
                }
 
321
                while(*Pattern != NOCARE && m-- > 0) Pattern++;  /* poit to . */
 
322
                num_pos = init(r_pat, table);
 
323
                if(num_pos <= 0) {
 
324
                        fprintf(stderr, "%s: illegal regular expression\n", Progname);
 
325
                        free(r_pat);
 
326
                        if (!EXITONERROR) {
 
327
                                errno = AGREP_ERROR;
 
328
                                return -1;
 
329
                        }
 
330
                        else exit(2);
 
331
                }
 
332
                if(num_pos > 30) {
 
333
                        fprintf(stderr, "%s: regular expression too long\n", Progname);
 
334
                        free(r_pat);
 
335
                        if (!EXITONERROR) {
 
336
                                errno = AGREP_ERROR;
 
337
                                return -1;
 
338
                        }
 
339
                        else exit(2);
 
340
                }
 
341
                strcpy(old_pat, Pattern); /* do real change to the Pattern to be returned */
 
342
                free(r_pat);
 
343
                return 0;
 
344
        } /* if regex */
 
345
 
 
346
        free(r_pat);
 
347
        return 0;
214
348
}
215
349