Mercurial > octave-nkf
comparison libinterp/corefcn/strfns.cc @ 18099:6a71e5030df5
Follow coding convention of defining and initializing only 1 variable per line in liboctinterp.
* libinterp/corefcn/balance.cc, libinterp/corefcn/bsxfun.cc,
libinterp/corefcn/cellfun.cc, libinterp/corefcn/data.cc,
libinterp/corefcn/dlmread.cc, libinterp/corefcn/dot.cc,
libinterp/corefcn/eig.cc, libinterp/corefcn/find.cc, libinterp/corefcn/gcd.cc,
libinterp/corefcn/gl-render.cc, libinterp/corefcn/gl2ps-renderer.cc,
libinterp/corefcn/graphics.cc, libinterp/corefcn/kron.cc,
libinterp/corefcn/load-save.cc, libinterp/corefcn/lookup.cc,
libinterp/corefcn/ls-hdf5.cc, libinterp/corefcn/ls-mat5.cc,
libinterp/corefcn/lu.cc, libinterp/corefcn/max.cc,
libinterp/corefcn/oct-map.cc, libinterp/corefcn/oct-obj.cc,
libinterp/corefcn/oct-stream.cc, libinterp/corefcn/sparse.cc,
libinterp/corefcn/sqrtm.cc, libinterp/corefcn/str2double.cc,
libinterp/corefcn/strfind.cc, libinterp/corefcn/strfns.cc,
libinterp/corefcn/tril.cc, libinterp/corefcn/txt-eng-ft.cc,
libinterp/corefcn/variables.cc, libinterp/corefcn/xdiv.cc,
libinterp/dldfcn/__delaunayn__.cc, libinterp/dldfcn/qr.cc,
libinterp/dldfcn/symrcm.cc, libinterp/dldfcn/tsearch.cc,
libinterp/octave-value/ov-base-diag.cc, libinterp/octave-value/ov-base-int.cc,
libinterp/octave-value/ov-base-mat.cc, libinterp/octave-value/ov-bool-mat.cc,
libinterp/octave-value/ov-bool-sparse.cc, libinterp/octave-value/ov-bool.cc,
libinterp/octave-value/ov-cell.cc, libinterp/octave-value/ov-class.cc,
libinterp/octave-value/ov-complex.cc, libinterp/octave-value/ov-cx-diag.cc,
libinterp/octave-value/ov-cx-mat.cc, libinterp/octave-value/ov-cx-sparse.cc,
libinterp/octave-value/ov-fcn-handle.cc,
libinterp/octave-value/ov-fcn-inline.cc, libinterp/octave-value/ov-float.cc,
libinterp/octave-value/ov-flt-complex.cc,
libinterp/octave-value/ov-flt-cx-diag.cc,
libinterp/octave-value/ov-flt-cx-mat.cc,
libinterp/octave-value/ov-flt-re-diag.cc,
libinterp/octave-value/ov-flt-re-mat.cc, libinterp/octave-value/ov-java.cc,
libinterp/octave-value/ov-range.cc, libinterp/octave-value/ov-re-diag.cc,
libinterp/octave-value/ov-re-mat.cc, libinterp/octave-value/ov-re-sparse.cc,
libinterp/octave-value/ov-scalar.cc, libinterp/octave-value/ov-str-mat.cc,
libinterp/octave-value/ov-usr-fcn.cc, libinterp/parse-tree/pt-cbinop.cc,
libinterp/parse-tree/pt-eval.cc, libinterp/parse-tree/pt-mat.cc:
Follow coding convention of defining and initializing only 1 variable per line
in liboctinterp.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 05 Dec 2013 10:50:17 -0800 |
parents | 175b392e91fe |
children | b560bac0fca2 |
comparison
equal
deleted
inserted
replaced
18098:6c706a83070f | 18099:6a71e5030df5 |
---|---|
645 // Apparently, Matlab ignores the dims with strncmp. It also | 645 // Apparently, Matlab ignores the dims with strncmp. It also |
646 static bool | 646 static bool |
647 strncmp_array_op (const charNDArray& s1, const charNDArray& s2, | 647 strncmp_array_op (const charNDArray& s1, const charNDArray& s2, |
648 octave_idx_type n) | 648 octave_idx_type n) |
649 { | 649 { |
650 octave_idx_type l1 = s1.numel (), l2 = s2.numel (); | 650 octave_idx_type l1 = s1.numel (); |
651 octave_idx_type l2 = s2.numel (); | |
651 return (n > 0 && n <= l1 && n <= l2 | 652 return (n > 0 && n <= l1 && n <= l2 |
652 && std::equal (s1.data (), s1.data () + n, s2.data ())); | 653 && std::equal (s1.data (), s1.data () + n, s2.data ())); |
653 } | 654 } |
654 | 655 |
655 // Otherwise, just use strings. Note that we neither extract substrings (which | 656 // Otherwise, just use strings. Note that we neither extract substrings (which |
656 // would mean a copy, at least in GCC), nor use string::compare (which is a | 657 // would mean a copy, at least in GCC), nor use string::compare (which is a |
657 // 3-way compare). | 658 // 3-way compare). |
658 static bool | 659 static bool |
659 strncmp_str_op (const std::string& s1, const std::string& s2, octave_idx_type n) | 660 strncmp_str_op (const std::string& s1, const std::string& s2, octave_idx_type n) |
660 { | 661 { |
661 octave_idx_type l1 = s1.length (), l2 = s2.length (); | 662 octave_idx_type l1 = s1.length (); |
663 octave_idx_type l2 = s2.length (); | |
662 return (n > 0 && n <= l1 && n <= l2 | 664 return (n > 0 && n <= l1 && n <= l2 |
663 && std::equal (s1.data (), s1.data () + n, s2.data ())); | 665 && std::equal (s1.data (), s1.data () + n, s2.data ())); |
664 } | 666 } |
665 | 667 |
666 DEFUN (strncmp, args, , | 668 DEFUN (strncmp, args, , |
797 // Like strncmp. | 799 // Like strncmp. |
798 static bool | 800 static bool |
799 strncmpi_array_op (const charNDArray& s1, const charNDArray& s2, | 801 strncmpi_array_op (const charNDArray& s1, const charNDArray& s2, |
800 octave_idx_type n) | 802 octave_idx_type n) |
801 { | 803 { |
802 octave_idx_type l1 = s1.numel (), l2 = s2.numel (); | 804 octave_idx_type l1 = s1.numel (); |
805 octave_idx_type l2 = s2.numel (); | |
803 return (n > 0 && n <= l1 && n <= l2 | 806 return (n > 0 && n <= l1 && n <= l2 |
804 && std::equal (s1.data (), s1.data () + n, s2.data (), | 807 && std::equal (s1.data (), s1.data () + n, s2.data (), |
805 icmp_char_eq ())); | 808 icmp_char_eq ())); |
806 } | 809 } |
807 | 810 |
808 // Ditto. | 811 // Ditto. |
809 static bool | 812 static bool |
810 strncmpi_str_op (const std::string& s1, const std::string& s2, | 813 strncmpi_str_op (const std::string& s1, const std::string& s2, |
811 octave_idx_type n) | 814 octave_idx_type n) |
812 { | 815 { |
813 octave_idx_type l1 = s1.length (), l2 = s2.length (); | 816 octave_idx_type l1 = s1.length (); |
817 octave_idx_type l2 = s2.length (); | |
814 return (n > 0 && n <= l1 && n <= l2 | 818 return (n > 0 && n <= l1 && n <= l2 |
815 && std::equal (s1.data (), s1.data () + n, s2.data (), | 819 && std::equal (s1.data (), s1.data () + n, s2.data (), |
816 icmp_char_eq ())); | 820 icmp_char_eq ())); |
817 } | 821 } |
818 | 822 |