Changeset 12a4d6e


Ignore:
Timestamp:
Mar 11, 2012, 11:24:43 PM (9 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
release-1.8
Children:
fe569d7
Parents:
07cd24d
git-author:
David Benjamin <davidben@mit.edu> (07/23/11 18:54:46)
git-committer:
David Benjamin <davidben@mit.edu> (03/11/12 23:24:43)
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

    r07cd24d r12a4d6e  
    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

    r5b54595 r12a4d6e  
    21282128
    21292129/* Create a new filter, or replace an existing one
    2130  * with a new definition.
     2130 * with a new definition. Returns true on success.
    21312131 */
    2132 void owl_function_create_filter(int argc, const char *const *argv)
     2132bool owl_function_create_filter(int argc, const char *const *argv)
    21332133{
    21342134  owl_filter *f;
     
    21382138  if (argc < 2) {
    21392139    owl_function_error("Wrong number of arguments to filter command");
    2140     return;
     2140    return false;
    21412141  }
    21422142
     
    21482148  if (!strcmp(argv[1], "all")) {
    21492149    owl_function_error("You may not change the 'all' filter.");
    2150     return;
     2150    return false;
    21512151  }
    21522152
     
    21562156    if (!f) {
    21572157      owl_function_error("The filter '%s' does not exist.", argv[1]);
    2158       return;
     2158      return false;
    21592159    }
    21602160    if (owl_util_string_to_color(argv[3])==OWL_COLOR_INVALID) {
    21612161      owl_function_error("The color '%s' is not available.", argv[3]);
    2162       return;
     2162      return false;
    21632163    }
    21642164    owl_filter_set_fgcolor(f, owl_util_string_to_color(argv[3]));
    21652165    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    2166     return;
     2166    return false;
    21672167  }
    21682168  if (argc==4 && !strcmp(argv[2], "-b")) {
     
    21702170    if (!f) {
    21712171      owl_function_error("The filter '%s' does not exist.", argv[1]);
    2172       return;
     2172      return false;
    21732173    }
    21742174    if (owl_util_string_to_color(argv[3])==OWL_COLOR_INVALID) {
    21752175      owl_function_error("The color '%s' is not available.", argv[3]);
    2176       return;
     2176      return false;
    21772177    }
    21782178    owl_filter_set_bgcolor(f, owl_util_string_to_color(argv[3]));
    21792179    owl_mainwin_redisplay(owl_global_get_mainwin(&g));
    2180     return;
     2180    return true;
    21812181  }
    21822182
     
    21852185  if (f == NULL) {
    21862186    owl_function_error("Invalid filter");
    2187     return;
     2187    return false;
    21882188  }
    21892189
     
    22062206  }
    22072207  owl_mainwin_redisplay(owl_global_get_mainwin(&g));
     2208  return true;
    22082209}
    22092210
Note: See TracChangeset for help on using the changeset viewer.