Mercurial > octave-nkf
comparison libinterp/interpfcn/graphics.cc @ 16312:d81ef5e64cf1
Accept only case-sensitive keywords 'default', 'factory', 'remove' for graphics properties.
For Matlab compatibility, change escaped versions of keywords ('\keyword') to 'keyword'.
* libinterp/interpfcn/graphics.cc(set, set_value_or_default): Switch from
caseless_str to std::string so that compare() is case sensitive. Look for
escaped keyword ('\default', '\factory') and replace with bare keyword.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 15 Mar 2013 10:21:06 -0700 |
parents | 9ba5c5ed3aeb |
children | fd5a4b7f59f7 |
comparison
equal
deleted
inserted
replaced
16311:9c4ac8f25a8c | 16312:d81ef5e64cf1 |
---|---|
1787 if (has_property) | 1787 if (has_property) |
1788 { | 1788 { |
1789 bool remove = false; | 1789 bool remove = false; |
1790 if (val.is_string ()) | 1790 if (val.is_string ()) |
1791 { | 1791 { |
1792 caseless_str tval = val.string_value (); | 1792 std::string tval = val.string_value (); |
1793 | 1793 |
1794 remove = tval.compare ("remove"); | 1794 remove = (tval.compare ("remove") == 0); |
1795 } | 1795 } |
1796 | 1796 |
1797 pval_map_type& pval_map = plist_map[pfx]; | 1797 pval_map_type& pval_map = plist_map[pfx]; |
1798 | 1798 |
1799 if (remove) | 1799 if (remove) |
2103 graphics_object::set_value_or_default (const caseless_str& name, | 2103 graphics_object::set_value_or_default (const caseless_str& name, |
2104 const octave_value& val) | 2104 const octave_value& val) |
2105 { | 2105 { |
2106 if (val.is_string ()) | 2106 if (val.is_string ()) |
2107 { | 2107 { |
2108 caseless_str tval = val.string_value (); | 2108 std::string tval = val.string_value (); |
2109 | 2109 |
2110 octave_value default_val; | 2110 octave_value default_val; |
2111 | 2111 |
2112 if (tval.compare ("default")) | 2112 if (tval.compare ("default") == 0) |
2113 { | 2113 { |
2114 default_val = get_default (name); | 2114 default_val = get_default (name); |
2115 | 2115 |
2116 if (error_state) | 2116 if (error_state) |
2117 return; | 2117 return; |
2118 | 2118 |
2119 rep->set (name, default_val); | 2119 rep->set (name, default_val); |
2120 } | 2120 } |
2121 else if (tval.compare ("factory")) | 2121 else if (tval.compare ("factory") == 0) |
2122 { | 2122 { |
2123 default_val = get_factory_default (name); | 2123 default_val = get_factory_default (name); |
2124 | 2124 |
2125 if (error_state) | 2125 if (error_state) |
2126 return; | 2126 return; |
2127 | 2127 |
2128 rep->set (name, default_val); | 2128 rep->set (name, default_val); |
2129 } | 2129 } |
2130 else | 2130 else |
2131 rep->set (name, val); | 2131 { |
2132 // Matlab specifically uses "\default" to escape string setting | |
2133 if (tval.compare ("\\default") == 0) | |
2134 rep->set (name, "default"); | |
2135 else if (tval.compare ("\\factory") == 0) | |
2136 rep->set (name, "factory"); | |
2137 else | |
2138 rep->set (name, val); | |
2139 } | |
2132 } | 2140 } |
2133 else | 2141 else |
2134 rep->set (name, val); | 2142 rep->set (name, val); |
2135 } | 2143 } |
2136 | 2144 |