changeset 4476:b7360f8eb035

[project @ 2003-07-30 17:17:21 by jwe]
author jwe
date Wed, 30 Jul 2003 17:17:21 +0000
parents 15c739d0c13c
children 87c2e107f811
files ChangeLog doc/faq/Octave-FAQ.texi doc/interpreter/basics.txi doc/interpreter/numbers.txi doc/interpreter/var.txi liboctave/ArrayN.cc liboctave/ChangeLog scripts/ChangeLog scripts/miscellaneous/dump_prefs.m src/ChangeLog src/lex.l src/octave.cc test/octave.test/prefer/prefer-1.m test/octave.test/prefer/prefer-10.m test/octave.test/prefer/prefer-11.m test/octave.test/prefer/prefer-2.m test/octave.test/prefer/prefer-3.m test/octave.test/prefer/prefer-4.m test/octave.test/prefer/prefer-5.m test/octave.test/prefer/prefer-6.m test/octave.test/prefer/prefer-7.m test/octave.test/prefer/prefer-8.m test/octave.test/prefer/prefer-9.m test/octave.test/prefer/prefer.exp
diffstat 24 files changed, 112 insertions(+), 180 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Jul 30 16:26:20 2003 +0000
+++ b/ChangeLog	Wed Jul 30 17:17:21 2003 +0000
@@ -1,3 +1,7 @@
+2003-07-30  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* ck-oct-fcns.m: Delete.
+
 2003-07-25  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* configure.in: Warn if --enable-dl but not --enable-shared.
--- a/doc/faq/Octave-FAQ.texi	Wed Jul 30 16:26:20 2003 +0000
+++ b/doc/faq/Octave-FAQ.texi	Wed Jul 30 17:17:21 2003 +0000
@@ -725,7 +725,6 @@
   page_screen_output            = false
   print_empty_dimensions        = false
   warn_function_name_clash      = false
-  whitespace_in_literal_matrix  = "traditional"
 @end group
 @end example
 
--- a/doc/interpreter/basics.txi	Wed Jul 30 16:26:20 2003 +0000
+++ b/doc/interpreter/basics.txi	Wed Jul 30 17:17:21 2003 +0000
@@ -165,7 +165,6 @@
   page_screen_output            = false
   print_empty_dimensions        = false
   warn_function_name_clash      = false
-  whitespace_in_literal_matrix  = "traditional"
 @end group
 @end example
 
--- a/doc/interpreter/numbers.txi	Wed Jul 30 16:26:20 2003 +0000
+++ b/doc/interpreter/numbers.txi	Wed Jul 30 17:17:21 2003 +0000
@@ -152,14 +152,7 @@
 Inside the square brackets that delimit a matrix expression, Octave
 looks at the surrounding context to determine whether spaces and newline
 characters should be converted into element and row separators, or
-simply ignored, so commands like
-
-@example
-[ linspace (1, 2) ]
-@end example
-
-@noindent
-and
+simply ignored, so an expression like
 
 @example
 @group
@@ -186,16 +179,39 @@
 
 @noindent
 the @samp{-} is treated as a unary operator and the result is the
-vector @code{[ 1, -1 ]}.
+vector @code{[ 1, -1 ]}.  Similarly, the expression
+
+@example
+[ sin (pi) ]
+@end example
+
+@noindent
+will be parsed as
+
+@example
+[ sin, (pi) ]
+@end example
 
