Fri 23 May 2014 04:23:13 PM UTC, comment #9:
I checked in the following change. It seems to fix the problem for me, though maybe we should also do something about dealing with the possibility of load_fcn_from file returning 0.
http://hg.savannah.gnu.org/hgweb/octave/rev/4293f49795d9
|
Mon 14 Apr 2014 03:11:40 PM UTC, comment #8:
Sounds right, but not simple to fix.
An obvious workaround is:
if exist("cd_data.m", "file")
if(fileread("cd_data.m") > 0)
cd_data;
endif
endif
So that the file is not read if it exists but is
empty.
Still not Matlab compatible, and misleading error
message.
|
Mon 14 Apr 2014 02:35:20 PM UTC, comment #7:
I assigned this to bug to myself, but if someone else wants to look at it, just let me know.
|
Mon 14 Apr 2014 02:24:51 PM UTC, comment #6:
The issue is that parse_fcn_file returns a null pointer when the file is completely empty. I can see how this makes sense from a parsing perspective, since there isn't anything in the file, but it does lead to this bug. Here is the backtrace:
I'm not going to go any further because the parser is not something I understand.
|
Mon 07 Apr 2014 03:28:36 PM UTC, comment #5:
@Rik: My guess is that Octave is not expecting to see
EOF as the first value in a file. Anything besides EOF seems to work.
Looks right to me. Should be easy to fix.
|
Mon 07 Apr 2014 03:22:49 PM UTC, comment #4:
The character doesn't even need to be something important like '#'. A single space character also works. My guess is that Octave is not expecting to see EOF as the first value in a file. Anything besides EOF seems to work.
|
Mon 07 Apr 2014 02:32:46 PM UTC, comment #3:
Mike,
All that is true, but this is still a regression
and Matlab incompatibility. And, the error message
is incorrect: the file exists, but is empty.
|
Mon 07 Apr 2014 12:27:38 PM UTC, comment #2:
Confirmed, executing an empty m-file did work in 3.6.4 but fails in 3.8.x and later. Using either source or run work as a workaround. Or adding a single '#' character to the file makes it a valid file for executing.
|
Mon 07 Apr 2014 12:13:41 PM UTC, comment #1:
Important note:
This only happens if the file is empty!!
Still, a regression.
And, incompatible with Matlab.
|
Mon 07 Apr 2014 12:01:56 PM UTC, original submission:
The following example code
if exist("cd_data.m", "file")
cd_data;
endif
fails with error: 'cd_data' undefined
for cd_data.m in the current directory, and the
path starting with
.
Note that exist("cd_data.m", "file")
returns 2 as it should.
This just happened as a result of updates in the
last few days.
|