changeset 6483:d00da2148c53

[project @ 2007-04-04 02:58:48 by jwe]
author jwe
date Wed, 04 Apr 2007 02:58:48 +0000
parents 7e958a1532c6
children 1ece41c144a6
files liboctave/ChangeLog src/ChangeLog src/error.cc src/file-io.cc src/oct-stream.cc src/pt-assign.cc
diffstat 6 files changed, 118 insertions(+), 103 deletions(-) [+]
line wrap: on
line diff
--- a/liboctave/ChangeLog	Wed Apr 04 02:37:07 2007 +0000
+++ b/liboctave/ChangeLog	Wed Apr 04 02:58:48 2007 +0000
@@ -6,7 +6,7 @@
 	fortran_vec method instead of OCTAVE_LOCAL_BUFFER to avoid
 	"maybe clobbered by vfork" warning.
 
-	* Sparse-op-defs.h (SPARSE_CUMSUM): Add parens to avoid ambiguous
+	* Sparse-op-defs.h (SPARSE_CUMSUM): Add braces to avoid ambiguous
 	if/else.
 
 	* oct-spparms.h (octave_sparse_params): Define copy constructor
--- a/src/ChangeLog	Wed Apr 04 02:37:07 2007 +0000
+++ b/src/ChangeLog	Wed Apr 04 02:58:48 2007 +0000
@@ -1,5 +1,8 @@
 2007-04-03  John W. Eaton  <jwe@octave.org>
 
+	* error.cc (Frethrow): Add braces to avoid ambiguous if/else.
+	* oct-stream.cc (octave_scan<>): Likewise.
+
 	* ov-fcn-handle.cc (make_fcn_handle): Pass ultimate parent
 	function name to lookup_function.
 
