Changeset 83e023e


Ignore:
Timestamp:
Jul 23, 2011, 7:22:12 PM (13 years ago)
Author:
David Benjamin <davidben@mit.edu>
Children:
c40d11a
Parents:
e9a939b
git-author:
David Benjamin <davidben@mit.edu> (07/23/11 18:54:46)
git-committer:
David Benjamin <davidben@mit.edu> (07/23/11 19:22:12)
Message:
Don't attempt to switch filters in :view -d if invalid

Add return value to owl_function_create_filter and check before
switching.
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    refeec7f r83e023e  
    21652165      myargv[i]=argv[i];
    21662166    }
    2167     owl_function_create_filter(argc, myargv);
    2168     owl_function_change_currentview_filter("owl-dynamic");
     2167    if (owl_function_create_filter(argc, myargv)) {
     2168      owl_function_change_currentview_filter("owl-dynamic");
     2169    }
    21692170    g_free(myargv);
    21702171    return NULL;
  • functions.c

    r6500907 r83e023e  
    21262126
    21272127/* Create a new filter, or replace an existing one
    2128  * with a new definition.
     2128 * with a new definition. Returns true on success.
    21292129 */
    2130 void owl_function_create_filter(int argc, const char *const *argv)
     2130bool owl_function_create_filter(int argc, const char *const *argv)
    21312131{
    21322132  owl_filter *f;
     
    21362136  if (argc < 2) {
    21372137    owl_function_error("Wrong number of arguments to filter command");
    2138     return;
     2138    return false;
    21392139  }
    21402140
     
    21462146  if (!strcmp(argv[1], "all")) {
    21472147    owl_function_error("You may not change the 'all' filter.");
    2148     return;
     2148    return false;
    21492149  }
    21502150
     
    21542154    if (!f) {
    21552155      owl_function_error("The filter '%s' does not exist.", argv[1]);
    2156       return;
     2156      return false;
    21572157    }
    21582158    if (owl_util_string_to_color(argv[3])==OWL_COLOR_INVALID) {
    21592159      owl_function_error("The color '%s' is not available.", argv[3]);
    2160       return;
     2160      return false;
    21612161    }
    21622162    owl_filter_set_fgcolor(f, owl_util_string_to_color(argv[3]));
    21632163    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    2164     return;
     2164    return false;
    21652165  }
    21662166  if (argc==4 && !strcmp(argv[2], "-b")) {
     
    21682168    if (!f) {
    21692169      owl_function_error("The filter '%s' does not exist.", argv[1]);
    2170       return;
     2170      return false;
    21712171    }
    21722172    if (owl_util_string_to_color(argv[3])==OWL_COLOR_INVALID) {
    21732173      owl_function_error("The color '%s' is not available.", argv[3]);
    2174       return;
     2174      return false;
    21752175    }
    21762176    owl_filter_set_bgcolor(f, owl_util_string_to_color(argv[3]));
    21772177    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    2178     return;
     2178    return true;
    21792179  }
    21802180
     
    21832183  if (f == NULL) {
    21842184    owl_function_error("Invalid filter");
    2185     return;
     2185    return false;
    21862186  }
    21872187
     
    22042204  }
    22052205  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     2206  return true;
    22062207}
    22072208
Note: See TracChangeset for help on using the changeset viewer.