changelog shortlog tags changeset files revisions annotate raw

scripts/miscellaneous/computer.m

changeset 10289: 4b124317dc38
parent:a2d9f325b65a
author: John W. Eaton <jwe@octave.org>
date: Tue Feb 09 20:58:55 2010 -0500 (50 minutes ago)
permissions: -rw-r--r--
description: base_properties::set_children: account for hidden children
1## Copyright (C) 2004, 2005, 2007, 2008 John W. Eaton
2##
3## This file is part of Octave.
4##
5## Octave is free software; you can redistribute it and/or modify it
6## under the terms of the GNU General Public License as published by
7## the Free Software Foundation; either version 3 of the License, or (at
8## your option) any later version.
9##
10## Octave is distributed in the hope that it will be useful, but
11## WITHOUT ANY WARRANTY; without even the implied warranty of
12## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13## General Public License for more details.
14##
15## You should have received a copy of the GNU General Public License
16## along with Octave; see the file COPYING. If not, see
17## <http://www.gnu.org/licenses/>.
18
19## -*- texinfo -*-
20## @deftypefn {Function File} {[@var{c}, @var{maxsize}, @var{endian}] =} computer ()
21## Print or return a string of the form @var{cpu}-@var{vendor}-@var{os}
22## that identifies the kind of computer Octave is running on. If invoked
23## with an output argument, the value is returned instead of printed. For
24## example,
25##
26## @example
27## @group
28## computer ()
29## @print{} i586-pc-linux-gnu
30##
31## x = computer ()
32## @result{} x = "i586-pc-linux-gnu"
33## @end group
34## @end example
35##
36## If two output arguments are requested, also return the maximum number
37## of elements for an array.
38##
39## If three output arguments are requested, also return the byte order
40## of the current system as a character (@code{"B"} for big-endian or
41## @code{"L"} for little-endian).
42## @end deftypefn
43
44function [c, maxsize, endian] = computer ()
45
46 if (nargin != 0)
47 warning ("computer: ignoring extra arguments");
48 endif
49
50 msg = octave_config_info ("canonical_host_type");
51
52 if (strcmp (msg, "unknown"))
53 msg = "Hi Dave, I'm a HAL-9000";
54 endif
55
56 if (nargout == 0)
57 printf ("%s\n", msg);
58 else
59 c = msg;
60 if (strcmp (octave_config_info ("USE_64_BIT_IDX_T"), "true"))
61 maxsize = 2^63-1;
62 else
63 maxsize = 2^31-1;
64 endif
65 if (octave_config_info ("words_big_endian"))
66 endian = "B";
67 elseif (octave_config_info ("words_little_endian"))
68 endian = "L";
69 else
70 endian = "?";
71 endif
72 endif
73
74endfunction
75
76%!assert((ischar (computer ())
77%! && computer () == octave_config_info ("canonical_host_type")));
78
79%!warning a =computer(2);
80