--- a/src/error.cc	Wed Apr 04 02:37:07 2007 +0000
+++ b/src/error.cc	Wed Apr 04 02:58:48 2007 +0000
@@ -840,46 +840,49 @@
     print_usage();
   else
     {
-      Octave_map err = args(0).map_value();
+      Octave_map err = args(0).map_value ();
 
-      if (!error_state)
+      if (! error_state)
 	{
-	  if (err.contains("message") && err.contains("identifier"))
+	  if (err.contains ("message") && err.contains ("identifier"))
 	    {
-	      std::string msg = err.contents("message")(0).string_value();
-	      std::string id = err.contents("identifier")(0).string_value();
+	      std::string msg = err.contents("message")(0).string_value ();
+	      std::string id = err.contents("identifier")(0).string_value ();
 	      int len = msg.length();
 	      std::string file;
 	      std::string nm;
 	      int l = -1;
 	      int c = -1;
 
-	      if (err.contains("stack"))
+	      if (err.contains ("stack"))
 		{
-		  Octave_map err_stack = err.contents("stack")(0).map_value();
+		  Octave_map err_stack = err.contents("stack")(0).map_value ();
+
+		  if (err_stack.contains ("file"))
+		    file = err_stack.contents("file")(0).string_value ();
 
-		  if (err_stack.contains("file"))
-		    file = err_stack.contents("file")(0).string_value();
-		  if (err_stack.contains("name"))
-		    nm = err_stack.contents("name")(0).string_value();
-		  if (err_stack.contains("line"))
-		    l = err_stack.contents("line")(0).nint_value();
-		  if (err_stack.contains("column"))
-		    c = err_stack.contents("column")(0).nint_value();
+		  if (err_stack.contains ("name"))
+		    nm = err_stack.contents("name")(0).string_value ();
+
+		  if (err_stack.contains ("line"))
+		    l = err_stack.contents("line")(0).nint_value ();
+
+		  if (err_stack.contains ("column"))
+		    c = err_stack.contents("column")(0).nint_value ();
 		}
 
 	      // Ugh.
-	      char *tmp_msg = strsave (msg.c_str());
+	      char *tmp_msg = strsave (msg.c_str ());
 	      if (tmp_msg[len-1] == '\n')
 		{
 		  if (len > 1)
 		    {
 		      tmp_msg[len - 1] = '\0';
-		      rethrow_error (id.c_str(), "%s\n", tmp_msg);
+		      rethrow_error (id.c_str (), "%s\n", tmp_msg);
 		    }
 		}
 	      else
-		rethrow_error (id.c_str(), "%s", tmp_msg);
+		rethrow_error (id.c_str (), "%s", tmp_msg);
 	      delete [] tmp_msg;
 
 	      // FIXME: Need to restore the stack as rethrow_error sets it?
@@ -888,27 +891,31 @@
 	      Vlast_error_line = l;
 	      Vlast_error_column = c;
 
-	      if (err.contains("stack"))
+	      if (err.contains ("stack"))
 		{
 		  if (file.empty ())
 		    {
 		      if (nm.empty ())
 			{
 			  if (l > 0)
-			    if (c > 0)
-			      pr_where_1 ("error: near line %d, column %d", 
-					  l, c);
-			    else
-			      pr_where_1 ("error: near line %d", l );
+			    {
+			      if (c > 0)
+				pr_where_1 ("error: near line %d, column %d", 
+					    l, c);
+			      else
+				pr_where_1 ("error: near line %d", l);
+			    }
 			}
 		      else
 			{
 			  if (l > 0)
-			    if (c > 0)
-			      pr_where_1 ("error: called from `%s' near line %d, column %d", 
-					  nm.c_str(), l, c);
-			    else
-			      pr_where_1 ("error: called from `%d' near line %d", nm.c_str(), l );
+			    {
+			      if (c > 0)
+				pr_where_1 ("error: called from `%s' near line %d, column %d", 
+					    nm.c_str (), l, c);
+			      else
+				pr_where_1 ("error: called from `%d' near line %d", nm.c_str (), l);
+			    }
 			}
 		    }
 		  else
@@ -916,20 +923,24 @@
 		      if (nm.empty ())
 			{
 			  if (l > 0)
-			    if (c > 0)
-			      pr_where_1 ("error: in file %s near line %d, column %d", 
-					  file.c_str(), l, c);
-			    else
-			      pr_where_1 ("error: in file %s near line %d", file.c_str(), l );
+			    {
+			      if (c > 0)
+				pr_where_1 ("error: in file %s near line %d, column %d", 
+					    file.c_str (), l, c);
+			      else
+				pr_where_1 ("error: in file %s near line %d", file.c_str (), l);
+			    }
 			}
 		      else
 			{
 			  if (l > 0)
-			    if (c > 0)
-			      pr_where_1 ("error: called from `%s' in file %s near line %d, column %d", 
-					  nm.c_str(), file.c_str(), l, c);
-			    else
-			      pr_where_1 ("error: called from `%d' in file %s near line %d", nm.c_str(), file.c_str(), l );
+			    {
+			      if (c > 0)
+				pr_where_1 ("error: called from `%s' in file %s near line %d, column %d", 
+					    nm.c_str (), file.c_str (), l, c);
+			      else
+				pr_where_1 ("error: called from `%d' in file %s near line %d", nm.c_str (), file.c_str (), l);
+			    }
 			}
 		    }
 		}
@@ -1407,7 +1418,7 @@
 	{
 	  if (args(0).is_string())
 	    {
-	      if (args(0).string_value() == "reset")
+	      if (args(0).string_value () == "reset")
 		{
 		  Vlast_error_message = std::string();
 		  Vlast_error_id = std::string();
@@ -1421,7 +1432,7 @@
 	    }
 	  else if (args(0).is_map ())
 	    {
-	      Octave_map new_err = args(0).map_value();
+	      Octave_map new_err = args(0).map_value ();
 	      std::string new_error_message;
 	      std::string new_error_id;
 	      std::string new_error_file;
@@ -1429,50 +1440,50 @@
 	      int new_error_line = -1;
 	      int new_error_column = -1;
 
-	      if (!error_state && new_err.contains("message"))
+	      if (! error_state && new_err.contains ("message"))
 		{
 		  const std::string tmp = 
-		    new_err.contents("message")(0).string_value();
+		    new_err.contents("message")(0).string_value ();
 		  new_error_message = tmp;
 		}
 
-	      if (!error_state && new_err.contains("identifier"))
+	      if (! error_state && new_err.contains ("identifier"))
 		{
 		  const std::string tmp = 
-		    new_err.contents("identifier")(0).string_value();
+		    new_err.contents("identifier")(0).string_value ();
 		  new_error_id = tmp;
 		}
 
-	      if (!error_state && new_err.contains("stack"))
+	      if (! error_state && new_err.contains ("stack"))
 		{
 		  Octave_map new_err_stack = 
-		    new_err.contents("identifier")(0).map_value();
+		    new_err.contents("identifier")(0).map_value ();
 
-		  if (!error_state && new_err_stack.contains("file"))
+		  if (! error_state && new_err_stack.contains ("file"))
 		    {
 		      const std::string tmp = 
-			new_err_stack.contents("file")(0).string_value();
+			new_err_stack.contents("file")(0).string_value ();
 		      new_error_file = tmp;
 		    }
 
-		  if (!error_state && new_err_stack.contains("name"))
+		  if (! error_state && new_err_stack.contains ("name"))
 		    {
 		      const std::string tmp = 
-			new_err_stack.contents("name")(0).string_value();
+			new_err_stack.contents("name")(0).string_value ();
 		      new_error_name = tmp;
 		    }
 
-		  if (!error_state && new_err_stack.contains("line"))
+		  if (! error_state && new_err_stack.contains ("line"))
 		    {
 		      const int tmp = 
-			new_err_stack.contents("line")(0).nint_value();
+			new_err_stack.contents("line")(0).nint_value ();
 		      new_error_line = tmp;
 		    }
 		  
-		  if (!error_state && new_err_stack.contains("column"))
+		  if (! error_state && new_err_stack.contains ("column"))
 		    {
 		      const int tmp = 
-			new_err_stack.contents("column")(0).nint_value();
+			new_err_stack.contents("column")(0).nint_value ();
 		      new_error_column = tmp;
 		    }
 		}
@@ -1491,7 +1502,7 @@
 	    error ("lasterror: argument must be a structure or a string");
 	}
 
-      if (!error_state)
+      if (! error_state)
 	retval = err;
     }
   else
--- a/src/file-io.cc	Wed Apr 04 02:37:07 2007 +0000
+++ b/src/file-io.cc	Wed Apr 04 02:58:48 2007 +0000
@@ -2028,7 +2028,7 @@
 }
 
 static octave_value
-const_value (const char *nm, const octave_value_list& args, int val)
+const_value (const char *, const octave_value_list& args, int val)
 {
   octave_value retval;
 
@@ -2109,7 +2109,7 @@
 }
 
 static octave_value
-const_value (const char *nm, const octave_value_list& args,
+const_value (const char *, const octave_value_list& args,
 	     const octave_value& val)
 {
   octave_value retval;
--- a/src/oct-stream.cc	Wed Apr 04 02:37:07 2007 +0000
+++ b/src/oct-stream.cc	Wed Apr 04 02:58:48 2007 +0000
@@ -1256,48 +1256,49 @@
 			int c3 = is.get ();
 
 			if (c3 != EOF)
-
-			  if (c3 == 'f')
-			    {
-			      int c4 = is.get ();
-
-			      if (c4 != EOF)
-				{
-				  is.putback (c4);
-
-				  if (isspace (c4) || ispunct (c4))
+			  {
+			    if (c3 == 'f')
+			      {
+				int c4 = is.get ();
+
+				if (c4 != EOF)
+				  {
+				    is.putback (c4);
+
+				    if (isspace (c4) || ispunct (c4))
+				      ref = octave_Inf;
+				    else
+				      {
+					is.putback (c3);
+					is.putback (c2);
+					is.putback (c1);
+
+					is >> ref;
+				      }
+				  }
+				else
+				  {
+				    is.clear ();
+
 				    ref = octave_Inf;
-				  else
-				    {
-				      is.putback (c3);
-				      is.putback (c2);
-				      is.putback (c1);
-
-				      is >> ref;
-				    }
-				}
-			      else
-				{
-				  is.clear ();
-
-				  ref = octave_Inf;
-				}
-			    }
-			  else
-			    {
-			      is.putback (c3);
-			      is.putback (c2);
-			      is.putback (c1);
-
-			      is >> ref;
-			    }
-		      }
-		    else
-		      {
-			is.putback (c2);
-			is.putback (c1);
-
-			is >> ref;
+				  }
+			      }
+			    else
+			      {
+				is.putback (c3);
+				is.putback (c2);
+				is.putback (c1);
+
+				is >> ref;
+			      }
+			}
+		      else
+			{
+			  is.putback (c2);
+			  is.putback (c1);
+
+			  is >> ref;
+			}
 		      }
 		  }
 	      }
--- a/src/pt-assign.cc	Wed Apr 04 02:37:07 2007 +0000
+++ b/src/pt-assign.cc	Wed Apr 04 02:58:48 2007 +0000
@@ -306,10 +306,10 @@
 {
   for (tree_argument_list::iterator p = lhs->begin (); p != lhs->end (); p++)
     {
-      tree_expression *lhs = *p;
+      tree_expression *lhs_expr = *p;
 
-      if (lhs)
-	maybe_warn_former_built_in_variable (lhs->name ());
+      if (lhs_expr)
+	maybe_warn_former_built_in_variable (lhs_expr->name ());
     }
 }