-Given @code{a = 1}, the expression
+@noindent
+and will result in an error since the @code{sin} function will be
+called with no arguments.  To get around this, you must omit the space
+between @code{sin} and the opening parenthesis, or enclose the
+expression in a set of parentheses:
+
+@example
+[ (sin (pi)) ]
+@end example
+
+Whitespace surrounding the single quote character (@samp{'}, used as a
+transpose operator and for delimiting character strings) can also cause
+confusion.  Given @code{a = 1}, the expression
 
 @example
 [ 1 a' ]
 @end example
 
 @noindent
-results in the single quote character @samp{'} being treated as a
+results in the single quote character being treated as a
 transpose operator and the result is the vector @code{[ 1, 1 ]}, but the
 expression
 
@@ -211,19 +227,14 @@
 @end example
 
 @noindent
-because to not do so would make it impossible to correctly parse the
-valid expression
+because to not do so would cause trouble when parsing the valid expression
 
 @example
 [ a 'foo' ]
 @end example
 
 For clarity, it is probably best to always use commas and semicolons to
-separate matrix elements and rows.  It is possible to enforce this style
-by setting the built-in variable @code{whitespace_in_literal_matrix} to
-@code{"ignore"}.
-
-@DOCSTRING(whitespace_in_literal_matrix)
+separate matrix elements and rows.
 
 @DOCSTRING(warn_separator_insert)
 
--- a/doc/interpreter/var.txi	Wed Jul 30 16:26:20 2003 +0000
+++ b/doc/interpreter/var.txi	Wed Jul 30 17:17:21 2003 +0000
@@ -407,7 +407,12 @@
 
 Default value: 0.
 
-@item warn_single_quote_string)
+@item warn_separator_insert
+@xref{Matrices}.
+
+Default value: 0.
+
+@item warn_single_quote_string
 @xref{String Conversions}.
 
 Default value: 0.
@@ -426,11 +431,6 @@
 @xref{The switch Statement}.
 
 Default value: 0.
-
-@item whitespace_in_literal_matrix
-@xref{Matrices}.
-
-Default value: @code{""}.
 @end vtable
 
 
--- a/liboctave/ArrayN.cc	Wed Jul 30 16:26:20 2003 +0000
+++ b/liboctave/ArrayN.cc	Wed Jul 30 17:17:21 2003 +0000
@@ -408,7 +408,7 @@
 		}
 	      break;
 
-	    case 1:
+	    default:
 	      rows = a_dims(0);
 
 	      for (int k = 0; k < rows; k++)
@@ -417,10 +417,6 @@
 		  os << " " << a.elem(ra_idx);
 		}
 	      break;
-
-	    default:
-	      (*current_liboctave_error_handler)
-		("std::operator <<: problems with dimensions (= 0)!");
 	    }
 
           os << "\n";
--- a/liboctave/ChangeLog	Wed Jul 30 16:26:20 2003 +0000
+++ b/liboctave/ChangeLog	Wed Jul 30 17:17:21 2003 +0000
@@ -1,3 +1,7 @@
+2003-30-07  Heine Kolltveit  <kolltvei@idi.ntnu.no>
+
+        * ArrayN.cc (operator <<): Corrected output.
+
 2003-07-30  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* ArrayN.cc (increment_index): New arg, start_dimension.
--- a/scripts/ChangeLog	Wed Jul 30 16:26:20 2003 +0000
+++ b/scripts/ChangeLog	Wed Jul 30 17:17:21 2003 +0000
@@ -1,3 +1,9 @@
+2003-07-30  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* miscellaneous/dump_prefs.m: Add warn_separator_insert and
+	warn_single_quote_string to the list.
+	Delete whitespace_in_literal_matrix from the list.
+
 2003-07-25  Paul Kienzle <pkienzle@users.sf.net>
 
 	* signal/autocov.m: Transpose result of conj because diag returns
--- a/scripts/miscellaneous/dump_prefs.m	Wed Jul 30 16:26:20 2003 +0000
+++ b/scripts/miscellaneous/dump_prefs.m	Wed Jul 30 17:17:21 2003 +0000
@@ -98,10 +98,11 @@
               "warn_neg_dim_as_zero";
               "warn_num_to_str";
               "warn_resize_on_range_error";
+              "warn_separator_insert";
+              "warn_single_quote_string";
               "warn_str_to_num";
               "warn_undefined_return_values";
-              "warn_variable_switch_label";
-              "whitespace_in_literal_matrix"];
+              "warn_variable_switch_label"];
 
   for i = 1:rows(var_list)
     var = deblank (var_list(i,:));
