Mercurial > octave-nkf
comparison libinterp/corefcn/oct-map.cc @ 20590:1a0a433c8263
eliminate more simple uses of error_state
* dirfns.cc, oct-map.cc, oct-stream.cc, regexp.cc, ov-base-mat.cc,
ov-cell.cc, pt-idx.cc, pt-mat.cc:
Eliminate simple uses of error_state.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Mon, 05 Oct 2015 21:13:12 -0400 |
parents | dd6345fd8a97 |
children |
comparison
equal
deleted
inserted
replaced
20589:b10432a40432 | 20590:1a0a433c8263 |
---|---|
912 { | 912 { |
913 case 1: | 913 case 1: |
914 { | 914 { |
915 idx_vector i = idx(0).index_vector (); | 915 idx_vector i = idx(0).index_vector (); |
916 | 916 |
917 if (! error_state) | 917 retval = index (i, resize_ok); |
918 retval = index (i, resize_ok); | |
919 } | 918 } |
920 break; | 919 break; |
921 | 920 |
922 case 2: | 921 case 2: |
923 { | 922 { |
924 idx_vector i = idx(0).index_vector (); | 923 idx_vector i = idx(0).index_vector (); |
925 | 924 |
926 if (! error_state) | 925 k = 1; |
927 { | 926 idx_vector j = idx(1).index_vector (); |
928 k = 1; | 927 |
929 idx_vector j = idx(1).index_vector (); | 928 retval = index (i, j, resize_ok); |
930 | |
931 retval = index (i, j, resize_ok); | |
932 } | |
933 } | 929 } |
934 break; | 930 break; |
935 | 931 |
936 default: | 932 default: |
937 { | 933 { |
938 Array<idx_vector> ia (dim_vector (n_idx, 1)); | 934 Array<idx_vector> ia (dim_vector (n_idx, 1)); |
939 | 935 |
940 for (k = 0; k < n_idx; k++) | 936 for (k = 0; k < n_idx; k++) |
941 { | 937 ia(k) = idx(k).index_vector (); |
942 ia(k) = idx(k).index_vector (); | 938 |
943 | 939 retval = index (ia, resize_ok); |
944 if (error_state) | |
945 break; | |
946 } | |
947 | |
948 if (! error_state) | |
949 retval = index (ia, resize_ok); | |
950 } | 940 } |
951 break; | 941 break; |
952 } | 942 } |
953 } | 943 } |
954 catch (index_exception& e) | 944 catch (index_exception& e) |
1122 { | 1112 { |
1123 case 1: | 1113 case 1: |
1124 { | 1114 { |
1125 idx_vector i = idx(0).index_vector (); | 1115 idx_vector i = idx(0).index_vector (); |
1126 | 1116 |
1127 if (! error_state) | 1117 assign (i, rhs); |
1128 assign (i, rhs); | |
1129 } | 1118 } |
1130 break; | 1119 break; |
1131 | 1120 |
1132 case 2: | 1121 case 2: |
1133 { | 1122 { |
1134 idx_vector i = idx(0).index_vector (); | 1123 idx_vector i = idx(0).index_vector (); |
1135 | 1124 |
1136 if (! error_state) | 1125 k = 1; |
1137 { | 1126 idx_vector j = idx(1).index_vector (); |
1138 k = 1; | 1127 |
1139 idx_vector j = idx(1).index_vector (); | 1128 assign (i, j, rhs); |
1140 | |
1141 assign (i, j, rhs); | |
1142 } | |
1143 } | 1129 } |
1144 break; | 1130 break; |
1145 | 1131 |
1146 default: | 1132 default: |
1147 { | 1133 { |
1148 Array<idx_vector> ia (dim_vector (n_idx, 1)); | 1134 Array<idx_vector> ia (dim_vector (n_idx, 1)); |
1149 | 1135 |
1150 for (k = 0; k < n_idx; k++) | 1136 for (k = 0; k < n_idx; k++) |
1151 { | 1137 ia(k) = idx(k).index_vector (); |
1152 ia(k) = idx(k).index_vector (); | 1138 |
1153 | 1139 assign (ia, rhs); |
1154 if (error_state) | |
1155 break; | |
1156 } | |
1157 | |
1158 if (! error_state) | |
1159 assign (ia, rhs); | |
1160 } | 1140 } |
1161 break; | 1141 break; |
1162 } | 1142 } |
1163 } | 1143 } |
1164 catch (index_exception& e) | 1144 catch (index_exception& e) |
1180 if (&ref == &tmp) | 1160 if (&ref == &tmp) |
1181 ref = Cell (dimensions); | 1161 ref = Cell (dimensions); |
1182 | 1162 |
1183 ref.assign (idx, rhs); | 1163 ref.assign (idx, rhs); |
1184 | 1164 |
1185 if (! error_state && ref.dims () != dimensions) | 1165 if (ref.dims () != dimensions) |
1186 { | 1166 { |
1187 dimensions = ref.dims (); | 1167 dimensions = ref.dims (); |
1188 | 1168 |
1189 octave_idx_type nf = nfields (); | 1169 octave_idx_type nf = nfields (); |
1190 for (octave_idx_type i = 0; i < nf; i++) | 1170 for (octave_idx_type i = 0; i < nf; i++) |
1194 } | 1174 } |
1195 | 1175 |
1196 optimize_dimensions (); | 1176 optimize_dimensions (); |
1197 } | 1177 } |
1198 | 1178 |
1199 if (! error_state && &ref == &tmp) | 1179 if (&ref == &tmp) |
1200 setfield (k, tmp); | 1180 setfield (k, tmp); |
1201 } | 1181 } |
1202 | 1182 |
1203 /* | 1183 /* |
1204 %!test | 1184 %!test |
1284 { | 1264 { |
1285 // Rethrow to allow more info to be reported later. | 1265 // Rethrow to allow more info to be reported later. |
1286 e.set_pos_if_unset (n_idx, i+1); | 1266 e.set_pos_if_unset (n_idx, i+1); |
1287 throw; | 1267 throw; |
1288 } | 1268 } |
1289 | 1269 } |
1290 if (error_state) | 1270 |
1291 break; | 1271 delete_elements (ia); |
1292 } | |
1293 | |
1294 if (! error_state) | |
1295 delete_elements (ia); | |
1296 } | 1272 } |
1297 | 1273 |
1298 /* | 1274 /* |
1299 ## test preservation of key order by indexing | 1275 ## test preservation of key order by indexing |
1300 %!test | 1276 %!test |