From owner-bug-octave at bevo dot che dot wisc dot edu Thu Dec 19 00:44:39 1996 Subject: Oh, no... From: "John W. Eaton" To: jcardoso at inescn dot pt Cc: help-octave at bevo dot che dot wisc dot edu, bug-octave@bevo.che.wisc.edu Date: Thu, 19 Dec 1996 00:43:54 -0600 On 12-Dec-1996, Joao Cardoso wrote: : Most of my m files dont't run with 2.0. The fault is of course : the changed behaviour of scanf family. Shouldn't a compatibility : flag exist, such as octave-1.1.1_mode = 1, such that I just need : to add it at the top of my 'old' m files, instead of changing : all scanf statments? The problem with adding another variable like this is that it makes it harder to write robust code. If you set the flag so that calls to fscanf behave one way, then call some function that expects the flag to be set another way, bad things will happen. I'd prefer to not add very many more of these flags. Of course, I can run sed on all my files, but : what about fget (and probably others) changed behaviour, from : [line count] = fgets(...) to just line = fgets(...)? I don't think there is any reason that fgetl() and fgets() shouldn't also return the lengths of the strings they read. I've appended a patch below that will fix this problem. Thanks, jwe Wed Dec 18 20:17:23 1996 John W. Eaton * file-io.cc (Ffgetl, Ffgets): Also return number of characters read. Index: file-io.cc =================================================================== RCS file: /home/jwe/src/master/octave/src/file-io.cc,v retrieving revision 1.85 diff -c -r1.85 file-io.cc *** file-io.cc 1996/11/03 03:26:04 1.85 --- file-io.cc 1996/12/19 04:46:58 *************** *** 182,192 **** } DEFUN (fgetl, args, , ! "STRING = fgetl (FILENUM [, LENGTH])\n\ \n\ read a string from a file") { ! octave_value retval = -1.0; int nargin = args.length (); --- 182,195 ---- } DEFUN (fgetl, args, , ! "[STRING, LENGTH] = fgetl (FILENUM [, LENGTH])\n\ \n\ read a string from a file") { ! octave_value_list retval; ! ! retval(1) = 0.0; ! retval(0) = -1.0; int nargin = args.length (); *************** *** 204,210 **** string tmp = os->getl (len_arg, err); if (! err) ! retval = tmp; } else gripe_invalid_file_id ("fgetl"); --- 207,216 ---- string tmp = os->getl (len_arg, err); if (! err) ! { ! retval(1) = (double) tmp.length (); ! retval(0) = tmp; ! } } else gripe_invalid_file_id ("fgetl"); *************** *** 216,226 **** } DEFUN (fgets, args, , ! "STRING = fgets (FILENUM [, LENGTH])\n\ \n\ read a string from a file") { ! octave_value retval = -1.0; int nargin = args.length (); --- 222,235 ---- } DEFUN (fgets, args, , ! "[STRING, LENGTH] = fgets (FILENUM [, LENGTH])\n\ \n\ read a string from a file") { ! octave_value_list retval; ! ! retval(1) = 0.0; ! retval(0) = -1.0; int nargin = args.length (); *************** *** 238,244 **** string tmp = os->gets (len_arg, err); if (! err) ! retval = tmp; } else gripe_invalid_file_id ("fgets"); --- 247,256 ---- string tmp = os->gets (len_arg, err); if (! err) ! { ! retval(1) = (double) tmp.length (); ! retval(0) = tmp; ! } } else gripe_invalid_file_id ("fgets");