Changeset 41c9a96 for global.c


Ignore:
Timestamp:
Jul 24, 2009, 12:59:23 AM (15 years ago)
Author:
Anders Kaseorg <andersk@mit.edu>
Branches:
master, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
64c9165
Parents:
ab225e0
git-author:
Anders Kaseorg <andersk@mit.edu> (07/24/09 00:51:10)
git-committer:
Anders Kaseorg <andersk@mit.edu> (07/24/09 00:59:23)
Message:
Reimplement search in terms of owl_regex.

The current implementation of stristr has problems and there isn’t a
good replacement available.  This was its only caller, so we can get
rid of it now.

Also, this will make it possible to search with arbitrary regexes if
someone feels like coming up with a syntax.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
File:
1 edited

Legend:

Unmodified
Added
Removed
  • global.c

    r898eb15 r41c9a96  
    6565  owl_fmtext_init_colorpair_mgr(&(g->cpmgr));
    6666  g->debug=OWL_DEBUG;
    67   g->searchstring=NULL;
     67  owl_regex_init(&g->search_re);
    6868  g->starttime=time(NULL); /* assumes we call init only a start time */
    6969  g->lastinputtime=g->starttime;
     
    708708
    709709int owl_global_is_search_active(owl_global *g) {
    710   if (g->searchstring != NULL) return(1);
    711   return(0);
    712 }
    713 
    714 void owl_global_set_search_string(owl_global *g, char *string) {
    715   if (g->searchstring != NULL) owl_free(g->searchstring);
    716   g->searchstring = string ? owl_strdup(string) : NULL;
    717 }
    718 
    719 char *owl_global_get_search_string(owl_global *g) {
    720   if (g->searchstring==NULL) return("");
    721   return(g->searchstring);
     710  if (owl_regex_is_set(&g->search_re)) return(1);
     711  return(0);
     712}
     713
     714void owl_global_set_search_re(owl_global *g, owl_regex *re) {
     715  if (owl_regex_is_set(&g->search_re)) {
     716    owl_regex_free(&g->search_re);
     717    owl_regex_init(&g->search_re);
     718  }
     719  if (re != NULL)
     720    owl_regex_copy(re, &g->search_re);
     721}
     722
     723owl_regex *owl_global_get_search_re(owl_global *g) {
     724  return &g->search_re;
    722725}
    723726
Note: See TracChangeset for help on using the changeset viewer.