--- a/src/ChangeLog	Wed Jul 30 16:26:20 2003 +0000
+++ b/src/ChangeLog	Wed Jul 30 17:17:21 2003 +0000
@@ -1,3 +1,18 @@
+2003-07-30  John W. Eaton  <jwe@bevo.che.wisc.edu>
+
+	* octave.cc (maximum_braindamage): Also set
+	warn_matlab_incompatible to TRUE.
+
+	* lex.l (whitespace_in_literal_matrix): Delete.
+	(symbols_of_lex): Delete DEFVAR for whitespace_in_literal_matrix.
+	(<MATRIX_START>{S}*\,{S}*, <MATRIX_START>{S}+,
+	(<MATRIX_START>{S}*{COMMENT}{SNLCMT}*,
+	<MATRIX_START>{S}*{NL}{SNLCMT}*, maybe_unput_comma): Behave as though
+	Vwhitespace_in_literal_matrix is always 1.
+
+	* octave.cc (maximum_braindamage): Don't set
+	whitespace_in_literal_matrix.
+
 2003-07-29  John W. Eaton  <jwe@bevo.che.wisc.edu>
 
 	* Makefile.in (install-lib): Use $(INSTALL), not
--- a/src/lex.l	Wed Jul 30 16:26:20 2003 +0000
+++ b/src/lex.l	Wed Jul 30 17:17:21 2003 +0000
@@ -142,48 +142,6 @@
 
 static bracket_brace_paren_nesting_level nesting_level;
 
-// Should whitespace in a literal matrix list be automatically
-// converted to commas and semicolons?
-//
-//   user specifies   value of var
-//   --------------   ------------
-//   "ignore"              2
-//   "traditional"         1
-//   anything else         0
-//
-// Octave will never insert a comma in a literal matrix list if the
-// user specifies "ignore".  For example, the statement [1 2] will
-// result in an error instead of being treated the same as [1, 2], and
-// the statement
-//
-//   [ 1, 2,
-//     3, 4 ]
-//
-// will result in the vector [1 2 3 4] instead of a matrix.
-//
-// Traditional behavior makes Octave convert spaces to a comma between
-// identifiers and `('.  For example, the statement
-//
-//   [eye (2)]
-//
-// will be parsed as
-//
-//   [eye, (2)]
-//
-// and will result in an error since the `eye' function will be
-// called with no arguments.  To get around this, you would have to
-// omit the space between `eye' and the `('.
-//
-// The default value is 0, which results in behavior that is the same
-// as traditional, except that Octave does not convert spaces to a
-// comma between identifiers and `('.  For example, the statement
-//
-//   [eye (2)]
-//
-// will result in a call to `eye' with the argument `2'.
-
-static int Vwhitespace_in_literal_matrix;
-
 static bool Vwarn_matlab_incompatible = false;
 
 static bool Vwarn_separator_insert = false;
@@ -337,8 +295,7 @@
       {
 	maybe_warn_separator_insert (';');
 
-	if (Vwhitespace_in_literal_matrix != 2)
-	  yyunput (';', yytext);
+	yyunput (';', yytext);
       }
 
     return (',');
@@ -366,20 +323,16 @@
 	  {
 	    maybe_warn_separator_insert (';');
 
-	    if (Vwhitespace_in_literal_matrix != 2)
-	      yyunput (';', yytext);
+	    yyunput (';', yytext);
 	  }
 
-	if (Vwhitespace_in_literal_matrix != 2)
-	  {
-	    lexer_flags.quote_is_transpose = false;
-	    lexer_flags.cant_be_identifier = false;
-	    lexer_flags.convert_spaces_to_comma = true;
-
-	    maybe_warn_separator_insert (',');
-
-	    return (',');
-	  }
+	lexer_flags.quote_is_transpose = false;
+	lexer_flags.cant_be_identifier = false;
+	lexer_flags.convert_spaces_to_comma = true;
+
+	maybe_warn_separator_insert (',');
+
+	return (',');
       }
   }
 
@@ -411,22 +364,18 @@
     fixup_column_count (yytext);
     eat_whitespace ();
 
-    if (Vwhitespace_in_literal_matrix != 2)
-      {
-	lexer_flags.quote_is_transpose = false;
-	lexer_flags.cant_be_identifier = false;
-	lexer_flags.convert_spaces_to_comma = true;
-
-	if (nesting_level.none ())
-	  return LEXICAL_ERROR;
-      }
+    lexer_flags.quote_is_transpose = false;
+    lexer_flags.cant_be_identifier = false;
+    lexer_flags.convert_spaces_to_comma = true;
+
+    if (nesting_level.none ())
+      return LEXICAL_ERROR;
 
     if (nesting_level.is_bracket ())
       {
 	maybe_warn_separator_insert (';');
 
-	if (Vwhitespace_in_literal_matrix != 2)
-	  return ';';
+	return ';';
       }
   }
 
