comparison src/file-io.cc @ 610:14b2a186a5c0

[project @ 1994-08-14 00:55:49 by jwe]
author jwe
date Sun, 14 Aug 1994 01:01:32 +0000
parents 80a8a79ea6e4
children aecbe369233b
comparison
equal deleted inserted replaced
609:cdc194110938 610:14b2a186a5c0
175 * open file. If the file has not already been opened, return NULL. 175 * open file. If the file has not already been opened, return NULL.
176 */ 176 */
177 Pix 177 Pix
178 return_valid_file (const tree_constant& arg) 178 return_valid_file (const tree_constant& arg)
179 { 179 {
180 if (arg.is_string_type ()) 180 if (arg.is_string ())
181 { 181 {
182 Pix p = file_list.first (); 182 Pix p = file_list.first ();
183 file_info file; 183 file_info file;
184 for (int i = 0; i < file_count; i++) 184 for (int i = 0; i < file_count; i++)
185 { 185 {
250 { 250 {
251 Pix p = return_valid_file (arg); 251 Pix p = return_valid_file (arg);
252 252
253 if (! p) 253 if (! p)
254 { 254 {
255 if (arg.is_string_type ()) 255 if (arg.is_string ())
256 { 256 {
257 char *name = arg.string_value (); 257 char *name = arg.string_value ();
258 258
259 struct stat buffer; 259 struct stat buffer;
260 int status = stat (name, &buffer); 260 int status = stat (name, &buffer);
486 fopen_internal (const Octave_object& args) 486 fopen_internal (const Octave_object& args)
487 { 487 {
488 Octave_object retval; 488 Octave_object retval;
489 Pix p; 489 Pix p;
490 490
491 if (! args(1).is_string_type ()) 491 if (! args(1).is_string ())
492 { 492 {
493 error ("fopen: file name must be a string"); 493 error ("fopen: file name must be a string");
494 return retval; 494 return retval;
495 } 495 }
496 496
504 retval(0) = tree_constant ((double) file.number ()); 504 retval(0) = tree_constant ((double) file.number ());
505 505
506 return retval; 506 return retval;
507 } 507 }
508 508
509 if (! args(2).is_string_type ()) 509 if (! args(2).is_string ())
510 { 510 {
511 error ("fopen: file mode must be a string"); 511 error ("fopen: file mode must be a string");
512 return retval; 512 return retval;
513 } 513 }
514 514
893 return chars_from_fmt_str; 893 return chars_from_fmt_str;
894 } 894 }
895 895
896 case 's': 896 case 's':
897 897
898 if (! args(fmt_arg_count).is_string_type ()) 898 if (! args(fmt_arg_count).is_string ())
899 goto invalid_conversion; 899 goto invalid_conversion;
900 else 900 else
901 { 901 {
902 chars_from_fmt_str++; 902 chars_from_fmt_str++;
903 fmt << *s << ends; 903 fmt << *s << ends;
907 return chars_from_fmt_str; 907 return chars_from_fmt_str;
908 } 908 }
909 909
910 case 'c': 910 case 'c':
911 911
912 if (! args(fmt_arg_count).is_string_type ()) 912 if (! args(fmt_arg_count).is_string ())
913 goto invalid_conversion; 913 goto invalid_conversion;
914 else 914 else
915 { 915 {
916 chars_from_fmt_str++; 916 chars_from_fmt_str++;
917 fmt << *s << ends; 917 fmt << *s << ends;
1003 char *fmt; 1003 char *fmt;
1004 file_info file; 1004 file_info file;
1005 1005
1006 if (strcmp (type, "fprintf") == 0) 1006 if (strcmp (type, "fprintf") == 0)
1007 { 1007 {
1008 if (args(2).is_string_type ()) 1008 if (args(2).is_string ())
1009 { 1009 {
1010 fmt = args(2).string_value (); 1010 fmt = args(2).string_value ();
1011 fmt_arg_count++; 1011 fmt_arg_count++;
1012 } 1012 }
1013 else 1013 else
1031 1031
1032 fmt = args(2).string_value (); 1032 fmt = args(2).string_value ();
1033 1033
1034 fmt_arg_count++; 1034 fmt_arg_count++;
1035 } 1035 }
1036 else if (args(1).is_string_type ()) 1036 else if (args(1).is_string ())
1037 { 1037 {
1038 fmt = args(1).string_value (); 1038 fmt = args(1).string_value ();
1039 fmt_arg_count++; 1039 fmt_arg_count++;
1040 } 1040 }
1041 else 1041 else
1324 1324
1325 fmt_arg_count = 0; 1325 fmt_arg_count = 0;
1326 1326
1327 if (strcmp (type, "scanf") != 0) 1327 if (strcmp (type, "scanf") != 0)
1328 { 1328 {
1329 if (args(2).is_string_type ()) 1329 if (args(2).is_string ())
1330 scanf_fmt = args(2).string_value (); 1330 scanf_fmt = args(2).string_value ();
1331 else 1331 else
1332 { 1332 {
1333 error ("%s: format must be a string", type); 1333 error ("%s: format must be a string", type);
1334 return retval; 1334 return retval;
1353 } 1353 }
1354 1354
1355 fptr = file.fptr (); 1355 fptr = file.fptr ();
1356 } 1356 }
1357 1357
1358 if ((! fptr && args(1).is_string_type ()) 1358 if ((! fptr && args(1).is_string ())
1359 || (doing_fscanf && file.number () == 0)) 1359 || (doing_fscanf && file.number () == 0))
1360 { 1360 {
1361 char *string; 1361 char *string;
1362 1362
1363 if (strcmp (type, "scanf") == 0) 1363 if (strcmp (type, "scanf") == 0)
1555 1555
1556 // Get type and number of bytes per element to read. 1556 // Get type and number of bytes per element to read.
1557 char *prec = "uchar"; 1557 char *prec = "uchar";
1558 if (nargin > 3) 1558 if (nargin > 3)
1559 { 1559 {
1560 if (args(3).is_string_type ()) 1560 if (args(3).is_string ())
1561 prec = args(3).string_value (); 1561 prec = args(3).string_value ();
1562 else 1562 else
1563 { 1563 {
1564 error ("fread: precision must be a specified as a string"); 1564 error ("fread: precision must be a specified as a string");
1565 return retval; 1565 return retval;
1717 1717
1718 // Get type and number of bytes per element to read. 1718 // Get type and number of bytes per element to read.
1719 char *prec = "uchar"; 1719 char *prec = "uchar";
1720 if (nargin > 3) 1720 if (nargin > 3)
1721 { 1721 {
1722 if (args(3).is_string_type ()) 1722 if (args(3).is_string ())
1723 prec = args(3).string_value (); 1723 prec = args(3).string_value ();
1724 else 1724 else
1725 { 1725 {
1726 error ("fwrite: precision must be a specified as a string"); 1726 error ("fwrite: precision must be a specified as a string");
1727 return retval; 1727 return retval;