Oh, no...

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Oh, no...

Joao Cardoso-7

Hi,

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? 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(...)?

Do you think that matlab compatibility is more important that
octave compatibility? After all, we are talking of compatibility
with a 1.1.1 release, not a beta one.

Anyway, thanks for 2.0
Joao

Yes, I read it, but there is really no turnaround?

  * The C-style I/O functions (fopen, fprintf, etc.) have been
    rewritten to be more compatible with Matlab.  The fputs function
    has also been added.  Usage of the *printf functions that was
    allowed in previous versions of Octave should still work.
    However, there is no way to make the new versions of the *scanf
    functions compatible with Matlab *and* previous versions of
    Octave.  An optional argument to the *scanf functions is now
    available to make them behave in a way that is compatible with
    previous versions of Octave.

--
Joao Cardoso, INESC  |  e-mail: [hidden email]
R. Jose Falcao 110   |  tel:    + 351 2 2094345
4000 Porto, Portugal |  fax:    + 351 2 2008487





Reply | Threaded
Open this post in threaded view
|

Oh, no...

John W. Eaton-6
On 12-Dec-1996, Joao Cardoso <[hidden email]> 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  <[hidden email]>

        * 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");