Esempio n. 1
0
File: string.c Progetto: amihwan/v7
V7_PRIVATE enum v7_err Str_match(struct v7_c_func_arg *cfa) {
#define v7 (cfa->v7) /* Needed for TRY() macro below */
  struct v7_val *arg = cfa->args[0];
  struct Resub sub;
  struct v7_val *arr = NULL;
  unsigned long shift = 0;

  if (cfa->num_args > 0) {
    TRY(check_str_re_conv(v7, &arg, 1));
    TRY(regex_check_prog(arg));
    do {
      if (!re_exec(arg->v.str.prog, arg->fl.fl,
                   cfa->this_obj->v.str.buf + shift, &sub)) {
        if (NULL == arr) {
          arr = v7_push_new_object(v7);
          v7_set_class(arr, V7_CLASS_ARRAY);
        }
        shift = sub.sub[0].end - cfa->this_obj->v.str.buf;
        v7_append(v7, arr, v7_mkv(v7, V7_TYPE_STR, sub.sub[0].start,
                                  sub.sub[0].end - sub.sub[0].start, 1));
      }
    } while (arg->fl.fl.re_g && shift < cfa->this_obj->v.str.len);
  }
  if (0 == shift) TRY(v7_make_and_push(v7, V7_TYPE_NULL));
  return V7_OK;
#undef v7
}
Esempio n. 2
0
File: string.c Progetto: amihwan/v7
V7_PRIVATE enum v7_err Str_search(struct v7_c_func_arg *cfa) {
#define v7 (cfa->v7) /* Needed for TRY() macro below */
  struct v7_val *arg = cfa->args[0];
  struct Resub sub;
  int shift = -1, utf_shift = -1;

  if (cfa->num_args > 0) {
    TRY(check_str_re_conv(v7, &arg, 1));
    TRY(regex_check_prog(arg));
    if (!re_exec(arg->v.str.prog, arg->fl.fl, cfa->this_obj->v.str.buf, &sub))
      shift = sub.sub[0].start - cfa->this_obj->v.str.buf;
  }
  if (shift > 0) { /* calc shift for UTF-8 */
    Rune rune;
    const char *str = cfa->this_obj->v.str.buf;
    utf_shift = 0;
    do {
      str += chartorune(&rune, str);
      utf_shift++;
    } while (str - cfa->this_obj->v.str.buf < shift);
  }
  v7_push_number(v7, utf_shift);
  return V7_OK;
#undef v7
}
Esempio n. 3
0
File: config.c Progetto: Aconex/pcp
static int
eval_match_comp(N_tag tag, bool_node *lhs, bool_node *rhs)
{
    int sts;
    char *res;
    char *str= get_strvalue(lhs);
    char *pat = get_strvalue(rhs);

    if (rhs->tag != N_pat) {
	eval_error("match");
    }

    res = re_comp(pat);
    if (res != NULL) {
	/* should have been checked at lex stage */
	/* => internal error */
	eval_error(res);
    }
    sts = re_exec(str);
    if (sts < 0) {
	eval_error("re_exec");
    }

    switch(tag) {
	case N_match: return sts;
	case N_nmatch: return !sts;
	default:
	    eval_error("match comparison");
    }/*switch*/
}
Esempio n. 4
0
static void get_either_iter(struct iter_data *data, char *name)
{
     int match;
#ifdef SOLARIS_REGEXPS
     match = (step(name, data->expbuf) != 0);
#endif
#ifdef POSIX_REGEXPS
     match = (regexec(&data->preg, name, 0, NULL, 0) == 0);
#endif
#ifdef BSD_REGEXPS
     match = (re_exec(name) != 0);
#endif
     if (match) {
	  if (data->n_names == data->sz_names) {
	       int new_sz = data->sz_names * 2;
	       char **new_names = realloc(data->names,
					  new_sz * sizeof(char *));
	       if (new_names) {
		    data->names = new_names;
		    data->sz_names = new_sz;
	       } else {
		    data->malloc_failed = 1;
		    free(name);
		    return;
	       }
	  }
	  data->names[data->n_names++] = name;
     } else
	  free(name);
}
Esempio n. 5
0
/* 
 * ===  FUNCTION  ======================================================================
 *         Name:  uri_parse
 *  Description:  URI objects can be created in two ways: 
 *                1) By downloading the uri from the database; or
 *                2) By creating the URI using a FQP string.
 *
 *                The uri_parse functin does not assume that the URI exists before it
 *                creates the object.  When it is call the object is created without an
 *                id.  This will need to be allocated by uri_db_update and should be done
 *                after the path is resolved.
 *
 *                On success the uri object will have the members returned by the re 
 *                allocated and zero will be returned.  On failure it will return a URI 
 *                offset error.
 * =====================================================================================
 */