@@ -2297,11 +2246,8 @@
 	    {
 	      maybe_warn_separator_insert (',');
 
-	      if (Vwhitespace_in_literal_matrix != 2)
-		{
-		  yyunput (',', yytext);
-		  return ']';
-		}
+	      yyunput (',', yytext);
+	      return ']';
 	    }
 	}
     }
@@ -2338,27 +2284,15 @@
 
       int index_op = (c1 == '(' || c1 == '{');
 
-      if (index_op)
-	{
-	  // If there is no space before the indexing op, we don't
-	  // insert a comma.
-	  if (! spc_gobbled)
-	    return;
-
-	  maybe_warn_separator_insert (',');
-
-	  // If there is a space, we only insert a comma if we are
-	  // trying to be Matlab-like.
-	  if (Vwhitespace_in_literal_matrix == 1)
-	    yyunput (',', yytext);
-	}
-      else
-	{
-	  maybe_warn_separator_insert (',');
-
-	  if (Vwhitespace_in_literal_matrix != 2)
-	    yyunput (',', yytext);
-	}
+      // If there is no space before the indexing op, we don't insert
+      // a comma.
+
+      if (index_op && ! spc_gobbled)
+	return;
+
+      maybe_warn_separator_insert (',');
+
+      yyunput (',', yytext);
     }
 }
 
@@ -2714,26 +2648,6 @@
   return 0;
 }
 
