bugGNU Octave - Bugs: bug #42064, executing empty m-file as a...

 
 

bug #42064: executing empty m-file as a command fails

Submitted by:  Michael Godfrey <godfrey>
Submitted on:  Mon 07 Apr 2014 12:01:56 PM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Regression
Status: FixedAssigned to: John W. Eaton <jwe>
Originator Name: GodfreyOpen/Closed: Closed
Release: devOperating System: GNU/Linux

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

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

John W. Eaton <jwe>
Project AdministratorIn charge of this item.
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.

Michael Godfrey <godfrey>
Project Member
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.

John W. Eaton <jwe>
Project AdministratorIn charge of this item.
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.

Rik <rik5>
Project Administrator
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.

Michael Godfrey <godfrey>
Project Member
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.

Rik <rik5>
Project Administrator
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.

Michael Godfrey <godfrey>
Project Member
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.

Mike Miller <mtmiller>
Project Administrator
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.

Michael Godfrey <godfrey>
Project Member
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.

Michael Godfrey <godfrey>
Project Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by rik5 (Posted a comment)
  • -unavailable- added by mtmiller (Posted a comment)
  • -unavailable- added by godfrey (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 5 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 23 May 2014 04:23:13 PM UTCjweStatusConfirmed=>Fixed
      Open/ClosedOpen=>Closed
    Mon 14 Apr 2014 02:35:20 PM UTCjweAssigned toNone=>jwe
    Mon 07 Apr 2014 12:27:38 PM UTCmtmillerStatusNone=>Confirmed
      Summaryfile search fails for .=>executing empty m-file as a command fails

    Back to the top


    Powered by Savane 3.1-cleanup1