Mercurial > jwe > octave
comparison libinterp/corefcn/ls-mat5.cc @ 28144:992a7a4f1476 stable
* ls-mat5.cc: Use warning_with_id for all warnings.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 26 Feb 2020 13:28:07 -0500 |
parents | a4268efb7334 |
children | d13ad9dc9348 7a8c69c4eb55 |
comparison
equal
deleted
inserted
replaced
28141:23f667483fab | 28144:992a7a4f1476 |
---|---|
923 | 923 |
924 if (ov_fcn.is_defined ()) | 924 if (ov_fcn.is_defined ()) |
925 tc = octave_value (new octave_fcn_handle (ov_fcn, fname)); | 925 tc = octave_value (new octave_fcn_handle (ov_fcn, fname)); |
926 else | 926 else |
927 { | 927 { |
928 warning ("load: can't find the file %s", | 928 warning_with_id ("Octave:load:file-not-found", |
929 fpath.c_str ()); | 929 "load: can't find the file %s", |
930 fpath.c_str ()); | |
930 goto skip_ahead; | 931 goto skip_ahead; |
931 } | 932 } |
932 } | 933 } |
933 } | 934 } |
934 else | 935 else |
944 | 945 |
945 if (ov_fcn.is_defined ()) | 946 if (ov_fcn.is_defined ()) |
946 tc = octave_value (new octave_fcn_handle (ov_fcn, fname)); | 947 tc = octave_value (new octave_fcn_handle (ov_fcn, fname)); |
947 else | 948 else |
948 { | 949 { |
949 warning ("load: can't find the file %s", | 950 warning_with_id ("Octave:load:file-not-found", |
950 fpath.c_str ()); | 951 "load: can't find the file %s", |
952 fpath.c_str ()); | |
951 goto skip_ahead; | 953 goto skip_ahead; |
952 } | 954 } |
953 } | 955 } |
954 } | 956 } |
955 } | 957 } |
956 else if (ftype == "nested") | 958 else if (ftype == "nested") |
957 { | 959 { |
958 warning ("load: can't load nested function"); | 960 warning_with_id ("Octave:load:unsupported-type", |
961 "load: can't load nested function"); | |
959 goto skip_ahead; | 962 goto skip_ahead; |
960 } | 963 } |
961 else if (ftype == "anonymous") | 964 else if (ftype == "anonymous") |
962 { | 965 { |
963 octave_scalar_map m2 | 966 octave_scalar_map m2 |
1183 octave::cdef_manager& cdm = interp.get_cdef_manager (); | 1186 octave::cdef_manager& cdm = interp.get_cdef_manager (); |
1184 | 1187 |
1185 if (cdm.find_class (classname, false, true).ok ()) | 1188 if (cdm.find_class (classname, false, true).ok ()) |
1186 { | 1189 { |
1187 tc = m; | 1190 tc = m; |
1188 warning ("load: classdef element has been converted to a struct"); | 1191 warning_with_id ("Octave:load:classdef-to-struct", |
1192 "load: classdef element has been converted to a struct"); | |
1189 } | 1193 } |
1190 else | 1194 else |
1191 { | 1195 { |
1192 octave_class *cls | 1196 octave_class *cls |
1193 = new octave_class (m, classname, | 1197 = new octave_class (m, classname, |
1195 | 1199 |
1196 if (cls->reconstruct_exemplar ()) | 1200 if (cls->reconstruct_exemplar ()) |
1197 { | 1201 { |
1198 | 1202 |
1199 if (! cls->reconstruct_parents ()) | 1203 if (! cls->reconstruct_parents ()) |
1200 warning ("load: unable to reconstruct object inheritance"); | 1204 warning_with_id ("Octave:load:classdef-object-inheritance", |
1205 "load: unable to reconstruct object inheritance"); | |
1201 | 1206 |
1202 tc = cls; | 1207 tc = cls; |
1203 | 1208 |
1204 octave::load_path& lp = interp.get_load_path (); | 1209 octave::load_path& lp = interp.get_load_path (); |
1205 | 1210 |
1218 } | 1223 } |
1219 } | 1224 } |
1220 else | 1225 else |
1221 { | 1226 { |
1222 tc = m; | 1227 tc = m; |
1223 warning ("load: element has been converted to a structure"); | 1228 warning_with_id ("Octave:load:classdef-to-struct", |
1229 "load: element has been converted to a structure"); | |
1224 } | 1230 } |
1225 } | 1231 } |
1226 } | 1232 } |
1227 } | 1233 } |
1228 else | 1234 else |
1413 found_big_char = true; | 1419 found_big_char = true; |
1414 } | 1420 } |
1415 } | 1421 } |
1416 | 1422 |
1417 if (found_big_char) | 1423 if (found_big_char) |
1418 warning ("load: can not read non-ASCII portions of UTF characters; replacing unreadable characters with '?'"); | 1424 warning_with_id ("Octave:load:unsupported-utf-char", |
1425 "load: can not read non-ASCII portions of UTF characters; replacing unreadable characters with '?'"); | |
1419 } | 1426 } |
1420 else if (type == miUTF8) | 1427 else if (type == miUTF8) |
1421 { | 1428 { |
1422 // Search for multi-byte encoded UTF8 characters and | 1429 // Search for multi-byte encoded UTF8 characters and |
1423 // replace with 0x3F for '?'... Give the user a warning | 1430 // replace with 0x3F for '?'... Give the user a warning |
1430 utf8_multi_byte = true; | 1437 utf8_multi_byte = true; |
1431 } | 1438 } |
1432 | 1439 |
1433 if (utf8_multi_byte) | 1440 if (utf8_multi_byte) |
1434 { | 1441 { |
1435 warning ("load: can not read multi-byte encoded UTF8 characters; replacing unreadable characters with '?'"); | 1442 warning_with_id ("Octave:load:unsupported-utf-char", |
1443 "load: can not read multi-byte encoded UTF8 characters; replacing unreadable characters with '?'"); | |
1436 for (octave_idx_type i = 0; i < n; i++) | 1444 for (octave_idx_type i = 0; i < n; i++) |
1437 { | 1445 { |
1438 unsigned char a | 1446 unsigned char a |
1439 = static_cast<unsigned char> (re(i)); | 1447 = static_cast<unsigned char> (re(i)); |
1440 if (a > 0x7f) | 1448 if (a > 0x7f) |
1461 // FIXME: With short-circuiting error(), no need for goto in code | 1469 // FIXME: With short-circuiting error(), no need for goto in code |
1462 data_read_error: | 1470 data_read_error: |
1463 error ("load: trouble reading binary file '%s'", filename.c_str ()); | 1471 error ("load: trouble reading binary file '%s'", filename.c_str ()); |
1464 | 1472 |
1465 skip_ahead: | 1473 skip_ahead: |
1466 warning ("load: skipping over '%s'", retval.c_str ()); | 1474 warning_with_id ("Octave:load:skip-unsupported-element", |
1475 "load: skipping over '%s'", retval.c_str ()); | |
1467 is.seekg (pos + static_cast<std::streamoff> (element_length)); | 1476 is.seekg (pos + static_cast<std::streamoff> (element_length)); |
1468 return read_mat5_binary_element (is, filename, swap, global, tc); | 1477 return read_mat5_binary_element (is, filename, swap, global, tc); |
1469 } | 1478 } |
1470 | 1479 |
1471 int | 1480 int |
1497 | 1506 |
1498 if (! swap) // version number is inverse swapped! | 1507 if (! swap) // version number is inverse swapped! |
1499 version = ((version >> 8) & 0xff) + ((version & 0xff) << 8); | 1508 version = ((version >> 8) & 0xff) + ((version & 0xff) << 8); |
1500 | 1509 |
1501 if (version != 1 && ! quiet) | 1510 if (version != 1 && ! quiet) |
1502 warning ("load: found version %d binary MAT file, " | 1511 warning_with_id ("Octave:load:unsupported-version", |
1503 "but only prepared for version 1", version); | 1512 "load: found version %d binary MAT file, but only prepared for version 1", |
1513 version); | |
1504 | 1514 |
1505 if (swap) | 1515 if (swap) |
1506 swap_bytes<8> (&subsys_offset, 1); | 1516 swap_bytes<8> (&subsys_offset, 1); |
1507 | 1517 |
1508 if (subsys_offset != 0x2020202020202020ULL && subsys_offset != 0ULL) | 1518 if (subsys_offset != 0x2020202020202020ULL && subsys_offset != 0ULL) |
1592 | 1602 |
1593 if (save_as_floats) | 1603 if (save_as_floats) |
1594 { | 1604 { |
1595 if (m.too_large_for_float ()) | 1605 if (m.too_large_for_float ()) |
1596 { | 1606 { |
1597 warning ("save: some values too large to save as floats --"); | 1607 warning_with_id ("Octave:save:too-large-for-float", |
1598 warning ("save: saving as doubles instead"); | 1608 "save: some values too large to save as floats -- saving as doubles instead"); |
1599 } | 1609 } |
1600 else | 1610 else |
1601 st = LS_FLOAT; | 1611 st = LS_FLOAT; |
1602 } | 1612 } |
1603 | 1613 |
2215 } | 2225 } |
2216 | 2226 |
2217 static void | 2227 static void |
2218 warn_dim_too_large (const std::string& name) | 2228 warn_dim_too_large (const std::string& name) |
2219 { | 2229 { |
2220 warning ("save: skipping %s: dimension too large for MAT format", | 2230 warning_with_id ("Octave:save:dimension-too-large", |
2221 name.c_str ()); | 2231 "save: skipping %s: dimension too large for MAT format", |
2232 name.c_str ()); | |
2222 } | 2233 } |
2223 | 2234 |
2224 // save the data from TC along with the corresponding NAME on stream | 2235 // save the data from TC along with the corresponding NAME on stream |
2225 // OS in the MatLab version 5 binary format. Return true on success. | 2236 // OS in the MatLab version 5 binary format. Return true on success. |
2226 | 2237 |