File: compile.C

package info (click to toggle)
peruser 4b33-10
  • links: PTS
  • area: main
  • in suites: woody
  • size: 2,944 kB
  • ctags: 1,064
  • sloc: cpp: 22,397; perl: 2,733; makefile: 345; sh: 335
file content (34 lines) | stat: -rw-r--r-- 683 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <stdio.h>
#include <stdlib.h>
#include <regex.h>
#include <string.h>

#include "npfile.h"
#include "npsearch.h"

int NP_Search::compile( char *regexp )
{
   if ( regexp == NULL )
   {
      strcpy( error_message, "NP_Search: compile(): NULL regular expression"
              " argument." );
      return 1;
   }

   if ( compiled )
      regfree( &regex );
   
   int result = regcomp( &regex, regexp, REG_EXTENDED );
   if ( result )
   {
      strcpy( error_message, "NP_Search: compile(): " );
      char buffer[ 256 ];
      regerror( result, &regex, buffer, sizeof buffer );
      strcat( error_message, buffer );
      return 1;
   }

   compiled = 1;
   return 0;
}