# HG changeset patch
# User jwe
# Date 856943537 0
# Node ID 76411ce43c05d5a4ed47986ec7897dd2341d285c
# Parent b1474687fb838b3d3fd381a29c97f640b390cc32
[project @ 1997-02-26 07:52:14 by jwe]
diff --git a/NEWS b/NEWS
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,11 @@
+Summary of changes for version 2.0.5:
+------------------------------------
+
+ * Commands like ls, save, and cd may now also be used as formal
+ parameters for functions.
+
+ * More tests.
+
Summary of changes for version 2.0.4:
------------------------------------
diff --git a/WWW/index.html b/WWW/index.html
--- a/WWW/index.html
+++ b/WWW/index.html
@@ -73,7 +73,7 @@
Contributed Functions
An archive of contributed functions for Octave is available from
-http://www.tsc.uvigo.es/GTS/Octave/oct_arch.html.
+http://www.tsc.uvigo.es/GTS/Octave.
diff --git a/doc/interpreter/eval.texi b/doc/interpreter/eval.texi
--- a/doc/interpreter/eval.texi
+++ b/doc/interpreter/eval.texi
@@ -66,13 +66,13 @@
by name, and use @code{feval} to call them.
@end deftypefn
-@cindex Fordyce, A. P.
-@findex newtroot
Here is a simple-minded function using @code{feval} that finds the root
of a user-supplied function of one variable using Newton's method.
@example
@group
+@cindex Fordyce, A. P.
+@findex newtroot
function result = newtroot (fname, x)
# usage: newtroot (fname, x)
diff --git a/doc/interpreter/set.texi b/doc/interpreter/set.texi
--- a/doc/interpreter/set.texi
+++ b/doc/interpreter/set.texi
@@ -27,8 +27,8 @@
@example
@group
-union ([ 1, 2, 3 ], [ 2, 3, 5 ])
- @result{} [ 1, 2, 5 ]
+union ([ 1, 2, 4 ], [ 2, 3, 5 ])
+ @result{} [ 1, 2, 3, 4, 5 ]
@end group
@end example
@end deftypefn
diff --git a/scripts/ChangeLog b/scripts/ChangeLog
--- a/scripts/ChangeLog
+++ b/scripts/ChangeLog
@@ -1,3 +1,11 @@
+Wed Feb 26 01:48:28 1997 John W. Eaton
+
+ * general/is_matrix.m: Return zero for empty matrices.
+
+Tue Feb 25 15:16:04 1997 John W. Eaton
+
+ * linear-algebra/vech.m: Size result just once.
+
Sun Feb 23 00:15:57 1997 John W. Eaton
* general/is_square.m: Handle empty matrices correctly.
diff --git a/scripts/general/is_matrix.m b/scripts/general/is_matrix.m
--- a/scripts/general/is_matrix.m
+++ b/scripts/general/is_matrix.m
@@ -29,7 +29,7 @@
if (nargin == 1)
[nr, nc] = size (x);
- retval = (nr >= 0 && nc >= 0);
+ retval = (nr > 0 && nc > 0);
else
usage ("is_matrix (x)");
endif
diff --git a/scripts/linear-algebra/vech.m b/scripts/linear-algebra/vech.m
--- a/scripts/linear-algebra/vech.m
+++ b/scripts/linear-algebra/vech.m
@@ -40,6 +40,7 @@
## This should be quicker than having an inner `for' loop as well.
## Ideally, vech should be written in C++.
n = rows (x);
+ v = zeros ((n+1)*n/2, 1);
count = 0;
for j = 1 : n
i = j : n;
diff --git a/scripts/special-matrix/hadamard.m b/scripts/special-matrix/hadamard.m
--- a/scripts/special-matrix/hadamard.m
+++ b/scripts/special-matrix/hadamard.m
@@ -31,11 +31,15 @@
usage ("hadamard (n)");
endif
- if (k < 1)
- retval = 1;
+ if (is_scalar (k))
+ if (k < 1)
+ retval = 1;
+ else
+ tmp = hadamard (k-1);
+ retval = [tmp, tmp; tmp, -tmp];
+ endif
else
- tmp = hadamard (k-1);
- retval = [tmp, tmp; tmp, -tmp];
+ error ("hadamard: expecting scalar argument");
endif
endfunction
diff --git a/src/ChangeLog b/src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,22 @@
+Tue Feb 25 22:21:05 1997 John W. Eaton
+
+ * time.cc (strftime): increase initial buffer size.
+
+Mon Feb 24 17:49:21 1997 John W. Eaton
+
+ * pt-fvc.cc (tree_builtin::eval): Enable checking for max number
+ of arguments.
+
+ * error.cc (handle_message): Don't fail if args is empty.
+
+Sun Feb 23 22:42:52 1997 John W. Eaton
+
+ * lex.h (lexical_feedback::looking_at_return_list): New field.
+ (lexical_feedback::looking_at_parameter_list): Ditto.
+ * lex.l (lexical_feedback::init): Initialize them.
+ (handle_identifier): Use them.
+ * parse.y: Likewise.
+
Fri Feb 21 15:35:18 1997 John W. Eaton
* lex.l: Require flex 2.5 or later (we really want 2.5.4 or later,
diff --git a/src/error.cc b/src/error.cc
--- a/src/error.cc
+++ b/src/error.cc
@@ -211,20 +211,23 @@
int nargin = args.length ();
- octave_value arg = ((nargin > 1) ? Fsprintf (args, 1) : args) (0);
-
- if (arg.is_defined ())
+ if (nargin > 0)
{
- if (arg.is_string ())
+ octave_value arg = ((nargin > 1) ? Fsprintf (args, 1) : args) (0);
+
+ if (arg.is_defined ())
{
- tstr = arg.string_value ();
- msg = tstr.c_str ();
-
- if (! msg)
+ if (arg.is_string ())
+ {
+ tstr = arg.string_value ();
+ msg = tstr.c_str ();
+
+ if (! msg)
+ return retval;
+ }
+ else if (arg.is_empty ())
return retval;
}
- else if (arg.is_empty ())
- return retval;
}
// Ugh.
diff --git a/src/lex.h b/src/lex.h
--- a/src/lex.h
+++ b/src/lex.h
@@ -137,6 +137,12 @@
// Nonzero means we're in the middle of defining a function.
int defining_func;
+ // Nonzero means we're parsing the return list for a function.
+ int looking_at_return_list;
+
+ // Nonzero means we're parsing the parameter list for a function.
+ int looking_at_parameter_list;
+
// GAG. Stupid kludge so that [[1,2][3,4]] will work.
int do_comma_insert;
diff --git a/src/lex.l b/src/lex.l
--- a/src/lex.l
+++ b/src/lex.l
@@ -1759,13 +1759,20 @@
// Kluge alert.
//
// If we are looking at a text style function, set up to gobble its
- // arguments. If the following token is `=', force the symbol to be
+ // arguments.
+ //
+ // If the following token is `=', or if we are parsing a function
+ // return list or function parameter list, force the symbol to be
// inserted as a variable in the current symbol table.
if (is_text_function_name (tok) && ! is_variable (tok))
{
- if (next_tok_is_eq)
- force_local_variable (tok);
+ if (next_tok_is_eq
+ || lexer_flags.looking_at_return_list
+ || lexer_flags.looking_at_parameter_list)
+ {
+ force_local_variable (tok);
+ }
else if (! next_tok_is_paren)
{
if (tok == "gset")
@@ -1877,6 +1884,10 @@
beginning_of_function = 0;
defining_func = 0;
+ // Not parsing a function return or parameter list.
+ looking_at_return_list = 0;
+ looking_at_parameter_list = 0;
+
// Not initially defining a matrix list.
braceflag = 0;
diff --git a/src/parse.y b/src/parse.y
--- a/src/parse.y
+++ b/src/parse.y
@@ -855,6 +855,10 @@
{ curr_sym_tab = global_sym_tab; }
;
+in_return_list : // empty
+ { lexer_flags.looking_at_return_list = 1; }
+ ;
+
local_symtab : // empty
{ curr_sym_tab = tmp_local_sym_tab; }
;
@@ -887,21 +891,29 @@
{ $$ = finish_function_def ($1, $4); }
;
-return_list_x : '[' safe local_symtab
+return_list_x : '[' safe local_symtab in_return_list
;
return_list : return_list_x ']'
- { $$ = new tree_parameter_list (); }
+ {
+ lexer_flags.looking_at_return_list = 0;
+ $$ = new tree_parameter_list ();
+ }
| return_list_x ELLIPSIS ']'
{
+ lexer_flags.looking_at_return_list = 0;
tree_parameter_list *tmp = new tree_parameter_list ();
tmp->mark_varargs_only ();
$$ = tmp;
}
| return_list1 ']'
- { $$ = $1; }
+ {
+ lexer_flags.looking_at_return_list = 0;
+ $$ = $1;
+ }
| return_list1 ',' ELLIPSIS ']'
{
+ lexer_flags.looking_at_return_list = 0;
$1->mark_varargs ();
$$ = $1;
}
@@ -981,6 +993,10 @@
}
;
+in_param_list : // empty
+ { lexer_flags.looking_at_parameter_list = 1; }
+ ;
+
param_list : '(' ')'
{
lexer_flags.quote_is_transpose = 0;
@@ -995,12 +1011,14 @@
}
| param_list1 ')'
{
+ lexer_flags.looking_at_parameter_list = 0;
lexer_flags.quote_is_transpose = 0;
$1->mark_as_formal_parameters ();
$$ = $1;
}
| param_list1 ',' ELLIPSIS ')'
{
+ lexer_flags.looking_at_parameter_list = 0;
lexer_flags.quote_is_transpose = 0;
$1->mark_as_formal_parameters ();
$1->mark_varargs ();
@@ -1008,8 +1026,8 @@
}
;
-param_list1 : '(' identifier
- { $$ = new tree_parameter_list ($2); }
+param_list1 : '(' in_param_list identifier
+ { $$ = new tree_parameter_list ($3); }
| param_list1 ',' identifier
{
$1->append ($3);
diff --git a/src/pt-fvc.cc b/src/pt-fvc.cc
--- a/src/pt-fvc.cc
+++ b/src/pt-fvc.cc
@@ -779,19 +779,19 @@
}
else if (is_mapper)
{
-// XXX FIXME XXX -- should we just assume nargin_max == 1?
-//
-// if (nargin > nargin_max)
-// ::error ("%s: too many arguments", my_name.c_str ());
-// else
- if (nargin > 0 && args(0).is_defined ())
- {
- octave_value tmp = apply_mapper_fcn (args(0), mapper_fcn, 0);
- retval(0) = tmp;
- }
+ if (nargin > 1)
+ ::error ("%s: too many arguments", my_name.c_str ());
+ else if (nargin < 1)
+ ::error ("%s: too few arguments", my_name.c_str ());
else
{
- ::error ("%s: too few arguments", my_name.c_str ());
+ if (args(0).is_defined ())
+ {
+ octave_value tmp = apply_mapper_fcn (args(0), mapper_fcn, 0);
+ retval(0) = tmp;
+ }
+ else
+ ::error ("%s: argument undefined", my_name.c_str ());
}
}
else
diff --git a/src/time.cc b/src/time.cc
--- a/src/time.cc
+++ b/src/time.cc
@@ -55,10 +55,8 @@
#if defined (HAVE_TM_ZONE)
m ["zone"] = tm->tm_zone;
#elif defined (HAVE_TZNAME)
- if (tm->tm_isdst && tzname[1] && *tzname[1])
- m ["zone"] = tzname[1];
- else
- m ["zone"] = tzname[0];
+ if (tm->tm_isdst == 0 || tm->tm_isdst == 1)
+ m ["zone"] = tzname[tm->tm_isdst];
#else
m ["zone"] = zone_name (tm);
#endif
@@ -285,7 +283,7 @@
if (! error_state)
{
- int bufsize = 128;
+ int bufsize = 1024;
char *buf = new char [bufsize];
while (! strftime (buf, bufsize, fmt.c_str (), tm))