diff src/ov.cc @ 4455:abbf63293766

[project @ 2003-07-11 01:01:16 by jwe]
author jwe
date Fri, 11 Jul 2003 01:01:17 +0000
parents f3c21a1d1c62
children d7d9ca19960a
line wrap: on
line diff
--- a/src/ov.cc	Fri Jul 11 00:58:56 2003 +0000
+++ b/src/ov.cc	Fri Jul 11 01:01:17 2003 +0000
@@ -75,12 +75,12 @@
 // semicolon has been appended to each statement).
 static bool Vsilent_functions;
 
-// If TRUE, allow assignments like
+// If TRUE, print a warning for assignments like
 //
 //   octave> A(1) = 3; A(2) = 5
 //
 // for A already defined and a matrix type.
-bool Vdo_fortran_indexing;
+bool Vwarn_fortran_indexing;
 
 // Should we warn about conversions from complex to real?
 int Vwarn_imag_to_real;
@@ -96,14 +96,6 @@
 //
 int Vwarn_str_to_num;
 
-// If TRUE, create column vectors when doing assignments like:
-//
-//   octave> A(1) = 3; A(2) = 5
-//
-// (for A undefined).  Only matters when resize_on_range_error is also
-// TRUE.
-static bool Vprefer_column_vectors;
-
 // If TRUE, print the name along with the value.
 bool Vprint_answer_id_name;
 
@@ -969,9 +961,12 @@
       for (int i = 0; i < nr; i++)
 	retval (i) = m (i, 0);
     }
-  else if (nr > 0 && nc > 0
-	   && (Vdo_fortran_indexing || force_vector_conversion))
+  else if (nr > 0 && nc > 0)
     {
+      // XXX FIXME XXX -- is warn_fortran_indexing the right variable here?
+      if (! force_vector_conversion && Vwarn_fortran_indexing)
+	gripe_implicit_conversion (type_name (), "real vector");
+
       retval.resize (nr * nc);
       int k = 0;
       for (int j = 0; j < nc; j++)
@@ -1041,9 +1036,12 @@
 	  retval (i) = static_cast<int> (d);
 	}
     }
-  else if (nr > 0 && nc > 0
-	   && (Vdo_fortran_indexing || force_vector_conversion))
+  else if (nr > 0 && nc > 0)
     {
+      // XXX FIXME XXX -- is warn_fortran_indexing the right variable here?
+      if (! force_vector_conversion && Vwarn_fortran_indexing)
+	gripe_implicit_conversion (type_name (), "real vector");
+
       retval.resize (nr * nc);
       int k = 0;
       for (int j = 0; j < nc; j++)
@@ -1105,9 +1103,12 @@
 	  retval (i) = m (i, 0);
 	}
     }
-  else if (nr > 0 && nc > 0
-	   && (Vdo_fortran_indexing || force_vector_conversion))
+  else if (nr > 0 && nc > 0)
     {
+      // XXX FIXME XXX -- is warn_fortran_indexing the right variable here?
+      if (! force_vector_conversion && Vwarn_fortran_indexing)
+	gripe_implicit_conversion (type_name (), "complex vector");
+
       retval.resize (nr * nc);
       int k = 0;
       for (int j = 0; j < nc; j++)
@@ -1753,11 +1754,11 @@
 }
 
 static int
-do_fortran_indexing (void)
+warn_fortran_indexing (void)
 {
-  Vdo_fortran_indexing = check_preference ("do_fortran_indexing");
+  Vwarn_fortran_indexing = check_preference ("warn_fortran_indexing");
 
-  liboctave_dfi_flag = Vdo_fortran_indexing;
+  liboctave_wfi_flag = Vwarn_fortran_indexing;
 
   return 0;
 }
@@ -1787,17 +1788,6 @@
 }
 
 static int
-prefer_column_vectors (void)
-{
-  Vprefer_column_vectors
-    = check_preference ("prefer_column_vectors");
-
-  liboctave_pcv_flag = Vprefer_column_vectors;
-
-  return 0;
-}
-
-static int
 print_answer_id_name (void)
 {
   Vprint_answer_id_name = check_preference ("print_answer_id_name");
@@ -1860,35 +1850,6 @@
 void
 symbols_of_ov (void)
 {
-  DEFVAR (do_fortran_indexing, false, do_fortran_indexing,
-    "-*- texinfo -*-\n\
-@defvr {Built-in Variable} do_fortran_indexing\n\
-If the value of @code{do_fortran_indexing} is nonzero, Octave allows \n\
-you to select elements of a two-dimensional matrix using a single index\n\
-by treating the matrix as a single vector created from the columns of\n\
-the matrix.  The default value is 0. \n\
-@end defvr");
-
-  DEFVAR (prefer_column_vectors, true, prefer_column_vectors,
-    "-*- texinfo -*-\n\
-@defvr {Built-in Variable} prefer_column_vectors\n\
-If @code{prefer_column_vectors} is nonzero, operations like\n\
-\n\
-@example\n\
-for i = 1:10\n\
-  a (i) = i;\n\
-endfor\n\
-@end example\n\
-\n\
-@noindent\n\
-(for @code{a} previously  undefined) produce column vectors.  Otherwise, row\n\
-vectors are preferred.  The default value is 1.\n\
-\n\
-If a variable is already defined to be a vector (a matrix with a single\n\
-row or column), the original orientation is respected, regardless of the\n\
-value of @code{prefer_column_vectors}.\n\
-@end defvr");
-
   DEFVAR (print_answer_id_name, true, print_answer_id_name,
     "-*- texinfo -*-\n\
 @defvr {Built-in Variable} print_answer_id_name\n\
@@ -1961,6 +1922,14 @@
 0, the warning is omitted.  The default value is 1.\n\
 @end defvr");
 
+  DEFVAR (warn_fortran_indexing, false, warn_fortran_indexing,
+    "-*- texinfo -*-\n\
+@defvr {Built-in Variable} warn_fortran_indexing\n\
+If the value of @code{warn_fortran_indexing} is nonzero, a warning is\n\
+printed for expressions which select elements of a two-dimensional matrix\n\
+using a single index.  The default value is 0.\n\
+@end defvr");
+
   DEFVAR (warn_imag_to_real, false, warn_imag_to_real,
     "-*- texinfo -*-\n\
 @defvr {Built-in Variable} warn_imag_to_real\n\