changeset 5427:a92afe70fb8d

[project @ 2005-08-16 19:49:23 by jwe]
author jwe
date Tue, 16 Aug 2005 19:49:32 +0000
parents ee16a0a46351
children 2a16423e4aa0
files scripts/ChangeLog scripts/miscellaneous/computer.m
diffstat 2 files changed, 27 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/ChangeLog	Mon Aug 15 19:59:49 2005 +0000
+++ b/scripts/ChangeLog	Tue Aug 16 19:49:32 2005 +0000
@@ -1,3 +1,8 @@
+2005-08-16  John W. Eaton  <jwe@octave.org>
+
+	* miscellaneous/computer.m: Handle optional maxsize and endian
+	outputs.
+
 2005-08-15  John W. Eaton  <jwe@octave.org>
 
 	* strings/strcat.m: Allow single argument.
--- a/scripts/miscellaneous/computer.m	Mon Aug 15 19:59:49 2005 +0000
+++ b/scripts/miscellaneous/computer.m	Tue Aug 16 19:49:32 2005 +0000
@@ -18,7 +18,7 @@
 ## 02110-1301, USA.
 
 ## -*- texinfo -*-
-## @deftypefn {Function File} {} computer ()
+## @deftypefn {Function File} {[@var{c}, @var{maxsize}, @var{endian}] =} computer ()
 ## Print or return a string of the form @var{cpu}-@var{vendor}-@var{os}
 ## that identifies the kind of computer Octave is running on.  If invoked
 ## with an output argument, the value is returned instead of printed.  For
@@ -33,9 +33,16 @@
 ##      @result{} x = "i586-pc-linux-gnu"
 ## @end group
 ## @end example
+##
+## If two output arguments are requested, also return the maximum number
+## of elements for an array.
+##
+## If three output arguments are requested, also return the byte order
+## of the current system as a character (@code{"B"} for big-endian or
+## @code{"L"} for little-endian).
 ## @end deftypefn
 
-function retval = computer ()
+function [c, maxsize, endian] = computer ()
 
   if (nargin != 0)
     warning ("computer: ignoring extra arguments");
@@ -50,7 +57,19 @@
   if (nargout == 0)
     printf ("%s\n", msg);
   else
-    retval = msg;
+    c = msg;
+    if (strcmp (octave_config_info ("USE_64_BIT_IDX_T"), "true"))
+      maxsize = 2^63-1;
+    else
+      maxsize = 2^31-1;
+    endif
+    if (octave_config_info ("words_big_endian"))
+      endian = "B";
+    elseif (octave_config_info ("words_little_endian"))
+      endian = "L";
+    else
+      endian = "?";
+    endif      
   endif
 
 endfunction