annotate libinterp/corefcn/ls-utils.cc @ 27923:bd51beb6205e

update formatting of copyright notices * Use <https://octave.org/copyright/> instead of <https://octave.org/COPYRIGHT.html/>. * For consistency with other comments in the Octave sources, use C++-style comments for copyright blocks in C and C++ files. * Use delimiters above and below copyright blocks that are appropriate for the language used in the file. * Eliminate extra spacing inside copyright blocks. * lex.ll (looks_like_copyright): Also allow newlines and carriage returns before the word "Copyright". * scripts/mk-doc.pl (gethelp): Also skip empty comment lines. * bp-table.cc, type.m: Adjust tests.
author John W. Eaton <jwe@octave.org>
date Wed, 08 Jan 2020 11:59:41 -0500
parents 1891570abac8
children 0a5b15007766
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27923
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
1 ////////////////////////////////////////////////////////////////////////
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
2 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
3 // Copyright (C) 2003-2020 The Octave Project Developers
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
4 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
5 // See the file COPYRIGHT.md in the top-level directory of this
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
6 // distribution or <https://octave.org/copyright/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
7 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
8 // This file is part of Octave.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
9 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
10 // Octave is free software: you can redistribute it and/or modify it
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
11 // under the terms of the GNU General Public License as published by
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
12 // the Free Software Foundation, either version 3 of the License, or
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
13 // (at your option) any later version.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
14 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
15 // Octave is distributed in the hope that it will be useful, but
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
16 // WITHOUT ANY WARRANTY; without even the implied warranty of
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
18 // GNU General Public License for more details.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
19 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
20 // You should have received a copy of the GNU General Public License
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
21 // along with Octave; see the file COPYING. If not, see
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
22 // <https://www.gnu.org/licenses/>.
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
23 //
bd51beb6205e update formatting of copyright notices
John W. Eaton <jwe@octave.org>
parents: 27919
diff changeset
24 ////////////////////////////////////////////////////////////////////////
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
25
21724
aba2e6293dd8 use "#if ..." consistently instead of "#ifdef" and "#ifndef"
John W. Eaton <jwe@octave.org>
parents: 21301
diff changeset
26 #if defined (HAVE_CONFIG_H)
21301
40de9f8f23a6 Use '#include "config.h"' rather than <config.h>.
Rik <rik@octave.org>
parents: 21200
diff changeset
27 # include "config.h"
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
28 #endif
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
29
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
30 #include "data-conv.h"
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
31
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
32 #include "ls-utils.h"
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
33
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
34 // MAX_VAL and MIN_VAL are assumed to have integral values even though
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
35 // they are stored in doubles.
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
36
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
37 save_type
4661
12b6fbd57436 [project @ 2003-11-25 05:41:35 by jwe]
jwe
parents: 4634
diff changeset
38 get_save_type (double /* max_val */, double /* min_val */)
4634
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
39 {
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
40 save_type st = LS_DOUBLE;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
41
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
42 // Matlab doesn't seem to load the UINT32 type correctly, so let's
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
43 // avoid it (and the other unsigned types, even though they may not
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
44 // have the same problem. And apparently, there are problems with
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
45 // other smaller types as well. If we avoid them all, then maybe we
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
46 // will avoid problems. Unfortunately, we won't be able to save
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
47 // space...
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
48
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
49 // if (max_val < 256 && min_val > -1)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
50 // st = LS_U_CHAR;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
51 // else if (max_val < 65536 && min_val > -1)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
52 // st = LS_U_SHORT;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
53 // else if (max_val < 4294967295UL && min_val > -1)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
54 // st = LS_U_INT;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
55 // else if (max_val < 128 && min_val >= -128)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
56 // st = LS_CHAR;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
57 // else if (max_val < 32768 && min_val >= -32768)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
58 // st = LS_SHORT;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
59 // else if (max_val <= 2147483647L && min_val >= -2147483647L)
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
60 // st = LS_INT;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
61
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
62 return st;
79fe96966ca0 [project @ 2003-11-19 21:22:39 by jwe]
jwe
parents:
diff changeset
63 }
11468
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
64
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
65 save_type
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
66 get_save_type (float /* max_val */, float /* min_val */)
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
67 {
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
68 save_type st = LS_FLOAT;
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
69
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
70 // Matlab doesn't seem to load the UINT32 type correctly, so let's
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
71 // avoid it (and the other unsigned types, even though they may not
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
72 // have the same problem. And apparently, there are problems with
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
73 // other smaller types as well. If we avoid them all, then maybe we
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
74 // will avoid problems. Unfortunately, we won't be able to save
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
75 // space...
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
76
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
77 // if (max_val < 256 && min_val > -1)
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
78 // st = LS_U_CHAR;
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
79 // else if (max_val < 65536 && min_val > -1)
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
80 // st = LS_U_SHORT;
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
81 // else if (max_val < 4294967295UL && min_val > -1)
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
82 // st = LS_U_INT;
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
83 // else if (max_val < 128 && min_val >= -128)
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
84 // st = LS_CHAR;
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
85 // else if (max_val < 32768 && min_val >= -32768)
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
86 // st = LS_SHORT;
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
87 // else if (max_val <= 2147483647L && min_val >= -2147483647L)
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
88 // st = LS_INT;
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
89
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
90 return st;
e1edf0ba3bcb Yet another single precision matlab file fix
David Bateman <dbateman@free.fr>
parents: 10160
diff changeset
91 }