Changeset 0d935a1 for commands.c
- Timestamp:
- Jun 27, 2011, 4:28:51 AM (14 years ago)
- Children:
- b75a8ac
- Parents:
- f4e857f
- git-author:
- Jason Gross <jgross@mit.edu> (06/27/11 01:14:13)
- git-committer:
- Jason Gross <jgross@mit.edu> (06/27/11 04:28:51)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
commands.c
re6d7e4e r0d935a1 1572 1572 int silent=0; 1573 1573 int requirebool=0; 1574 owl_variable *v; 1574 1575 1575 1576 if (argc == 1) { … … 1594 1595 return NULL; 1595 1596 } 1596 owl_variable_set_fromstring(owl_global_get_vardict(&g), var, val, !silent, requirebool); 1597 1598 v = owl_variable_get_var(owl_global_get_vardict(&g), var); 1599 if (v == NULL) { 1600 if (!silent) owl_function_error("Unknown variable %s", var); 1601 } else if (requirebool && v->type != OWL_VARIABLE_BOOL) { 1602 if (!silent) owl_function_error("Variable %s is not a boolean", var); 1603 } else { 1604 owl_variable_set_fromstring(v, val, !silent); 1605 } 1597 1606 return NULL; 1598 1607 } … … 1600 1609 char *owl_command_unset(int argc, const char *const *argv, const char *buff) 1601 1610 { 1611 owl_variable *v; 1602 1612 const char *var, *val; 1603 1613 int silent=0; … … 1614 1624 return NULL; 1615 1625 } 1616 owl_variable_set_fromstring(owl_global_get_vardict(&g), var, val, !silent, 1); 1626 1627 v = owl_variable_get_var(owl_global_get_vardict(&g), var); 1628 if (v == NULL) { 1629 if (!silent) owl_function_error("Unknown variable %s", var); 1630 } else if (v->type != OWL_VARIABLE_BOOL) { 1631 if (!silent) owl_function_error("Variable %s is not a boolean", var); 1632 } else { 1633 owl_variable_set_fromstring(v, val, !silent); 1634 } 1617 1635 return NULL; 1618 1636 } … … 1622 1640 const char *var; 1623 1641 char *value; 1642 const owl_variable *v; 1624 1643 1625 1644 if (argc==1) { … … 1633 1652 var=argv[1]; 1634 1653 1635 value = owl_variable_get_tostring(owl_global_get_vardict(&g), var); 1636 if (value) { 1637 owl_function_makemsg("%s = '%s'", var, value); 1654 v = owl_variable_get_var(owl_global_get_vardict(&g), var); 1655 if (v) { 1656 value = owl_variable_get_tostring(v); 1657 if (value == NULL) 1658 owl_function_makemsg("%s = <null>", var); 1659 else 1660 owl_function_makemsg("%s = '%s'", var, value); 1638 1661 g_free(value); 1639 1662 } else { … … 2505 2528 } 2506 2529 2507 char *owl_command_getvar(int argc, const char *const *argv, const char *buff) 2508 { 2530 CALLER_OWN char *owl_command_getvar(int argc, const char *const *argv, const char *buff) 2531 { 2532 const owl_variable *v; 2509 2533 if (argc != 2) { 2510 2534 owl_function_makemsg("Wrong number of arguments for %s", argv[0]); 2511 2535 return NULL; 2512 2536 } 2513 return owl_variable_get_tostring(owl_global_get_vardict(&g), argv[1]); 2537 v = owl_variable_get_var(owl_global_get_vardict(&g), argv[1]); 2538 if (v == NULL) return NULL; 2539 return owl_variable_get_tostring(v); 2514 2540 } 2515 2541
Note: See TracChangeset
for help on using the changeset viewer.