Mercurial > hg > octave-nkf
changeset 5739:d090d39bb82c
[project @ 2006-04-05 06:56:24 by jwe]
author | jwe |
---|---|
date | Wed, 05 Apr 2006 06:56:25 +0000 |
parents | 126d7f1945ee |
children | b2637e696bb4 |
files | src/ChangeLog src/Makefile.in src/mk-pkg-add src/parse.y |
diffstat | 4 files changed, 77 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2006-04-05 John W. Eaton <jwe@octave.org> + + * Makefile.in (mk-pkg-add): Use mfilename to simplify. + (PKG_ADD): Don't pass --prefix arg to mk-pkg-add. + (PKG_ADD.inst): Delete target. + (clean): Don't remove PKG_ADD.inst. + (install-oct): Don't depend on PKG_ADD.inst. Install PKG_ADD, not + PKG_ADD.inst. + + * parse.y (Fmfilename): New function. + 2006-04-04 David Bateman <dbateman@free.fr> * help.cc (Flookfor): Skip overloaded functions. Lookup help text
--- a/src/Makefile.in +++ b/src/Makefile.in @@ -345,11 +345,7 @@ @$(top_srcdir)/move-if-change $@-t $@ PKG_ADD: $(DLD_DEF_FILES) - $(srcdir)/mk-pkg-add --prefix $(shell pwd) $(DLD_DEF_FILES) > $@-t - mv $@-t $@ - -PKG_ADD.inst: $(srcdir)/mk-pkg-add $(DLD_DEF_FILES) - $(srcdir)/mk-pkg-add --install $(DLD_DEF_FILES) > $@-t + $(srcdir)/mk-pkg-add $(DLD_DEF_FILES) > $@-t mv $@-t $@ DOCSTRINGS: gendoc$(BUILD_EXEEXT) @@ -402,9 +398,9 @@ cd $(DESTDIR)$(bindir) ; $(LN_S) octave-$(version)$(EXEEXT) octave$(EXEEXT) .PHONY: install-bin -install-oct: PKG_ADD.inst +install-oct: $(top_srcdir)/mkinstalldirs $(DESTDIR)$(octfiledir) - $(INSTALL_DATA) PKG_ADD.inst $(DESTDIR)$(octfiledir)/PKG_ADD + $(INSTALL_DATA) PKG_ADD $(DESTDIR)$(octfiledir)/PKG_ADD if [ -n "$(OCT_FILES)" ]; then \ xfiles="$(OCT_FILES)"; \ for f in $$xfiles; do \ @@ -478,7 +474,6 @@ rm -f $(PICOBJ) $(DLD_PICOBJ) stmp-pic gendoc$(EXEEXT) rm -f builtins.cc ops.cc defaults.h oct-conf.h def-files var-files rm -f PKG_ADD - rm -f PKG_ADD.inst -rmdir pic .PHONY: clean
--- a/src/mk-pkg-add +++ b/src/mk-pkg-add @@ -2,26 +2,6 @@ SED=${SED:-'sed'} -install=false -if [ $1 = "--prefix" ]; then - shift - prefix="$1" - shift -elif [ $1 = "--install" ]; then - install=true - shift -fi - -if [ $# -gt 0 ]; then - if $install; then - cat <<EOF -__octfiledir__ = strrep (octave_config_info ("octfiledir"), - octave_config_info ("prefix"), - OCTAVE_HOME); -EOF - fi -fi - for f in "$@"; do if [ -f $f ]; then @@ -36,13 +16,7 @@ if [ "$n" = "$base" ]; then true else - if [ -n "$prefix" ]; then - echo "autoload (\"$n\", strcat (\"$prefix\", filesep, \"$base.oct\"));" - elif $install; then - echo "autoload (\"$n\", strcat (__octfiledir__, filesep, \"$base.oct\"));" - else - echo "autoload (\"$n\", \"$base.oct\");" - fi + echo "autoload (\"$n\", fullfile (fileparts (mfilename (\"fullpath\")), \"$base.oct\"));" fi done fi
--- a/src/parse.y +++ b/src/parse.y @@ -3584,6 +3584,68 @@ unwind_protect::run_frame ("source_file"); } +DEFUN (mfilename, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} mfilename ()\n\ +@deftypefnx {Built-in Function} {} mfilename (@code{\"fullpath\"})\n\ +@deftypefnx {Built-in Function} {} mfilename (@code{\"fullpathext\"})\n\ +Return the name of the currently executing file. At the top-level,\n\ +return the empty string. Given the argument @code{\"fullpath\"},\n\ +include the directory part of the file name, but not the extension.\n\ +Given the argument @code{\"fullpathext\"}, include the directory part\n\ +of the file name and the extension.\n\ +@end deftypfn") +{ + octave_value retval; + + int nargin = args.length (); + + if (nargin > 1) + { + print_usage ("mfilename"); + return retval; + } + + std::string arg; + + if (nargin == 1) + { + arg = args(0).string_value (); + + if (error_state) + { + error ("mfilename: expecting argument to be a character string"); + return retval; + } + } + + std::string fname; + + if (curr_caller_function) + fname = curr_caller_function->fcn_file_name (); + + if (arg == "fullpathext") + retval = fname; + else + { + size_t pos = fname.rfind ('.'); + + fname = (pos != NPOS) ? fname.substr (0, pos) : fname; + + if (arg == "fullpath") + retval = fname; + else + { + pos = fname.rfind (file_ops::dir_sep_char); + + retval = (pos != NPOS) ? fname.substr (pos+1) : fname; + } + } + + return retval; +} + + DEFUN (source, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} source (@var{file})\n\