Mercurial > hg > octave-lyh
changeset 5947:009fa69b6182
[project @ 2006-08-21 16:15:20 by jwe]
author | jwe |
---|---|
date | Mon, 21 Aug 2006 16:15:20 +0000 |
parents | 4b433225128d |
children | 8b4d38c76bfa |
files | scripts/ChangeLog scripts/general/num2str.m scripts/pkg/pkg.m |
diffstat | 3 files changed, 47 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,14 @@ +2006-08-21 Søren Hauberg <soren@hauberg.org> + + * pkg/pkg.m: Handle multiple packages in a single file. + Insert directory separator between OCTAVE_HOME and rest of package + installation directory. + +2006-08-21 John W. Eaton <jwe@octave.org> + + * general/num2str.m: Early return if arg is empty. + From Thomas Treichl <Thomas.Treichl@gmx.net>. + 2006-08-21 David Bateman <dbateman@free.fr> * strings/mat2str.m: Compute NC before using.
--- a/scripts/general/num2str.m +++ b/scripts/general/num2str.m @@ -32,15 +32,14 @@ function retval = num2str (x, arg) if (nargin != 1 && nargin != 2) - usage ("num2str (x) or num2str (x, precision) or num2str (x, fmt)"); + print_usage (); endif if (ischar (x)) retval = x; - return; - endif - - if (iscomplex (x)) + elseif (isempty (x)) + retval = ""; + elseif (iscomplex (x)) if (nargin == 2) if (ischar (arg)) fmt = strcat (arg, "%-+", arg(2:end), "i");
--- a/scripts/pkg/pkg.m +++ b/scripts/pkg/pkg.m @@ -27,6 +27,9 @@ ## @deftypefnx{Command} pkg load -nodeps @var{pkg-name} ... ## XXX: Where's the docs? ## @end deftypefn + +## PKG_ADD: mark_as_command pkg + function [local_packages, global_packages] = pkg(varargin) ## Handle input if (length(varargin) == 0 || !iscellstr(varargin)) @@ -89,7 +92,11 @@ if (issuperuser()) global_install = true; if (!prefix_exist) - OCTAVE_PACKAGE_PREFIX = [OCTAVE_HOME "share/octave/packages/"]; + if (strcmp(OCTAVE_HOME()(end),"/")) + OCTAVE_PACKAGE_PREFIX = [OCTAVE_HOME "share/octave/packages/"]; + else + OCTAVE_PACKAGE_PREFIX = [OCTAVE_HOME "/share/octave/packages/"]; + endif endif else global_install = false; @@ -123,9 +130,7 @@ endif ## Uncompress the packages and read the DESCRIPTION files - tmpdirs = cell(1, length(files)); - packdirs = cell(1, length(files)); - descriptions = cell(1, length(files)); + tmpdirs = packdirs = descriptions = {}; try ## Unpack the package files and read the DESCRIPTION files packages_to_uninstall = []; @@ -134,7 +139,7 @@ ## Create a temporary directory tmpdir = tmpnam(); - tmpdirs{i} = tmpdir; + tmpdirs{end+1} = tmpdir; [status, msg] = mkdir(tmpdir); if (status != 1) error("Couldn't create temporary directory: %s\n", msg); @@ -143,35 +148,37 @@ ## Uncompress the package untar(tgz, tmpdir); - ## Get the name of the directory produced by tar + ## Get the name of the directories produced by tar [dirlist, err, msg] = readdir(tmpdir); if (err) error("Couldn't read directory produced by tar: %s\n", msg); endif - packdir = [tmpdir "/" dirlist{end} "/"]; - packdirs{i} = packdir; + + for k = 3:length(dirlist) # the two first entries of dirlist are "." and ".." + packdir = [tmpdir "/" dirlist{k} "/"]; + packdirs{end+1} = packdir; - ## Make sure the package contains necessary files - verify_directory(packdir); + ## Make sure the package contains necessary files + verify_directory(packdir); - ## Read the DESCRIPTION file - filename = [packdir "DESCRIPTION"]; - desc = get_description(filename); + ## Read the DESCRIPTION file + filename = [packdir "DESCRIPTION"]; + desc = get_description(filename); - ## Set default installation directory - desc.dir = [prefix "/" desc.name "-" desc.version]; + ## Set default installation directory + desc.dir = [prefix "/" desc.name "-" desc.version]; - ## Save desc - descriptions{i} = desc; + ## Save desc + descriptions{end+1} = desc; - ## Are any of the new packages already installed? - ## If so we'll remove the old version. - for j = 1:length(packages) - if (strcmp(packages{j}.name, desc.name)) - packages_to_uninstall(end+1) = j; - endif - endfor - + ## Are any of the new packages already installed? + ## If so we'll remove the old version. + for j = 1:length(packages) + if (strcmp(packages{j}.name, desc.name)) + packages_to_uninstall(end+1) = j; + endif + endfor + endfor endfor catch ## Something went wrong, delete tmpdirs