# HG changeset patch # User Rik # Date 1435114859 25200 # Node ID 140ce5e857bfc484c2e4a212f2ee6e37cf842522 # Parent c2206fda3986c552a41b62e9e53d7e54c9258199# Parent b8c1b3e9aa91d4070848a4212971b063e3334e9e maint: Periodic merge of stable to default. diff -r c2206fda3986 -r 140ce5e857bf examples/code/myfeval.c --- a/examples/code/myfeval.c Mon Jun 22 16:40:39 2015 -0700 +++ b/examples/code/myfeval.c Tue Jun 23 20:00:59 2015 -0700 @@ -10,7 +10,7 @@ mexPrintf ("I have %d inputs and %d outputs\n", nrhs, nlhs); - if (nrhs < 1 || ! mxIsString (prhs[0])) + if (nrhs < 1 || ! mxIsChar (prhs[0])) mexErrMsgTxt ("ARG1 must be a function name"); str = mxArrayToString (prhs[0]); diff -r c2206fda3986 -r 140ce5e857bf examples/code/mypow2.c --- a/examples/code/mypow2.c Mon Jun 22 16:40:39 2015 -0700 +++ b/examples/code/mypow2.c Tue Jun 23 20:00:59 2015 -0700 @@ -8,8 +8,8 @@ mwIndex i; double *vri, *vro; - if (nrhs != 1 || ! mxIsNumeric (prhs[0])) - mexErrMsgTxt ("ARG1 must be a matrix"); + if (nrhs != 1 || ! mxIsDouble (prhs[0])) + mexErrMsgTxt ("ARG1 must be a double matrix"); n = mxGetNumberOfElements (prhs[0]); plhs[0] = mxCreateNumericArray (mxGetNumberOfDimensions (prhs[0]), diff -r c2206fda3986 -r 140ce5e857bf examples/code/myprop.c --- a/examples/code/myprop.c Mon Jun 22 16:40:39 2015 -0700 +++ b/examples/code/myprop.c Tue Jun 23 20:00:59 2015 -0700 @@ -9,10 +9,10 @@ if (nrhs < 2 || nrhs > 3) mexErrMsgTxt ("incorrect number of arguments"); - if (!mxIsDouble (prhs[0])) - mexErrMsgTxt ("handle expected to be a double scalar"); - if (!mxIsChar (prhs[1])) - mexErrMsgTxt ("expected property to be a string"); + if (! mxIsDouble (prhs[0])) + mexErrMsgTxt ("handle must be a double scalar"); + if (! mxIsChar (prhs[1])) + mexErrMsgTxt ("property must be a string"); handle = mxGetScalar (prhs[0]); mxGetString (prhs[1], property, 256); diff -r c2206fda3986 -r 140ce5e857bf examples/code/myset.c --- a/examples/code/myset.c Mon Jun 22 16:40:39 2015 -0700 +++ b/examples/code/myset.c Tue Jun 23 20:00:59 2015 -0700 @@ -6,29 +6,32 @@ { char *str; mxArray *v; + int found = 0; - if (nrhs != 2 || ! mxIsString (prhs[0])) - mexErrMsgTxt ("expects symbol name and value"); + if (nrhs != 2 || ! mxIsChar (prhs[0])) + mexErrMsgTxt ("Arguments must be a symbol name and a value"); str = mxArrayToString (prhs[0]); + // FIXME: If variable does not exist, error is reported which prevents + // subsequent mexGetArray function from working. v = mexGetArray (str, "global"); - if (v) { mexPrintf ("%s is a global variable with the following value:\n", str); mexCallMATLAB (0, NULL, 1, &v, "disp"); + found = 1; } - v = mexGetArray (str, "caller"); + if (! found) + v = mexGetArray (str, "caller"); - if (v) + if (! found && v) { mexPrintf ("%s is a caller variable with the following value:\n", str); mexCallMATLAB (0, NULL, 1, &v, "disp"); } // WARNING!! Can't do this in MATLAB! Must copy variable first. - mxSetName (prhs[1], str); - mexPutArray (prhs[1], "caller"); + mexPutVariable ("caller", str, prhs[1]); } diff -r c2206fda3986 -r 140ce5e857bf examples/code/mystruct.c --- a/examples/code/mystruct.c Mon Jun 22 16:40:39 2015 -0700 +++ b/examples/code/mystruct.c Tue Jun 23 20:00:59 2015 -0700 @@ -10,7 +10,7 @@ const char *keys[] = { "this", "that" }; if (nrhs != 1 || ! mxIsStruct (prhs[0])) - mexErrMsgTxt ("expects struct"); + mexErrMsgTxt ("ARG1 must be a struct"); for (i = 0; i < mxGetNumberOfFields (prhs[0]); i++) for (j = 0; j < mxGetNumberOfElements (prhs[0]); j++) diff -r c2206fda3986 -r 140ce5e857bf libgui/graphics/GLCanvas.cc --- a/libgui/graphics/GLCanvas.cc Mon Jun 22 16:40:39 2015 -0700 +++ b/libgui/graphics/GLCanvas.cc Tue Jun 23 20:00:59 2015 -0700 @@ -46,6 +46,7 @@ #endif { setFocusPolicy (Qt::ClickFocus); + setFocus(); } GLCanvas::~GLCanvas (void) diff -r c2206fda3986 -r 140ce5e857bf libgui/graphics/gl-select.cc --- a/libgui/graphics/gl-select.cc Mon Jun 22 16:40:39 2015 -0700 +++ b/libgui/graphics/gl-select.cc Tue Jun 23 20:00:59 2015 -0700 @@ -206,11 +206,11 @@ opengl_selector::draw_image (const image::properties& props) { Matrix xd = props.get_xdata ().matrix_value (); - octave_idx_type nc = props.get_cdata ().matrix_value ().columns (); + octave_idx_type nc = props.get_cdata ().columns (); double x_pix_size = (xd(1) - xd(0)) / (nc - 1); Matrix yd = props.get_ydata ().matrix_value (); - octave_idx_type nr = props.get_cdata ().matrix_value ().rows (); + octave_idx_type nr = props.get_cdata ().rows (); double y_pix_size = (yd(1) - yd(0)) / (nr - 1); ColumnVector p1(3, 0.0), p2(3, 0.0), p3(3, 0.0), p4(3, 0.0); diff -r c2206fda3986 -r 140ce5e857bf libgui/src/octave-gui.cc --- a/libgui/src/octave-gui.cc Mon Jun 22 16:40:39 2015 -0700 +++ b/libgui/src/octave-gui.cc Tue Jun 23 20:00:59 2015 -0700 @@ -123,14 +123,13 @@ #endif // show wizard if this is the first run - if (resource_manager::is_first_run ()) + if (resource_manager::is_first_run () && start_gui) { // before wizard resource_manager::config_translators (&qt_tr, &qsci_tr, &gui_tr); application.installTranslator (&qt_tr); application.installTranslator (&gui_tr); - if (start_gui) - application.installTranslator (&qsci_tr); + application.installTranslator (&qsci_tr); welcome_wizard welcomeWizard; diff -r c2206fda3986 -r 140ce5e857bf libinterp/corefcn/graphics.in.h --- a/libinterp/corefcn/graphics.in.h Mon Jun 22 16:40:39 2015 -0700 +++ b/libinterp/corefcn/graphics.in.h Tue Jun 23 20:00:59 2015 -0700 @@ -1461,6 +1461,7 @@ { size_constraints.remove (dim_vector (1, -1)); size_constraints.remove (dim_vector (-1, 1)); + size_constraints.remove (dim_vector (0, 0)); add_constraint (dim_vector (1, len)); add_constraint (dim_vector (len, 1)); @@ -4742,7 +4743,9 @@ void init (void) { xdata.add_constraint (2); + xdata.add_constraint (dim_vector (0, 0)); ydata.add_constraint (2); + ydata.add_constraint (dim_vector (0, 0)); cdata.add_constraint ("double"); cdata.add_constraint ("single"); cdata.add_constraint ("logical"); diff -r c2206fda3986 -r 140ce5e857bf libinterp/corefcn/mex.cc --- a/libinterp/corefcn/mex.cc Mon Jun 22 16:40:39 2015 -0700 +++ b/libinterp/corefcn/mex.cc Tue Jun 23 20:00:59 2015 -0700 @@ -617,8 +617,8 @@ { if (ndims_arg < 2) { - dims[0] = 1; - dims[1] = 1; + dims[0] = 0; + dims[1] = 0; } for (mwIndex i = 0; i < ndims_arg; i++) diff -r c2206fda3986 -r 140ce5e857bf libinterp/corefcn/oct-hdf5.h --- a/libinterp/corefcn/oct-hdf5.h Mon Jun 22 16:40:39 2015 -0700 +++ b/libinterp/corefcn/oct-hdf5.h Tue Jun 23 20:00:59 2015 -0700 @@ -29,14 +29,12 @@ #include "oct-hdf5-types.h" -#define HDF5_SAVE_TYPE H5T_NATIVE_UINT8 #ifdef USE_64_BIT_IDX_T #define H5T_NATIVE_IDX H5T_NATIVE_INT64 #else #define H5T_NATIVE_IDX H5T_NATIVE_INT #endif - #endif #endif diff -r c2206fda3986 -r 140ce5e857bf libinterp/octave-value/ov-int16.cc --- a/libinterp/octave-value/ov-int16.cc Mon Jun 22 16:40:39 2015 -0700 +++ b/libinterp/octave-value/ov-int16.cc Tue Jun 23 20:00:59 2015 -0700 @@ -40,6 +40,10 @@ #include "ops.h" #include "ov-base.h" +#if defined (HAVE_HDF5) +#define HDF5_SAVE_TYPE H5T_NATIVE_INT16 +#endif + #include "ov-base-int.h" #include "ov-base-int.cc" #include "ov-int16.h" diff -r c2206fda3986 -r 140ce5e857bf libinterp/octave-value/ov-int32.cc --- a/libinterp/octave-value/ov-int32.cc Mon Jun 22 16:40:39 2015 -0700 +++ b/libinterp/octave-value/ov-int32.cc Tue Jun 23 20:00:59 2015 -0700 @@ -40,6 +40,10 @@ #include "ops.h" #include "ov-base.h" +#if defined (HAVE_HDF5) +#define HDF5_SAVE_TYPE H5T_NATIVE_INT32 +#endif + #include "ov-base-int.h" #include "ov-base-int.cc" #include "ov-int32.h" diff -r c2206fda3986 -r 140ce5e857bf libinterp/octave-value/ov-int64.cc --- a/libinterp/octave-value/ov-int64.cc Mon Jun 22 16:40:39 2015 -0700 +++ b/libinterp/octave-value/ov-int64.cc Tue Jun 23 20:00:59 2015 -0700 @@ -40,6 +40,10 @@ #include "ops.h" #include "ov-base.h" +#if defined (HAVE_HDF5) +#define HDF5_SAVE_TYPE H5T_NATIVE_INT64 +#endif + #include "ov-base-int.h" #include "ov-base-int.cc" #include "ov-int64.h" diff -r c2206fda3986 -r 140ce5e857bf libinterp/octave-value/ov-int8.cc --- a/libinterp/octave-value/ov-int8.cc Mon Jun 22 16:40:39 2015 -0700 +++ b/libinterp/octave-value/ov-int8.cc Tue Jun 23 20:00:59 2015 -0700 @@ -40,6 +40,10 @@ #include "ops.h" #include "ov-base.h" +#if defined (HAVE_HDF5) +#define HDF5_SAVE_TYPE H5T_NATIVE_INT8 +#endif + #include "ov-base-int.h" #include "ov-base-int.cc" #include "ov-int8.h" diff -r c2206fda3986 -r 140ce5e857bf libinterp/octave-value/ov-java.cc --- a/libinterp/octave-value/ov-java.cc Mon Jun 22 16:40:39 2015 -0700 +++ b/libinterp/octave-value/ov-java.cc Tue Jun 23 20:00:59 2015 -0700 @@ -1281,6 +1281,20 @@ jobj = jni_env->NewStringUTF (s.c_str ()); jcls = jni_env->GetObjectClass (jobj); } + else if (val.is_cellstr ()) + { + const Array str_arr = val.cellstr_value (); + const octave_idx_type n = str_arr.numel (); + jclass_ref scls (jni_env, jni_env->FindClass ("java/lang/String")); + jobjectArray array = jni_env->NewObjectArray (n, scls, NULL); + for (octave_idx_type i = 0; i < n; i++) + { + jstring_ref jstr (jni_env, jni_env->NewStringUTF (str_arr(i).c_str ())); + jni_env->SetObjectArrayElement (array, i, jstr); + } + jobj = array; + jcls = jni_env->GetObjectClass (jobj); + } else if (val.numel () > 1 && val.dims ().is_vector ()) { #define IF_UNBOX_PRIMITIVE_ARRAY(CHECK_TYPE, METHOD_TYPE, OCTAVE_TYPE, JAVA_TYPE, JAVA_TYPE_CAP) \ @@ -1414,20 +1428,6 @@ error ("cannot convert matrix of type '%s'", val.class_name ().c_str ()); } } - else if (val.is_cellstr ()) - { - Cell cellStr = val.cell_value (); - jclass_ref scls (jni_env, jni_env->FindClass ("java/lang/String")); - jobjectArray array = jni_env->NewObjectArray (cellStr.numel (), scls, 0); - for (int i = 0; i < cellStr.numel (); i++) - { - jstring_ref jstr (jni_env, - jni_env->NewStringUTF (cellStr(i).string_value().c_str ())); - jni_env->SetObjectArrayElement (array, i, jstr); - } - jobj = array; - jcls = jni_env->GetObjectClass (jobj); - } else { jclass rcls = find_octave_class (jni_env, "org/octave/OctaveReference"); @@ -2502,4 +2502,10 @@ %! assert (class (javaObject ("java.lang.Byte", int8 (1))), "java.lang.Byte"); %! assert (class (javaObject ("java.lang.Short", uint16 (1))), "java.lang.Short"); %! assert (class (javaObject ("java.lang.Short", int16 (1))), "java.lang.Short"); + +## Automatic conversion from string cell array into String[] (bug #45290) +%!testif HAVE_JAVA +%! assert (javaMethod ("binarySearch", "java.util.Arrays", {"aaa", "bbb", "ccc", "zzz"}, "aaa"), 0) +%! assert (javaMethod ("binarySearch", "java.util.Arrays", {"aaa", "bbb", "ccc", "zzz"}, "zzz"), 3) +%! assert (javaMethod ("binarySearch", "java.util.Arrays", {"aaa", "bbb", "ccc", "zzz"}, "hhh") < 0) */ diff -r c2206fda3986 -r 140ce5e857bf libinterp/octave-value/ov-uint16.cc --- a/libinterp/octave-value/ov-uint16.cc Mon Jun 22 16:40:39 2015 -0700 +++ b/libinterp/octave-value/ov-uint16.cc Tue Jun 23 20:00:59 2015 -0700 @@ -40,6 +40,10 @@ #include "ops.h" #include "ov-base.h" +#if defined (HAVE_HDF5) +#define HDF5_SAVE_TYPE H5T_NATIVE_UINT16 +#endif + #include "ov-base-int.h" #include "ov-base-int.cc" #include "ov-uint16.h" diff -r c2206fda3986 -r 140ce5e857bf libinterp/octave-value/ov-uint32.cc --- a/libinterp/octave-value/ov-uint32.cc Mon Jun 22 16:40:39 2015 -0700 +++ b/libinterp/octave-value/ov-uint32.cc Tue Jun 23 20:00:59 2015 -0700 @@ -40,6 +40,10 @@ #include "ops.h" #include "ov-base.h" +#if defined (HAVE_HDF5) +#define HDF5_SAVE_TYPE H5T_NATIVE_UINT32 +#endif + #include "ov-base-int.h" #include "ov-base-int.cc" #include "ov-uint32.h" diff -r c2206fda3986 -r 140ce5e857bf libinterp/octave-value/ov-uint64.cc --- a/libinterp/octave-value/ov-uint64.cc Mon Jun 22 16:40:39 2015 -0700 +++ b/libinterp/octave-value/ov-uint64.cc Tue Jun 23 20:00:59 2015 -0700 @@ -40,6 +40,10 @@ #include "ops.h" #include "ov-base.h" +#if defined (HAVE_HDF5) +#define HDF5_SAVE_TYPE H5T_NATIVE_UINT64 +#endif + #include "ov-base-int.h" #include "ov-base-int.cc" #include "ov-uint64.h" diff -r c2206fda3986 -r 140ce5e857bf libinterp/octave-value/ov-uint8.cc --- a/libinterp/octave-value/ov-uint8.cc Mon Jun 22 16:40:39 2015 -0700 +++ b/libinterp/octave-value/ov-uint8.cc Tue Jun 23 20:00:59 2015 -0700 @@ -40,6 +40,10 @@ #include "ops.h" #include "ov-base.h" +#if defined (HAVE_HDF5) +#define HDF5_SAVE_TYPE H5T_NATIVE_UINT8 +#endif + #include "ov-base-int.h" #include "ov-base-int.cc" #include "ov-uint8.h" diff -r c2206fda3986 -r 140ce5e857bf scripts/specfun/ellipke.m --- a/scripts/specfun/ellipke.m Mon Jun 22 16:40:39 2015 -0700 +++ b/scripts/specfun/ellipke.m Tue Jun 23 20:00:59 2015 -0700 @@ -94,7 +94,6 @@ endif sz = size (m); - m = m(:); if (! isreal (m)) error ("ellipke: M must be real"); elseif (any (m > 1)) @@ -127,8 +126,8 @@ mult_k = 1./sqrt (1 - m(idx_neg)); mult_e = sqrt (1 - m(idx_neg)); m(idx_neg) = -m(idx_neg) ./ (1 - m(idx_neg)); - a = ones (sum (idx), 1); b = sqrt (1 - m(idx)); + a = ones (size (b)); c = sqrt (m(idx)); f = 0.5; sum = f*c.^2; diff -r c2206fda3986 -r 140ce5e857bf test/io.tst --- a/test/io.tst Mon Jun 22 16:40:39 2015 -0700 +++ b/test/io.tst Tue Jun 23 20:00:59 2015 -0700 @@ -191,6 +191,35 @@ %! %! assert (save_status && load_status); +%!testif HAVE_HDF5 +%! +%! s8 = int8 (fix ((2^8 - 1) * (rand (2, 2) - 0.5))); +%! u8 = uint8 (fix ((2^8 - 1) * (rand (2, 2) - 0.5))); +%! s16 = int16 (fix ((2^16 - 1) * (rand (2, 2) - 0.5))); +%! u16 = uint16 (fix ((2^16 - 1) * (rand (2, 2) - 0.5))); +%! s32 = int32 (fix ((2^32 - 1) * (rand (2, 2) - 0.5))); +%! u32 = uint32 (fix ((2^32 - 1) * (rand (2, 2) - 0.5))); +%! s64 = int64 (fix ((2^64 - 1) * (rand (2, 2) - 0.5))); +%! u64 = uint64 (fix ((2^64 - 1) * (rand (2, 2) - 0.5))); +%! s8t = s8; u8t = u8; s16t = s16; u16t = u16; s32t = s32; u32t = u32; +%! s64t = s64; u64t = u64; +%! h5file = tempname (); +%! unwind_protect +%! eval (sprintf ("save -hdf5 %s %s", h5file, "s8 u8 s16 u16 s32 u32 s64 u64")); +%! clear s8 u8 s16 u16 s32 u32 s64 u64; +%! load (h5file); +%! assert (s8, s8t); +%! assert (u8, u8t); +%! assert (s16, s16t); +%! assert (u16, u16t); +%! assert (s32, s32t); +%! assert (u32, u32t); +%! assert (s64, s64t); +%! assert (u64, u64t); +%! unwind_protect_cleanup +%! unlink (h5file); +%! end_unwind_protect + %!test %! %! STR.scalar_fld = 1; @@ -639,3 +668,8 @@ %!assert (sprintf ("%c,%c,%c,%c", "abcd"), "a,b,c,d"); %!assert (sprintf ("%s,%s,%s,%s", "abcd"), "abcd,"); + +%!assert (sprintf ("|%x|", "Octave"), "|4f||63||74||61||76||65|"); +%!assert (sprintf ("|%X|", "Octave"), "|4F||63||74||61||76||65|"); +%!assert (sprintf ("|%o|", "Octave"), "|117||143||164||141||166||145|"); +