# HG changeset patch # User Rik # Date 1383067719 25200 # Node ID 224e76250443553a6e11dada44fdb1212c987711 # Parent 86c6ae5f969ee6eaae7fd47b4964f5202c36d8b7 Use GNU style coding conventions for code in examples/ * examples/embedded.cc, examples/fortdemo.cc, examples/helloworld.cc, examples/make_int.cc, examples/mycell.c, examples/myfeval.c, examples/myfunc.c, examples/mypow2.c, examples/myprop.c, examples/myset.c, examples/mystring.c, examples/mystruct.c, examples/oct_demo.cc, examples/oregonator.cc: Use GNU style coding conventions for code in examples/ diff -r 86c6ae5f969e -r 224e76250443 examples/embedded.cc --- a/examples/embedded.cc Tue Oct 29 09:54:40 2013 -0700 +++ b/examples/embedded.cc Tue Oct 29 10:28:39 2013 -0700 @@ -16,20 +16,20 @@ octave_idx_type n = 2; octave_value_list in; - for (octave_idx_type i = 0; i < n; i++) + for (octave_idx_type i = 0; i < n; i++) in(i) = octave_value (5 * (i + 2)); - + octave_value_list out = feval ("gcd", in, 1); - if (!error_state && out.length () > 0) - std::cout << "GCD of [" - << in(0).int_value () - << ", " + if (! error_state && out.length () > 0) + std::cout << "GCD of [" + << in(0).int_value () + << ", " << in(1).int_value () - << "] is " << out(0).int_value () + << "] is " << out(0).int_value () << std::endl; else std::cout << "invalid\n"; - + clean_up_and_exit (0); } diff -r 86c6ae5f969e -r 224e76250443 examples/fortdemo.cc --- a/examples/fortdemo.cc Tue Oct 29 09:54:40 2013 -0700 +++ b/examples/fortdemo.cc Tue Oct 29 10:28:39 2013 -0700 @@ -5,8 +5,7 @@ { F77_RET_T F77_FUNC (fortsub, FORTSUB) - (const int&, double*, F77_CHAR_ARG_DECL - F77_CHAR_ARG_LEN_DECL); + (const int&, double*, F77_CHAR_ARG_DECL F77_CHAR_ARG_LEN_DECL); } DEFUN_DLD (fortdemo, args, , "Fortran Demo") @@ -25,8 +24,8 @@ octave_idx_type na = a.numel (); OCTAVE_LOCAL_BUFFER (char, ctmp, 128); - F77_XFCN (fortsub, FORTSUB, (na, av, ctmp - F77_CHAR_ARG_LEN (128))); + F77_XFCN (fortsub, FORTSUB, + (na, av, ctmp F77_CHAR_ARG_LEN (128))); retval(1) = std::string (ctmp); retval(0) = a; diff -r 86c6ae5f969e -r 224e76250443 examples/helloworld.cc --- a/examples/helloworld.cc Tue Oct 29 09:54:40 2013 -0700 +++ b/examples/helloworld.cc Tue Oct 29 10:28:39 2013 -0700 @@ -1,7 +1,7 @@ #include DEFUN_DLD (helloworld, args, nargout, - "Hello World Help String") + "Hello World Help String") { int nargin = args.length (); diff -r 86c6ae5f969e -r 224e76250443 examples/make_int.cc --- a/examples/make_int.cc Tue Oct 29 09:54:40 2013 -0700 +++ b/examples/make_int.cc Tue Oct 29 10:28:39 2013 -0700 @@ -72,10 +72,10 @@ bool is_numeric_type (void) const { return true; } bool valid_as_scalar_index (void) const - { return scalar == 1; } + { return scalar == 1; } bool valid_as_zero_index (void) const - { return scalar == 0; } + { return scalar == 0; } bool is_true (void) const { return (scalar != 0); } @@ -88,7 +88,7 @@ Complex complex_value (bool = false) const { return scalar; } ComplexMatrix complex_matrix_value (bool = false) const - { return ComplexMatrix (1, 1, Complex (scalar)); } + { return ComplexMatrix (1, 1, Complex (scalar)); } octave_value gnot (void) const { return octave_value ((double) ! scalar); } @@ -231,7 +231,7 @@ DEFBINOP_OP (el_or, integer, integer, ||) DEFUN_DLD (make_int, args, , - "int_val = make_int (val)\n\ + "int_val = make_int (val)\n\ \n\ Creates an integer variable from VAL.") { @@ -243,7 +243,7 @@ mlock (); octave_stdout << "installing integer type at type-id = " - << octave_integer::static_type_id () << "\n"; + << octave_integer::static_type_id () << "\n"; INSTALL_UNOP (op_not, octave_integer, gnot); INSTALL_UNOP (op_uminus, octave_integer, uminus); @@ -289,7 +289,7 @@ } DEFUN_DLD (doit, args, , - "doit (I)") + "doit (I)") { octave_value_list retval; diff -r 86c6ae5f969e -r 224e76250443 examples/mycell.c --- a/examples/mycell.c Tue Oct 29 09:54:40 2013 -0700 +++ b/examples/mycell.c Tue Oct 29 10:28:39 2013 -0700 @@ -12,7 +12,7 @@ n = mxGetNumberOfElements (prhs[0]); n = (n > nlhs ? nlhs : n); - + for (i = 0; i < n; i++) plhs[i] = mxDuplicateArray (mxGetCell (prhs[0], i)); } diff -r 86c6ae5f969e -r 224e76250443 examples/myfeval.c --- a/examples/myfeval.c Tue Oct 29 09:54:40 2013 -0700 +++ b/examples/myfeval.c Tue Oct 29 10:28:39 2013 -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 || ! mxIsString (prhs[0])) mexErrMsgTxt ("ARG1 must be a function name"); str = mxArrayToString (prhs[0]); diff -r 86c6ae5f969e -r 224e76250443 examples/myfunc.c --- a/examples/myfunc.c Tue Oct 29 09:54:40 2013 -0700 +++ b/examples/myfunc.c Tue Oct 29 10:28:39 2013 -0700 @@ -11,5 +11,5 @@ if (strcmp (nm, "myfunc") == 0) mexPrintf ("This is the principal function\n", nm); - return; + return; } diff -r 86c6ae5f969e -r 224e76250443 examples/mypow2.c --- a/examples/mypow2.c Tue Oct 29 09:54:40 2013 -0700 +++ b/examples/mypow2.c Tue Oct 29 10:28:39 2013 -0700 @@ -7,14 +7,15 @@ mwSize n; mwIndex i; double *vri, *vro; - + if (nrhs != 1 || ! mxIsNumeric (prhs[0])) mexErrMsgTxt ("ARG1 must be a matrix"); n = mxGetNumberOfElements (prhs[0]); - plhs[0] = mxCreateNumericArray - (mxGetNumberOfDimensions (prhs[0]), mxGetDimensions (prhs[0]), - mxGetClassID (prhs[0]), mxIsComplex (prhs[0])); + plhs[0] = mxCreateNumericArray (mxGetNumberOfDimensions (prhs[0]), + mxGetDimensions (prhs[0]), + mxGetClassID (prhs[0]), + mxIsComplex (prhs[0])); vri = mxGetPr (prhs[0]); vro = mxGetPr (plhs[0]); diff -r 86c6ae5f969e -r 224e76250443 examples/myprop.c --- a/examples/myprop.c Tue Oct 29 09:54:40 2013 -0700 +++ b/examples/myprop.c Tue Oct 29 10:28:39 2013 -0700 @@ -13,11 +13,11 @@ mexErrMsgTxt ("handle expected to be a double scalar"); if (!mxIsChar (prhs[1])) mexErrMsgTxt ("expected property to be a string"); - + handle = mxGetScalar (prhs[0]); mxGetString (prhs[1], property, 256); plhs[0] = mxDuplicateArray (mexGet (handle, property)); - + if (nrhs == 3) if (mexSet (handle, property, mxDuplicateArray (prhs[2]))) mexErrMsgTxt ("failed to set property"); diff -r 86c6ae5f969e -r 224e76250443 examples/myset.c --- a/examples/myset.c Tue Oct 29 09:54:40 2013 -0700 +++ b/examples/myset.c Tue Oct 29 10:28:39 2013 -0700 @@ -29,6 +29,6 @@ } // WARNING!! Can't do this in MATLAB! Must copy variable first. - mxSetName (prhs[1], str); + mxSetName (prhs[1], str); mexPutArray (prhs[1], "caller"); } diff -r 86c6ae5f969e -r 224e76250443 examples/mystring.c --- a/examples/mystring.c Tue Oct 29 09:54:40 2013 -0700 +++ b/examples/mystring.c Tue Oct 29 10:28:39 2013 -0700 @@ -9,8 +9,8 @@ mwIndex i, j; mxChar *pi, *po; - if (nrhs != 1 || ! mxIsChar (prhs[0]) || - mxGetNumberOfDimensions (prhs[0]) > 2) + if (nrhs != 1 || ! mxIsChar (prhs[0]) + || mxGetNumberOfDimensions (prhs[0]) > 2) mexErrMsgTxt ("ARG1 must be a char matrix"); m = mxGetM (prhs[0]); diff -r 86c6ae5f969e -r 224e76250443 examples/mystruct.c --- a/examples/mystruct.c Tue Oct 29 09:54:40 2013 -0700 +++ b/examples/mystruct.c Tue Oct 29 10:28:39 2013 -0700 @@ -15,8 +15,7 @@ for (i = 0; i < mxGetNumberOfFields (prhs[0]); i++) for (j = 0; j < mxGetNumberOfElements (prhs[0]); j++) { - mexPrintf ("field %s(%d) = ", - mxGetFieldNameByNumber (prhs[0], i), j); + mexPrintf ("field %s(%d) = ", mxGetFieldNameByNumber (prhs[0], i), j); v = mxGetFieldByNumber (prhs[0], j, i); mexCallMATLAB (0, NULL, 1, &v, "disp"); } diff -r 86c6ae5f969e -r 224e76250443 examples/oct_demo.cc --- a/examples/oct_demo.cc Tue Oct 29 09:54:40 2013 -0700 +++ b/examples/oct_demo.cc Tue Oct 29 10:28:39 2013 -0700 @@ -51,7 +51,7 @@ // from gcc about an unused function parameter. DEFUN_DLD (oct_demo, args, , - "[...] = oct_demo (...)\n\ + "[...] = oct_demo (...)\n\ \n\ Print a greeting followed by the values of all the arguments passed.\n\ Return all arguments in reverse order.") diff -r 86c6ae5f969e -r 224e76250443 examples/oregonator.cc --- a/examples/oregonator.cc Tue Oct 29 09:54:40 2013 -0700 +++ b/examples/oregonator.cc Tue Oct 29 10:28:39 2013 -0700 @@ -1,7 +1,7 @@ #include DEFUN_DLD (oregonator, args, , - "The `oregonator'.\n\ + "The `oregonator'.\n\ \n\ Reference:\n\ \n\