extern int
uri_parse( uriobj_t *uri, regexpr_t *re, const char *fqp)
{
	int err = 0;
	init_uriobj_str(uri);
	if( errno ) {
		return errno;
	}
	*(re->re_subject) = strdup(fqp);
	re->re_length = strlen(fqp);
	err = re_exec( re, RE_ID);
	if( err > 0 ) {
		err = 0;
		*(uri->uri_scheme) = usplice(fqp, re->re_ovector[RE_S_S], re->re_ovector[RE_S_E] -1);
		*(uri->uri_auth)   = usplice(fqp, re->re_ovector[RE_A_S], re->re_ovector[RE_A_E] -1);
		*(uri->uri_path)   = usplice(fqp, re->re_ovector[RE_P_S], re->re_ovector[RE_P_E] -1);
		*(uri->uri_query)  = usplice(fqp, re->re_ovector[RE_Q_S], re->re_ovector[RE_Q_E] -1);
		*(uri->uri_frag)   = usplice(fqp, re->re_ovector[RE_F_S], re->re_ovector[RE_F_E] -1);
		uri->uri_id = uri->uri_flags = 0;
		*(uri->uri_host) = *(uri->uri_port)
			         = *(uri->uri_ip)
			         = NULL;
	}
	return err;
}
Esempio n. 6
0
STATIC mp_obj_t mod_re_exec(bool is_anchored, uint n_args, const mp_obj_t *args) {
    mp_obj_re_t *self = mod_re_compile(1, args);

    const mp_obj_t args2[] = {self, args[1]};
    mp_obj_match_t *match = re_exec(is_anchored, 2, args2);
    return match;
}
Esempio n. 7
0
int match_file(FILE *f, re *regexp)
{
        ssize_t read;
        size_t len;
        char *line = NULL;
        int matched = 0;

        while ((read = getline(&line, &len, f)) != -1) {
                if (line[read - 1] == '\n') {
                        line[read - 1] = '\0';
                }
                
                if (re_exec(regexp, line)) {
                        matched |= 1;
                                
                        fwrite(line, sizeof(char), read - 1, stdout);
                        fwrite("\n", sizeof(char), 1, stdout);
                }
                
                free(line);
                line = NULL;
        }
        
        return matched;
}
Esempio n. 8
0
File: filebrowse.c Progetto: 8l/ted
match_selreg(char *fname)
{
int i;
#ifdef	USE_BSD_REG
char *err;
#else
regex_t	reg;
#endif
for(i=0;i<SELREGN;i++) {
#ifdef	USE_BSD_REG
	if (err=re_comp(selreg[i])) {
		error(err);
		return 1;
	}
	if (re_exec(fname)) {
		return 1;
	}
#else
	if (regcomp(&reg,selreg[i],0)) {
		return 1;
	}
	if (!regexec(&reg,fname,0,0,0)) {
		regfree(&reg);
		return 1;
	}
	regfree(&reg);
#endif
}
return 0;
}
Esempio n. 9
0
int
main (void)
{
  const char *err;
  size_t i;
  int ret = 0;

#ifdef HAVE_MCHECK_H
  mtrace ();
#endif

  for (i = 0; i < 100; ++i)
    {
      err = re_comp ("a t.st");
      if (err)
	{
	  printf ("re_comp failed: %s\n", err);
	  ret = 1;
	}

      if (! re_exec ("This is a test."))
	{
	  printf ("re_exec failed\n");
	  ret = 1;
	}
    }

  return ret;
}
Esempio n. 10
0
File: string.c Progetto: amihwan/v7
V7_PRIVATE enum v7_err Str_split(struct v7_c_func_arg *cfa) {
#define v7 (cfa->v7) /* Needed for TRY() macro below */
  struct v7_val *arg = cfa->args[0], *arr = v7_push_new_object(v7);
  struct Resub sub, sub1;
  int limit = 1000000, elem = 0, i, len;
  unsigned long shift = 0;

  v7_set_class(arr, V7_CLASS_ARRAY);
  if (cfa->num_args > 0) {
    if (cfa->num_args > 1 && cfa->args[1]->type == V7_TYPE_NUM)
      limit = cfa->args[1]->v.num;
    TRY(check_str_re_conv(v7, &arg, 1));
    TRY(regex_check_prog(arg));
    for (; elem < limit && shift < cfa->this_obj->v.str.len; elem++) {
      if (re_exec(arg->v.str.prog, arg->fl.fl, cfa->this_obj->v.str.buf + shift,
                  &sub))
        break;
      v7_append(v7, arr,
                v7_mkv(v7, V7_TYPE_STR, cfa->this_obj->v.str.buf + shift,
                       sub.sub[0].start - cfa->this_obj->v.str.buf - shift, 1));
      for (i = 1; i < sub.subexpr_num; i++)
        v7_append(v7, arr, v7_mkv(v7, V7_TYPE_STR, sub.sub[i].start,
                                  sub.sub[i].end - sub.sub[i].start, 1));
      shift = sub.sub[0].end - cfa->this_obj->v.str.buf;
      sub1 = sub;
    }
  }
  len = cfa->this_obj->v.str.len - shift;
  if (elem < limit && len > 0)
    v7_append(v7, arr, v7_mkv(v7, V7_TYPE_STR, cfa->this_obj->v.str.buf + shift,
                              len, 1));
  return V7_OK;
#undef v7
}
Esempio n. 11
0
/*-------------------------------------------------------------------
 *   MatchPattern                 04.24.90  GH
 *
 *   Catch-all routine for pattern-matching. Directs the search through
 *   BM_Srch(), BYG_Srch() or strstr() depending on heuristics based
 *   on pattern content.
 *-------------------------------------------------------------------
 */
