# HG changeset patch # User jwe # Date 781136565 0 # Node ID f0133cd328521939765c1d59fe8b79a354e03df9 # Parent b284388e8999817faf7ccf085b0eb6c923d3dfbc [project @ 1994-10-02 22:22:45 by jwe] diff --git a/src/file-io.cc b/src/file-io.cc --- a/src/file-io.cc +++ b/src/file-io.cc @@ -144,10 +144,9 @@ file_count = 3; } -/* - * Given a file name or number, return a pointer to the corresponding - * open file. If the file has not already been opened, return NULL. - */ +// Given a file name or number, return a pointer to the corresponding +// open file. If the file has not already been opened, return NULL. + Pix return_valid_file (const tree_constant& arg) { @@ -669,9 +668,8 @@ return retval; } -/* - * Tell current position of file. - */ +// Tell current position of file. + DEFUN ("ftell", Fftell, Sftell, 1, 1, "POSITION = ftell (FILENAME or FILENUM): returns the current file position") { @@ -926,10 +924,8 @@ return -1; } +// Formatted printing to a file. -/* - * Formatted printing to a file. - */ DEFUN ("fprintf", Ffprintf, Sfprintf, -1, 1, "fprintf (FILENAME or FILENUM, FORMAT, ...)") { @@ -945,9 +941,8 @@ return retval; } -/* - * Formatted printing. - */ +// Formatted printing. + DEFUN ("printf", Fprintf, Sprintf, -1, 1, "printf (FORMAT, ...)") { @@ -963,9 +958,8 @@ return retval; } -/* - * Formatted printing to a string. - */ +// Formatted printing to a string. + DEFUN ("sprintf", Fsprintf, Ssprintf, -1, 1, "s = sprintf (FORMAT, ...)") { @@ -1251,9 +1245,8 @@ return -1; } -/* - * Formatted reading from a file. - */ +// Formatted reading from a file. + DEFUN ("fscanf", Ffscanf, Sfscanf, 2, -1, "[A, B, C, ...] = fscanf (FILENAME or FILENUM, FORMAT)") { @@ -1269,9 +1262,8 @@ return retval; } -/* - * Formatted reading. - */ +// Formatted reading. + DEFUN ("scanf", Fscanf, Sscanf, 1, -1, "[A, B, C, ...] = scanf (FORMAT)") { @@ -1287,9 +1279,8 @@ return retval; } -/* - * Formatted reading from a string. - */ +// Formatted reading from a string. + DEFUN ("sscanf", Fsscanf, Ssscanf, 2, -1, "[A, B, C, ...] = sscanf (STRING, FORMAT)") { @@ -1441,9 +1432,8 @@ return retval; } -/* - * Find out how many elements are left to read. - */ +// Find out how many elements are left to read. + static long num_items_remaining (FILE *fptr, char *type) { @@ -1511,29 +1501,28 @@ return retval; } -/* - * Read binary data from a file. - * - * [data, count] = fread (fid, size, 'precision') - * - * fid : the file id from fopen - * size : the size of the matrix or vector or scaler to read - * - * n : reads n elements of a column vector - * inf : reads to the end of file (default) - * [m, n] : reads enough elements to fill the matrix - * the number of columns can be inf - * - * precision : type of the element. Can be: - * - * char, uchar, schar, short, ushort, int, uint, - * long, ulong, float, double - * - * Default is uchar. - * - * data : output data - * count : number of elements read - */ +// Read binary data from a file. +// +// [data, count] = fread (fid, size, 'precision') +// +// fid : the file id from fopen +// size : the size of the matrix or vector or scaler to read +// +// n : reads n elements of a column vector +// inf : reads to the end of file (default) +// [m, n] : reads enough elements to fill the matrix +// the number of columns can be inf +// +// precision : type of the element. Can be: +// +// char, uchar, schar, short, ushort, int, uint, +// long, ulong, float, double +// +// Default is uchar. +// +// data : output data +// count : number of elements read + Octave_object fread_internal (const Octave_object& args, int nargout) { @@ -1676,22 +1665,21 @@ return retval; } -/* - * Write binary data to a file. - * - * count = fwrite (fid, data, 'precision') - * - * fid : file id from fopen - * Data : data to be written - * precision : type of output element. Can be: - * - * char, uchar, schar, short, ushort, int, uint, - * long, float, double - * - * Default is uchar. - * - * count : the number of elements written - */ +// Write binary data to a file. +// +// count = fwrite (fid, data, 'precision') +// +// fid : file id from fopen +// Data : data to be written +// precision : type of output element. Can be: +// +// char, uchar, schar, short, ushort, int, uint, +// long, float, double +// +// Default is uchar. +// +// count : the number of elements written + Octave_object fwrite_internal (const Octave_object& args, int nargout) { @@ -1699,7 +1687,7 @@ int nargin = args.length (); - Pix p = file_io_get_file (args(1), "a+", "fwrite"); + Pix p = file_io_get_file (args(0), "a+", "fwrite"); if (! p) return retval; @@ -1708,7 +1696,7 @@ char *prec = "uchar"; if (nargin > 2) { - prec = args(3).string_value (); + prec = args(2).string_value (); if (error_state) { @@ -1719,7 +1707,7 @@ file_info file = file_list (p); - Matrix m = args(2).matrix_value (); + Matrix m = args(1).matrix_value (); if (! error_state) { @@ -1749,14 +1737,13 @@ return retval; } -/* - * Check for an EOF condition on a file opened by fopen. - * - * eof = feof (fid) - * - * fid : file id from fopen - * eof : non zero for an end of file condition - */ +// Check for an EOF condition on a file opened by fopen. +// +// eof = feof (fid) +// +// fid : file id from fopen +// eof : non zero for an end of file condition + Octave_object feof_internal (const Octave_object& args, int nargout) { @@ -1793,15 +1780,14 @@ return retval; } -/* - * Check for an error condition on a file opened by fopen. - * - * [message, errnum] = ferror (fid) - * - * fid : file id from fopen - * message : system error message - * errnum : error number - */ +// Check for an error condition on a file opened by fopen. +// +// [message, errnum] = ferror (fid) +// +// fid : file id from fopen +// message : system error message +// errnum : error number + Octave_object ferror_internal (const Octave_object& args, int nargout) {