Mercurial > octave
comparison libinterp/corefcn/load-save.cc @ 28217:87554d9ac6f8 stable
Warn if -v7.3 format is used for load/save (bug #45706).
* load-save.cc (Fload, Fsave): Document that -v7.3 format is not implemented.
* load-save.cc (load_save_system::parse_save_options): Detect '-v7.3' option
and issue an error() that format is not implemented.
* load-save.cc (load_save_system::load): Detect '-v7.3' option and issue an
error() that format is not implemented. Re-order if/elseif tree for clarity.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 14 Apr 2020 11:09:42 -0700 |
parents | 9f9ac219896d |
children | d13ad9dc9348 dc80e087df4b |
comparison
equal
deleted
inserted
replaced
28208:c3dd445fcc2f | 28217:87554d9ac6f8 |
---|---|
573 fmt.set_type (HDF5); | 573 fmt.set_type (HDF5); |
574 #else | 574 #else |
575 err_disabled_feature ("save", "HDF5"); | 575 err_disabled_feature ("save", "HDF5"); |
576 #endif | 576 #endif |
577 } | 577 } |
578 else if (argv[i] == "-mat-binary" || argv[i] == "-mat" | 578 else if (argv[i] == "-v7.3" || argv[i] == "-V7.3" || argv[i] == "-7.3") |
579 || argv[i] == "-m" || argv[i] == "-6" || argv[i] == "-v6" | 579 { |
580 || argv[i] == "-V6") | 580 error ("save: Matlab file format -v7.3 is not yet implemented"); |
581 } | |
582 #if defined (HAVE_ZLIB) | |
583 else if (argv[i] == "-v7" || argv[i] == "-V7" || argv[i] == "-7" | |
584 || argv[i] == "-mat7-binary") | |
585 { | |
586 fmt.set_type (MAT7_BINARY); | |
587 } | |
588 #endif | |
589 else if (argv[i] == "-mat" || argv[i] == "-m" | |
590 || argv[i] == "-v6" || argv[i] == "-V6" || argv[i] == "-6" | |
591 || argv[i] == "-mat-binary") | |
581 { | 592 { |
582 fmt.set_type (MAT5_BINARY); | 593 fmt.set_type (MAT5_BINARY); |
583 } | 594 } |
584 #if defined (HAVE_ZLIB) | 595 else if (argv[i] == "-v4" || argv[i] == "-V4" || argv[i] == "-4" |
585 else if (argv[i] == "-mat7-binary" || argv[i] == "-7" | 596 || argv[i] == "-mat4-binary") |
586 || argv[i] == "-v7" || argv[i] == "-V7") | |
587 { | |
588 fmt.set_type (MAT7_BINARY); | |
589 } | |
590 #endif | |
591 else if (argv[i] == "-mat4-binary" || argv[i] == "-V4" | |
592 || argv[i] == "-v4" || argv[i] == "-4") | |
593 { | 597 { |
594 fmt.set_type (MAT_BINARY); | 598 fmt.set_type (MAT_BINARY); |
595 } | 599 } |
596 else if (argv[i] == "-float-binary" || argv[i] == "-f") | 600 else if (argv[i] == "-float-binary" || argv[i] == "-f") |
597 { | 601 { |
1173 bool list_only = false; | 1177 bool list_only = false; |
1174 bool verbose = false; | 1178 bool verbose = false; |
1175 | 1179 |
1176 for (; i < argc; i++) | 1180 for (; i < argc; i++) |
1177 { | 1181 { |
1178 if (argv[i] == "-force" || argv[i] == "-f") | 1182 if (argv[i] == "-text" || argv[i] == "-t") |
1179 { | 1183 { |
1180 // Silently ignore this | 1184 format = TEXT; |
1181 // warning ("load: -force ignored"); | |
1182 } | |
1183 else if (argv[i] == "-list" || argv[i] == "-l") | |
1184 { | |
1185 list_only = true; | |
1186 } | |
1187 else if (argv[i] == "-verbose" || argv[i] == "-v") | |
1188 { | |
1189 verbose = true; | |
1190 } | |
1191 else if (argv[i] == "-ascii" || argv[i] == "-a") | |
1192 { | |
1193 format = MAT_ASCII; | |
1194 } | 1185 } |
1195 else if (argv[i] == "-binary" || argv[i] == "-b") | 1186 else if (argv[i] == "-binary" || argv[i] == "-b") |
1196 { | 1187 { |
1197 format = BINARY; | 1188 format = BINARY; |
1198 } | |
1199 else if (argv[i] == "-mat-binary" || argv[i] == "-mat" | |
1200 || argv[i] == "-m" || argv[i] == "-6" || argv[i] == "-v6") | |
1201 { | |
1202 format = MAT5_BINARY; | |
1203 } | |
1204 else if (argv[i] == "-7" || argv[i] == "-v7") | |
1205 { | |
1206 format = MAT7_BINARY; | |
1207 } | |
1208 else if (argv[i] == "-mat4-binary" || argv[i] == "-V4" | |
1209 || argv[i] == "-v4" || argv[i] == "-4") | |
1210 { | |
1211 format = MAT_BINARY; | |
1212 } | 1189 } |
1213 else if (argv[i] == "-hdf5" || argv[i] == "-h") | 1190 else if (argv[i] == "-hdf5" || argv[i] == "-h") |
1214 { | 1191 { |
1215 #if defined (HAVE_HDF5) | 1192 #if defined (HAVE_HDF5) |
1216 format = HDF5; | 1193 format = HDF5; |
1217 #else | 1194 #else |
1218 err_disabled_feature ("load", "HDF5"); | 1195 err_disabled_feature ("load", "HDF5"); |
1219 #endif | 1196 #endif |
1220 } | 1197 } |
1198 else if (argv[i] == "-ascii" || argv[i] == "-a") | |
1199 { | |
1200 format = MAT_ASCII; | |
1201 } | |
1202 else if (argv[i] == "-v7.3" || argv[i] == "-V7.3" || argv[i] == "-7.3") | |
1203 { | |
1204 error ("load: Matlab file format -v7.3 is not yet implemented"); | |
1205 } | |
1206 else if (argv[i] == "-v7" || argv[i] == "-V7" || argv[i] == "-7" | |
1207 || argv[i] == "-mat7-binary") | |
1208 { | |
1209 format = MAT7_BINARY; | |
1210 } | |
1211 else if (argv[i] == "-mat" || argv[i] == "-m" | |
1212 || argv[i] == "-v6" || argv[i] == "-V6" || argv[i] == "-6" | |
1213 || argv[i] == "-mat-binary") | |
1214 { | |
1215 format = MAT5_BINARY; | |
1216 } | |
1217 else if (argv[i] == "-v4" || argv[i] == "-V4" || argv[i] == "-4" | |
1218 || argv[i] == "-mat4-binary") | |
1219 { | |
1220 format = MAT_BINARY; | |
1221 } | |
1222 else if (argv[i] == "-force" || argv[i] == "-f") | |
1223 { | |
1224 // Silently ignore this | |
1225 // warning ("load: -force ignored"); | |
1226 } | |
1221 else if (argv[i] == "-import" || argv[i] == "-i") | 1227 else if (argv[i] == "-import" || argv[i] == "-i") |
1222 { | 1228 { |
1223 warning ("load: -import ignored"); | 1229 warning ("load: -import ignored"); |
1224 } | 1230 } |
1225 else if (argv[i] == "-text" || argv[i] == "-t") | 1231 else if (argv[i] == "-list" || argv[i] == "-l") |
1226 { | 1232 { |
1227 format = TEXT; | 1233 list_only = true; |
1234 } | |
1235 else if (argv[i] == "-verbose" || argv[i] == "-v") | |
1236 { | |
1237 verbose = true; | |
1228 } | 1238 } |
1229 else | 1239 else |
1230 break; | 1240 break; |
1231 } | 1241 } |
1232 | 1242 |
1618 @item -import | 1628 @item -import |
1619 This option is accepted for backward compatibility but is ignored. | 1629 This option is accepted for backward compatibility but is ignored. |
1620 Octave can now support multi-dimensional HDF data and automatically | 1630 Octave can now support multi-dimensional HDF data and automatically |
1621 modifies variable names if they are invalid Octave identifiers. | 1631 modifies variable names if they are invalid Octave identifiers. |
1622 | 1632 |
1623 @item -mat | |
1624 @itemx -mat-binary | |
1625 @itemx -6 | |
1626 @itemx -v6 | |
1627 @itemx -7 | |
1628 @itemx -v7 | |
1629 Force Octave to assume the file is in @sc{matlab}'s version 6 or 7 binary | |
1630 format. | |
1631 | |
1632 @item -mat4-binary | |
1633 @itemx -4 | |
1634 @itemx -v4 | |
1635 @itemx -V4 | |
1636 Force Octave to assume the file is in the binary format written by | |
1637 @sc{matlab} version 4. | |
1638 | |
1639 @item -text | 1633 @item -text |
1640 Force Octave to assume the file is in Octave's text format. | 1634 Force Octave to assume the file is in Octave's text format. |
1635 | |
1636 @item -v7.3 | |
1637 @itemx -V7.3 | |
1638 @itemx -7.3 | |
1639 Octave does @strong{not} yet implement @sc{matlab}'s v7.3 binary data format. | |
1640 | |
1641 @item -v7 | |
1642 @itemx -V7 | |
1643 @itemx -7 | |
1644 @itemx -mat7-binary | |
1645 Force Octave to assume the file is in @sc{matlab}'s version 7 binary format. | |
1646 | |
1647 @item -v6 | |
1648 @itemx -V6 | |
1649 @itemx -6 | |
1650 @itemx -mat | |
1651 @itemx -mat-binary | |
1652 Force Octave to assume the file is in @sc{matlab}'s version 6 binary format. | |
1653 | |
1654 @item -v4 | |
1655 @itemx -V4 | |
1656 @itemx -4 | |
1657 @itemx -mat4-binary | |
1658 Force Octave to assume the file is in @sc{matlab}'s version 4 binary format. | |
1659 | |
1641 @end table | 1660 @end table |
1642 @seealso{save, dlmwrite, csvwrite, fwrite} | 1661 @seealso{save, dlmwrite, csvwrite, fwrite} |
1643 @end deftypefn */) | 1662 @end deftypefn */) |
1644 { | 1663 { |
1645 octave::load_save_system& load_save_sys = interp.get_load_save_system (); | 1664 octave::load_save_system& load_save_sys = interp.get_load_save_system (); |
1719 @item -float-hdf5 | 1738 @item -float-hdf5 |
1720 Save the data in @sc{hdf5} format but using only single precision. Use this | 1739 Save the data in @sc{hdf5} format but using only single precision. Use this |
1721 format @strong{only} if you know that all the values to be saved can be | 1740 format @strong{only} if you know that all the values to be saved can be |
1722 represented in single precision. | 1741 represented in single precision. |
1723 | 1742 |
1724 @item -V7 | 1743 @item -text |
1725 @itemx -v7 | 1744 Save the data in Octave's text data format. (default) |
1745 | |
1746 @item -v7.3 | |
1747 @itemx -V7.3 | |
1748 @itemx -7.3 | |
1749 Octave does @strong{not} yet implement @sc{matlab}'s v7.3 binary data format. | |
1750 | |
1751 @item -v7 | |
1752 @itemx -V7 | |
1726 @itemx -7 | 1753 @itemx -7 |
1727 @itemx -mat7-binary | 1754 @itemx -mat7-binary |
1728 Save the data in @sc{matlab}'s v7 binary data format. | 1755 Save the data in @sc{matlab}'s v7 binary data format. |
1729 | 1756 |
1730 @item -V6 | 1757 @item -v6 |
1731 @itemx -v6 | 1758 @itemx -V6 |
1732 @itemx -6 | 1759 @itemx -6 |
1733 @itemx -mat | 1760 @itemx -mat |
1734 @itemx -mat-binary | 1761 @itemx -mat-binary |
1735 Save the data in @sc{matlab}'s v6 binary data format. | 1762 Save the data in @sc{matlab}'s v6 binary data format. |
1736 | 1763 |
1737 @item -V4 | 1764 @item -v4 |
1738 @itemx -v4 | 1765 @itemx -V4 |
1739 @itemx -4 | 1766 @itemx -4 |
1740 @itemx -mat4-binary | 1767 @itemx -mat4-binary |
1741 Save the data in the binary format written by @sc{matlab} version 4. | 1768 Save the data in @sc{matlab}'s v4 binary data format. |
1742 | |
1743 @item -text | |
1744 Save the data in Octave's text data format. (default). | |
1745 | 1769 |
1746 @item -zip | 1770 @item -zip |
1747 @itemx -z | 1771 @itemx -z |
1748 Use the gzip algorithm to compress the file. This works on files that are | 1772 Use the gzip algorithm to compress the file. This works on files that are |
1749 compressed with gzip outside of Octave, and gzip can also be used to convert | 1773 compressed with gzip outside of Octave, and gzip can also be used to convert |
1774 | 1798 |
1775 Except when using the @sc{matlab} binary data file format or the @samp{-ascii} | 1799 Except when using the @sc{matlab} binary data file format or the @samp{-ascii} |
1776 format, saving global variables also saves the global status of the variable. | 1800 format, saving global variables also saves the global status of the variable. |
1777 If the variable is restored at a later time using @samp{load}, it will be | 1801 If the variable is restored at a later time using @samp{load}, it will be |
1778 restored as a global variable. | 1802 restored as a global variable. |
1803 | |
1804 Example: | |
1779 | 1805 |
1780 The command | 1806 The command |
1781 | 1807 |
1782 @example | 1808 @example |
1783 save -binary data a b* | 1809 save -binary data a b* |