BYTE *
MatchPattern( BYTE *pattern, BYTE *text, int text_len )
{
        char *dstr;  /* mostly for debugging */
        BYTE *pmatch;

        Debug("%s %s\n",pattern,igset[searchtype]);
        if(dstr = strpbrk((char *)pattern,"#."))
        {
                re_comp( (char *) pattern, igset[searchtype] );
                pmatch =  (BYTE *) re_exec(text);
        }
        else
        {
                if(strlen(pattern) > 2)
                        pmatch = BM_Srch(pattern,text,text_len,
                                         (BYTE *)igset[searchtype] );
                else
                {
                       pmatch = strstr( text, pattern );
                       beg_of_patt = pmatch;
                       end_of_patt = pmatch+1;
                       /*
                       ** Move end_of_patt beyond ignore set characters
                       */
                       while(strchr((char *)igset[searchtype],*end_of_patt))
                                end_of_patt++;
                }
        }

        return( pmatch );
}/*
Esempio n. 12
0
LDAP_CALL
ldap_getfirstfilter( LDAPFiltDesc *lfdp, char *tagpat, char *value )
{
    LDAPFiltList	*flp;

    if ( lfdp == NULL || tagpat == NULL || value == NULL ) {
	return( NULL );	/* punt */
    }

    if ( lfdp->lfd_curvalcopy != NULL ) {
	NSLDAPI_FREE( lfdp->lfd_curvalcopy );
	NSLDAPI_FREE( lfdp->lfd_curvalwords );
    }

    NSLDAPI_FREE(lfdp->lfd_curval);
    if ((lfdp->lfd_curval = nsldapi_strdup(value)) == NULL) {
	return( NULL );
    }

    lfdp->lfd_curfip = NULL;

    for ( flp = lfdp->lfd_filtlist; flp != NULL; flp = flp->lfl_next ) {
	if ( re_comp( tagpat ) == NULL && re_exec( flp->lfl_tag ) == 1
		&& re_comp( flp->lfl_pattern ) == NULL
		&& re_exec( lfdp->lfd_curval ) == 1 ) {
	    lfdp->lfd_curfip = flp->lfl_ilist;
	    break;
	}
    }

    if ( lfdp->lfd_curfip == NULL ) {
	return( NULL );
    }

    if (( lfdp->lfd_curvalcopy = nsldapi_strdup( value )) == NULL ) {
	return( NULL );
    }

    if ( break_into_words( lfdp->lfd_curvalcopy, flp->lfl_delims,
		&lfdp->lfd_curvalwords ) < 0 ) {
	NSLDAPI_FREE( lfdp->lfd_curvalcopy );
	lfdp->lfd_curvalcopy = NULL;
	return( NULL );
    }

    return( ldap_getnextfilter( lfdp ));
}
Esempio n. 13
0
File: magic.c Progetto: bbs-io/mbse
int GetMagicRec(int Typ, int First)
{
    int	    Eof = FALSE;
    char    *temp, mask[256];
    FILE    *FeM;

    if (First)
	MagicNr = 0;

    temp = calloc(PATH_MAX, sizeof(char));
    snprintf(temp, PATH_MAX, "%s/etc/magic.data", getenv("MBSE_ROOT"));
    if ((FeM = fopen(temp, "r")) == NULL) {
	Syslog('+', "Huh? No magic file? (%s)", temp);
	free(temp);
	return FALSE;
    }

    fread(&magichdr, sizeof(magichdr), 1, FeM);

    do {
	if (fseek(FeM, magichdr.hdrsize + (MagicNr * magichdr.recsize), SEEK_SET) != 0) {
	    WriteError("$Can't seek record %ld in %s", MagicNr, temp);
	    free(temp);
	    fclose(FeM);
	    return FALSE;
	}

	MagicNr++;

	if (fread(&magic, magichdr.recsize, 1, FeM) == 1) {

	    if ((magic.Active) && (magic.Attrib == Typ) && (strcasecmp(magic.From, TIC.TicIn.Area) == 0)) {

		memset(&mask, 0, sizeof(mask));
		strcpy(mask, re_mask(magic.Mask, FALSE));
		if ((re_comp(mask)) == NULL) {
		    if (re_exec(TIC.NewFile)) {
			fclose(FeM);
			free(temp);
			return TRUE;
		    }
		} else {
		    WriteError("Magic: re_comp(%s) failed", mask);
		}
	    }

	} else {
	    Eof = TRUE;
	}

    } while (!Eof);

    free(temp);
    fclose(FeM);
    return FALSE;
}
Esempio n. 14
0
int 
PostProc (char *UDoc, int verbatim)
{
  if (!post_proc)
    return 1;

  if (verbatim)
    return strstr (UDoc, post_proc) != NULL;
  return re_exec ((char *) UDoc);
}
pid_t FAST_FUNC fork_or_rexec(char **argv)
{
	pid_t pid;
	/* Maybe we are already re-execed and come here again? */
	if (re_execed)
		return 0;
	pid = xvfork();
	if (pid) /* parent */
		return pid;
	/* child - re-exec ourself */
	re_exec(argv);
}
Esempio n. 16
0
LDAPFiltInfo *
ldap_getfirstfilter( LDAPFiltDesc *lfdp, char *tagpat, char *value )
{
    LDAPFiltList	*flp;

    if ( lfdp->lfd_curvalcopy != NULL ) {
	free( lfdp->lfd_curvalcopy );
	free( lfdp->lfd_curvalwords );
    }

    lfdp->lfd_curval = value;
    lfdp->lfd_curfip = NULL;

    for ( flp = lfdp->lfd_filtlist; flp != NULL; flp = flp->lfl_next ) {
	if ( re_comp( tagpat ) == NULL && re_exec( flp->lfl_tag ) == 1
		&& re_comp( flp->lfl_pattern ) == NULL
		&& re_exec( lfdp->lfd_curval ) == 1 ) {
	    lfdp->lfd_curfip = flp->lfl_ilist;
	    break;
	}
    }

    if ( lfdp->lfd_curfip == NULL ) {
	return( NULL );
    }

    if (( lfdp->lfd_curvalcopy = strdup( value )) == NULL ) {
	return( NULL );
    }

    if ( break_into_words( lfdp->lfd_curvalcopy, flp->lfl_delims,
		&lfdp->lfd_curvalwords ) < 0 ) {
	free( lfdp->lfd_curvalcopy );
	lfdp->lfd_curvalcopy = NULL;
	return( NULL );
    }

    return( ldap_getnextfilter( lfdp ));
}
Esempio n. 17
0
void forkexit_or_rexec(char **argv)
{
	pid_t pid;
	/* Maybe we are already re-execed and come here again? */
	if (re_execed)
		return;

	pid = vfork();
	if (pid < 0) /* wtf? */
		bb_perror_msg_and_die("vfork");
	if (pid) /* parent */
		exit(0);
	/* child - re-exec ourself */
	re_exec(argv);
}
Esempio n. 18
0
/*
 - regexec - execute regular expression
 */