-static int
-whitespace_in_literal_matrix (void)
-{
-  int pref = 0;
-
-  std::string val = builtin_string_variable ("whitespace_in_literal_matrix");
-
-  if (! val.empty ())
-    {
-      if (val == "ignore")
-	pref = 2;
-      else if (val == "traditional")
-	pref = 1;
-    }
-
-  Vwhitespace_in_literal_matrix = pref;
-
-  return 0;
-}
-
 void
 symbols_of_lex (void)
 {
@@ -2757,13 +2671,6 @@
 Print warning if a signle quote character is used to introduce a\n\
 string constant.\n\
 @end defvr");
-
-  DEFVAR (whitespace_in_literal_matrix, "", whitespace_in_literal_matrix,
-    "-*- texinfo -*-\n\
-@defvr {Built-in Variable} whitespace_in_literal_matrix\n\
-Control auto-insertion of commas and semicolons in literal matrices.\n\
-@end defvr");
-
 }
 
 /*
--- a/src/octave.cc	Wed Jul 30 16:26:20 2003 +0000
+++ b/src/octave.cc	Wed Jul 30 17:17:21 2003 +0000
@@ -351,7 +351,7 @@
   bind_builtin_variable ("page_screen_output", false);
   bind_builtin_variable ("print_empty_dimensions", false);
   bind_builtin_variable ("warn_function_name_clash", false);
-  bind_builtin_variable ("whitespace_in_literal_matrix", "traditional");
+  bind_builtin_variable ("warn_matlab_incompatible", true);
 }
 
 // You guessed it.
--- a/test/octave.test/prefer/prefer-1.m	Wed Jul 30 16:26:20 2003 +0000
+++ b/test/octave.test/prefer/prefer-1.m	Wed Jul 30 17:17:21 2003 +0000
@@ -1,2 +1,2 @@
-whitespace_in_literal_matrix = "ignore";
 m = [3 2];
+all (m == (3:-1:2))
--- a/test/octave.test/prefer/prefer-10.m	Wed Jul 30 16:26:20 2003 +0000
+++ b/test/octave.test/prefer/prefer-10.m	Wed Jul 30 17:17:21 2003 +0000
@@ -1,3 +1,2 @@
-whitespace_in_literal_matrix = 0;
-m = [3,2];
-[m(1)]
+a = 2;
+[a- 1]
--- a/test/octave.test/prefer/prefer-11.m	Wed Jul 30 16:26:20 2003 +0000
+++ b/test/octave.test/prefer/prefer-11.m	Wed Jul 30 17:17:21 2003 +0000
@@ -1,3 +1,2 @@
-whitespace_in_literal_matrix = 0;
-m = [3,2];
-all ([m,(1)] == [3,2,1])
+a = 1;
+all ([a -1] == (1:-2:-1))
--- a/test/octave.test/prefer/prefer-2.m	Wed Jul 30 16:26:20 2003 +0000
+++ b/test/octave.test/prefer/prefer-2.m	Wed Jul 30 17:17:21 2003 +0000
@@ -1,4 +1,3 @@
-whitespace_in_literal_matrix = "ignore";
 m = [3,
  2];
-all (m == (3:-1:2))
+all (m == (3:-1:2)')
--- a/test/octave.test/prefer/prefer-3.m	Wed Jul 30 16:26:20 2003 +0000
+++ b/test/octave.test/prefer/prefer-3.m	Wed Jul 30 17:17:21 2003 +0000
@@ -1,3 +1,2 @@
-whitespace_in_literal_matrix = "ignore";
-m = [3,2];
-[m   (1)]
+a = 2;
+[a - 1]
--- a/test/octave.test/prefer/prefer-4.m	Wed Jul 30 16:26:20 2003 +0000
+++ b/test/octave.test/prefer/prefer-4.m	Wed Jul 30 17:17:21 2003 +0000
@@ -1,3 +1,2 @@
-whitespace_in_literal_matrix = "ignore";
 m = [3,2];
-[m(1)]
+[m ']
--- a/test/octave.test/prefer/prefer-5.m	Wed Jul 30 16:26:20 2003 +0000
+++ b/test/octave.test/prefer/prefer-5.m	Wed Jul 30 17:17:21 2003 +0000
@@ -1,2 +1,1 @@
-whitespace_in_literal_matrix = "traditional";
 all ([3 2] == (3:-1:2))
--- a/test/octave.test/prefer/prefer-6.m	Wed Jul 30 16:26:20 2003 +0000
+++ b/test/octave.test/prefer/prefer-6.m	Wed Jul 30 17:17:21 2003 +0000
@@ -1,2 +1,1 @@
-whitespace_in_literal_matrix = "traditional";
 all ([3, 2] == (3:-1:2))
--- a/test/octave.test/prefer/prefer-7.m	Wed Jul 30 16:26:20 2003 +0000
+++ b/test/octave.test/prefer/prefer-7.m	Wed Jul 30 17:17:21 2003 +0000
@@ -1,3 +1,2 @@
-whitespace_in_literal_matrix = "traditional";
 m = [3,2];
-all ([m (1)] == [3,2,1])
+all ([m (1)] == (3:-1:1))
--- a/test/octave.test/prefer/prefer-8.m	Wed Jul 30 16:26:20 2003 +0000
+++ b/test/octave.test/prefer/prefer-8.m	Wed Jul 30 17:17:21 2003 +0000
@@ -1,3 +1,2 @@
-whitespace_in_literal_matrix = "traditional";
 m = [3,2];
 [m(1)]
--- a/test/octave.test/prefer/prefer-9.m	Wed Jul 30 16:26:20 2003 +0000
+++ b/test/octave.test/prefer/prefer-9.m	Wed Jul 30 17:17:21 2003 +0000
@@ -1,3 +1,2 @@
-whitespace_in_literal_matrix = 0;
 m = [3,2];
-[m   (1)]
+all ([m (1)] == (3:-1:1))
--- a/test/octave.test/prefer/prefer.exp	Wed Jul 30 16:26:20 2003 +0000
+++ b/test/octave.test/prefer/prefer.exp	Wed Jul 30 17:17:21 2003 +0000
@@ -1,7 +1,7 @@
 ## whitespace_in_literal_matrix
 
 set test whitespace-in-literal-matrix-1
-set prog_output "parse error.*"
+set prog_output "^ans = 1"
 do_test prefer-1.m
 
 set test whitespace-in-literal-matrix-2
@@ -9,11 +9,11 @@
 do_test prefer-2.m
 
 set test whitespace-in-literal-matrix-3
-set prog_output "^ans = 3"
+set prog_output "^ans = 1"
 do_test prefer-3.m
 
 set test whitespace-in-literal-matrix-4
-set prog_output "^ans = 3"
+set prog_output "^error:.*"
 do_test prefer-4.m
 
 set test whitespace-in-literal-matrix-5
@@ -33,11 +33,11 @@
 do_test prefer-8.m
 
 set test whitespace-in-literal-matrix-9
-set prog_output "^ans = 3"
+set prog_output "^ans = 1"
 do_test prefer-9.m
 
 set test whitespace-in-literal-matrix-10
-set prog_output "^ans = 3"
+set prog_output "^ans = 1"
 do_test prefer-10.m
 
 set test whitespace-in-literal-matrix-11