changeset 5539:b800ae36fc6a

[project @ 2005-11-16 18:45:32 by jwe]
author jwe
date Wed, 16 Nov 2005 18:45:32 +0000
parents 8d2903f71c96
children cda6a105ae9a
files scripts/ChangeLog scripts/general/shiftdim.m src/Cell.cc src/ChangeLog src/Makefile.in src/mk-pkg-add src/oct-map.cc src/ov-base-mat.cc src/ov-base-sparse.cc src/ov-str-mat.cc src/ov.cc
diffstat 11 files changed, 77 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Sat Nov 12 02:31:23 2005 +0000
+++ b/scripts/ChangeLog	Wed Nov 16 18:45:32 2005 +0000
@@ -1,3 +1,7 @@
+2005-11-15  John W. Eaton  <jwe@octave.org>
+
+	* general/shiftdim.m: Doc fix.
+
 2005-11-07  Keith Goodman  <kwgoodman@gmail.com>
 
 	* set/unique.m: Doc string fix.
--- a/scripts/general/shiftdim.m	Sat Nov 12 02:31:23 2005 +0000
+++ b/scripts/general/shiftdim.m	Wed Nov 16 18:45:32 2005 +0000
@@ -21,10 +21,10 @@
 ## @deftypefn {Function File} {@var{y}} = shiftdim (@var{x}, @var{n})
 ## @deftypefnx {Function File} {[@var{y}, @var{ns}]} = shiftdim (@var{x})
 ## Shifts the dimension of @var{x} by @var{n}, where @var{n} must be
-## an integer scalar. When @var{n} is negative, the dimensions of
+## an integer scalar. When @var{n} is positive, the dimensions of
 ## @var{x} are shifted to the left, with the leading dimensions
-## circulated to the end. If @var{n} is positive, then the dimensions
-## of @var{x} are shifted to the right, with the @var{n} singleton
+## circulated to the end. If @var{n} is negative, then the dimensions
+## of @var{x} are shifted to the right, with @var{n} leading singleton
 ## dimensions added.
 ##
 ## Called with a single argument, @code{shiftdim}, removes the leading