int
regexec(
    regex_t *re,
    const char *str,
    size_t nmatch,
    regmatch_t pmatch[],
    int flags)
{
    const char *start;
    size_t len;
    int f = flags;

    if (f & REG_STARTEND) {
	start = str + pmatch[0].rm_so;
	len = pmatch[0].rm_eo - pmatch[0].rm_so;
	f &= ~REG_STARTEND;
    } else {
	start = str;
	len = strlen(str);
    }

    return re_exec(re, start, len, nmatch, pmatch, f);
}
Esempio n. 19
0
STATIC mp_obj_t re_match(mp_uint_t n_args, const mp_obj_t *args) {
    return re_exec(true, n_args, args);
}
Esempio n. 20
0
File: report.c Progetto: veox/pcb
static int
ReportNetLengthByName (char *tofind, int x, int y)
{
  int result;
  char *netname = 0;
  Coord length = 0;
  int found = 0;
  int i;
  LibraryMenuType *net;
  ConnectionType conn;
  int net_found = 0;
#if defined(USE_RE)
  int use_re = 0;
#endif
#if defined(HAVE_REGCOMP)
  regex_t elt_pattern;
  regmatch_t match;
#endif
#if defined(HAVE_RE_COMP)
  char *elt_pattern;
#endif

  if (!PCB)
    return 1;

  if (!tofind)
    return 1;

#if defined(USE_RE)
      use_re = 1;
      for (i = 0; i < PCB->NetlistLib.MenuN; i++)
	{
	  net = PCB->NetlistLib.Menu + i;
	  if (strcasecmp (tofind, net->Name + 2) == 0)
	    use_re = 0;
	}
      if (use_re)
	{
#if defined(HAVE_REGCOMP)
	  result =
	    regcomp (&elt_pattern, tofind,
		     REG_EXTENDED | REG_ICASE | REG_NOSUB);
	  if (result)
	    {
	      char errorstring[128];

	      regerror (result, &elt_pattern, errorstring, 128);
	      Message (_("regexp error: %s\n"), errorstring);
	      regfree (&elt_pattern);
	      return (1);
	    }
#endif
#if defined(HAVE_RE_COMP)
	  if ((elt_pattern = re_comp (tofind)) != NULL)
	    {
	      Message (_("re_comp error: %s\n"), elt_pattern);
	      return (1);
	    }
#endif
	}
#endif

  for (i = 0; i < PCB->NetlistLib.MenuN; i++)
    {
      net = PCB->NetlistLib.Menu + i;

#if defined(USE_RE)
	  if (use_re)
	    {
#if defined(HAVE_REGCOMP)
	      if (regexec (&elt_pattern, net->Name + 2, 1, &match, 0) != 0)
		continue;
#endif
#if defined(HAVE_RE_COMP)
	      if (re_exec (net->Name + 2) != 1)
		continue;
#endif
	    }
	  else
#endif
	  if (strcasecmp (net->Name + 2, tofind))
	    continue;

        if (SeekPad (net->Entry, &conn, false))
        {
          switch (conn.type)
          {
            case PIN_TYPE:
              x = ((PinType *) (conn.ptr2))->X;
              y = ((PinType *) (conn.ptr2))->Y;
              net_found=1;
	      break;
            case PAD_TYPE:
              x = ((PadType *) (conn.ptr2))->Point1.X;
              y = ((PadType *) (conn.ptr2))->Point1.Y;
              net_found=1;
	      break;
          }
	  if (net_found)
	    break;
        }
    }

  if (!net_found)
    {
      gui->log (_("No net named %s\n"), tofind);
      return 1;
    }

#ifdef HAVE_REGCOMP
  if (use_re)
    regfree (&elt_pattern);
#endif

  /* Reset all connection flags and save an undo-state to get back
   * to the state the board was in when we started.
   *
   * After this, we don't add any changes to the undo system, but
   * ensure we get back to a point where we can Undo() our changes
   * by resetting the connections with ClearFlagOnAllObjects() before
   * calling Undo() when we are finished.
   */
  ClearFlagOnAllObjects (true, FOUNDFLAG);
  IncrementUndoSerialNumber ();

  length = XYtoNetLength (x, y, &found);
  netname = net->Name + 2;

  ClearFlagOnAllObjects (false, FOUNDFLAG);
  Undo (true);

  if (!found)
    {
      if (net_found)
        gui->log (_("Net found, but no lines or arcs were flagged.\n"));
      else
        gui->log (_("Net not found.\n"));

      return 1;
    }

  {
    char buf[50];
    pcb_snprintf(buf, 50, _("%$m*"), Settings.grid_unit->suffix, length);
    if (netname)
      gui->log (_("Net \"%s\" length: %s\n"), netname, buf);
    else
      gui->log (_("Net length: %s\n"), buf);
  }

  return 0;
}
Esempio n. 21
0
int
main(int argc, char **argv)
{
        typedef enum {
                YOW, FETCH, STORE, DELETE, SCAN, REGEXP
        } commands;
        char opt;
        int flags;
        int giveusage = 0;
        int verbose = 0;
        commands what = YOW;
        char *comarg[3];
        int st_flag = DBM_INSERT;
        int argn;
        DBM *db;
        datum key;
        datum content;

        flags = O_RDWR;
        argn = 0;

        while ((opt = getopt(argc, argv, "acdfFm:rstvx")) != ':') {
                switch (opt) {
                case 'a':
                        what = SCAN;
                        break;
                case 'c':
                        flags |= O_CREAT;
                        break;
                case 'd':
                        what = DELETE;
                        break;
                case 'f':
                        what = FETCH;
                        break;
                case 'F':
                        what = REGEXP;
                        break;
                case 'm':
                        flags &= ~(000007);
                        if (strcmp(optarg, "r") == 0)
                                flags |= O_RDONLY;
                        else if (strcmp(optarg, "w") == 0)
                                flags |= O_WRONLY;
                        else if (strcmp(optarg, "rw") == 0)
                                flags |= O_RDWR;
                        else {
                                fprintf(stderr, "Invalid mode: \"%s\"\n", optarg);
                                giveusage = 1;
                        }
                        break;
                case 'r':
                        st_flag = DBM_REPLACE;
                        break;
                case 's':
                        what = STORE;
                        break;
                case 't':
                        flags |= O_TRUNC;
                        break;
                case 'v':
                        verbose = 1;
                        break;
                case 'x':
                        flags |= O_EXCL;
                        break;
                case '!':
                        giveusage = 1;
                        break;
                case '?':
                        if (argn < 3)
                                comarg[argn++] = optarg;
                        else {
                                fprintf(stderr, "Too many arguments.\n");
                                giveusage = 1;
                        }
                        break;
                }
        }

        if (giveusage || what == YOW || argn < 1) {
                fprintf(stderr, "Usage: %s database [-m r|w|rw] [-crtx] -a|-d|-f|-F|-s [key [content]]\n", argv[0]);
                exit(-1);
        }

        if ((db = dbm_open(comarg[0], flags, 0777)) == NULL) {
                fprintf(stderr, "Error opening database \"%s\"\n", comarg[0]);
                exit(-1);
        }

        if (argn > 1)
                key = read_datum(comarg[1]);
        if (argn > 2)
                content = read_datum(comarg[2]);

        switch (what) {

        case SCAN:
                key = dbm_firstkey(db);
                if (dbm_error(db)) {
                        fprintf(stderr, "Error when fetching first key\n");
                        goto db_exit;
                }
                while (key.dptr != NULL) {
                        content = dbm_fetch(db, key);
                        if (dbm_error(db)) {
                                fprintf(stderr, "Error when fetching ");
                                print_datum(key);
                                printf("\n");
                                goto db_exit;
                        }
                        print_datum(key);
                        printf(": ");
                        print_datum(content);
                        printf("\n");
                        if (dbm_error(db)) {
                                fprintf(stderr, "Error when fetching next key\n");
                                goto db_exit;
                        }
                        key = dbm_nextkey(db);
                }
                break;

        case REGEXP:
                if (argn < 2) {
                        fprintf(stderr, "Missing regular expression.\n");
                        goto db_exit;
                }
                if (re_comp(comarg[1])) {
                        fprintf(stderr, "Invalid regular expression\n");
                        goto db_exit;
                }
                key = dbm_firstkey(db);
                if (dbm_error(db)) {
                        fprintf(stderr, "Error when fetching first key\n");
                        goto db_exit;
                }
                while (key.dptr != NULL) {
                        if (re_exec(key2s(key))) {
                                content = dbm_fetch(db, key);
                                if (dbm_error(db)) {
                                        fprintf(stderr, "Error when fetching ");
                                        print_datum(key);
                                        printf("\n");
                                        goto db_exit;
                                }
                                print_datum(key);
                                printf(": ");
                                print_datum(content);
                                printf("\n");
                                if (dbm_error(db)) {
                                        fprintf(stderr, "Error when fetching next key\n");
                                        goto db_exit;
                                }
                        }
                        key = dbm_nextkey(db);
                }
                break;

        case FETCH:
                if (argn < 2) {
                        fprintf(stderr, "Missing fetch key.\n");
                        goto db_exit;
                }
                content = dbm_fetch(db, key);
                if (dbm_error(db)) {
                        fprintf(stderr, "Error when fetching ");
                        print_datum(key);
                        printf("\n");
                        goto db_exit;
                }
                if (content.dptr == NULL) {
                        fprintf(stderr, "Cannot find ");
                        print_datum(key);
                        printf("\n");
                        goto db_exit;
                }
                print_datum(key);
                printf(": ");
                print_datum(content);
                printf("\n");
                break;

        case DELETE:
                if (argn < 2) {
                        fprintf(stderr, "Missing delete key.\n");
                        goto db_exit;
                }
                if (dbm_delete(db, key) || dbm_error(db)) {
                        fprintf(stderr, "Error when deleting ");
                        print_datum(key);
                        printf("\n");
                        goto db_exit;
                }
                if (verbose) {
                        print_datum(key);
                        printf(": DELETED\n");
                }
                break;

        case STORE:
                if (argn < 3) {
                        fprintf(stderr, "Missing key and/or content.\n");
                        goto db_exit;
                }
                if (dbm_store(db, key, content, st_flag) || dbm_error(db)) {
                        fprintf(stderr, "Error when storing ");
                        print_datum(key);
                        printf("\n");
                        goto db_exit;
                }
                if (verbose) {
                        print_datum(key);
                        printf(": ");
                        print_datum(content);
                        printf(" STORED\n");
                }
                break;
        }

db_exit:
        dbm_clearerr(db);
        dbm_close(db);
        if (dbm_error(db)) {
                fprintf(stderr, "Error closing database \"%s\"\n", comarg[0]);
                exit(-1);
        }
}
Esempio n. 22
0
static int
Netlist (int argc, char **argv, Coord x, Coord y)
{
  NFunc func;
  int i, j;
  LibraryMenuType *net;
  LibraryEntryType *pin;
  int net_found = 0;
  int pin_found = 0;
#if defined(USE_RE)
  int use_re = 0;
#endif
#if defined(HAVE_REGCOMP)
  regex_t elt_pattern;
  regmatch_t match;
#endif
#if defined(HAVE_RE_COMP)
  char *elt_pattern;
#endif

  if (!PCB)
    return 1;
  if (argc == 0)
    {
      Message (netlist_syntax);
      return 1;
    }
  if (strcasecmp (argv[0], "find") == 0)
    func = netlist_find;
  else if (strcasecmp (argv[0], "select") == 0)
    func = netlist_select;
  else if (strcasecmp (argv[0], "rats") == 0)
    func = netlist_rats;
  else if (strcasecmp (argv[0], "norats") == 0)
    func = netlist_norats;
  else if (strcasecmp (argv[0], "clear") == 0)
    {
      func = netlist_clear;
      if (argc == 1)
	{
	  netlist_clear (NULL, NULL);
	  return 0;
	}
    }
  else if (strcasecmp (argv[0], "style") == 0)
    func = (NFunc)netlist_style;
  else if (strcasecmp (argv[0], "add") == 0)
    {
      /* Add is different, because the net/pin won't already exist.  */
      return netlist_add (ARG(1), ARG(2));
    }
  else if (strcasecmp (argv[0], "sort") == 0)
    {
      sort_netlist ();
      return 0;
    }
  else if (strcasecmp (argv[0], "freeze") == 0)
    {
      netlist_frozen ++;
      return 0;
    }
  else if (strcasecmp (argv[0], "thaw") == 0)
    {
      if (netlist_frozen > 0)
	{
	  netlist_frozen --;
	  if (netlist_needs_update)
	    NetlistChanged (0);
	}
      return 0;
    }
  else if (strcasecmp (argv[0], "forcethaw") == 0)
    {
      netlist_frozen = 0;
      if (netlist_needs_update)
	NetlistChanged (0);
      return 0;
    }
  else
    {
      Message (netlist_syntax);
      return 1;
    }

#if defined(USE_RE)
  if (argc > 1)
    {
      int result;
      use_re = 1;
      for (i = 0; i < PCB->NetlistLib.MenuN; i++)
	{
	  net = PCB->NetlistLib.Menu + i;
	  if (strcasecmp (argv[1], net->Name + 2) == 0)
	    use_re = 0;
	}
      if (use_re)
	{
#if defined(HAVE_REGCOMP)
	  result =
	    regcomp (&elt_pattern, argv[1],
		     REG_EXTENDED | REG_ICASE | REG_NOSUB);
	  if (result)
	    {
	      char errorstring[128];

	      regerror (result, &elt_pattern, errorstring, 128);
	      Message (_("regexp error: %s\n"), errorstring);
	      regfree (&elt_pattern);
	      return (1);
	    }
#endif
#if defined(HAVE_RE_COMP)
	  if ((elt_pattern = re_comp (argv[1])) != NULL)
	    {
	      Message (_("re_comp error: %s\n"), elt_pattern);
	      return (false);
	    }
#endif
	}
    }
#endif

  for (i = PCB->NetlistLib.MenuN-1; i >= 0; i--)
    {
      net = PCB->NetlistLib.Menu + i;

      if (argc > 1)
	{
#if defined(USE_RE)
	  if (use_re)
	    {
#if defined(HAVE_REGCOMP)
	      if (regexec (&elt_pattern, net->Name + 2, 1, &match, 0) != 0)
		continue;
#endif
#if defined(HAVE_RE_COMP)
	      if (re_exec (net->Name + 2) != 1)
		continue;
#endif
	    }
	  else
#endif
	  if (strcasecmp (net->Name + 2, argv[1]))
	    continue;
	}
      net_found = 1;

      pin = 0;
      if (func == (void *)netlist_style)
	{
	  netlist_style (net, ARG(2));
	}
      else if (argc > 2)
	{
	  int l = strlen (argv[2]);
	  for (j = net->EntryN-1; j >= 0 ; j--)
	    if (strcasecmp (net->Entry[j].ListEntry, argv[2]) == 0
		|| (strncasecmp (net->Entry[j].ListEntry, argv[2], l) == 0
		    && net->Entry[j].ListEntry[l] == '-'))
	      {
		pin = net->Entry + j;
		pin_found = 1;
		func (net, pin);
	      }
	}
      else
	func (net, 0);
    }

  if (argc > 2 && !pin_found)
    {
      gui->log ("Net %s has no pin %s\n", argv[1], argv[2]);
      return 1;
    }
  else if (!net_found)
    {
      gui->log ("No net named %s\n", argv[1]);
    }
#ifdef HAVE_REGCOMP
  if (use_re)
    regfree (&elt_pattern);
#endif

  return 0;
}
Esempio n. 23
0
static void split(const char *fn)
{
    FILE *fp, *op = NULL;
    long long bytes = bytecount, lines = linecount, n, m;
    char b[4096];
    int c;

    if (fn[0] == '-' && fn[1] == '\0')
	fp = stdin;
    else if ((fp = fopen(fn, "r")) == NULL) {
	fprintf(stderr, "cannot open input");
	exit(1);
    }

    if (linecount > 0) {
	if (pattern == NULL) {
	    while ((c = getc(fp)) != EOF) {
		if (lines >= linecount) {
		    lines = 0;
		    if (op)
			fclose(op);
		    op = nextfile();
		}
		putc(c, op);
		if (c == '\n')
		    lines++;
	    }
	} else {
	    /* process line by line and only count lines
	       matching the pattern */
	    if (re_comp(pattern) != NULL)
		usage();
	    while (fgets(b, 4096, fp) != NULL) {
		/* does the line match? */
		if (re_exec(b))
		    lines++;
		if (lines >= linecount) {
		    lines = 0;
		    if (op)
			fclose(op);
		    op = nextfile();
		}
		fputs(b, op);
	    }
	}
    } else {
	do {
	    if ((n = bytecount - bytes) > sizeof b)
		n = sizeof b;
	    else if (n == 0 && (n = bytecount) > sizeof b)
		n = sizeof b;
	    m = fread(b, 1, n, fp);
	    if (bytes >= bytecount) {
		bytes = 0;
		if (op)
		    fclose(op);
		op = nextfile();
	    }
	    if (m) {
		fwrite(b, 1, m, op);
		bytes += m;
	    }
	}
	while (m);
    }
}
Esempio n. 24
0
int ascanf_strcmp ( ASCB_ARGLIST ) 
{ ASCB_FRAME_SHORT
  ascanf_Function *s1, *s2;
	set_NaN(*result);
	ascanf_arg_error= 0;
	if( !args || ascanf_arguments< 2 ){
		ascanf_arg_error= 1;
	}
	else{
		if( !(s1= parse_ascanf_address(args[0], 0, "ascanf_strcmp", (int) ascanf_verbose, NULL )) || 
			(s1->type== _ascanf_procedure || s1->type== _ascanf_function || !s1->usage)
		){
			if( s1 ){
				fprintf( StdErr, " (warning: 1st argument [%s=%s,\"%s\"] is not a valid string)== ",
					s1->name, ad2str( s1->value, d3str_format, 0), (s1->usage)? s1->usage : "<NULL>"
				);
			}
			else{
				fprintf( StdErr, " (warning: 1st argument is NULL)== " );
			}
		}
		if( !(s2= parse_ascanf_address(args[1], 0, "ascanf_strcmp", (int) ascanf_verbose, NULL )) || 
			(s2->type== _ascanf_procedure || s2->type== _ascanf_function || !s2->usage)
		){
			if( s2 ){
				fprintf( StdErr, " (warning: 2nd argument [%s=%s,\"%s\"] is not a valid string)== ",
					s2->name, ad2str( s2->value, d3str_format, 0), (s2->usage)? s2->usage : "<NULL>"
				);
			}
			else{
				fprintf( StdErr, " (warning: 2nd argument is NULL)== " );
			}
		}
		if( s1 && s2 && s1->usage && s2->usage ){
			if( strncmp( s2->usage, "RE^", 3)== 0 && s2->usage[ strlen(s2->usage)-1]== '$' ){
			  char *c;
				if( (c= re_comp( &(s2->usage[2]) )) ){
					ascanf_emsg= c;
				}
				else{
					*result= !re_exec( s1->usage );
				}
			}
			else{
				if( ascanf_arguments> 2 ){
					if( args[2]< 0 ){
						*result= strncmp( s1->usage, s2->usage, strlen(s2->usage) );
					}
					else{
						*result= strncmp( s1->usage, s2->usage, (int) args[2] );
					}
				}
				else{
					*result= strcmp( s1->usage, s2->usage );
				}
			}
		}
		else{
			set_Inf(*result, 1);
		}
	}
	return(!ascanf_arg_error);
}
Esempio n. 25
0
/* ARGSUSED */
static int
ls_fileproc (void *callerdat, struct file_info *finfo)
{
    Vers_TS *vers;
    char *regex_err;
    Node *p, *n;
    bool isdead;
    const char *filename;

    if (regexp_match)
    {
#ifdef FILENAMES_CASE_INSENSITIVE
	  re_set_syntax (REG_ICASE|RE_SYNTAX_EGREP);
#else
	  re_set_syntax (RE_SYNTAX_EGREP);
#endif
	  if ((regex_err = re_comp (regexp_match)) != NULL)
	  {
	      error (1, 0, "bad regular expression passed to 'ls': %s",
                     regex_err);
	  }
	  if (re_exec (finfo->file) == 0)
	      return 0;				/* no match */
    }

    vers = Version_TS (finfo, NULL, show_tag, show_date, 1, 0);
    /* Skip dead revisions unless specifically requested to do otherwise.
     * We also bother to check for long_format so we can print the state.
     */
    if (vers->vn_rcs && (!show_dead_revs || long_format))
	isdead = RCS_isdead (finfo->rcs, vers->vn_rcs);
    else
	isdead = false;
    if (!vers->vn_rcs || (!show_dead_revs && isdead))
    {
        freevers_ts (&vers);
	return 0;
    }

    p = findnode (callerdat, finfo->update_dir);
    if (!p)
    {
	/* This only occurs when a complete path to a file is specified on the
	 * command line.  Put the file in the root list.
	 */
	filename = finfo->fullname;

	/* Add update_dir node.  */
	p = findnode (callerdat, ".");
	if (!p)
	{
	    p = getnode ();
	    p->key = xstrdup (".");
	    p->data = getlist ();
	    p->delproc = ls_delproc;
	    addnode (callerdat, p);
	}
    }
    else
	filename = finfo->file;

    n = getnode();
    if (entries_format)
    {
	char *outdate = entries_time (RCS_getrevtime (finfo->rcs, vers->vn_rcs,
                                                      0, 0));
	n->data = Xasprintf ("/%s/%s/%s/%s/%s%s\n",
                             filename, vers->vn_rcs,
                             outdate, vers->options,
                             show_tag ? "T" : "", show_tag ? show_tag : "");
	free (outdate);
    }
    else if (long_format)
    {
	struct long_format_data *out =
		xmalloc (sizeof (struct long_format_data));
	out->header = Xasprintf ("%-5.5s",
                                 vers->options[0] != '\0' ? vers->options
                                                          : "----");
	/* FIXME: Do we want to mimc the real `ls' command's date format?  */
	out->time = gmformat_time_t (RCS_getrevtime (finfo->rcs, vers->vn_rcs,
                                                     0, 0));
	out->footer = Xasprintf (" %-9.9s%s %s%s", vers->vn_rcs,
                                 strlen (vers->vn_rcs) > 9 ? "+" : " ",
                                 show_dead_revs ? (isdead ? "dead " : "     ")
                                                : "",
                                 filename);
	n->data = out;
	n->delproc = long_format_data_delproc;
    }
    else
	n->data = Xasprintf ("%s\n", filename);

    addnode (p->data, n);

    freevers_ts (&vers);
    return 0;
}
Esempio n. 26
0
/*
 * Delete a file
 */
