Mercurial > octave-nkf
comparison libinterp/corefcn/file-io.cc @ 20463:7ac907da9fba
Use error() rather than ::error() unless explicitly required.
* resource-manager.cc (instance_ok), shortcut-manager.cc (instance_ok),
daspk.cc (DASPK_ABORT, DASPK_ABORT2), dasrt.cc (DASRT_ABORT, DASRT_ABORT2),
dassl.cc (DASSL_ABORT, DASSL_ABORT2), debug.cc (instance_ok),
display.cc (instance_ok), dynamic-ld.cc (octave_shlib_list::instance_ok,
octave_dynamic_loader::instance_ok, do_load_oct, do_load_mex), file-io.cc
(fopen_mode_to_ios_mode, do_stream_open, Ffprintf, Fsprintf, Fscanf, Ffscanf,
get_sscanf_data, Fsscanf, do_fread, do_fwrite, Fpopen, Ftempname, convert,
Fumask), graphics.in.h (graphics_toolkit::instance_ok,
gh_manager::instance_ok), load-path.cc (instance_ok),
ls-oct-ascii.cc (save_three_d), lsode.cc (LSODE_ABORT, LSODE_ABORT2),
oct-errno.in.cc (instance_ok), octave-link.cc (connect_link),
pager.cc (octave_pager_stream::instance_ok, octave_diary_stream::instance_ok),
quad.cc (QUAD_ABORT, QUAD_ABORT2),
sighandlers.cc (w32_interrupt_manager::instance_ok,
octave_child_list::instance_ok), symtab.cc (do_update_nest),
symtab.h (instance_ok), syscalls.cc (convert), toplev.h (instance_ok),
txt-eng-ft.cc (instance_ok, set_mode), urlwrite.cc (instance_ok),
__init_fltk__.cc (instance_ok), ov-builtin.cc (do_multi_index_op),
ov-classdef.cc (class_fevalStatic, make_class, octave_classdef::subsasgn,
do_multi_index_op, cdef_object_array::subsref, cdef_object_array::subsasgn,
install_meth, meta_subsref, run_constructor, make_meta_class, get_value,
set_value, check_method), ov-classdef.h (meta_subsref, instance_ok),
ov-fcn-handle.cc (octave_fcn_handle), ov-mex-fcn.cc (do_multi_index_op),
ov-range.h (octave_range), ov-typeinfo.cc (instance_ok),
ov-usr-fcn.cc (subsref, do_multi_index_op), pt-arg-list.cc (Fend,
convert_to_const_vector), pt-cell.cc (rvalue1), pt-colon.cc (append, rvalue1),
pt-eval.cc (visit_simple_for_command, visit_switch_command),
pt-exp.cc (is_logically_true, rvalue), pt-id.cc (eval_undefined_error),
pt-id.h (workspace_error), pt-mat.cc (get_concat_class):
Use error() rather than ::error().
author | Rik <rik@octave.org> |
---|---|
date | Thu, 06 Aug 2015 08:09:01 -0700 |
parents | d9f35ceff9e1 |
children | 859423f351a3 |
comparison
equal
deleted
inserted
replaced
20462:d5b877b86ed4 | 20463:7ac907da9fba |
---|---|
228 | std::ios::binary); | 228 | std::ios::binary); |
229 else if (mode == "a+b" || mode == "ab+" || mode == "a+") | 229 else if (mode == "a+b" || mode == "ab+" || mode == "a+") |
230 retval = (std::ios::in | std::ios::out | std::ios::app | 230 retval = (std::ios::in | std::ios::out | std::ios::app |
231 | std::ios::binary); | 231 | std::ios::binary); |
232 else | 232 else |
233 ::error ("invalid mode specified"); | 233 error ("invalid mode specified"); |
234 } | 234 } |
235 | 235 |
236 return retval; | 236 return retval; |
237 } | 237 } |
238 | 238 |
574 std::string arch = tc_arch.string_value (); | 574 std::string arch = tc_arch.string_value (); |
575 | 575 |
576 retval = do_stream_open (name, mode, arch, fid); | 576 retval = do_stream_open (name, mode, arch, fid); |
577 } | 577 } |
578 else | 578 else |
579 ::error ("%s: architecture type must be a string", fcn); | 579 error ("%s: architecture type must be a string", fcn); |
580 } | 580 } |
581 else | 581 else |
582 ::error ("%s: file mode must be a string", fcn); | 582 error ("%s: file mode must be a string", fcn); |
583 } | 583 } |
584 else | 584 else |
585 ::error ("%s: file name must be a string", fcn); | 585 error ("%s: file name must be a string", fcn); |
586 | 586 |
587 return retval; | 587 return retval; |
588 } | 588 } |
589 | 589 |
590 DEFUN (fopen, args, nargout, | 590 DEFUN (fopen, args, nargout, |
944 } | 944 } |
945 | 945 |
946 result = os.printf (args(fmt_n), tmp_args, who); | 946 result = os.printf (args(fmt_n), tmp_args, who); |
947 } | 947 } |
948 else | 948 else |
949 ::error ("%s: format TEMPLATE must be a string", who.c_str ()); | 949 error ("%s: format TEMPLATE must be a string", who.c_str ()); |
950 } | 950 } |
951 } | 951 } |
952 else | 952 else |
953 print_usage (); | 953 print_usage (); |
954 | 954 |
999 } | 999 } |
1000 | 1000 |
1001 result = stdout_stream.printf (args(0), tmp_args, who); | 1001 result = stdout_stream.printf (args(0), tmp_args, who); |
1002 } | 1002 } |
1003 else | 1003 else |
1004 ::error ("%s: format TEMPLATE must be a string", who.c_str ()); | 1004 error ("%s: format TEMPLATE must be a string", who.c_str ()); |
1005 } | 1005 } |
1006 else | 1006 else |
1007 print_usage (); | 1007 print_usage (); |
1008 | 1008 |
1009 if (nargout > 0) | 1009 if (nargout > 0) |
1127 retval(0) = (result.empty () | 1127 retval(0) = (result.empty () |
1128 ? octave_value (charMatrix (1, 0), type) | 1128 ? octave_value (charMatrix (1, 0), type) |
1129 : octave_value (result, type)); | 1129 : octave_value (result, type)); |
1130 } | 1130 } |
1131 else | 1131 else |
1132 ::error ("%s: format TEMPLATE must be a string", who.c_str ()); | 1132 error ("%s: format TEMPLATE must be a string", who.c_str ()); |
1133 } | 1133 } |
1134 else | 1134 else |
1135 ::error ("%s: unable to create output buffer", who.c_str ()); | 1135 error ("%s: unable to create output buffer", who.c_str ()); |
1136 } | 1136 } |
1137 else | 1137 else |
1138 print_usage (); | 1138 print_usage (); |
1139 | 1139 |
1140 return retval; | 1140 return retval; |
1203 if (! error_state) | 1203 if (! error_state) |
1204 { | 1204 { |
1205 if (args(1).is_string ()) | 1205 if (args(1).is_string ()) |
1206 retval = os.oscanf (args(1), who); | 1206 retval = os.oscanf (args(1), who); |
1207 else | 1207 else |
1208 ::error ("%s: format TEMPLATE must be a string", who.c_str ()); | 1208 error ("%s: format TEMPLATE must be a string", who.c_str ()); |
1209 } | 1209 } |
1210 } | 1210 } |
1211 else | 1211 else |
1212 { | 1212 { |
1213 retval(2) = "unknown error"; | 1213 retval(2) = "unknown error"; |
1240 retval(0) = tmp; | 1240 retval(0) = tmp; |
1241 } | 1241 } |
1242 } | 1242 } |
1243 } | 1243 } |
1244 else | 1244 else |
1245 ::error ("%s: format must be a string", who.c_str ()); | 1245 error ("%s: format must be a string", who.c_str ()); |
1246 } | 1246 } |
1247 } | 1247 } |
1248 else | 1248 else |
1249 print_usage (); | 1249 print_usage (); |
1250 } | 1250 } |
1262 octave_value tmp = val.reshape (dim_vector (1, val.numel ())); | 1262 octave_value tmp = val.reshape (dim_vector (1, val.numel ())); |
1263 | 1263 |
1264 retval = tmp.string_value (); | 1264 retval = tmp.string_value (); |
1265 } | 1265 } |
1266 else | 1266 else |
1267 ::error ("sscanf: argument STRING must be a string"); | 1267 error ("sscanf: argument STRING must be a string"); |
1268 | 1268 |
1269 return retval; | 1269 return retval; |
1270 } | 1270 } |
1271 | 1271 |
1272 DEFUN (sscanf, args, , | 1272 DEFUN (sscanf, args, , |
1299 if (os.is_valid ()) | 1299 if (os.is_valid ()) |
1300 { | 1300 { |
1301 if (args(1).is_string ()) | 1301 if (args(1).is_string ()) |
1302 retval = os.oscanf (args(1), who); | 1302 retval = os.oscanf (args(1), who); |
1303 else | 1303 else |
1304 ::error ("%s: format TEMPLATE must be a string", who.c_str ()); | 1304 error ("%s: format TEMPLATE must be a string", who.c_str ()); |
1305 } | 1305 } |
1306 else | 1306 else |
1307 ::error ("%s: unable to create temporary input buffer", | 1307 error ("%s: unable to create temporary input buffer", who.c_str ()); |
1308 who.c_str ()); | |
1309 } | 1308 } |
1310 else | 1309 else |
1311 ::error ("%s: argument STRING must be a string", who.c_str ()); | 1310 error ("%s: argument STRING must be a string", who.c_str ()); |
1312 } | 1311 } |
1313 else | 1312 else |
1314 { | 1313 { |
1315 if (nargin == 2 || nargin == 3) | 1314 if (nargin == 2 || nargin == 3) |
1316 { | 1315 { |
1351 retval(1) = count; | 1350 retval(1) = count; |
1352 retval(0) = tmp; | 1351 retval(0) = tmp; |
1353 } | 1352 } |
1354 } | 1353 } |
1355 else | 1354 else |
1356 ::error ("%s: format TEMPLATE must be a string", | 1355 error ("%s: format TEMPLATE must be a string", |
1357 who.c_str ()); | 1356 who.c_str ()); |
1358 } | 1357 } |
1359 else | 1358 else |
1360 ::error ("%s: unable to create temporary input buffer", | 1359 error ("%s: unable to create temporary input buffer", |
1361 who.c_str ()); | 1360 who.c_str ()); |
1362 } | 1361 } |
1363 } | 1362 } |
1364 else | 1363 else |
1365 print_usage (); | 1364 print_usage (); |
1366 } | 1365 } |
1429 if (! error_state) | 1428 if (! error_state) |
1430 retval = os.read (size, block_size, input_type, | 1429 retval = os.read (size, block_size, input_type, |
1431 output_type, skip, flt_fmt, count); | 1430 output_type, skip, flt_fmt, count); |
1432 } | 1431 } |
1433 else | 1432 else |
1434 ::error ("fread: ARCH architecture type must be a string"); | 1433 error ("fread: ARCH architecture type must be a string"); |
1435 } | 1434 } |
1436 else | 1435 else |
1437 ::error ("fread: SKIP must be an integer"); | 1436 error ("fread: SKIP must be an integer"); |
1438 } | 1437 } |
1439 else | 1438 else |
1440 ::error ("fread: invalid PRECISION specified"); | 1439 error ("fread: invalid PRECISION specified"); |
1441 } | 1440 } |
1442 else | 1441 else |
1443 ::error ("fread: PRECISION must be a string"); | 1442 error ("fread: PRECISION must be a string"); |
1444 } | 1443 } |
1445 else | 1444 else |
1446 ::error ("fread: invalid SIZE specified"); | 1445 error ("fread: invalid SIZE specified"); |
1447 | 1446 |
1448 return retval; | 1447 return retval; |
1449 } | 1448 } |
1450 | 1449 |
1451 DEFUN (fread, args, , | 1450 DEFUN (fread, args, , |
1697 if (! error_state) | 1696 if (! error_state) |
1698 retval = os.write (data, block_size, output_type, | 1697 retval = os.write (data, block_size, output_type, |
1699 skip, flt_fmt); | 1698 skip, flt_fmt); |
1700 } | 1699 } |
1701 else | 1700 else |
1702 ::error ("fwrite: ARCH architecture type must be a string"); | 1701 error ("fwrite: ARCH architecture type must be a string"); |
1703 } | 1702 } |
1704 else | 1703 else |
1705 ::error ("fwrite: SKIP must be an integer"); | 1704 error ("fwrite: SKIP must be an integer"); |
1706 } | 1705 } |
1707 else | 1706 else |
1708 ::error ("fwrite: invalid PRECISION specified"); | 1707 error ("fwrite: invalid PRECISION specified"); |
1709 } | 1708 } |
1710 else | 1709 else |
1711 ::error ("fwrite: PRECISION must be a string"); | 1710 error ("fwrite: PRECISION must be a string"); |
1712 | 1711 |
1713 return retval; | 1712 return retval; |
1714 } | 1713 } |
1715 | 1714 |
1716 DEFUN (fwrite, args, , | 1715 DEFUN (fwrite, args, , |
1927 octave_stream ops = octave_oprocstream::create (name); | 1926 octave_stream ops = octave_oprocstream::create (name); |
1928 | 1927 |
1929 retval = octave_stream_list::insert (ops); | 1928 retval = octave_stream_list::insert (ops); |
1930 } | 1929 } |
1931 else | 1930 else |
1932 ::error ("popen: invalid MODE specified"); | 1931 error ("popen: invalid MODE specified"); |
1933 } | 1932 } |
1934 else | 1933 else |
1935 ::error ("popen: MODE must be a string"); | 1934 error ("popen: MODE must be a string"); |
1936 } | 1935 } |
1937 else | 1936 else |
1938 ::error ("popen: COMMAND must be a string"); | 1937 error ("popen: COMMAND must be a string"); |
1939 } | 1938 } |
1940 else | 1939 else |
1941 print_usage (); | 1940 print_usage (); |
1942 | 1941 |
1943 return retval; | 1942 return retval; |
1994 if (len > 0) | 1993 if (len > 0) |
1995 { | 1994 { |
1996 if (args(0).is_string ()) | 1995 if (args(0).is_string ()) |
1997 dir = args(0).string_value (); | 1996 dir = args(0).string_value (); |
1998 else | 1997 else |
1999 ::error ("DIR must be a string"); | 1998 error ("DIR must be a string"); |
2000 } | 1999 } |
2001 | 2000 |
2002 std::string pfx ("oct-"); | 2001 std::string pfx ("oct-"); |
2003 if (len > 1) | 2002 if (len > 1) |
2004 { | 2003 { |
2005 if (args(1).is_string ()) | 2004 if (args(1).is_string ()) |
2006 pfx = args(1).string_value (); | 2005 pfx = args(1).string_value (); |
2007 else | 2006 else |
2008 ::error ("PREFIX must be a string"); | 2007 error ("PREFIX must be a string"); |
2009 } | 2008 } |
2010 | 2009 |
2011 retval = octave_tempnam (dir, pfx); | 2010 retval = octave_tempnam (dir, pfx); |
2012 } | 2011 } |
2013 else | 2012 else |
2212 int retval = 0; | 2211 int retval = 0; |
2213 | 2212 |
2214 int tmp = x % obase; | 2213 int tmp = x % obase; |
2215 | 2214 |
2216 if (tmp > ibase - 1) | 2215 if (tmp > ibase - 1) |
2217 ::error ("umask: invalid digit"); | 2216 error ("umask: invalid digit"); |
2218 else | 2217 else |
2219 { | 2218 { |
2220 retval = tmp; | 2219 retval = tmp; |
2221 int mult = ibase; | 2220 int mult = ibase; |
2222 while ((x = (x - tmp) / obase)) | 2221 while ((x = (x - tmp) / obase)) |
2223 { | 2222 { |
2224 tmp = x % obase; | 2223 tmp = x % obase; |
2225 if (tmp > ibase - 1) | 2224 if (tmp > ibase - 1) |
2226 { | 2225 { |
2227 ::error ("umask: invalid digit"); | 2226 error ("umask: invalid digit"); |
2228 break; | 2227 break; |
2229 } | 2228 } |
2230 retval += mult * tmp; | 2229 retval += mult * tmp; |
2231 mult *= ibase; | 2230 mult *= ibase; |
2232 } | 2231 } |
2264 if (! error_state) | 2263 if (! error_state) |
2265 { | 2264 { |
2266 if (mask < 0) | 2265 if (mask < 0) |
2267 { | 2266 { |
2268 status = -1; | 2267 status = -1; |
2269 ::error ("umask: MASK must be a positive integer value"); | 2268 error ("umask: MASK must be a positive integer value"); |
2270 } | 2269 } |
2271 else | 2270 else |
2272 { | 2271 { |
2273 int oct_mask = convert (mask, 8, 10); | 2272 int oct_mask = convert (mask, 8, 10); |
2274 | 2273 |
2277 } | 2276 } |
2278 } | 2277 } |
2279 else | 2278 else |
2280 { | 2279 { |
2281 status = -1; | 2280 status = -1; |
2282 ::error ("umask: MASK must be an integer"); | 2281 error ("umask: MASK must be an integer"); |
2283 } | 2282 } |
2284 } | 2283 } |
2285 else | 2284 else |
2286 print_usage (); | 2285 print_usage (); |
2287 | 2286 |