Mercurial > octave
changeset 25294:01ad54f997f5
Allow filenames which begin with a '.' to be returned from mfilename (bug #53707).
* oct-parse.in.yy (Fmfilename): Improve docstring. Check that the position
of a '.' is not the first character before removing the "extension" from
the filename.
author | Rik <rik@octave.org> |
---|---|
date | Sat, 21 Apr 2018 18:11:46 -0700 |
parents | affd44707573 |
children | b99b0d423807 |
files | libinterp/parse-tree/oct-parse.in.yy |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/parse-tree/oct-parse.in.yy Thu Apr 19 19:16:54 2018 -0700 +++ b/libinterp/parse-tree/oct-parse.in.yy Sat Apr 21 18:11:46 2018 -0700 @@ -5092,13 +5092,16 @@ @deftypefnx {} {} mfilename ("fullpathext") Return the name of the currently executing file. -When called from outside an m-file return the empty string. +The base name of the currently executing script or function is returned without +any extension. If called from outside an m-file, such as the command line, +return the empty string. Given the argument @qcode{"fullpath"}, include the directory part of the filename, but not the extension. Given the argument @qcode{"fullpathext"}, include the directory part of the filename and the extension. +@seealso{inputname, dbstack} @end deftypefn */) { octave_value retval; @@ -5134,7 +5137,7 @@ size_t dpos = fname.rfind (octave::sys::file_ops::dir_sep_char ()); size_t epos = fname.rfind ('.'); - if (epos <= dpos) + if (epos <= dpos+1) epos = std::string::npos; fname = (epos != std::string::npos) ? fname.substr (0, epos) : fname;