void Delete(int UnDel, int Area, char *File)
{
    char		mask[256];
    int			rc = FALSE;
    struct _fdbarea	*fdb_area = NULL;

    if (UnDel)
	IsDoing("Undelete file");
    else
	IsDoing("Delete file");
    ftnd_colour(LIGHTRED, BLACK);

    /*
     * Check area
     */
    if (LoadAreaRec(Area) == FALSE) {
	WriteError("Can't load record %d", Area);
	die(FTNERR_INIT_ERROR);
    }
    if (!area.Available) {
	WriteError("Area %d not available", Area);
	if (!do_quiet)
	    printf("Area %d not available\n", Area);
	die(FTNERR_CONFIG_ERROR);
    }

    if ((fdb_area = ftnddb_OpenFDB(Area, 30)) == NULL)
	die(FTNERR_GENERAL);


    ftnd_colour(CYAN, BLACK);
    strcpy(mask, re_mask(File, FALSE));
    if (re_comp(mask))
	die(FTNERR_GENERAL);

    while (fread(&fdb, fdbhdr.recsize, 1, fdb_area->fp) == 1) {
	if (re_exec(fdb.LName) || re_exec(fdb.Name)) {
	    if (UnDel && fdb.Deleted) {
		fdb.Deleted = FALSE;
		Syslog('+', "Marked file %s in area %d for undeletion", fdb.Name, Area);
		if (!do_quiet)
		    printf("Marked file %s in area %d for undeletion\n", fdb.Name, Area);
		rc = TRUE;
	    }
	    if (!UnDel && !fdb.Deleted) {
		fdb.Deleted = TRUE;
		Syslog('+', "Marked file %s in area %d for deletion", fdb.Name, Area);
		if (!do_quiet)
		    printf("Marked file %s in area %d for deletion\n", fdb.Name, Area);
		rc = TRUE;
	    }
	    if (rc) {
		if (ftnddb_LockFDB(fdb_area, 30)) {
		    fseek(fdb_area->fp, - fdbhdr.recsize, SEEK_CUR);
		    fwrite(&fdb, fdbhdr.recsize, 1, fdb_area->fp);
		    ftnddb_UnlockFDB(fdb_area);
		} else {
		    rc = FALSE;
		}
	    }
	}
    }
    ftnddb_CloseFDB(fdb_area);

    if (!rc) {
	Syslog('+', "%selete %s in area %d failed", UnDel?"Und":"D", File, Area);
	if (!do_quiet)
	    printf("%selete %s in area %d failed\n", UnDel?"Und":"D", File, Area);
    }
}
Esempio n. 27
0
File: string.c Progetto: amihwan/v7
V7_PRIVATE enum v7_err Str_replace(struct v7_c_func_arg *cfa) {
#define v7 (cfa->v7) /* Needed for TRY() macro below */
  struct v7_val *result = v7_push_new_object(v7);
  const char *out_str = cfa->this_obj->v.str.buf;
  uint8_t own = 1;
  size_t out_len = cfa->this_obj->v.str.len;
  int old_sp = v7->sp;

  if (cfa->num_args > 1) {
    const char *const str_end =
        cfa->this_obj->v.str.buf + cfa->this_obj->v.str.len;
    char *p = cfa->this_obj->v.str.buf;
    uint32_t out_sub_num = 0;
    struct v7_val *re = cfa->args[0], *str_func = cfa->args[1], *arr = NULL;
    struct re_tok out_sub[V7_RE_MAX_REPL_SUB], *ptok = out_sub;
    struct Resub loot;
    TRY(check_str_re_conv(v7, &re, 1));
    TRY(regex_check_prog(re));
    if (v7_is_class(str_func, V7_CLASS_FUNCTION)) {
      arr = v7_push_new_object(v7);
      v7_set_class(arr, V7_CLASS_ARRAY);
      TRY(v7_push(v7, str_func));
    } else
      TRY(check_str_re_conv(v7, &str_func, 0));

    out_len = 0;
    do {
      int i;
      if (re_exec(re->v.str.prog, re->fl.fl, p, &loot)) break;
      if (p != loot.sub->start) {
        ptok->start = p;
        ptok->end = loot.sub->start;
        ptok++;
        out_len += loot.sub->start - p;
        out_sub_num++;
      }

      if (NULL != arr) { /* replace function */
        Rune rune;
        int old_sp = v7->sp, utf_shift = 0;
        struct v7_val *rez_str;
        for (i = 0; i < loot.subexpr_num; i++)
          v7_push_string(v7, loot.sub[i].start,
                         loot.sub[i].end - loot.sub[i].start, 1);
        for (i = 0; p + i < loot.sub[0].start;
             i += chartorune(&rune, p + i), utf_shift++)
          ;
        TRY(push_number(v7, utf_shift));
        TRY(v7_push(v7, cfa->this_obj));
        rez_str = v7_call(v7, cfa->this_obj, loot.subexpr_num + 2);
        TRY(check_str_re_conv(v7, &rez_str, 0));
        if (rez_str->v.str.len) {
          ptok->start = rez_str->v.str.buf;
          ptok->end = rez_str->v.str.buf + rez_str->v.str.len;
          ptok++;
          out_len += rez_str->v.str.len;
          out_sub_num++;
          v7_append(v7, arr, rez_str);
        }
        TRY(inc_stack(v7, old_sp - v7->sp));
      } else { /* replace string */
        struct Resub newsub;
        re_rplc(&loot, p, str_func->v.str.buf, &newsub);
        for (i = 0; i < newsub.subexpr_num; i++) {
          ptok->start = newsub.sub[i].start;
          ptok->end = newsub.sub[i].end;
          ptok++;
          out_len += newsub.sub[i].end - newsub.sub[i].start;
          out_sub_num++;
        }
      }
      p = (char *)loot.sub->end;
    } while (re->fl.fl.re_g && p < str_end);
    if (p < str_end) {
      ptok->start = p;
      ptok->end = str_end;
      ptok++;
      out_len += str_end - p;
      out_sub_num++;
    }
    out_str = malloc(out_len + 1);
    CHECK(out_str, V7_OUT_OF_MEMORY);
    ptok = out_sub;
    p = (char *)out_str;
    do {
      size_t ln = ptok->end - ptok->start;
      memcpy(p, ptok->start, ln);
      p += ln;
      ptok++;
    } while (--out_sub_num);
    *p = '\0';
    own = 0;
  }
  TRY(inc_stack(v7, old_sp - v7->sp));
  v7_init_str(result, out_str, out_len, own);
  result->fl.fl.str_alloc = 1;
  return V7_OK;
#undef v7
}
Esempio n. 28
0
STATIC mp_obj_t re_search(mp_uint_t n_args, const mp_obj_t *args) {
    return re_exec(false, n_args, args);
}
Esempio n. 29
0
static int
update_princ_encryption_1(void *cb, krb5_db_entry *ent)
{
    struct update_enc_mkvno *p = cb;
    char *pname = 0;
    krb5_error_code retval;
    int match;
    krb5_timestamp now;
    int result;
    krb5_kvno old_mkvno;

    retval = krb5_unparse_name(util_context, ent->princ, &pname);
    if (retval) {
        com_err(progname, retval,
                _("getting string representation of principal name"));
        goto fail;
    }

    if (krb5_principal_compare(util_context, ent->princ, master_princ)) {
        goto skip;
    }

#ifdef SOLARIS_REGEXPS
    match = (step(pname, p->expbuf) != 0);
#endif
#ifdef POSIX_REGEXPS
    match = (regexec(&p->preg, pname, 0, NULL, 0) == 0);
#endif
#ifdef BSD_REGEXPS
    match = (re_exec(pname) != 0);
#endif
    if (!match) {
        goto skip;
    }
    p->re_match_count++;
    retval = krb5_dbe_get_mkvno(util_context, ent, &old_mkvno);
    if (retval) {
        com_err(progname, retval,
                _("determining master key used for principal '%s'"), pname);
        goto fail;
    }
    /* Line up "skip" and "update" messages for viewing.  */
    if (old_mkvno == new_mkvno) {
        if (p->dry_run && p->verbose)
            printf(_("would skip:   %s\n"), pname);
        else if (p->verbose)
            printf(_("skipping: %s\n"), pname);
        p->already_current++;
        goto skip;
    }
    if (p->dry_run) {
        if (p->verbose)
            printf(_("would update: %s\n"), pname);
        p->updated++;
        goto skip;
    } else if (p->verbose)
        printf(_("updating: %s\n"), pname);
    retval = master_key_convert (util_context, ent);
    if (retval) {
        com_err(progname, retval,
                _("error re-encrypting key for principal '%s'"), pname);
        goto fail;
    }
    if ((retval = krb5_timeofday(util_context, &now))) {
        com_err(progname, retval, _("while getting current time"));
        goto fail;
    }

    if ((retval = krb5_dbe_update_mod_princ_data(util_context, ent,
                                                 now, master_princ))) {
        com_err(progname, retval,
                _("while updating principal '%s' modification time"), pname);
        goto fail;
    }

    ent->mask |= KADM5_KEY_DATA;

    if ((retval = krb5_db_put_principal(util_context, ent))) {
        com_err(progname, retval, _("while updating principal '%s' key data "
                                    "in the database"), pname);
        goto fail;
    }
    p->updated++;
skip:
    result = 0;
    goto egress;
fail:
    exit_status++;
    result = 1;
egress:
    if (pname)
        krb5_free_unparsed_name(util_context, pname);
    return result;
}
Esempio n. 30
0
static bool
rematch (const char *re, const char *s)
{
  /*
   * If this system has regular expression capability, then
   * add support for regular expressions in the skip lists.
   */

#if defined(HAVE_REGCOMP)

  int result;
  regmatch_t match;
  regex_t compiled;

  /* compile the regular expression */
  result = regcomp (&compiled, re, REG_EXTENDED | REG_ICASE | REG_NOSUB);
  if (result)
    {
      char errorstring[128];

      regerror (result, &compiled, errorstring, sizeof (errorstring));
      Message ("regexp error: %s\n", errorstring);
      regfree (&compiled);
      return (false);
    }

  result = regexec (&compiled, s, 1, &match, 0);
  regfree (&compiled);

  if (result == 0)
    return (true);
  else
    return (false);

#elif defined(HAVE_RE_COMP)
  int m;
  char *rslt;

  /* compile the regular expression */
  if ((rslt = re_comp (re)) != NULL)
    {
      Message ("re_comp error: %s\n", rslt);
      return (false);
    }

  m = re_exec (s);

  switch m
    {
    case 1:
      return (true);
      break;

    case 0:
      return (false);
      break;

    default:
      Message ("re_exec error\n");
      break;
    }

#else
  return (false);
#endif

}