Changeset 486688f for variable.c


Ignore:
Timestamp:
Sep 28, 2002, 1:14:45 PM (18 years ago)
Author:
Erik Nygren <nygren@mit.edu>
Branches:
master, barnowl_perlaim, debian, owl, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
88736cb
Parents:
55a4578
Message:
Will attempt to keep the current message as close as possible
	     to the previous current message after an expunge.
"set <variable>" and "unset <variable>" now work for boolean variables.
	   (although I'm not totally happy with how I implemented it.)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • variable.c

    r700c712 r486688f  
    430430
    431431/* returns 0 on success, prints a status msg if msg is true */
    432 int owl_variable_set_fromstring(owl_vardict *d, char *name, char *value, int msg) {
     432int owl_variable_set_fromstring(owl_vardict *d, char *name, char *value, int msg, int requirebool) {
    433433  owl_variable *v;
    434434  char buff2[1024];
     
    441441  if (!v->set_fromstring_fn) {
    442442    if (msg) owl_function_makemsg("Variable %s is read-only", name);
    443     return -1;
    444    
     443    return -1;   
     444  }
     445  if (requirebool && v->type!=OWL_VARIABLE_BOOL) {
     446    if (msg) owl_function_makemsg("Variable %s is not a boolean", name);
     447    return -1;   
    445448  }
    446449  if (0 != v->set_fromstring_fn(v, value)) {
     
    801804  FAIL_UNLESS("set bool 1", 0==owl_variable_set_bool_on(&vd,"personalbell"));
    802805  FAIL_UNLESS("get bool 2", 1==owl_variable_get_bool(&vd,"personalbell"));
    803   FAIL_UNLESS("set bool 3", 0==owl_variable_set_fromstring(&vd,"personalbell","off",0));
     806  FAIL_UNLESS("set bool 3", 0==owl_variable_set_fromstring(&vd,"personalbell","off",0,0));
    804807  FAIL_UNLESS("get bool 4", 0==owl_variable_get_bool(&vd,"personalbell"));
    805   FAIL_UNLESS("set bool 5", -1==owl_variable_set_fromstring(&vd,"personalbell","xxx",0));
     808  FAIL_UNLESS("set bool 5", -1==owl_variable_set_fromstring(&vd,"personalbell","xxx",0,0));
    806809  FAIL_UNLESS("get bool 6", 0==owl_variable_get_bool(&vd,"personalbell"));
    807810
     
    819822  FAIL_UNLESS("set int 1b", -1==owl_variable_set_int(&vd,"typewinsize",-3));
    820823  FAIL_UNLESS("get int 2b", 12==owl_variable_get_int(&vd,"typewinsize"));
    821   FAIL_UNLESS("set int 3", 0==owl_variable_set_fromstring(&vd,"typewinsize","9",0));
     824  FAIL_UNLESS("set int 3", 0==owl_variable_set_fromstring(&vd,"typewinsize","9",0,0));
    822825  FAIL_UNLESS("get int 4", 9==owl_variable_get_int(&vd,"typewinsize"));
    823   FAIL_UNLESS("set int 5", -1==owl_variable_set_fromstring(&vd,"typewinsize","xxx",0));
    824   FAIL_UNLESS("set int 6", -1==owl_variable_set_fromstring(&vd,"typewinsize","",0));
     826  FAIL_UNLESS("set int 5", -1==owl_variable_set_fromstring(&vd,"typewinsize","xxx",0,0));
     827  FAIL_UNLESS("set int 6", -1==owl_variable_set_fromstring(&vd,"typewinsize","",0,0));
    825828  FAIL_UNLESS("get int 7", 9==owl_variable_get_int(&vd,"typewinsize"));
    826829
     
    833836  FAIL_UNLESS("set enum 1b", -1==owl_variable_set_int(&vd,"webbrowser",209));
    834837  FAIL_UNLESS("get enum 2b", OWL_WEBBROWSER_GALEON==owl_variable_get_int(&vd,"webbrowser"));
    835   FAIL_UNLESS("set enum 3", 0==owl_variable_set_fromstring(&vd,"webbrowser","none",0));
     838  FAIL_UNLESS("set enum 3", 0==owl_variable_set_fromstring(&vd,"webbrowser","none",0,0));
    836839  FAIL_UNLESS("get enum 4", OWL_WEBBROWSER_NONE==owl_variable_get_int(&vd,"webbrowser"));
    837   FAIL_UNLESS("set enum 5", 0==owl_variable_set_fromstring(&vd,"webbrowser","netscape",0));
     840  FAIL_UNLESS("set enum 5", 0==owl_variable_set_fromstring(&vd,"webbrowser","netscape",0,0));
    838841  FAIL_UNLESS("get enum 6", OWL_WEBBROWSER_NETSCAPE==owl_variable_get_int(&vd,"webbrowser"));
    839   FAIL_UNLESS("set enum 7", -1==owl_variable_set_fromstring(&vd,"webbrowser","xxx",0));
    840   FAIL_UNLESS("set enum 8", -1==owl_variable_set_fromstring(&vd,"webbrowser","",0));
    841   FAIL_UNLESS("set enum 9", -1==owl_variable_set_fromstring(&vd,"webbrowser","netscapey",0));
     842  FAIL_UNLESS("set enum 7", -1==owl_variable_set_fromstring(&vd,"webbrowser","xxx",0,0));
     843  FAIL_UNLESS("set enum 8", -1==owl_variable_set_fromstring(&vd,"webbrowser","",0,0));
     844  FAIL_UNLESS("set enum 9", -1==owl_variable_set_fromstring(&vd,"webbrowser","netscapey",0,0));
    842845  FAIL_UNLESS("get enum 10", OWL_WEBBROWSER_NETSCAPE==owl_variable_get_int(&vd,"webbrowser"));
    843846
Note: See TracChangeset for help on using the changeset viewer.