changeset 27058:f6e59ee37fee

Emit an error if localtime or gmtime is called with a non-scalar argument (bug #56190). * time.cc (Flocaltime, Fgmtime): Use numel() to check that argument to function only has one element. Otherwise, call print_usage().
author Rik <rik@octave.org>
date Mon, 22 Apr 2019 21:08:08 -0700
parents 986128cf1e07
children 2bf6dcb1563c
files libinterp/corefcn/time.cc
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/time.cc	Mon Apr 22 17:33:51 2019 -0700
+++ b/libinterp/corefcn/time.cc	Mon Apr 22 21:08:08 2019 -0700
@@ -156,7 +156,7 @@
 @seealso{strftime, strptime, localtime, mktime, time, now, date, clock, datenum, datestr, datevec, calendar, weekday}
 @end deftypefn */)
 {
-  if (args.length () != 1)
+  if (args.length () != 1 || args(0).numel () != 1)
     print_usage ();
 
   double tmp = args(0).double_value ();
@@ -211,7 +211,7 @@
 @seealso{strftime, strptime, gmtime, mktime, time, now, date, clock, datenum, datestr, datevec, calendar, weekday}
 @end deftypefn */)
 {
-  if (args.length () != 1)
+  if (args.length () != 1 || args(0).numel () != 1)
     print_usage ();
 
   double tmp = args(0).double_value ();