comparison src/if_py_both.h @ 4513:cadb57fbb781 v7.3.1004

updated for version 7.3.1004 Problem: No error when option could not be set. Solution: Report an error. (ZyX)
author Bram Moolenaar <bram@vim.org>
date Tue, 21 May 2013 22:38:18 +0200
parents ce94a870b59b
children 57393dc4b811
comparison
equal deleted inserted replaced
4512:1faad5feb5f3 4513:cadb57fbb781
1519 return NULL; 1519 return NULL;
1520 } 1520 }
1521 } 1521 }
1522 1522
1523 static int 1523 static int
1524 set_option_value_err(key, numval, stringval, opt_flags)
1525 char_u *key;
1526 int numval;
1527 char_u *stringval;
1528 int opt_flags;
1529 {
1530 char_u *errmsg;
1531
1532 if ((errmsg = set_option_value(key, numval, stringval, opt_flags)))
1533 {
1534 if (VimTryEnd())
1535 return FAIL;
1536 PyErr_SetVim((char *)errmsg);
1537 return FAIL;
1538 }
1539 return OK;
1540 }
1541
1542 static int
1524 set_option_value_for(key, numval, stringval, opt_flags, opt_type, from) 1543 set_option_value_for(key, numval, stringval, opt_flags, opt_type, from)
1525 char_u *key; 1544 char_u *key;
1526 int numval; 1545 int numval;
1527 char_u *stringval; 1546 char_u *stringval;
1528 int opt_flags; 1547 int opt_flags;
1530 void *from; 1549 void *from;
1531 { 1550 {
1532 win_T *save_curwin = NULL; 1551 win_T *save_curwin = NULL;
1533 tabpage_T *save_curtab = NULL; 1552 tabpage_T *save_curtab = NULL;
1534 buf_T *save_curbuf = NULL; 1553 buf_T *save_curbuf = NULL;
1554 int r = 0;
1535 1555
1536 VimTryStart(); 1556 VimTryStart();
1537 switch (opt_type) 1557 switch (opt_type)
1538 { 1558 {
1539 case SREQ_WIN: 1559 case SREQ_WIN:
1543 if (VimTryEnd()) 1563 if (VimTryEnd())
1544 return -1; 1564 return -1;
1545 PyErr_SetVim("Problem while switching windows."); 1565 PyErr_SetVim("Problem while switching windows.");
1546 return -1; 1566 return -1;
1547 } 1567 }
1548 set_option_value(key, numval, stringval, opt_flags); 1568 r = set_option_value_err(key, numval, stringval, opt_flags);
1549 restore_win(save_curwin, save_curtab); 1569 restore_win(save_curwin, save_curtab);
1570 if (r == FAIL)
1571 return -1;
1550 break; 1572 break;
1551 case SREQ_BUF: 1573 case SREQ_BUF:
1552 switch_buffer(&save_curbuf, (buf_T *)from); 1574 switch_buffer(&save_curbuf, (buf_T *)from);
1553 set_option_value(key, numval, stringval, opt_flags); 1575 r = set_option_value_err(key, numval, stringval, opt_flags);
1554 restore_buffer(save_curbuf); 1576 restore_buffer(save_curbuf);
1577 if (r == FAIL)
1578 return -1;
1555 break; 1579 break;
1556 case SREQ_GLOBAL: 1580 case SREQ_GLOBAL:
1557 set_option_value(key, numval, stringval, opt_flags); 1581 r = set_option_value_err(key, numval, stringval, opt_flags);
1582 if (r == FAIL)
1583 return -1;
1558 break; 1584 break;
1559 } 1585 }
1560 return VimTryEnd(); 1586 return VimTryEnd();
1561 } 1587 }
1562 1588
1609 opt_flags = (self->opt_type ? OPT_LOCAL : OPT_GLOBAL); 1635 opt_flags = (self->opt_type ? OPT_LOCAL : OPT_GLOBAL);
1610 1636
1611 if (flags & SOPT_BOOL) 1637 if (flags & SOPT_BOOL)
1612 { 1638 {
1613 int istrue = PyObject_IsTrue(valObject); 1639 int istrue = PyObject_IsTrue(valObject);
1640
1614 if (istrue == -1) 1641 if (istrue == -1)
1615 return -1; 1642 return -1;
1616 r = set_option_value_for(key, istrue, NULL, 1643 r = set_option_value_for(key, istrue, NULL,
1617 opt_flags, self->opt_type, self->from); 1644 opt_flags, self->opt_type, self->from);
1618 } 1645 }