# HG changeset patch # User jwe # Date 1156176920 0 # Node ID 009fa69b6182dac6f91d0ac280af9967f64dc8ae # Parent 4b433225128d9aa6a8f31d3ab5660be5d12bac02 [project @ 2006-08-21 16:15:20 by jwe] diff -r 4b433225128d -r 009fa69b6182 scripts/ChangeLog --- a/scripts/ChangeLog Mon Aug 21 15:57:09 2006 +0000 +++ b/scripts/ChangeLog Mon Aug 21 16:15:20 2006 +0000 @@ -1,3 +1,14 @@ +2006-08-21 Søren Hauberg + + * 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 + + * general/num2str.m: Early return if arg is empty. + From Thomas Treichl . + 2006-08-21 David Bateman * strings/mat2str.m: Compute NC before using. diff -r 4b433225128d -r 009fa69b6182 scripts/general/num2str.m --- a/scripts/general/num2str.m Mon Aug 21 15:57:09 2006 +0000 +++ b/scripts/general/num2str.m Mon Aug 21 16:15:20 2006 +0000 @@ -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"); diff -r 4b433225128d -r 009fa69b6182 scripts/pkg/pkg.m --- a/scripts/pkg/pkg.m Mon Aug 21 15:57:09 2006 +0000 +++ b/scripts/pkg/pkg.m Mon Aug 21 16:15:20 2006 +0000 @@ -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