--- a/src/Cell.cc	Sat Nov 12 02:31:23 2005 +0000
+++ b/src/Cell.cc	Wed Nov 16 18:45:32 2005 +0000
@@ -53,6 +53,10 @@
 
   switch (n)
     {
+    case 0:
+      retval = *this;
+      break;
+
     case 1:
       {
 	idx_vector i = idx_arg(0).index_vector ();
--- a/src/ChangeLog	Sat Nov 12 02:31:23 2005 +0000
+++ b/src/ChangeLog	Wed Nov 16 18:45:32 2005 +0000
@@ -1,3 +1,19 @@
+2005-11-16  John W. Eaton  <jwe@octave.org>
+
+	* Makefile.in (PKG_ADD.inst): New target.
+	(install): Dependo on it.
+	(clean): Remove it.
+
+	* mk-pkg-add: New option --install.  Don't use --prefix option.
+	Delete obsolete comments.
+
+	* Cell.cc (Cell::index): Indexing with () is a no-op, not an error.
+	* oct-map.cc (Octave_map::index): Likewise.
+	* ov-base-mat.cc (octave_base_matrix<MT>::do_index_op): Likewise.
+	* ov-base-sparse.cc (octave_base_sparse<T>::do_index_op): Likewise.
+	* ov-str-mat.cc (octave_char_matrix_str::do_index_op_internal):
+	Likewise.
+
 2005-11-11  John W. Eaton  <jwe@octave.org>
 
 	* Makefile.in (install-oct): Fix thinko in previous change.
--- a/src/Makefile.in	Sat Nov 12 02:31:23 2005 +0000
+++ b/src/Makefile.in	Wed Nov 16 18:45:32 2005 +0000
@@ -343,8 +343,12 @@
 	@$(top_srcdir)/move-if-change $@-t $@
 
 PKG_ADD: $(DLD_DEF_FILES)
-	$(srcdir)/mk-pkg-add --prefix $(shell pwd) $(DLD_DEF_FILES) > PKG_ADD-t
-	mv PKG_ADD-t PKG_ADD
+	$(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
+	mv $@-t $@
 
 DOCSTRINGS: gendoc$(BUILD_EXEEXT)
 	./gendoc > $@-t
@@ -396,9 +400,9 @@
 	cd $(DESTDIR)$(bindir) ; $(LN_S) octave-$(version)$(EXEEXT) octave$(EXEEXT)
 .PHONY: install-bin
 
-install-oct:
+install-oct: PKG_ADD.inst
 	$(top_srcdir)/mkinstalldirs $(DESTDIR)$(octfiledir)
-	$(srcdir)/mk-pkg-add --prefix $(octfiledir) $(DLD_DEF_FILES) > $(DESTDIR)$(octfiledir)/PKG_ADD
+	$(INSTALL_DATA) PKG_ADD.inst $(DESTDIR)$(octfiledir)/PKG_ADD
 	if [ -n "$(OCT_FILES)" ]; then \
 	  xfiles="$(OCT_FILES)"; \
 	  for f in $$xfiles; do \
@@ -472,6 +476,7 @@
 	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	Sat Nov 12 02:31:23 2005 +0000
+++ b/src/mk-pkg-add	Wed Nov 16 18:45:32 2005 +0000
@@ -1,21 +1,25 @@
 #! /bin/sh -e
 
-# Create additional links to .oct files that define more than one
-# function.
-
-# If the first arg is --print, only print the links we need to make.
-
-# The first non-option arg is taken as the directory where the .oct
-# files are installed.  The remaining arguments should be the list of
-# .df files corresponding to the source files that were used to
-# create the .oct files.
-
 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
@@ -33,7 +37,9 @@
 	  true
 	else
           if [ -n "$prefix" ]; then
-	    echo "autoload (\"$n\", \"$prefix/$base.oct\");"
+	    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
--- a/src/oct-map.cc	Sat Nov 12 02:31:23 2005 +0000
+++ b/src/oct-map.cc	Wed Nov 16 18:45:32 2005 +0000
@@ -349,10 +349,9 @@
 	}
     }
   else
-    error ("invalid number of indices (= 0) for %d-dimensional struct array",
-	   ndims ());
+    retval = *this;
 
-  return error_state ? Octave_map () : retval;
+  return retval;
 }
 
 /*
--- a/src/ov-base-mat.cc	Sat Nov 12 02:31:23 2005 +0000
+++ b/src/ov-base-mat.cc	Wed Nov 16 18:45:32 2005 +0000
@@ -139,7 +139,7 @@
   switch (n_idx)
     {
     case 0:
-      error ("invalid number of indices (= 0) for %d-dimensional array", nd);
+      retval = matrix;
       break;
 
     case 1:
--- a/src/ov-base-sparse.cc	Sat Nov 12 02:31:23 2005 +0000
+++ b/src/ov-base-sparse.cc	Wed Nov 16 18:45:32 2005 +0000
@@ -55,7 +55,7 @@
   switch (n_idx)
     {
     case 0:
-      error ("invalid number of indices (= 0) for %d-dimensional array", nd);
+      retval = matrix;
       break;
 
     case 1:
--- a/src/ov-str-mat.cc	Sat Nov 12 02:31:23 2005 +0000
+++ b/src/ov-str-mat.cc	Wed Nov 16 18:45:32 2005 +0000
@@ -90,15 +90,8 @@
 
   switch (len)
     {
-    case 2:
-      {
-	idx_vector i = idx (0).index_vector ();
-	idx_vector j = idx (1).index_vector ();
-
-	if (! error_state)
-	  retval = octave_value (charNDArray (matrix.index (i, j, resize_ok)),
-				 true, type);
-      }
+    case 0:
+      retval = octave_value (matrix, true, type);
       break;
 
     case 1:
@@ -111,8 +104,15 @@
       }
       break;
 
-    case 0:
-      error ("invalid number of indices (= 0) for %d-dimensional character array", matrix.ndims ());
+    case 2:
+      {
+	idx_vector i = idx (0).index_vector ();
+	idx_vector j = idx (1).index_vector ();
+
+	if (! error_state)
+	  retval = octave_value (charNDArray (matrix.index (i, j, resize_ok)),
+				 true, type);
+      }
       break;
 
     default:
--- a/src/ov.cc	Sat Nov 12 02:31:23 2005 +0000
+++ b/src/ov.cc	Wed Nov 16 18:45:32 2005 +0000
@@ -799,12 +799,18 @@
 octave_value::~octave_value (void)
 {
 #if defined (MDEBUG)
-  std::cerr << "~octave_value: rep: " << rep
-	    << " rep->count: " << rep->count << "\n";
+  if (rep)
+    std::cerr << "~octave_value: rep: " << rep
+	      << " rep->count: " << rep->count << std::endl;
+  else
+    std::cerr << "~octave_value: rep is 0!" << std::endl;
 #endif
 
   if (rep && --rep->count == 0)
-    delete rep;
+    {
+      delete rep;
+      rep = 0;
+    }
 }
 
 octave_value *