Changeset ca54fd6 for commands.c
- Timestamp:
- Jul 3, 2011, 8:42:55 PM (13 years ago)
- Branches:
- master, release-1.10, release-1.8, release-1.9
- Children:
- ca749a9
- Parents:
- bc1d648
- git-author:
- Jason Gross <jgross@mit.edu> (06/27/11 01:14:13)
- git-committer:
- Jason Gross <jgross@mit.edu> (07/03/11 20:42:55)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
commands.c
re6d7e4e rca54fd6 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 && owl_variable_get_type(v) != 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 (owl_variable_get_type(v) != 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) { 1654 v = owl_variable_get_var(owl_global_get_vardict(&g), var); 1655 if (v) { 1656 value = owl_variable_get_tostring(v); 1637 1657 owl_function_makemsg("%s = '%s'", var, value); 1638 1658 g_free(value); … … 2505 2525 } 2506 2526 2507 char *owl_command_getvar(int argc, const char *const *argv, const char *buff) 2508 { 2527 CALLER_OWN char *owl_command_getvar(int argc, const char *const *argv, const char *buff) 2528 { 2529 const owl_variable *v; 2509 2530 if (argc != 2) { 2510 2531 owl_function_makemsg("Wrong number of arguments for %s", argv[0]); 2511 2532 return NULL; 2512 2533 } 2513 return owl_variable_get_tostring(owl_global_get_vardict(&g), argv[1]); 2534 v = owl_variable_get_var(owl_global_get_vardict(&g), argv[1]); 2535 if (v == NULL) return NULL; 2536 return owl_variable_get_tostring(v); 2514 2537 } 2515 2538
Note: See TracChangeset
for help on using the changeset viewer.